54 void Foam::nastranSurfaceWriter::formatOS(
OFstream& os)
const 59 os.
setf(ios_base::uppercase);
85 void Foam::nastranSurfaceWriter::writeCoord
107 os.
setf(ios_base::left);
108 os <<
setw(8) <<
"GRID";
109 os.
unsetf(ios_base::left);
110 os.
setf(ios_base::right);
111 os <<
setw(8) << pointi + 1
117 os.
unsetf(ios_base::right);
123 os.
setf(ios_base::left);
124 os <<
setw(8) <<
"GRID*";
125 os.
unsetf(ios_base::left);
126 os.
setf(ios_base::right);
127 os <<
setw(16) << pointi + 1
132 os.
unsetf(ios_base::right);
133 os.
setf(ios_base::left);
134 os <<
setw(8) <<
"*";
135 os.
unsetf(ios_base::left);
136 os.
setf(ios_base::right);
137 os <<
setw(16) << p.
z()
139 os.
unsetf(ios_base::right);
163 void Foam::nastranSurfaceWriter::writeFace
165 const word& faceType,
189 os.
setf(ios_base::left);
190 os <<
setw(8) << faceType;
191 os.
unsetf(ios_base::left);
192 os.
setf(ios_base::right);
193 os <<
setw(8) << nFace++
198 os <<
setw(8) << facePts[i] + 1;
202 os.
unsetf(ios_base::right);
208 os.
setf(ios_base::left);
209 os <<
setw(8) <<
word(faceType +
"*");
210 os.
unsetf(ios_base::left);
211 os.
setf(ios_base::right);
212 os <<
setw(16) << nFace++
217 os <<
setw(16) << facePts[i] + 1;
221 os.
unsetf(ios_base::right);
222 os.
setf(ios_base::left);
223 os <<
setw(8) <<
"*";
224 os.
unsetf(ios_base::left);
225 os.
setf(ios_base::right);
230 os.
unsetf(ios_base::right);
236 os << faceType <<
',' 241 os <<
',' << facePts[i] + 1;
258 void Foam::nastranSurfaceWriter::writeGeometry
274 writeCoord(points[pointi], pointi, os);
288 const face&
f = faces[facei];
292 writeFace(
"CTRIA3", faces[facei], nFace, os);
293 decomposedFaces[facei].append(faces[facei]);
295 else if (f.
size() == 4)
297 writeFace(
"CQUAD4", faces[facei], nFace, os);
298 decomposedFaces[facei].append(faces[facei]);
309 writeFace(
"CTRIA3", triFaces[triI], nFace, os);
310 decomposedFaces[facei].append(triFaces[triI]);
340 if (nastranDict.found(
"format"))
349 fieldMap_.insert(fieldSet[i].first(), fieldSet[i].second());
352 if (nastranDict.found(
"scale"))
354 nastranDict.lookup(
"scale") >> scale_;
375 if (!
isDir(outputDir))
380 OFstream os(outputDir/surfaceName +
".dat");
388 os <<
"TITLE=OpenFOAM " << surfaceName.c_str() <<
" mesh" <<
nl 390 <<
"BEGIN BULK" <<
nl;
394 writeGeometry(points, faces, decomposedFaces, os);
396 if (!
isDir(outputDir))
401 os <<
"ENDDATA" <<
endl;
#define forAll(list, i)
Loop across all elements in list.
nastranSurfaceWriter(const IOstream::streamFormat writeFormat)
Construct given write format.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
void unsetf(const ios_base::fmtflags uf)
Unset flags of stream.
A face is a list of labels corresponding to mesh vertices.
virtual int precision() const
Get precision of output field.
ios_base::fmtflags setf(const ios_base::fmtflags f)
Set flags of stream.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual ~nastranSurfaceWriter()
Destructor.
const fileName & name() const
Return the name of the stream.
Initialise the NamedEnum HashTable from the static list of names.
label triangles(const pointField &points, label &triI, faceList &triFaces) const
Split into triangles using existing points.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
A class for handling words, derived from string.
Convenience macros for instantiating writer methods for surfaceWriter classes.
streamFormat
Enumeration for the format of data in the stream.
defineSurfaceWriterWriteFields(nastranSurfaceWriter)
errorManip< error > abort(error &err)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
makeSurfaceWriterType(ensightSurfaceWriter)
static const NamedEnum< format, 3 > formatNames_
Enum read(Istream &) const
Read a word from Istream and return the corresponding.
Base class for surface writers.
virtual void write(const fileName &outputDir, const fileName &surfaceName, const pointField &points, const faceList &faces) const
Write single surface geometry to file.
Omanip< int > setw(const int i)
IOstream & scientific(IOstream &io)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.