41 namespace surfaceWriters
60 Foam::Ostream& Foam::surfaceWriters::nastranWriter::writeKeyword
70 void Foam::surfaceWriters::nastranWriter::writeCoord
81 void Foam::surfaceWriters::nastranWriter::writeFace
104 writeKeyword(
os, faceType) << separator_;
106 os.setf(std::ios_base::right);
108 writeValue(
os, elemId) << separator_;
109 writeValue(
os, propId);
111 switch (writeFormat_)
113 case fieldFormat::SHORT :
115 for (
const label pointi : facePts)
117 writeValue(
os, pointi + 1);
123 case fieldFormat::LONG :
127 writeValue(
os, facePts[i] + 1);
131 os.unsetf(std::ios_base::right);
132 writeKeyword(
os,
"");
133 os.setf(std::ios_base::right);
140 case fieldFormat::FREE :
142 for (
const label pointi : facePts)
145 writeValue(
os, pointi + 1);
153 os.unsetf(std::ios_base::right);
157 void Foam::surfaceWriters::nastranWriter::writeGeometry
160 const meshedSurf& surf,
162 DynamicList<face>& decompFaces
166 const faceList& faces = surf.faces();
168 const labelList& elemIds = surf.faceIds();
171 bool useOrigFaceIds =
173 elemIds.size() == faces.size()
180 for (
const auto&
f : faces)
184 useOrigFaceIds =
false;
199 writeCoord(
os,
points[pointi], pointi);
203 decompOffsets.resize(faces.size()+1);
206 decompOffsets[0] = 0;
215 const face&
f = faces[facei];
219 elemId = elemIds[facei];
223 const label propId = 1 + (facei < zones.size() ? zones[facei] : 0);
227 writeFace(
os,
"CTRIA3",
f, ++elemId, propId);
229 else if (
f.size() == 4)
231 writeFace(
os,
"CQUAD4",
f, ++elemId, propId);
236 f.triangles(
points, decompFaces);
240 label decompi = decompOffsets[facei];
241 decompi < decompFaces.size();
249 decompFaces[decompi],
257 decompOffsets[facei+1] = decompFaces.size();
268 if (pidsUsed.empty())
270 pidsUsed.resize(1,
Zero);
273 for (
auto pid : pidsUsed)
275 writeKeyword(
os,
"PSHELL") << separator_;
276 writeValue(
os,
pid+1);
278 for (label i = 0; i < 7; ++i)
292 writeKeyword(
os,
"MAT1") << separator_;
295 for (label i = 0; i < 7; ++i)
310 writeFormat_(fieldFormat::SHORT),
312 commonGeometry_(false),
330 fileFormats::NASCore::fieldFormatNames.getOrDefault
338 commonGeometry_(options.getOrDefault(
"commonGeometry", false)),
341 if (writeFormat_ == fieldFormat::FREE)
371 open(surf, outputPath, parallel);
386 open(
points, faces, outputPath, parallel);
399 if (useTimeDir() && !
timeName().empty())
402 outputFile = outputPath_.
path() /
timeName() / outputPath_.name();
404 outputFile.
ext(
"nas");
408 Info<<
"Writing nastran geometry to " << outputFile <<
endl;
413 const meshedSurfRef& surf = adjustSurface();
422 OFstream
os(outputFile);
425 os <<
"TITLE=OpenFOAM " << outputPath_.name() <<
" geometry" <<
nl 426 <<
"BEGIN BULK" <<
nl;
429 DynamicList<face> decompFaces;
433 os <<
"ENDDATA" <<
nl;
A surface writer for the Nastran file format - both surface mesh and fields.
A class for handling file names.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as found_if.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual fileName write()
Write surface geometry to file.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static std::string path(const std::string &str)
Return directory path name (part before last /)
defineSurfaceWriterWriteFields(Foam::surfaceWriters::nastranWriter)
word ext() const
Return file name extension (part after last .)
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
Abstract definition of a meshed surface defined by faces and points.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
List< face > faceList
List of faces.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
vectorField pointField
pointField is a vectorField.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
pid_t pid()
Return the PID of this process.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Istream and Ostream manipulators taking arguments.
OBJstream os(runTime.globalPath()/outputName)
nastranWriter()
Default construct. Default SHORT format.
Convenience macros for instantiating surfaceWriter methods.
defineTypeName(abaqusWriter)
vector point
Point is a vector.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Base class for surface writers.
List< label > labelList
A List of labels.
addToRunTimeSelectionTable(surfaceWriter, abaqusWriter, word)
static constexpr const zero Zero
Global zero (0)