60Foam::Ostream& Foam::surfaceWriters::nastranWriter::writeKeyword
70void Foam::surfaceWriters::nastranWriter::writeCoord
81void 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);
157void 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)
311 commonGeometry_(false),
324 fileFormats::NASCore::fieldFormatNames.getOrDefault
331 commonGeometry_(options.getOrDefault(
"commonGeometry", false))
333 if (writeFormat_ == fieldFormat::FREE)
354 if (
format == loadFormat::PLOAD2)
358 else if (
format == loadFormat::PLOAD4)
360 pload4_.push_back(item.first());
368 const meshedSurf& surf,
369 const fileName& outputPath,
376 open(surf, outputPath, parallel);
404 if (useTimeDir() && !
timeName().empty())
407 outputFile = outputPath_.
path() /
timeName() / outputPath_.name();
409 outputFile.
ext(
"nas");
413 Info<<
"Writing nastran geometry to " << outputFile <<
endl;
418 const meshedSurfRef& surf = adjustSurface();
430 os <<
"TITLE=OpenFOAM " << outputPath_.name() <<
" geometry" <<
nl
431 <<
"BEGIN BULK" <<
nl;
434 DynamicList<face> decompFaces;
438 os <<
"ENDDATA" <<
nl;
Istream and Ostream manipulators taking arguments.
Various functions to operate on Lists.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void push_back(const T &val)
Append an element at the end of the list.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
An ordered pair of two objects of type <T> with first() and second() elements.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
A class for handling file names.
word ext() const
Return file name extension (part after last .).
static std::string path(const std::string &str)
Return directory path name (part before last /).
Implements a meshed surface by referencing another meshed surface or faces/points components.
Abstract definition of a meshed surface defined by faces and points.
Base class for surface writers.
surfaceWriter()
Default construct.
virtual void open(const fileName &outputPath)
Open for output on specified path, using existing surface.
bool wroteGeom_
Track if geometry has been written since the last open.
bool useTimeDir() const noexcept
Should a time directory be spliced into the output path?
void checkOpen() const
Verify that the outputPath_ has been set or FatalError.
bool parallel_
Writing in parallel (via master).
bool empty() const
The surface to write is empty if the global number of faces is zero.
bool verbose_
Additional output verbosity.
const meshedSurfRef & adjustSurface() const
Merge surfaces (if not upToDate) and return merged (parallel) or regular surface (non-parallel) and a...
fileName outputPath_
The full output directory and file (surface) name.
A surface writer for the Nastran file format - both surface mesh and fields.
Foam::fileFormats::NASCore::loadFormat loadFormat
Output load format.
Foam::fileFormats::NASCore::fieldFormat fieldFormat
File field formats.
nastranWriter()
Default construct. Default FREE format.
virtual fileName write()
Write surface geometry to file.
A class for handling words, derived from Foam::string.
#define defineTypeName(Type)
Define the typeName.
OBJstream os(runTime.globalPath()/outputName)
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as found_if.
Namespace for surface writers.
List< label > labelList
A List of labels.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector point
Point is a vector.
pid_t pid()
Return the PID of this process.
static constexpr const zero Zero
Global zero (0).
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
constexpr char nl
The newline '\n' character (0x0a).
word format(conversionProperties.get< word >("format"))
#define forAll(list, i)
Loop across all elements in list.
Convenience macros for instantiating surfaceWriter methods.
#define defineSurfaceWriterWriteFields(ThisClass)