153 #include "readFields.H"
165 using namespace Foam;
169 template<
class GeoField>
177 os <<
' ' << flds[i].name();
188 os <<
' ' << flds[i];
202 Info<<
"Combining patches:" <<
endl;
210 isA<emptyPolyPatch>(pp)
211 || isA<nonConformalPolyPatch>(pp)
215 Info<<
" discarding empty/nonConformal/processor patch "
230 return patchIDs.shrink();
236 int main(
int argc,
char *argv[])
240 "legacy VTK file format writer"
249 "only convert the specified fields - eg '(p T U)'"
255 "convert a mesh subset corresponding to the specified cellSet"
261 "restrict conversion to the specified faceSet"
267 "restrict conversion to the specified pointSet"
272 "write in ASCII format instead of binary"
278 "cell types to write as polyhedra - 'none', 'polyhedra', or 'all'"
283 "write surfaceScalarFields (e.g., phi)"
288 "use cell value on patches instead of patch value itself"
293 "do not generate file for mesh, only for patches"
303 "combine all patches into a single file"
309 "a list of patches to exclude - eg '( inlet \".*Wall\" )' "
319 "don't link processor VTK files - parallel only"
324 "use the time name instead of the time index when naming the files"
348 <<
"Using ASCII rather than binary VTK format because "
349 "floatScalar and/or label are not 4 bytes in size."
359 <<
"Using neighbouring cell value instead of patch value"
368 <<
"Outputting cell values only" <<
nl <<
endl;
378 Info<<
"Not including patches " << excludePatches <<
nl <<
endl;
384 string vtkName = runTime.caseName();
388 vtkName = cellSetName;
395 if (i != string::npos)
397 vtkName = vtkName.substr(i);
410 fileName fvPath(runTime.path()/
"VTK");
427 || cellSetName.size()
428 || faceSetName.size()
429 || pointSetName.size()
433 Info<<
"Keeping old VTK files in " << fvPath <<
nl <<
endl;
437 Info<<
"Deleting old VTK files in " << fvPath <<
nl <<
endl;
447 vtkMesh vMesh(mesh, polyhedra, cellSetName);
454 runTime.setTime(
timeDirs[timeI], timeI);
472 IOobject* positionsPtr = sprayObjs.lookup(
word(
"positions"));
476 if (allCloudDirs.
insert(cloudDirs[i]))
478 Info<<
"At time: " << runTime.name()
479 <<
" detected cloud directory : " << cloudDirs[i]
489 runTime.setTime(
timeDirs[timeI], timeI);
491 Info<<
"Time: " << runTime.name() <<
endl;
494 useTimeName ? runTime.name() :
Foam::name(runTime.timeIndex());
500 const fvMesh& mesh = vMesh.mesh();
512 if (faceSetName.size())
515 faceSet set(mesh, faceSetName);
518 mkDir(fvPath/set.name());
522 fvPath/set.name()/set.name()
528 Info<<
" FaceSet : " << patchFileName <<
endl;
536 if (pointSetName.size())
542 mkDir(fvPath/set.name());
546 fvPath/set.name()/set.name()
552 Info<<
" pointSet : " << patchFileName <<
endl;
579 if (!specifiedFields || selectedFields.
size())
582 print(
" volScalarField::Internal :",
Info, visf);
585 print(
" volVectorField::Internal :",
Info, vivf);
595 print(
" volSphericalTensorFields::Internal :",
Info, visptf);
605 print(
" volSymmTensorFields::Internal :",
Info, visytf);
608 print(
" volTensorFields::Internal :",
Info, vitf);
611 label nVolInternalFields =
627 if (!specifiedFields || selectedFields.
size())
630 print(
" volScalarFields :",
Info, vsf);
633 print(
" volVectorFields :",
Info, vvf);
643 print(
" volSphericalTensorFields :",
Info, vsptf);
653 print(
" volSymmTensorFields :",
Info, vsytf);
656 print(
" volTensorFields :",
Info, vtf);
670 Info<<
" pointScalarFields : switched off"
671 <<
" (\"-noPointValues\" (at your option)\n";
672 Info<<
" pointVectorFields : switched off"
673 <<
" (\"-noPointValues\" (at your option)\n";
682 if (!noPointValues && !(specifiedFields && selectedFields.
empty()))
692 print(
" pointScalarFields :",
Info, psf);
702 print(
" pointVectorFields :",
Info, pvf);
712 print(
" pointSphericalTensorFields :",
Info, psptf);
722 print(
" pointSymmTensorFields :",
Info, psytf);
732 print(
" pointTensorFields :",
Info, ptf);
754 Info<<
" Internal : " << vtkFileName <<
endl;
764 1 + nVolInternalFields + nVolFields
768 writer.writeCellIDs();
773 writer.write(visptf);
774 writer.write(visytf);
789 vMesh.nFieldPoints(),
790 nVolFields + nPointFields
806 writer.write(pInterp, vsf);
807 writer.write(pInterp, vvf);
808 writer.write(pInterp, vsptf);
809 writer.write(pInterp, vsytf);
810 writer.write(pInterp, vtf);
831 print(
" surfScalarFields :",
Info, ssf);
842 print(
" surfVectorFields :",
Info, svf);
857 svf.
set(sz+i, ssfiPtr);
861 mkDir(fvPath /
"surfaceFields");
896 mkDir(fvPath/
"allPatches");
900 if (vMesh.useSubMesh())
903 fvPath/
"allPatches"/cellSetName
911 fvPath/
"allPatches"/
"allPatches"
917 Info<<
" Combined patches : " << patchFileName <<
endl;
925 getSelectedPatches(
patches, excludePatches)
937 writer.writePatchIDs();
973 if (vMesh.useSubMesh())
976 fvPath/pp.
name()/cellSetName
990 Info<<
" Patch : " << patchFileName <<
endl;
1010 writer.writePatchIDs();
1015 writer.write(vsptf);
1016 writer.write(vsytf);
1032 writer.write(psptf);
1033 writer.write(psytf);
1042 writer.write(pInter, vsf);
1043 writer.write(pInter, vvf);
1044 writer.write(pInter, vsptf);
1045 writer.write(pInter, vsytf);
1046 writer.write(pInter, vtf);
1068 print(
" surfScalarFields :",
Info, ssf);
1079 print(
" surfVectorFields :",
Info, svf);
1091 if (vMesh.useSubMesh())
1094 fvPath/fz.
name()/cellSetName
1108 Info<<
" FaceZone : " << patchFileName <<
endl;
1155 +
"_" + timeDesc +
".vtk"
1158 Info<<
" Lagrangian: " << lagrFileName <<
endl;
1168 IOobject* positionsPtr = sprayObjs.lookup(
word(
"positions"));
1174 print(
Info, labelNames);
1177 Info<<
" scalars :";
1178 print(
Info, scalarNames);
1181 Info<<
" vectors :";
1182 print(
Info, vectorNames);
1191 Info<<
" spherical tensors :";
1192 print(
Info, sphereNames);
1201 Info<<
" symm tensors :";
1202 print(
Info, symmNames);
1205 Info<<
" tensors :";
1206 print(
Info, tensorNames);
1218 writer.writeFieldsHeader
1221 + scalarNames.size()
1222 + vectorNames.size()
1223 + sphereNames.size()
1225 + tensorNames.size()
1229 writer.writeIOField<
label>(labelNames);
1230 writer.writeIOField<scalar>(scalarNames);
1231 writer.writeIOField<
vector>(vectorNames);
1234 writer.writeIOField<
tensor>(tensorNames);
1248 writer.writeFieldsHeader(0);
1262 mkDir(runTime.globalPath()/
"VTK");
1263 chDir(runTime.globalPath()/
"VTK");
1265 Info<<
"Linking all processor files to " << runTime.globalPath()/
"VTK"
1277 label sz = dirs.size();
1278 dirs.setSize(sz + 1);
1287 fileName procFile(procVTK/dirs[i]/subFiles[j]);
graph_traits< Graph >::vertices_size_type size_type
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
static pointMesh & New(const polyMesh &mesh)
static const char *const typeName
Generic GeometricField class.
A HashTable with keys but without contents.
bool insert(const Key &key)
Insert a new entry.
label size() const
Return number of elements in table.
bool empty() const
Return true if the hash table is empty.
List of IOobjects with searching and retrieving facilities.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
A List with indirect addressing.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component,...
static bool & parRun()
Is this a parallel run?
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
label size() const
Return the number of elements in the UPtrList.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static void addNote(const string &)
Add extra notes for the usage information.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
static const word prefix
The prefix to local: lagrangian.
A subset of mesh faces organised as a primitive patch.
A class for handling file names.
Mesh data needed to do the Finite Volume discretisation.
const surfaceVectorField & Sf() const
Return cell face area vectors.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
Writes Lagrangian points and fields.
const word & name() const
Return name.
static word defaultRegion
Return the default region name.
const meshFaceZones & faceZones() const
Return face zones.
virtual const faceList & faces() const
Return raw faces.
readUpdateState
Enumeration defining the state of the mesh after a read update.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
virtual void rename(const word &newName)
Rename.
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
Interpolate from cell centres to points (vertices) using inverse distance weighting.
Encapsulation of VTK mesh data. Holds mesh or meshsubset and polyhedral-cell decomposition on it.
static const NamedEnum< vtkPolyhedra, 3 > vtkPolyhedraNames_
Names of groups of cell types retain as polyhedra.
vtkPolyhedra
Groups of cell types retain as polyhedra.
A class for handling words, derived from string.
const word & name() const
Return name.
int main(int argc, char *argv[])
static instantList timeDirs
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
void writePointDataHeader(std::ostream &, const label nPoints, const label nFields)
void writeCellDataHeader(std::ostream &, const label nCells, const label nFields)
void writeSurfFields(const bool binary, const vtkMesh &vMesh, const fileName &fileName, const UPtrList< const surfaceVectorField > &surfVectorFields)
void writeFaceSet(const bool binary, const vtkMesh &vMesh, const faceSet &set, const fileName &fileName)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
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.
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
bool rmDir(const fileName &)
Remove a directory and its contents.
float floatScalar
Float precision floating point scalar type.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
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.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
void writePointSet(const bool binary, const vtkMesh &vMesh, const pointSet &set, const fileName &fileName)
bool chDir(const fileName &dir)
Change the current directory to the one given and return true,.
Foam::argList args(argc, argv)
Operations on lists of strings.
const word cloudName(propsDict.lookup("cloudName"))
Write faceSet to vtk polydata file. Only one data which is original faceID.
Write pointSet to vtk polydata file. Only one data which is original pointID.
Write a patch with its data.