155#undef foamToEnsight_useTimeIndex
161int main(
int argc,
char *argv[])
165 "Translate OpenFOAM data to Ensight format with individual parts"
166 " for cellZones, unzoned cells and patches"
181 "Write in ASCII format instead of 'C Binary'"
187 "Starting index for consecutive number of Ensight data/ files."
188 " Ignore the time index contained in the uniform/time file."
195 "Sub-directory name for Ensight output (default: 'EnSight')"
200 "Suppress removal of existing EnSight output directory"
206 "Width of Ensight data subdir"
211 "Use zero-gradient cell values on patches"
217 "Force interpolation of values to nodes"
223 "Suppress writing any patches"
230 "Suppress writing the internal mesh"
235 "Suppress writing any cellZones"
240 "Suppress writing lagrangian positions and fields"
247 "Suppress conversion of pointFields, disable -nodeValues"
252 "Suppress writing the geometry."
253 " Can be useful for converting partial results for a static geometry"
266 "Suppress output of finite-area mesh/fields",
271 {
"finite-area", 2112},
279 "Specify single patch or multiple patches to write\n"
280 "Eg, 'inlet' or '(outlet \"inlet.*\")'"
286 "Exclude single or multiple patches from writing\n"
287 "Eg, 'outlet' or '( inlet \".*Wall\" )'"
296 "Specify single or multiple faceZones to write\n"
297 "Eg, 'cells' or '( slice \"mfp-.*\" )'."
303 "Specify single or multiple fields to write (all by default)\n"
304 "Eg, 'T' or '( \"U.*\" )'"
310 "Exclude single or multiple fields",
316 "Suppress conversion of fields"
323 "Specify single or multiple cellZones to write\n"
324 "Eg, 'cells' or '( slice \"mfp-.*\" )'."
344 const int optVerbose =
args.verbose();
345 const bool doBoundary = !
args.found(
"no-boundary");
346 const bool doInternal = !
args.found(
"no-internal");
347 const bool doCellZones = !
args.found(
"no-cellZones");
348 const bool doLagrangian = !
args.found(
"no-lagrangian");
349 const bool doFiniteArea = !
args.found(
"no-finite-area");
350 const bool doPointValues = !
args.found(
"no-point-data");
351 const bool nearCellValue =
args.found(
"nearCellValue") && doBoundary;
354 label indexingNumber(0);
355 const bool doConsecutive =
args.readIfPresent(
"index", indexingNumber);
358 bool doGeometry = !
args.found(
"no-mesh");
362 Info<<
"Using neighbouring cell value instead of patch value"
367 Info<<
"Point fields and interpolated point data"
368 <<
" disabled with the '-no-point-data' option"
378 caseOpts.nodeValues(doPointValues &&
args.found(
"nodeValues"));
379 caseOpts.width(
args.getOrDefault<label>(
"width", 8));
380 caseOpts.overwrite(!
args.found(
"no-overwrite"));
391 if (
args.found(
"patches"))
395 if (
args.found(
"exclude-patches"))
400 if (
args.found(
"faceZones"))
404 if (
args.found(
"cellZones"))
413 wordRes includedFields, excludedFields;
414 const bool doConvertFields = !
args.found(
"no-fields");
417 if (
args.readListIfPresent<
wordRe>(
"fields", includedFields))
419 Info<<
"Including fields "
422 if (
args.readListIfPresent<
wordRe>(
"exclude-fields", excludedFields))
424 Info<<
"Excluding fields "
430 Info<<
"Field conversion disabled with the '-no-fields' option" <<
nl;
460 const word ensDirName =
args.getOrDefault<
word>(
"name",
"EnSight");
464 if (!outputDir.isAbsolute())
466 outputDir =
args.globalPath()/outputDir;
479 Info<<
"Converting " << timeDirs.
size() <<
" time steps" <<
nl;
487 Info<<
"has moving mesh: ignoring '-no-mesh' option" <<
endl;
503 <<
timer.cpuTimeIncrement() <<
" s, "
509 runTime.setTime(timeDirs[timei], timei);
535 ensCase.setTime(timeDirs[timei],
timeIndex);
542 for (
auto& ensFaCase : ensFaCases)
544 ensFaCase.setTime(timeDirs[timei],
timeIndex);
553 for (
auto& ensFaMesh : ensFaMeshes)
560 if ((timei == 0 || moving) && doGeometry)
567 ensMesh.write(
os.ref());
571 forAll(ensFaMeshes, areai)
573 const auto& ensFaCase = ensFaCases[areai];
574 const auto& ensFaMesh = ensFaMeshes[areai];
579 ensFaMesh.write(
os.ref());
587 objects.filterObjects
596 forAll(ensFaMeshes, areai)
598 auto* ensFaCasePtr = ensFaCases.get(areai);
599 auto* ensFaMeshPtr = ensFaMeshes.get(areai);
606 const auto&
areaMesh = ensFaMeshPtr->mesh();
631 <<
timer.cpuTimeIncrement() <<
" s, "
649 <<
timer.elapsedCpuTime() <<
" s, "
Istream and Ostream manipulators taking arguments.
Helper routines for reading a field or fields, for foamToEnsight.
List< HashTable< wordHashSet > > availableFaRegionObjectNames(meshes.size())
List< wordHashSet > availableRegionObjectNames(meshes.size())
bool hasMovingMesh(false)
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
label filterObjects(const UnaryPredicate &pred, const bool pruning=false)
Filter to retain or prune given object names.
@ NO_REGISTER
Do not request registration (bool: false).
streamFormat
Data format (ascii | binary | coherent).
@ ASCII
"ascii" (normal default)
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Mesh data needed to do the Finite Area discretisation.
static void addVerboseOption(const string &usage="", bool advanced=false)
Enable a 'verbose' bool option, with usage information.
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static void ignoreOptionCompat(std::pair< const char *, int > compat, bool expectArg)
Specify an option to be ignored.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Configuration options for the ensightCase.
Configuration options for the ensightMesh.
bool useBoundaryMesh() const noexcept
Using boundary?
const wordRes & faceZoneSelection() const noexcept
Selection of face zones. Empty if unspecified.
bool useInternalMesh() const noexcept
Using internal?
void print(Ostream &os) const
Report values.
const wordRes & patchSelection() const noexcept
Selection of patches. Empty if unspecified.
const wordRes & patchExclude() const noexcept
Excluded patches. Empty if unspecified.
bool useCellZones() const noexcept
Using cellZones?
const wordRes & cellZoneSelection() const noexcept
Selection of cell zones. Empty if unspecified.
A class for handling file names.
Memory usage information for the current process, and the system memory that is free.
int64_t peak() const noexcept
Peak memory at last update - (VmPeak in /proc/PID/status).
int64_t size() const noexcept
Memory size at last update - (VmSize in /proc/PID/status).
Database for mesh data, solution data, solver performance and other reduced data.
static const word & regionName(const word ®ion)
The mesh region name or word::null if polyMesh::defaultRegion.
readUpdateState
Enumeration defining the state of the mesh after a read update.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
Implements a timeout mechanism via sigalarm.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
A collection of functions for writing areaField content in ensight format.
A collection of functions for writing clouds as ensight file content.
A collection of functions for writing volField content in ensight format.
OBJstream os(runTime.globalPath()/outputName)
List< PtrDynList< ensightFaMesh > > ensightMeshesFa(regionNames.size())
PtrList< ensightCase > ensightCases(regionNames.size())
PtrList< ensightMesh > ensightMeshes(regionNames.size())
List< PtrDynList< ensightCase > > ensightCasesFa(regionNames.size())
bool allowFaModels() noexcept
The enable/disable state for regionFaModel (default: true).
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
cpuTimePosix cpuTime
Selection of preferred clock mechanism for the elapsed cpu time.
constexpr char nl
The newline '\n' character (0x0a).
word format(conversionProperties.get< word >("format"))
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Functor wrapper of allow/deny lists of wordRe for filtering.