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)
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)
368 const meshedSurf& surf,
369 const fileName& outputPath,
371 const dictionary& options
376 open(surf, outputPath, parallel);
391 open(
points, faces, 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;
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 /)
void push_back(const T &val)
Append an element at the end of the list.
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.
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.
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.
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...
OBJstream os(runTime.globalPath()/outputName)
nastranWriter()
Default construct. Default FREE format.
Convenience macros for instantiating surfaceWriter methods.
defineTypeName(abaqusWriter)
word format(conversionProperties.get< word >("format"))
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)
Foam::fileFormats::NASCore::loadFormat loadFormat
Output load format.
static constexpr const zero Zero
Global zero (0)