Go to the documentation of this file.
36 Foam::Ostream& Foam::surfaceWriters::nastranWriter::writeValue
44 case fieldFormat::SHORT :
46 os <<
setw(8) << value;
50 case fieldFormat::LONG :
52 os <<
setw(16) << value;
56 case fieldFormat::FREE :
68 Foam::Ostream& Foam::surfaceWriters::nastranWriter::writeFaceValue
90 const label setId = 1;
93 writeKeyword(os, fileFormats::NASCore::loadFormatNames[
format])
97 os.
setf(std::ios_base::right);
99 writeValue(os, setId) << separator_;
103 case loadFormat::PLOAD2 :
107 writeValue(os, value);
111 writeValue(os,
mag(value));
115 writeValue(os, elemId);
119 case loadFormat::PLOAD4 :
121 writeValue(os, elemId);
123 for (
direction d = 0; d < pTraits<Type>::nComponents; ++d)
132 os.
unsetf(std::ios_base::right);
143 const word& fieldName,
149 if (!fieldMap_.found(fieldName))
152 <<
"No mapping found between field " << fieldName
153 <<
" and corresponding Nastran field. Available types are:"
157 return fileName::null;
165 if (useTimeDir() && !
timeName().empty())
170 outputFile /= fieldName / outputPath_.
name();
171 outputFile.
ext(
"nas");
177 const scalar varScale =
179 std::is_integral<Type>::value
181 : fieldScale_.getOrDefault<scalar>(fieldName, 1)
186 Info<<
"Writing field " << fieldName;
187 if (!
equal(varScale, 1))
189 Info<<
" (scaling " << varScale <<
')';
191 Info<<
" to " << outputFile <<
endl;
198 << fileFormats::NASCore::loadFormatNames[
format]
199 <<
" cannot be used for higher rank values"
200 <<
" - reverting to mag()" <<
endl;
209 if (Pstream::master() || !parallel_)
211 const auto&
values = tfield();
218 const scalar timeValue(0);
228 fileFormats::NASCore::setPrecision(os, writeFormat_);
230 os <<
"TITLE=OpenFOAM " << outputFile.
name()
231 << token::SPACE << fieldName <<
" data" <<
nl;
233 if (useTimeDir() && !
timeName().empty())
240 <<
"TIME " << timeValue <<
nl
242 <<
"BEGIN BULK" <<
nl;
245 writeGeometry(os, surf, decompOffsets, decompFaces);
251 <<
"$ Field data" <<
nl
261 const bool useOrigFaceIds =
263 elemIds.size() == faces.size()
264 && decompFaces.empty()
270 if (this->isPointData())
277 elemId = elemIds[facei];
280 const label beginElemId = elemId;
285 label decompi = decompOffsets[facei];
286 decompi < decompOffsets[facei+1];
290 const face&
f = decompFaces[decompi];
293 for (
const label verti :
f)
297 v *= (varScale /
f.size());
299 writeFaceValue(os,
format, v, ++elemId);
304 if (beginElemId == elemId)
306 const face&
f = faces[facei];
309 for (
const label verti :
f)
313 v *= (varScale /
f.size());
315 writeFaceValue(os,
format, v, ++elemId);
321 auto valIter =
values.cbegin();
328 elemId = elemIds[facei];
331 const Type v(varScale * *valIter);
338 (decompOffsets[facei+1] - decompOffsets[facei])
343 writeFaceValue(os,
format, v, ++elemId);
348 writeFooter(os, surf)
349 <<
"ENDDATA" <<
endl;
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)
Return directory path name (part before last /)
A class for managing temporary objects.
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.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
virtual const faceList & faces() const =0
The faces used for the surface.
Abstract definition of a meshed surface defined by faces and points.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAll(list, i)
Loop across all elements in list.
word format(conversionProperties.get< word >("format"))
Generic templated field type.
messageStream Info
Information stream (uses stdout - output is on the master only)
Istream and Ostream manipulators taking arguments.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
word ext() const
Return file name extension (part after last .)
Omanip< int > setw(const int i)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Output to file stream, using an OSstream.
ios_base::fmtflags setf(const ios_base::fmtflags f)
Set flags of stream.
virtual const labelList & faceIds() const
Per-face identifier (eg, element Id)
void unsetf(const ios_base::fmtflags f)
Unset flags of stream.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Traits class for primitives.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A face is a list of labels corresponding to mesh vertices.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
#define WarningInFunction
Report a warning using Foam::Warning.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?