152 #include "readFields.H" 153 #include "writeFuns.H" 160 #include "writePointSet.H" 167 template<
class GeoField>
168 void print(
const char* msg, Ostream& os,
const PtrList<const GeoField>& flds)
175 os <<
' ' << flds[i].name();
182 void print(Ostream& os,
const wordList& flds)
186 os <<
' ' << flds[i];
194 const polyBoundaryMesh& patches,
195 const List<wordRe>& excludePatches
198 DynamicList<label> patchIDs(patches.size());
200 Info<<
"Combining patches:" <<
endl;
204 const polyPatch& pp = patches[
patchi];
208 isType<emptyPolyPatch>(pp)
209 || (Pstream::parRun() && isType<processorPolyPatch>(pp))
212 Info<<
" discarding empty/processor patch " <<
patchi 213 <<
" " << pp.name() <<
endl;
217 Info<<
" excluding patch " <<
patchi 218 <<
" " << pp.name() <<
endl;
223 Info<<
" patch " <<
patchi <<
" " << pp.name() <<
endl;
226 return patchIDs.shrink();
232 int main(
int argc,
char *argv[])
236 "legacy VTK file format writer" 238 timeSelector::addOptions();
245 "only convert the specified fields - eg '(p T U)'" 251 "convert a mesh subset corresponding to the specified cellSet" 257 "restrict conversion to the specified faceSet" 263 "restrict conversion to the specified pointSet" 265 argList::addBoolOption
268 "write in ASCII format instead of binary" 270 argList::addBoolOption
273 "write polyhedral cells without tet/pyramid decomposition" 275 argList::addBoolOption
278 "write surfaceScalarFields (e.g., phi)" 280 argList::addBoolOption
283 "use cell value on patches instead of patch value itself" 285 argList::addBoolOption
288 "do not generate file for mesh, only for patches" 290 argList::addBoolOption
295 argList::addBoolOption
298 "combine all patches into a single file" 304 "a list of patches to exclude - eg '( inlet \".*Wall\" )' " 306 argList::addBoolOption
311 argList::addBoolOption
314 "don't link processor VTK files - parallel only" 316 argList::addBoolOption
319 "use the time name instead of the time index when naming the files" 337 <<
"Using ASCII rather than binary VTK format because " 338 "floatScalar and/or label are not 4 bytes in size." 348 <<
"Using neighbouring cell value instead of patch value" 357 <<
"Outputting cell values only" <<
nl <<
endl;
362 List<wordRe> excludePatches;
367 Info<<
"Not including patches " << excludePatches <<
nl <<
endl;
373 string vtkName =
runTime.caseName();
377 vtkName = cellSetName;
379 else if (Pstream::parRun())
384 if (i != string::npos)
386 vtkName = vtkName.substr(i);
399 fileName fvPath(
runTime.path()/
"VTK");
402 fileName regionPrefix =
"";
416 || cellSetName.size()
417 || faceSetName.size()
418 || pointSetName.size()
422 Info<<
"Keeping old VTK files in " << fvPath <<
nl <<
endl;
426 Info<<
"Deleting old VTK files in " << fvPath <<
nl <<
endl;
436 vtkMesh vMesh(mesh, cellSetName);
440 HashSet<fileName> allCloudDirs;
443 runTime.setTime(timeDirs[timeI], timeI);
448 runTime.timePath()/regionPrefix/cloud::prefix,
454 IOobjectList sprayObjs
458 cloud::prefix/cloudDirs[i]
461 IOobject* positionsPtr = sprayObjs.lookup(word(
"positions"));
465 if (allCloudDirs.insert(cloudDirs[i]))
467 Info<<
"At time: " <<
runTime.timeName()
468 <<
" detected cloud directory : " << cloudDirs[i]
478 runTime.setTime(timeDirs[timeI], timeI);
487 polyMesh::readUpdateState meshState = vMesh.readUpdate();
489 const fvMesh& mesh = vMesh.mesh();
493 meshState == polyMesh::TOPO_CHANGE
494 || meshState == polyMesh::TOPO_PATCH_CHANGE
497 Info<<
" Read new mesh" <<
nl <<
endl;
502 if (faceSetName.size())
505 faceSet
set(
mesh, faceSetName);
510 fileName patchFileName
518 Info<<
" FaceSet : " << patchFileName <<
endl;
525 if (pointSetName.size())
528 pointSet
set(
mesh, pointSetName);
533 fileName patchFileName
541 Info<<
" pointSet : " << patchFileName <<
endl;
552 HashSet<word> selectedFields;
561 PtrList<const volScalarField> vsf;
562 PtrList<const volVectorField> vvf;
563 PtrList<const volSphericalTensorField> vSpheretf;
564 PtrList<const volSymmTensorField> vSymmtf;
565 PtrList<const volTensorField> vtf;
567 if (!specifiedFields || selectedFields.size())
570 print(
" volScalarFields :", Info, vsf);
573 print(
" volVectorFields :", Info, vvf);
583 print(
" volSphericalTensorFields :", Info, vSpheretf);
593 print(
" volSymmTensorFields :", Info, vSymmtf);
596 print(
" volTensorFields :", Info, vtf);
611 Info<<
" pointScalarFields : switched off" 612 <<
" (\"-noPointValues\" (at your option)\n";
613 Info<<
" pointVectorFields : switched off" 614 <<
" (\"-noPointValues\" (at your option)\n";
617 PtrList<const pointScalarField> psf;
618 PtrList<const pointVectorField> pvf;
619 PtrList<const pointSphericalTensorField> pSpheretf;
620 PtrList<const pointSymmTensorField> pSymmtf;
621 PtrList<const pointTensorField> ptf;
623 if (!noPointValues && !(specifiedFields && selectedFields.empty()))
633 print(
" pointScalarFields :", Info, psf);
643 print(
" pointVectorFields :", Info, pvf);
653 print(
" pointSphericalTensorFields :", Info, pSpheretf);
663 print(
" pointSymmTensorFields :", Info, pSymmtf);
673 print(
" pointTensorFields :", Info, ptf);
695 Info<<
" Internal : " << vtkFileName <<
endl;
698 internalWriter writer(vMesh, binary, vtkFileName);
701 writeFuns::writeCellDataHeader
709 writer.writeCellIDs();
714 writer.write(vSpheretf);
715 writer.write(vSymmtf);
720 writeFuns::writePointDataHeader
723 vMesh.nFieldPoints(),
724 nVolFields+nPointFields
730 writer.write(pSpheretf);
731 writer.write(pSymmtf);
735 volPointInterpolation pInterp(mesh);
736 writer.write(pInterp, vsf);
737 writer.write(pInterp, vvf);
738 writer.write(pInterp, vSpheretf);
739 writer.write(pInterp, vSymmtf);
740 writer.write(pInterp, vtf);
752 PtrList<const surfaceScalarField> ssf;
761 print(
" surfScalarFields :", Info, ssf);
763 PtrList<const surfaceVectorField> svf;
772 print(
" surfVectorFields :", Info, svf);
774 if (ssf.size() + svf.size() > 0)
777 label sz = svf.size();
779 svf.setSize(sz+ssf.size());
787 svf.set(sz+i, ssfiPtr);
791 mkDir(fvPath /
"surfaceFields");
793 fileName surfFileName
820 const polyBoundaryMesh& patches = mesh.boundaryMesh();
824 mkDir(fvPath/
"allPatches");
826 fileName patchFileName;
828 if (vMesh.useSubMesh())
831 fvPath/
"allPatches"/cellSetName
839 fvPath/
"allPatches"/
"allPatches" 845 Info<<
" Combined patches : " << patchFileName <<
endl;
853 getSelectedPatches(patches, excludePatches)
857 writeFuns::writeCellDataHeader
865 writer.writePatchIDs();
870 writer.write(vSpheretf);
871 writer.write(vSymmtf);
876 writeFuns::writePointDataHeader
886 writer.write(pSpheretf);
887 writer.write(pSymmtf);
898 const polyPatch& pp = patches[
patchi];
902 mkDir(fvPath/pp.name());
904 fileName patchFileName;
906 if (vMesh.useSubMesh())
909 fvPath/pp.name()/cellSetName
917 fvPath/pp.name()/pp.name()
923 Info<<
" Patch : " << patchFileName <<
endl;
934 if (!isA<emptyPolyPatch>(pp))
937 writeFuns::writeCellDataHeader
945 writer.writePatchIDs();
950 writer.write(vSpheretf);
951 writer.write(vSymmtf);
956 writeFuns::writePointDataHeader
967 writer.write(pSpheretf);
968 writer.write(pSymmtf);
971 PrimitivePatchInterpolation<primitivePatch> pInter
977 writer.write(pInter, vsf);
978 writer.write(pInter, vvf);
979 writer.write(pInter, vSpheretf);
980 writer.write(pInter, vSymmtf);
981 writer.write(pInter, vtf);
996 PtrList<const surfaceScalarField> ssf;
1005 print(
" surfScalarFields :", Info, ssf);
1007 PtrList<const surfaceVectorField> svf;
1016 print(
" surfVectorFields :", Info, svf);
1022 const faceZone& fz = zones[zoneI];
1024 mkDir(fvPath/fz.name());
1026 fileName patchFileName;
1028 if (vMesh.useSubMesh())
1031 fvPath/fz.name()/cellSetName
1039 fvPath/fz.name()/fz.name()
1045 Info<<
" FaceZone : " << patchFileName <<
endl;
1049 IndirectList<face>(mesh.faces(), fz),
1053 surfaceMeshWriter writer
1062 writeFuns::writeCellDataHeader
1066 ssf.size()+svf.size()
1084 const fileName& cloudName = iter.key();
1087 mkDir(fvPath/cloud::prefix/cloudName);
1089 fileName lagrFileName
1091 fvPath/cloud::prefix/cloudName/cloudName
1092 +
"_" + timeDesc +
".vtk" 1095 Info<<
" Lagrangian: " << lagrFileName <<
endl;
1098 IOobjectList sprayObjs
1105 IOobject* positionsPtr = sprayObjs.lookup(word(
"positions"));
1109 wordList labelNames(sprayObjs.names(labelIOField::typeName));
1111 print(Info, labelNames);
1113 wordList scalarNames(sprayObjs.names(scalarIOField::typeName));
1114 Info<<
" scalars :";
1115 print(Info, scalarNames);
1117 wordList vectorNames(sprayObjs.names(vectorIOField::typeName));
1118 Info<<
" vectors :";
1119 print(Info, vectorNames);
1125 sphericalTensorIOField::typeName
1128 Info<<
" spherical tensors :";
1129 print(Info, sphereNames);
1135 symmTensorIOField::typeName
1138 Info<<
" symm tensors :";
1139 print(Info, symmNames);
1141 wordList tensorNames(sprayObjs.names(tensorIOField::typeName));
1142 Info<<
" tensors :";
1143 print(Info, tensorNames);
1145 lagrangianWriter writer
1155 writer.writeParcelHeader
1158 + scalarNames.size()
1159 + vectorNames.size()
1160 + sphereNames.size()
1162 + tensorNames.size()
1166 writer.writeIOField<
label>(labelNames);
1167 writer.writeIOField<scalar>(scalarNames);
1168 writer.writeIOField<
vector>(vectorNames);
1171 writer.writeIOField<
tensor>(tensorNames);
1175 lagrangianWriter writer
1185 writer.writeParcelHeader(0);
1197 if (Pstream::parRun() && doLinks)
1202 Info<<
"Linking all processor files to " <<
runTime.path()/
".."/
"VTK" 1209 /
"processor" +
name(Pstream::myProcNo())
1214 label sz = dirs.size();
1224 fileName procFile(procVTK/dirs[i]/subFiles[j]);
1234 +
name(Pstream::myProcNo())
1238 if (
system(cmd.c_str()) == -1)
1241 <<
"Could not execute command " << cmd <<
endl;
1248 Info<<
"End\n" <<
endl;
List< instant > instantList
List of instants.
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
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.
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.
void writePointSet(const bool binary, const primitiveMesh &mesh, const topoSet &set, const fileName &fileName)
Write pointSet to vtk polydata file.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
bool chDir(const fileName &dir)
Change the current directory to the one given and return true,.
Vector< scalar > vector
A scalar version of the templated Vector.
Operations on lists of strings.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
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.
void writeSurfFields(const bool binary, const vtkMesh &vMesh, const fileName &fileName, const UPtrList< const surfaceVectorField > &surfVectorFields)
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
float floatScalar
Float precision floating point scalar type.
Write faceSet to vtk polydata file. Only one data which is original faceID.
void writeFaceSet(const bool binary, const vtkMesh &vMesh, const faceSet &set, const fileName &fileName)
List< label > labelList
A List of labels.
fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true)
Read a directory and return the entries as a string list.
graph_traits< Graph >::vertices_size_type size_type
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
bool rmDir(const fileName &)
Remove a directory and its contents.
Write a patch with its data.
virtual void rename(const word &newName)
Rename.
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.
const word cloudName(propsDict.lookup("cloudName"))
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars.
Foam::argList args(argc, argv)
List< fileName > fileNameList
A List of fileNames.
Tensor< scalar > tensor
Tensor of scalars.
int system(const std::string &command)
Execute the specified command.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.