33 void Foam::nastranSurfaceWriter::writeFaceValue
35 const word& nasFieldName,
49 Type scaledValue = scale_*value;
55 os.setf(ios_base::left);
56 os <<
setw(8) << nasFieldName;
57 os.unsetf(ios_base::left);
58 os.setf(ios_base::right);
62 for (
direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
67 os.unsetf(ios_base::right);
73 os.setf(ios_base::left);
74 os <<
setw(8) << word(nasFieldName +
"*");
75 os.unsetf(ios_base::left);
76 os.setf(ios_base::right);
80 for (
direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
85 os.unsetf(ios_base::right);
89 os.setf(ios_base::left);
91 os.unsetf(ios_base::left);
97 os << nasFieldName <<
',' 101 for (
direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
103 os <<
',' <<
component(scaledValue, dirI);
118 void Foam::nastranSurfaceWriter::Write
120 const fileName& outputDir,
121 const fileName& surfaceName,
124 const word& fieldName,
125 const Field<Type>& values,
126 const bool isNodeValues
129 if (!fieldMap_.found(fieldName))
132 <<
"No mapping found between field " << fieldName
133 <<
" and corresponding Nastran field. Available types are:" 140 const word& nasFieldName(fieldMap_[fieldName]);
142 if (!
isDir(outputDir/fieldName))
144 mkDir(outputDir/fieldName);
148 const scalar timeValue = 0.0;
150 OFstream os(outputDir/fieldName/surfaceName +
".dat");
155 Info<<
"Writing nastran file to " << os.name() <<
endl;
158 os <<
"TITLE=OpenFOAM " << surfaceName.c_str() <<
" " << fieldName
161 <<
"TIME " << timeValue << nl
163 <<
"BEGIN BULK" <<
nl;
165 List<DynamicList<face>> decomposedFaces(faces.size());
167 writeGeometry(points, faces, decomposedFaces, os);
171 <<
"$ Field data" << nl
178 forAll(decomposedFaces, i)
180 const DynamicList<face>& dFaces = decomposedFaces[i];
184 const face&
f = dFaces[facei];
188 v += values[f[fptI]];
192 writeFaceValue(nasFieldName, v, ++n, os);
200 forAll(decomposedFaces, i)
202 const DynamicList<face>& dFaces = decomposedFaces[i];
206 writeFaceValue(nasFieldName, values[facei], ++n, os);
211 os <<
"ENDDATA" <<
endl;
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
vectorField pointField
pointField is a vectorField.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Istream and Ostream manipulators taking arguments.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
#define WarningInFunction
Report a warning using Foam::Warning.
Omanip< int > setw(const int i)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)