152 #include "readFields.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;
501 if (faceSetName.size())
504 faceSet
set(
mesh, faceSetName);
509 fileName patchFileName
517 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;
562 PtrList<const volScalarField::Internal> visf;
563 PtrList<const volVectorField::Internal> vivf;
564 PtrList<const volSphericalTensorField::Internal> visptf;
565 PtrList<const volSymmTensorField::Internal> visytf;
566 PtrList<const volTensorField::Internal> vitf;
568 if (!specifiedFields || selectedFields.size())
571 print(
" volScalarField::Internal :", Info, visf);
574 print(
" volVectorField::Internal :", Info, vivf);
584 print(
" volSphericalTensorFields::Internal :", Info, visptf);
594 print(
" volSymmTensorFields::Internal :", Info, visytf);
597 print(
" volTensorFields::Internal :", Info, vitf);
600 label nVolInternalFields =
610 PtrList<const volScalarField> vsf;
611 PtrList<const volVectorField> vvf;
612 PtrList<const volSphericalTensorField> vsptf;
613 PtrList<const volSymmTensorField> vsytf;
614 PtrList<const volTensorField> vtf;
616 if (!specifiedFields || selectedFields.size())
619 print(
" volScalarFields :", Info, vsf);
622 print(
" volVectorFields :", Info, vvf);
632 print(
" volSphericalTensorFields :", Info, vsptf);
642 print(
" volSymmTensorFields :", Info, vsytf);
645 print(
" volTensorFields :", Info, vtf);
659 Info<<
" pointScalarFields : switched off" 660 <<
" (\"-noPointValues\" (at your option)\n";
661 Info<<
" pointVectorFields : switched off" 662 <<
" (\"-noPointValues\" (at your option)\n";
665 PtrList<const pointScalarField> psf;
666 PtrList<const pointVectorField> pvf;
667 PtrList<const pointSphericalTensorField> psptf;
668 PtrList<const pointSymmTensorField> psytf;
669 PtrList<const pointTensorField> ptf;
671 if (!noPointValues && !(specifiedFields && selectedFields.empty()))
681 print(
" pointScalarFields :", Info, psf);
691 print(
" pointVectorFields :", Info, pvf);
701 print(
" pointSphericalTensorFields :", Info, psptf);
711 print(
" pointSymmTensorFields :", Info, psytf);
721 print(
" pointTensorFields :", Info, ptf);
743 Info<<
" Internal : " << vtkFileName <<
endl;
746 internalWriter writer(vMesh, binary, vtkFileName);
753 1 + nVolInternalFields + nVolFields
757 writer.writeCellIDs();
762 writer.write(visptf);
763 writer.write(visytf);
778 vMesh.nFieldPoints(),
779 nVolFields + nPointFields
790 volPointInterpolation pInterp(mesh);
791 writer.write(pInterp, vsf);
792 writer.write(pInterp, vvf);
793 writer.write(pInterp, vsptf);
794 writer.write(pInterp, vsytf);
795 writer.write(pInterp, vtf);
807 PtrList<const surfaceScalarField> ssf;
816 print(
" surfScalarFields :", Info, ssf);
818 PtrList<const surfaceVectorField> svf;
827 print(
" surfVectorFields :", Info, svf);
829 if (ssf.size() + svf.size() > 0)
832 label sz = svf.size();
834 svf.setSize(sz + ssf.size());
842 svf.set(sz+i, ssfiPtr);
846 mkDir(fvPath /
"surfaceFields");
848 fileName surfFileName
875 const polyBoundaryMesh& patches = mesh.boundaryMesh();
879 mkDir(fvPath/
"allPatches");
881 fileName patchFileName;
883 if (vMesh.useSubMesh())
886 fvPath/
"allPatches"/cellSetName
894 fvPath/
"allPatches"/
"allPatches" 900 Info<<
" Combined patches : " << patchFileName <<
endl;
908 getSelectedPatches(patches, excludePatches)
920 writer.writePatchIDs();
950 const polyPatch& pp = patches[
patchi];
954 mkDir(fvPath/pp.name());
956 fileName patchFileName;
958 if (vMesh.useSubMesh())
961 fvPath/pp.name()/cellSetName
969 fvPath/pp.name()/pp.name()
975 Info<<
" Patch : " << patchFileName <<
endl;
986 if (!isA<emptyPolyPatch>(pp))
997 writer.writePatchIDs();
1002 writer.write(vsptf);
1003 writer.write(vsytf);
1019 writer.write(psptf);
1020 writer.write(psytf);
1023 PrimitivePatchInterpolation<primitivePatch> pInter
1029 writer.write(pInter, vsf);
1030 writer.write(pInter, vvf);
1031 writer.write(pInter, vsptf);
1032 writer.write(pInter, vsytf);
1033 writer.write(pInter, vtf);
1048 PtrList<const surfaceScalarField> ssf;
1057 print(
" surfScalarFields :", Info, ssf);
1059 PtrList<const surfaceVectorField> svf;
1068 print(
" surfVectorFields :", Info, svf);
1074 const faceZone& fz = zones[zoneI];
1076 mkDir(fvPath/fz.name());
1078 fileName patchFileName;
1080 if (vMesh.useSubMesh())
1083 fvPath/fz.name()/cellSetName
1091 fvPath/fz.name()/fz.name()
1097 Info<<
" FaceZone : " << patchFileName <<
endl;
1101 IndirectList<face>(mesh.faces(), fz),
1105 surfaceMeshWriter writer
1118 ssf.size() + svf.size()
1136 const fileName& cloudName = iter.key();
1139 mkDir(fvPath/cloud::prefix/cloudName);
1141 fileName lagrFileName
1143 fvPath/cloud::prefix/cloudName/cloudName
1144 +
"_" + timeDesc +
".vtk" 1147 Info<<
" Lagrangian: " << lagrFileName <<
endl;
1150 IOobjectList sprayObjs
1157 IOobject* positionsPtr = sprayObjs.lookup(word(
"positions"));
1161 wordList labelNames(sprayObjs.names(labelIOField::typeName));
1163 print(Info, labelNames);
1165 wordList scalarNames(sprayObjs.names(scalarIOField::typeName));
1166 Info<<
" scalars :";
1167 print(Info, scalarNames);
1169 wordList vectorNames(sprayObjs.names(vectorIOField::typeName));
1170 Info<<
" vectors :";
1171 print(Info, vectorNames);
1177 sphericalTensorIOField::typeName
1180 Info<<
" spherical tensors :";
1181 print(Info, sphereNames);
1187 symmTensorIOField::typeName
1190 Info<<
" symm tensors :";
1191 print(Info, symmNames);
1193 wordList tensorNames(sprayObjs.names(tensorIOField::typeName));
1194 Info<<
" tensors :";
1195 print(Info, tensorNames);
1197 lagrangianWriter writer
1207 writer.writeParcelHeader
1210 + scalarNames.size()
1211 + vectorNames.size()
1212 + sphereNames.size()
1214 + tensorNames.size()
1218 writer.writeIOField<
label>(labelNames);
1219 writer.writeIOField<scalar>(scalarNames);
1220 writer.writeIOField<
vector>(vectorNames);
1223 writer.writeIOField<
tensor>(tensorNames);
1227 lagrangianWriter writer
1237 writer.writeParcelHeader(0);
1249 if (Pstream::parRun() && doLinks)
1254 Info<<
"Linking all processor files to " <<
runTime.path()/
".."/
"VTK" 1261 /
"processor" +
name(Pstream::myProcNo())
1266 label sz = dirs.size();
1267 dirs.setSize(sz + 1);
1276 fileName procFile(procVTK/dirs[i]/subFiles[j]);
1286 +
name(Pstream::myProcNo())
1290 if (
system(cmd.c_str()) == -1)
1293 <<
"Could not execute command " << cmd <<
endl;
1300 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.
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,.
void writeCellDataHeader(std::ostream &, const label nCells, const label nFields)
Vector< scalar > vector
A scalar version of the templated Vector.
Operations on lists of strings.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
void writePointSet(const bool binary, const primitiveMesh &mesh, const topoSet &set, const fileName &fileName)
Write pointSet to vtk polydata file.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
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)
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
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.
void writePointDataHeader(std::ostream &, const label nPoints, const label nFields)
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.