Go to the documentation of this file.
41 namespace surfaceWriters
60 Foam::Ostream& Foam::surfaceWriters::nastranWriter::writeKeyword
70 void Foam::surfaceWriters::nastranWriter::writeCoord
88 writeKeyword(
os,
"GRID") << separator_;
90 os.setf(std::ios_base::right);
92 writeValue(
os, pointI+1) << separator_;
93 writeValue(
os,
"") << separator_;
94 writeValue(
os, pt.x()) << separator_;
95 writeValue(
os, pt.y()) << separator_;
99 case fieldFormat::SHORT :
102 os.unsetf(std::ios_base::right);
106 case fieldFormat::LONG :
109 os.unsetf(std::ios_base::right);
110 writeKeyword(
os,
"");
111 os.setf(std::ios_base::right);
113 writeValue(
os, pt.z()) <<
nl;
117 case fieldFormat::FREE :
119 writeValue(
os, pt.z()) <<
nl;
124 os.unsetf(std::ios_base::right);
128 void Foam::surfaceWriters::nastranWriter::writeFace
131 const word& faceType,
151 writeKeyword(
os, faceType) << separator_;
153 os.setf(std::ios_base::right);
155 writeValue(
os, elemId) << separator_;
156 writeValue(
os, propId);
158 switch (writeFormat_)
160 case fieldFormat::SHORT :
162 for (
const label pointi : facePts)
164 writeValue(
os, pointi + 1);
170 case fieldFormat::LONG :
174 writeValue(
os, facePts[i] + 1);
178 os.unsetf(std::ios_base::right);
179 writeKeyword(
os,
"");
180 os.setf(std::ios_base::right);
187 case fieldFormat::FREE :
189 for (
const label pointi : facePts)
192 writeValue(
os, pointi + 1);
200 os.unsetf(std::ios_base::right);
204 void Foam::surfaceWriters::nastranWriter::writeGeometry
207 const meshedSurf& surf,
209 DynamicList<face>& decompFaces
213 const faceList& faces = surf.faces();
215 const labelList& elemIds = surf.faceIds();
218 bool useOrigFaceIds =
220 elemIds.size() == faces.size()
227 for (
const auto&
f : faces)
231 useOrigFaceIds =
false;
246 writeCoord(
os,
points[pointi]*geometryScale_, pointi);
250 decompOffsets.resize(faces.size()+1);
253 decompOffsets[0] = 0;
262 const face&
f = faces[facei];
266 elemId = elemIds[facei];
270 const label propId = 1 + (facei < zones.size() ? zones[facei] : 0);
274 writeFace(
os,
"CTRIA3",
f, ++elemId, propId);
276 else if (
f.size() == 4)
278 writeFace(
os,
"CQUAD4",
f, ++elemId, propId);
283 f.triangles(
points, decompFaces);
287 label decompi = decompOffsets[facei];
288 decompi < decompFaces.size();
296 decompFaces[decompi],
304 decompOffsets[facei+1] = decompFaces.size();
315 if (pidsUsed.empty())
317 pidsUsed.resize(1,
Zero);
320 for (
auto pid : pidsUsed)
322 writeKeyword(
os,
"PSHELL") << separator_;
323 writeValue(
os,
pid+1);
325 for (label i = 0; i < 7; ++i)
339 writeKeyword(
os,
"MAT1") << separator_;
342 for (label i = 0; i < 7; ++i)
359 commonGeometry_(false),
382 commonGeometry_(options.
getOrDefault(
"commonGeometry",
false)),
383 geometryScale_(options.
getOrDefault<scalar>(
"scale", 1)),
387 if (writeFormat_ == fieldFormat::FREE)
417 open(surf, outputPath, parallel);
432 open(
points, faces, outputPath, parallel);
445 if (useTimeDir() && !
timeName().empty())
448 outputFile = outputPath_.
path() /
timeName() / outputPath_.name();
450 outputFile.
ext(
"nas");
454 Info<<
"Writing nastran geometry to " << outputFile <<
endl;
470 os <<
"TITLE=OpenFOAM " << outputPath_.name() <<
" geometry" <<
nl
471 <<
"BEGIN BULK" <<
nl;
478 os <<
"ENDDATA" <<
nl;
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Base class for surface writers.
A class for handling file names.
defineTypeName(abaqusWriter)
static std::string path(const std::string &str)
Return directory path name (part before last /)
static constexpr const zero Zero
Global zero (0)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Abstract definition of a meshed surface defined by faces and points.
static bool master(const label communicator=worldComm)
Am I the master process.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Convenience macros for instantiating surfaceWriter methods.
#define forAll(list, i)
Loop across all elements in list.
addToRunTimeSelectionTable(surfaceWriter, abaqusWriter, word)
messageStream Info
Information stream (stdout output on master, null elsewhere)
pid_t pid()
Return the PID of this process.
Istream and Ostream manipulators taking arguments.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
Macros for easy insertion into run-time selection tables.
word ext() const
Return file name extension (part after last .)
Omanip< int > setw(const int i)
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Output to file stream, using an OSstream.
List< face > faceList
A List of faces.
virtual fileName write()
Write surface geometry to file.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
True if there is a value in the list that satisfies the predicate.
Various functions to operate on Lists.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
vector point
Point is a vector.
UList< label > labelUList
A UList of labels.
A surface writer for the Nastran file format - both surface mesh and fields.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
nastranWriter()
Default construct. Default SHORT format.
defineSurfaceWriterWriteFields(Foam::surfaceWriters::nastranWriter)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?