147 #include "readFields.H" 159 #include "writeAreaFields.H" 160 #include "writeDimFields.H" 161 #include "writeVolFields.H" 162 #include "writePointFields.H" 171 const polyBoundaryMesh&
patches,
172 const autoPtr<wordRes::filter>& patchSelector
177 if (patchSelector && !patchSelector().empty())
198 for (
const label patchi : indices)
202 if (isType<emptyPolyPatch>(
pp))
206 else if (UPstream::parRun() && bool(isA<processorPolyPatch>(
pp)))
211 indices[
count] = patchi;
215 indices.resize(
count);
224 vtk::outputOptions getOutputOptions(
const argList&
args)
227 vtk::outputOptions opts;
235 if (
sizeof(
float) != 4 ||
sizeof(label) != 4)
240 <<
"Using ASCII rather than legacy binary VTK format since " 241 <<
"float and/or label are not 4 bytes in size." 261 int main(
int argc,
char *argv[])
265 "General OpenFOAM to VTK file writer" 267 timeSelector::addOptions();
270 argList::setAdvanced(
"decomposeParDict");
272 argList::addVerboseOption();
274 argList::addBoolOption
277 "Write in ASCII format instead of binary" 279 argList::addBoolOption
282 "Write legacy format instead of xml",
285 argList::addBoolOption
288 "Decompose polyhedral cells into tets/pyramids",
291 argList::ignoreOptionCompat
296 argList::ignoreOptionCompat
306 "Convert mesh subset corresponding to specified cellSet",
313 "Convert mesh subset corresponding to specified cellZone",
320 "Convert specified faceSet only",
327 "Convert specified pointSet only",
334 "Specify single or multiple faceZones to write\n" 335 "Eg, 'cells' or '( slice \"mfp-.*\" )'.",
342 "Specify single or multiple fields to write (all by default)\n" 343 "Eg, 'T' or '(p T U \"alpha.*\")'" 349 "Exclude single or multiple fields",
352 argList::addBoolOption
355 "Suppress conversion of fields" 358 argList::addBoolOption
361 "Write field values on processor boundaries only",
364 argList::addBoolOption
367 "Write surfaceScalarFields (eg, phi)",
370 argList::addBoolOption
373 "Suppress output of finite-area mesh/fields",
376 argList::ignoreOptionCompat
378 {
"finite-area", 2112},
381 argList::ignoreOptionCompat
383 {
"finiteAreaFields", 2012},
387 argList::addBoolOption
390 "Use cell value on patches instead of patch value itself",
393 argList::addBoolOption
396 "Suppress output for boundary patches" 398 argList::addBoolOption
401 "Suppress output for internal volume mesh" 403 argList::addBoolOption
406 "Suppress writing lagrangian positions and fields" 408 argList::addOptionCompat(
"no-lagrangian", {
"noLagrangian", 1806});
410 argList::addBoolOption
413 "Suppress conversion of pointFields. No interpolated PointData." 415 argList::addOptionCompat(
"no-point-data", {
"noPointValues", 1806});
417 argList::addBoolOption
420 "Additional mesh id fields (cellID, procID, patchID)",
424 argList::addBoolOption
427 "Additional pointID field for internal mesh",
431 argList::addBoolOption
434 "Combine all patches into a single file" 436 argList::addOptionCompat(
"one-boundary", {
"allPatches", 1806});
444 "Specify single patch or multiple patches to write\n" 445 "Eg, 'top' or '( front \".*back\" )'" 451 "Exclude single or multiple patches from writing\n" 452 "Eg, 'outlet' or '( inlet \".*Wall\" )'",
455 argList::addOptionCompat(
"exclude-patches", {
"excludePatches", 2112});
457 argList::ignoreOptionCompat
459 {
"noFaceZones", 1806},
462 argList::ignoreOptionCompat
467 argList::ignoreOptionCompat
469 {
"useTimeName", 1806},
472 argList::addBoolOption
475 "Remove any existing VTK output directory" 481 "Directory name for VTK output (default: 'VTK')" 487 const bool decomposePoly =
args.
found(
"poly-decomp");
488 const bool doBoundary = !
args.
found(
"no-boundary");
489 const bool doInternal = !
args.
found(
"no-internal");
490 const bool doLagrangian = !
args.
found(
"no-lagrangian");
491 const bool doFiniteArea = !
args.
found(
"no-finite-area");
492 const bool doSurfaceFields =
args.
found(
"surfaceFields");
493 const bool oneBoundary =
args.
found(
"one-boundary") && doBoundary;
494 const bool nearCellValue =
args.
found(
"nearCellValue") && doBoundary;
496 const vtk::outputOptions writeOpts = getOutputOptions(
args);
498 bool processorFieldsOnly =
false;
502 if (!UPstream::parRun())
504 Info<<
"Ignoring processor patch writing in serial" 507 else if (writeOpts.legacy())
509 Info<<
"Ignoring processor patch writing in legacy format" 514 processorFieldsOnly =
true;
516 Info<<
"Writing processor patch fields only" 523 Info<<
"Using neighbouring cell value instead of patch value" 527 bool doPointValues = !
args.
found(
"no-point-data");
530 Info<<
"Point fields and interpolated point data" 531 <<
" disabled with the '-no-point-data' option" 535 const bool withPointIds =
args.
found(
"with-point-ids");
538 Info<<
"Write point ids requested";
542 Info<<
", but ignored due to the '-no-point-data' option";
548 const bool withMeshIds =
args.
found(
"with-ids");
551 Info<<
"Writing mesh ids (cell, patch, proc) requested" <<
nl;
555 wordRes includedPatches, excludedPatches;
556 autoPtr<wordRes::filter> patchSelector(
nullptr);
559 bool resetFilter =
false;
563 Info<<
"Including patches " 569 Info<<
"Excluding patches " 581 wordRes includedFields, excludedFields;
582 autoPtr<wordRes::filter> fieldSelector(
nullptr);
583 bool doConvertFields = !
args.
found(
"no-fields");
586 bool resetFilter =
false;
589 Info<<
"Including fields " 592 resetFilter = !includedFields.empty();
594 if (includedFields.empty())
599 doConvertFields =
false;
600 Info<<
"Field conversion disabled by '-fields ()' option" <<
nl 601 <<
"Should use -no-fields instead" <<
endl;
607 Info<<
"Excluding fields " 611 if (resetFilter && doConvertFields)
617 else if (doConvertFields)
619 Info<<
"Field conversion disabled with the '-no-fields' option" <<
nl;
624 const wordRes selectedFaceZones(
args.
getList<wordRe>(
"faceZones",
false));
631 HashTable<vtk::seriesWriter, fileName> vtkSeries;
637 word cellSelectionName;
641 fvMeshSubsetProxy::subsetType cellSubsetType = fvMeshSubsetProxy::NONE;
649 vtkName = cellSelectionName;
650 cellSubsetType = fvMeshSubsetProxy::SET;
652 Info<<
"Converting cellSet " << cellSelectionName
653 <<
" only. New outside faces as \"oldInternalFaces\"." 658 vtkName = cellSelectionName;
659 cellSubsetType = fvMeshSubsetProxy::ZONE;
661 Info<<
"Converting cellZone " << cellSelectionName
662 <<
" only. New outside faces as \"oldInternalFaces\"." 673 const char *
const opt
674 : {
"cellSet",
"cellZone",
"faceSet",
"pointSet" }
679 Info<<
"Ignoring -" << opt <<
" for multi-regions" <<
nl;
692 if (UPstream::master())
703 Info<<
"Removing old directory " 718 #include "createMeshAccounting.H" 720 Info<<
"VTK mesh topology: " 721 << timer.cpuTimeIncrement() <<
" s, " 729 runTime.setTime(timeDirs[timei], timei);
732 const scalar timeValue =
runTime.value();
759 polyMesh::readUpdateState meshState =
760 meshProxy.readUpdate();
762 const fvMesh&
mesh = meshProxy.mesh();
766 meshState == polyMesh::TOPO_CHANGE
767 || meshState == polyMesh::TOPO_PATCH_CHANGE
771 vtuMeshCells.clear();
783 IOobjectList objects(0);
789 IOobjectList(meshProxy.baseMesh(),
runTime.timeName());
791 if (fieldSelector && !fieldSelector().empty())
793 objects.filterObjects(fieldSelector());
802 objects.filterClasses
804 [](
const word& clsName)
813 if (processorFieldsOnly)
821 #include "convertVolumeFields.H" 827 #include "convertAreaFields.H" 830 #include "convertLagrangian.H" 838 outputDir/vtkName +
"-regions" + timeDesc +
".vtm" 841 vtmMultiRegion.setTime(timeValue);
844 fileName seriesName(vtk::seriesWriter::base(
outputName));
846 vtk::seriesWriter& series = vtkSeries(seriesName);
853 series.load(seriesName,
true, timeValue);
857 series.write(seriesName);
861 << timer.cpuTimeIncrement() <<
" s, " 867 << timer.elapsedCpuTime() <<
" s, "
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Extract list indices for all items with 'name()' that matches.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< T > getList(const label index) const
Get a List of values from the argument at index.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
const fileName & globalCaseName() const noexcept
Return global case name.
Operations on lists of strings.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
#define forAll(list, i)
Loop across all elements in list.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
word outputName("finiteArea-edges.obj")
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
int64_t peak() const noexcept
Peak memory at last update - (VmPeak in /proc/PID/status)
Write topoSet in VTK format.
fileName relativePath(const fileName &input, const bool caseTag=false) const
Return the input relative to the globalPath by stripping off a leading value of the globalPath...
bool rmDir(const fileName &directory, const bool silent=false, const bool emptyOnly=false)
Remove a directory and its contents recursively,.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
Memory usage information for the current process, and the system memory that is free.
PtrList< fvMeshSubsetProxy > meshProxies(meshes.size())
PtrList< vtk::vtuCells > vtuMappings(meshes.size())
vector point
Point is a vector.
cpuTimePosix cpuTime
Selection of preferred clock mechanism for the elapsed cpu time.
#define WarningInFunction
Report a warning using Foam::Warning.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
const polyBoundaryMesh & patches
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
List< label > labelList
A List of labels.
List< instant > instantList
List of instants.
Foam::argList args(argc, argv)
bool found(const word &optName) const
Return true if the named option is found.
int64_t size() const noexcept
Memory size at last update - (VmSize in /proc/PID/status)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
fileName globalPath() const
Return the full path to the global case.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.