87 #include "readFields.H" 98 template<
class GeoField>
99 void print(
const char* msg, Ostream& os,
const PtrList<GeoField>& flds)
106 os <<
' ' << flds[i].name();
113 void print(Ostream& os,
const wordList& flds)
117 os <<
' ' << flds[i];
125 const polyBoundaryMesh& patches,
126 const List<wordRe>& excludePatches
129 DynamicList<label> patchIDs(patches.size());
131 Info<<
"Combining patches:" <<
endl;
135 const polyPatch& pp = patches[
patchi];
139 isType<emptyPolyPatch>(pp)
140 || (Pstream::parRun() && isType<processorPolyPatch>(pp))
143 Info<<
" discarding empty/processor patch " <<
patchi 144 <<
" " << pp.name() <<
endl;
148 Info<<
" excluding patch " <<
patchi 149 <<
" " << pp.name() <<
endl;
154 Info<<
" patch " <<
patchi <<
" " << pp.name() <<
endl;
157 return patchIDs.shrink();
164 int main(
int argc,
char *argv[])
168 "Tecplot binary file format writer" 171 timeSelector::addOptions();
178 "convert selected fields only. eg, '(p T U)'" 184 "restrict conversion to the specified cellSet" 190 "restrict conversion to the specified cellSet" 192 argList::addBoolOption
195 "output cell value on patches instead of patch value itself" 197 argList::addBoolOption
200 "do not generate file for mesh, only for patches" 202 argList::addBoolOption
210 "patches (wildcards) to exclude" 212 argList::addBoolOption
229 <<
"Using neighbouring cell value instead of patch value" 236 <<
"Outputting cell values only" <<
nl <<
endl;
239 List<wordRe> excludePatches;
244 Info<<
"Not including patches " << excludePatches <<
nl <<
endl;
252 vtkName = cellSetName;
254 else if (Pstream::parRun())
257 vtkName = runTime.caseName();
261 if (i != string::npos)
263 vtkName = vtkName.substr(i);
268 vtkName = runTime.caseName();
277 fileName fvPath(runTime.path()/
"Tecplot360");
279 fileName regionPrefix =
"";
293 || cellSetName.size()
297 Info<<
"Keeping old files in " << fvPath <<
nl <<
endl;
301 Info<<
"Deleting old VTK files in " << fvPath <<
nl <<
endl;
311 vtkMesh vMesh(mesh, cellSetName);
315 runTime.setTime(timeDirs[timeI], timeI);
317 Info<<
"Time: " << runTime.timeName() <<
endl;
319 const word timeDesc =
name(timeI);
323 polyMesh::readUpdateState meshState = vMesh.readUpdate();
325 const fvMesh& mesh = vMesh.mesh();
327 INTEGER4 nFaceNodes = 0;
328 forAll(mesh.faces(), facei)
330 nFaceNodes += mesh.faces()[facei].size();
338 IOobjectList objects(mesh, runTime.timeName());
340 HashSet<word> selectedFields;
348 PtrList<volScalarField> vsf;
349 readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vsf);
350 print(
" volScalarFields :", Info, vsf);
352 PtrList<volVectorField> vvf;
353 readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vvf);
354 print(
" volVectorFields :", Info, vvf);
356 PtrList<volSphericalTensorField> vSpheretf;
357 readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vSpheretf);
358 print(
" volSphericalTensorFields :", Info, vSpheretf);
360 PtrList<volSymmTensorField> vSymmtf;
361 readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vSymmtf);
362 print(
" volSymmTensorFields :", Info, vSymmtf);
364 PtrList<volTensorField> vtf;
365 readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vtf);
366 print(
" volTensorFields :", Info, vtf);
373 Info<<
" pointScalarFields : switched off" 374 <<
" (\"-noPointValues\" (at your option)\n";
375 Info<<
" pointVectorFields : switched off" 376 <<
" (\"-noPointValues\" (at your option)\n";
379 PtrList<pointScalarField> psf;
380 PtrList<pointVectorField> pvf;
424 print(
" pointScalarFields :", Info, psf);
434 print(
" pointVectorFields :", Info, pvf);
473 DynamicList<INTEGER4> varLocation;
476 DynamicList<INTEGER4> cellVarLocation;
479 tecplotWriter::getTecplotNames
482 ValueLocation_CellCentered,
486 tecplotWriter::getTecplotNames
489 ValueLocation_CellCentered,
494 tecplotWriter::getTecplotNames
497 ValueLocation_CellCentered,
501 tecplotWriter::getTecplotNames
504 ValueLocation_CellCentered,
509 tecplotWriter::getTecplotNames
512 ValueLocation_CellCentered,
516 tecplotWriter::getTecplotNames
519 ValueLocation_CellCentered,
524 tecplotWriter::getTecplotNames
527 ValueLocation_CellCentered,
531 tecplotWriter::getTecplotNames
534 ValueLocation_CellCentered,
539 tecplotWriter::getTecplotNames
542 ValueLocation_CellCentered,
546 tecplotWriter::getTecplotNames
549 ValueLocation_CellCentered,
557 tecplotWriter::getTecplotNames
565 tecplotWriter::getTecplotNames
575 INTEGER4 strandID = 1;
578 if (meshState != polyMesh::UNCHANGED)
591 tecplotWriter writer(runTime);
593 string allVarNames = string(
"X Y Z ") + varNames;
594 DynamicList<INTEGER4> allVarLocation;
595 allVarLocation.append(ValueLocation_Nodal);
596 allVarLocation.append(ValueLocation_Nodal);
597 allVarLocation.append(ValueLocation_Nodal);
598 allVarLocation.append(varLocation);
608 writer.writePolyhedralZone
618 writer.writeField(mesh.points().component(0)());
619 writer.writeField(mesh.points().component(1)());
620 writer.writeField(mesh.points().component(2)());
625 writer.writeField(vsf[i]);
629 writer.writeField(vvf[i]);
633 writer.writeField(vSpheretf[i]);
637 writer.writeField(vSymmtf[i]);
641 writer.writeField(vtf[i]);
646 writer.writeField(psf[i]);
650 writer.writeField(pvf[i]);
653 writer.writeConnectivity(mesh);
672 tecplotWriter writer(runTime);
682 writer.writePolyhedralZone
687 List<INTEGER4>(3, ValueLocation_Nodal),
692 writer.writeField(mesh.points().component(0)());
693 writer.writeField(mesh.points().component(1)());
694 writer.writeField(mesh.points().component(2)());
696 writer.writeConnectivity(mesh);
709 tecplotWriter writer(runTime);
716 DataFileType_Solution
719 writer.writePolyhedralZone
731 writer.writeField(vsf[i]);
735 writer.writeField(vvf[i]);
739 writer.writeField(vSpheretf[i]);
743 writer.writeField(vSymmtf[i]);
747 writer.writeField(vtf[i]);
752 writer.writeField(psf[i]);
756 writer.writeField(pvf[i]);
772 const word setName =
args[
"faceSet"];
773 labelList faceLabels(faceSet(mesh, setName).toc());
776 mkDir(fvPath/setName);
778 fileName patchFileName
780 fvPath/setName/setName
786 Info<<
" FaceSet : " << patchFileName <<
endl;
788 tecplotWriter writer(runTime);
790 string allVarNames = string(
"X Y Z ") + cellVarNames;
791 DynamicList<INTEGER4> allVarLocation;
792 allVarLocation.append(ValueLocation_Nodal);
793 allVarLocation.append(ValueLocation_Nodal);
794 allVarLocation.append(ValueLocation_Nodal);
795 allVarLocation.append(cellVarLocation);
807 IndirectList<face>(mesh.faces(), faceLabels),
811 writer.writePolygonalZone
820 writer.writeField(ipp.localPoints().component(0)());
821 writer.writeField(ipp.localPoints().component(1)());
822 writer.writeField(ipp.localPoints().component(2)());
880 writer.writeConnectivity(ipp);
893 const polyBoundaryMesh& patches = mesh.boundaryMesh();
895 labelList patchIDs(getSelectedPatches(patches, excludePatches));
897 mkDir(fvPath/
"boundaryMesh");
899 fileName patchFileName;
901 if (vMesh.useSubMesh())
904 fvPath/
"boundaryMesh"/cellSetName
912 fvPath/
"boundaryMesh"/
"boundaryMesh" 918 Info<<
" Combined patches : " << patchFileName <<
endl;
920 tecplotWriter writer(runTime);
922 string allVarNames = string(
"X Y Z ") + varNames;
923 DynamicList<INTEGER4> allVarLocation;
924 allVarLocation.append(ValueLocation_Nodal);
925 allVarLocation.append(ValueLocation_Nodal);
926 allVarLocation.append(ValueLocation_Nodal);
927 allVarLocation.append(varLocation);
939 label patchID = patchIDs[i];
940 const polyPatch& pp = patches[patchID];
945 Info<<
" Writing patch " << patchID <<
"\t" << pp.name()
946 <<
"\tstrand:" << strandID <<
nl <<
endl;
950 IndirectList<face>(pp,
identity(pp.size())),
954 writer.writePolygonalZone
963 writer.writeField(ipp.localPoints().component(0)());
964 writer.writeField(ipp.localPoints().component(1)());
965 writer.writeField(ipp.localPoints().component(2)());
1008 writer.getPatchField
1020 writer.getPatchField
1033 psf[i].boundaryField()[patchID].patchInternalField()()
1040 pvf[i].boundaryField()[patchID].patchInternalField()()
1044 writer.writeConnectivity(ipp);
1048 Info<<
" Skipping zero sized patch " << patchID
1049 <<
"\t" << pp.name()
1066 if (doFaceZones && zones.size() > 0)
1068 mkDir(fvPath/
"faceZoneMesh");
1070 fileName patchFileName;
1072 if (vMesh.useSubMesh())
1075 fvPath/
"faceZoneMesh"/cellSetName
1083 fvPath/
"faceZoneMesh"/
"faceZoneMesh" 1089 Info<<
" FaceZone : " << patchFileName <<
endl;
1091 tecplotWriter writer(runTime);
1093 string allVarNames = string(
"X Y Z ") + cellVarNames;
1094 DynamicList<INTEGER4> allVarLocation;
1095 allVarLocation.append(ValueLocation_Nodal);
1096 allVarLocation.append(ValueLocation_Nodal);
1097 allVarLocation.append(ValueLocation_Nodal);
1098 allVarLocation.append(cellVarLocation);
1110 const faceZone& pp = zones[zoneI];
1116 IndirectList<face>(mesh.faces(), pp),
1120 writer.writePolygonalZone
1129 writer.writeField(ipp.localPoints().component(0)());
1130 writer.writeField(ipp.localPoints().component(1)());
1131 writer.writeField(ipp.localPoints().component(2)());
1190 writer.writeConnectivity(ipp);
1194 Info<<
" Skipping zero sized faceZone " << zoneI
1195 <<
"\t" << pp.name()
1215 runTime.timePath()/regionPrefix/cloud::prefix,
1220 forAll(cloudDirs, cloudI)
1222 IOobjectList sprayObjs
1226 cloud::prefix/cloudDirs[cloudI]
1229 IOobject* positionsPtr = sprayObjs.lookup(
"positions");
1233 mkDir(fvPath/cloud::prefix/cloudDirs[cloudI]);
1235 fileName lagrFileName
1237 fvPath/cloud::prefix/cloudDirs[cloudI]/cloudDirs[cloudI]
1238 +
"_" + timeDesc +
".plt" 1241 Info<<
" Lagrangian: " << lagrFileName <<
endl;
1243 wordList labelNames(sprayObjs.names(labelIOField::typeName));
1245 print(Info, labelNames);
1247 wordList scalarNames(sprayObjs.names(scalarIOField::typeName));
1248 Info<<
" scalars :";
1249 print(Info, scalarNames);
1251 wordList vectorNames(sprayObjs.names(vectorIOField::typeName));
1252 Info<<
" vectors :";
1253 print(Info, vectorNames);
1284 passiveParticleCloud parcels(mesh, cloudDirs[cloudI]);
1291 positions[n++] = elmnt().position();
1295 string allVarNames = string(
"X Y Z");
1296 DynamicList<INTEGER4> allVarLocation;
1297 allVarLocation.append(ValueLocation_Nodal);
1298 allVarLocation.append(ValueLocation_Nodal);
1299 allVarLocation.append(ValueLocation_Nodal);
1301 tecplotWriter::getTecplotNames<label>
1304 ValueLocation_Nodal,
1309 tecplotWriter::getTecplotNames<scalar>
1312 ValueLocation_Nodal,
1317 tecplotWriter::getTecplotNames<vector>
1320 ValueLocation_Nodal,
1326 tecplotWriter writer(runTime);
1336 writer.writeOrderedZone
1345 writer.writeField(positions.component(0)());
1346 writer.writeField(positions.component(1)());
1347 writer.writeField(positions.component(2)());
1357 mesh.time().timeName(),
1358 cloud::prefix/cloudDirs[cloudI],
1360 IOobject::MUST_READ,
1369 sfld[j] = scalar(
fld[j]);
1371 writer.writeField(sfld);
1381 mesh.time().timeName(),
1382 cloud::prefix/cloudDirs[cloudI],
1384 IOobject::MUST_READ,
1389 writer.writeField(
fld);
1399 mesh.time().timeName(),
1400 cloud::prefix/cloudDirs[cloudI],
1402 IOobject::MUST_READ,
1407 writer.writeField(
fld);
1415 Info<<
"End\n" <<
endl;
List< instant > instantList
List of instants.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
#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.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
Operations on lists of strings.
PrimitivePatch< face, IndirectList, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
vectorField pointField
pointField is a vectorField.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
bool optionFound(const word &opt) const
Return true if the named option is found.
List< label > labelList
A List of labels.
graph_traits< Graph >::vertices_size_type size_type
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
bool rmDir(const fileName &)
Remove a dirctory and its contents.
volScalarField scalarField(fieldObject, mesh)
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
word name(const complex &)
Return a string representation of a complex.
List< word > wordList
A List of words.
#define WarningInFunction
Report a warning using Foam::Warning.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
Foam::argList args(argc, argv)
List< fileName > fileNameList
A List of fileNames.
fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true)
Read a directory and return the entries as a string list.