Go to the documentation of this file.
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");
230 const scalar varScale =
232 std::is_integral<Type>::value
234 : fieldScale_.getOrDefault<scalar>(fieldName, 1)
239 Info<<
"Writing field " << fieldName;
240 if (!
equal(varScale, 1))
242 Info<<
" (scaling " << varScale <<
')';
244 Info<<
" to " << outputFile <<
endl;
249 tmp<Field<Type>> tfield = mergeField(localValues) * varScale;
251 const meshedSurf& surf = surface();
255 const auto&
values = tfield();
257 if (!
isDir(outputFile.path()))
259 mkDir(outputFile.path());
262 const scalar timeValue(0);
266 DynamicList<face> decompFaces;
269 OFstream
os(outputFile);
272 os <<
"TITLE=OpenFOAM " << outputFile.name()
275 if (useTimeDir() && !
timeName().empty())
281 os <<
"TIME " << timeValue <<
nl
283 <<
"BEGIN BULK" <<
nl;
287 os <<
"INCLUDE '" << geomFileName.c_str() <<
"'" <<
nl;
307 <<
"$ Field data" <<
nl
312 const faceList& faces = surf.faces();
316 const bool useOrigFaceIds =
318 elemIds.size() == faces.size()
320 && decompFaces.empty()
326 if (this->isPointData())
332 elemId = elemIds[facei];
335 const label beginElemId = elemId;
340 label decompi = decompOffsets[facei];
341 decompi < decompOffsets[facei+1];
345 const face&
f = decompFaces[decompi];
348 for (
const label verti :
f)
354 writeFaceValue(
os,
format, v, ++elemId);
359 if (beginElemId == elemId)
361 const face&
f = faces[facei];
364 for (
const label verti :
f)
370 writeFaceValue(
os,
format, v, ++elemId);
376 auto valIter =
values.cbegin();
382 elemId = elemIds[facei];
385 const Type v(*valIter);
392 (decompOffsets[facei+1] - decompOffsets[facei])
397 writeFaceValue(
os,
format, v, ++elemId);
List< label > labelList
A List of labels.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
A class for handling words, derived from Foam::string.
A class for handling file names.
static std::string path(const std::string &str)
A class for managing temporary objects.
static constexpr const zero Zero
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
static std::string name(const std::string &str)
virtual const faceList & faces() const =0
Abstract definition of a meshed surface defined by faces and points.
static bool master(const label communicator=worldComm)
Ostream & endl(Ostream &os)
word format(conversionProperties.get< word >("format"))
Istream and Ostream manipulators taking arguments.
label max(const labelHashSet &set, label maxValue=labelMin)
virtual const pointField & points() const =0
OBJstream os(runTime.globalPath()/outputName)
Omanip< int > setw(const int i)
Output to file stream, using an OSstream.
virtual const labelList & faceIds() const
List< face > faceList
A List of faces.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A traits class, which is primarily used for primitives.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
void write(vtk::formatter &fmt, const Type &val, const label n=1)
A face is a list of labels corresponding to mesh vertices.
Various functions to operate on Lists.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
UList< label > labelUList
A UList of labels.
bool mkDir(const fileName &pathName, mode_t mode=0777)
bool equal(const T &s1, const T &s2)
#define WarningInFunction
bool isDir(const fileName &name, const bool followLink=true)