37 Foam::Ostream& Foam::surfaceWriters::nastranWriter::writeValue
45 case fieldFormat::SHORT :
51 case fieldFormat::LONG :
57 case fieldFormat::FREE :
69 Foam::Ostream& Foam::surfaceWriters::nastranWriter::writeFaceValue
91 const label setId = 1;
98 os.setf(std::ios_base::right);
100 writeValue(
os, setId) << separator_;
104 case loadFormat::PLOAD2 :
108 writeValue(
os, value);
112 writeValue(
os,
mag(value));
116 writeValue(
os, elemId);
120 case loadFormat::PLOAD4 :
122 writeValue(
os, elemId);
124 for (
direction d = 0; d < pTraits<Type>::nComponents; ++d)
133 os.unsetf(std::ios_base::right);
144 const word& fieldName,
152 if (!wroteGeom_ && commonGeometry_)
175 !std::is_integral<Type>::value
176 && !fieldMap_.empty()
177 && !fieldMap_.found(fieldName)
181 <<
"No mapping found between field " << fieldName
182 <<
" and corresponding Nastran field. Available types:" 187 if (
format == loadFormat::PLOAD2 && pTraits<Type>::nComponents != 1)
191 <<
" cannot be used for higher rank values" 192 <<
" - reverting to mag()" <<
endl;
202 fileName outputFile = outputPath_.path();
203 if (useTimeDir() && !
timeName().empty())
209 fileName geomFileName;
213 geomFileName = outputPath_.name().ext(
"nas");
216 outputFile /= fieldName +
'_' + outputPath_.name();
222 outputFile /= fieldName / outputPath_.name();
224 outputFile.
ext(
"bdf");
227 tmp<Field<Type>> tfield = adjustField(fieldName, mergeField(localValues));
231 Info<<
" to " << outputFile <<
endl;
236 const meshedSurfRef& surf = adjustSurface();
240 const auto&
values = tfield();
242 if (!
isDir(outputFile.path()))
244 mkDir(outputFile.path());
247 const scalar timeValue(0);
251 DynamicList<face> decompFaces;
254 OFstream
os(outputFile);
257 os <<
"TITLE=OpenFOAM " << outputFile.name()
260 if (useTimeDir() && !
timeName().empty())
266 os <<
"TIME " << timeValue <<
nl 268 <<
"BEGIN BULK" <<
nl;
272 os <<
"INCLUDE '" << geomFileName.c_str() <<
"'" <<
nl;
292 <<
"$ Field data" <<
nl 297 const faceList& faces = surf.faces();
301 const bool useOrigFaceIds =
303 elemIds.size() == faces.size()
305 && decompFaces.empty()
311 if (this->isPointData())
317 elemId = elemIds[facei];
320 const label beginElemId = elemId;
325 label decompi = decompOffsets[facei];
326 decompi < decompOffsets[facei+1];
330 const face&
f = decompFaces[decompi];
333 for (
const label verti :
f)
339 writeFaceValue(
os,
format, v, ++elemId);
344 if (beginElemId == elemId)
346 const face&
f = faces[facei];
349 for (
const label verti :
f)
355 writeFaceValue(
os,
format, v, ++elemId);
361 auto valIter =
values.cbegin();
367 elemId = elemIds[facei];
370 const Type v(*valIter);
377 (decompOffsets[facei+1] - decompOffsets[facei])
382 writeFaceValue(
os,
format, v, ++elemId);
A class for handling file names.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as found_if.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A traits class, which is primarily used for primitives.
UList< label > labelUList
A UList of labels.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
word ext() const
Return file name extension (part after last .)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
List< face > faceList
List of faces.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Generic templated field type.
A class for handling words, derived from Foam::string.
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)
word format(conversionProperties.get< word >("format"))
#define WarningInFunction
Report a warning using Foam::Warning.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Omanip< int > setw(const int i)
List< label > labelList
A List of labels.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
static constexpr const zero Zero
Global zero (0)