Loading...
Searching...
No Matches
foamToVTK.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Application
28 foamToVTK
29
30Group
31 grpPostProcessingUtilities
32
33Description
34 General OpenFOAM to VTK file writer.
35
36 Other bits
37 - Handles volFields, pointFields, surfaceScalarField, surfaceVectorField
38 fields.
39 - Mesh topo changes.
40 - Output legacy or xml VTK format in ascii or binary.
41 - Single time step writing.
42 - Write subset only.
43 - Optional decomposition of cells.
44
45Usage
46 \b foamToVTK [OPTION]
47
48 Options:
49 - \par -ascii
50 Write VTK data in ASCII format instead of binary.
51
52 - \par -legacy
53 Write VTK data in legacy format instead of XML format
54
55 - \par -fields <fields>
56 Specify single or multiple fields to write (all by default)
57 For example,
58 \verbatim
59 -fields T
60 -fields '(p T U \"alpha.*\")'
61 \endverbatim
62 The quoting is required to avoid shell expansions and to pass the
63 information as a single argument.
64
65 - \par -surfaceFields
66 Write surfaceScalarFields (e.g., phi)
67
68 - \par -cellSet <name>
69 - \par -cellZone <name>
70 Restrict conversion to either the cellSet or the cellZone.
71
72 - \par -faceSet <name>
73 - \par -pointSet <name>
74 Restrict conversion to the faceSet or pointSet.
75
76 - \par -faceZones zone or zone list
77 Specify single faceZone or or multiple faceZones (name or regex)
78 to write
79
80 - \par -nearCellValue
81 Output cell value on patches instead of patch value itself
82
83 - \par -no-boundary
84 Suppress output for all boundary patches
85
86 - \par -no-internal
87 Suppress output for internal (volume) mesh
88
89 - \par -no-lagrangian
90 Suppress writing Lagrangian positions and fields.
91
92 - \par -no-point-data
93 Suppress conversion of pointFields. No interpolated PointData.
94
95 - \par -with-ids
96 Additional mesh id fields (cellID, procID, patchID)
97
98 - \par -with-point-ids
99 Additional pointID field for internal mesh
100
101 - \par -poly-decomp
102 Decompose polyhedral cells into tets/pyramids
103
104 - \par -one-boundary
105 Combine all patches into a single boundary file
106
107 - \par -patches NAME | LIST
108 Specify single patch or multiple patches (name or regex) to write
109 For example,
110 \verbatim
111 -patches top
112 -patches '( front \".*back\" )'
113 \endverbatim
114
115 - \par -exclude-patches NAME | LIST
116 Exclude single or multiple patches (name or regex) from writing.
117 For example,
118 \verbatim
119 -exclude-patches '( inlet_1 inlet_2 "proc.*")'
120 \endverbatim
121
122Note
123 The mesh subset is handled by fvMeshSubsetProxy. Slight inconsistency in
124 interpolation: on the internal field it interpolates the whole volField
125 to the whole-mesh pointField and then selects only those values it
126 needs for the subMesh (using the fvMeshSubset cellMap(), pointMap()
127 functions). For the patches however it uses the
128 fvMeshSubset.interpolate function to directly interpolate the
129 whole-mesh values onto the subset patch.
130
131\*---------------------------------------------------------------------------*/
132
133#include "fvCFD.H"
134#include "pointMesh.H"
135#include "emptyPolyPatch.H"
137#include "faceZoneMesh.H"
138#include "faMesh.H"
139#include "areaFields.H"
140#include "fvMeshSubsetProxy.H"
141#include "faceSet.H"
142#include "pointSet.H"
143#include "HashOps.H"
144#include "regionProperties.H"
145
146#include "Cloud.H"
147#include "readFields.H"
148#include "reportFields.H"
149
150#include "foamVtmWriter.H"
152#include "foamVtkPatchWriter.H"
156#include "foamVtkWriteTopoSet.H"
157#include "foamVtkSeriesWriter.H"
158
159#include "writeAreaFields.H"
160#include "writeDimFields.H"
161#include "writeVolFields.H"
162#include "writePointFields.H"
163#include "writeSurfaceFields.H"
164
165#include "memInfo.H"
166
167// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168
169namespace Foam
170{
171
172// Simple wrapper for polyBoundaryMesh::indices() with some additional logic
173struct polyBoundaryPatchSelector
174{
175 wordRes allow_;
176 wordRes deny_;
177
178 void clear()
179 {
180 allow_.clear();
181 deny_.clear();
182 }
183
184 //- Forward to polyBoundaryMesh::indices() with additional handling.
185 // Prune emptyPolyPatch (always) and processorPolyPatch (in parallel)
186 labelList indices(const polyBoundaryMesh& pbm) const
187 {
188 labelList ids = pbm.indices(allow_, deny_);
189
190 const bool excludeProcPatches = UPstream::parRun();
191
192 // Prune undesirable patches
193 label count = 0;
194 for (const label patchi : ids)
195 {
196 const auto& pp = pbm[patchi];
197
198 if (isType<emptyPolyPatch>(pp))
199 {
200 continue;
201 }
202 else if (excludeProcPatches && bool(isA<processorPolyPatch>(pp)))
203 {
204 break; // No processor patches for parallel output
205 }
206
207 ids[count] = patchi;
208 ++count;
209 }
210
211 ids.resize(count);
212 return ids;
213 }
214};
215
216} // End namespace Foam
217
218
219//
220// Process args for output options (-ascii, -legacy)
221//
222vtk::outputOptions getOutputOptions(const argList& args)
223{
224 // Default is inline ASCII xml
225 vtk::outputOptions opts;
226
227 if (args.found("legacy"))
228 {
229 opts.legacy(true);
230
231 if (!args.found("ascii"))
232 {
233 if constexpr (sizeof(float) != 4 || sizeof(label) != 4)
234 {
235 opts.ascii(true);
236
238 << "Using ASCII rather than legacy binary VTK format since "
239 << "float and/or label are not 4 bytes in size."
240 << nl << endl;
241 }
242 else
243 {
244 opts.ascii(false);
245 }
246 }
247 }
248 else
249 {
250 opts.ascii(args.found("ascii"));
251 }
252
253 return opts;
254}
255
256
257// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258
259int main(int argc, char *argv[])
260{
261 argList::addNote
262 (
263 "General OpenFOAM to VTK file writer"
264 );
265 timeSelector::addOptions();
266
267 // Less frequently used - reduce some clutter
268 argList::setAdvanced("decomposeParDict");
269
270 argList::addVerboseOption();
271
272 argList::addBoolOption
273 (
274 "ascii",
275 "Write in ASCII format instead of binary"
276 );
277 argList::addBoolOption
278 (
279 "legacy",
280 "Write legacy format instead of xml",
281 true // mark as an advanced option
282 );
283 argList::addBoolOption
284 (
285 "poly-decomp",
286 "Decompose polyhedral cells into tets/pyramids",
287 true // mark as an advanced option
288 );
289 argList::ignoreOptionCompat
290 (
291 {"xml", 1806}, // xml is now default, use -legacy to toggle
292 false // bool option, no argument
293 );
294 argList::ignoreOptionCompat
295 (
296 {"poly", 1806}, // poly is now default, use -poly-decomp to toggle
297 false // bool option, no argument
298 );
299
300 argList::addOption
301 (
302 "cellSet",
303 "name",
304 "Convert mesh subset corresponding to specified cellSet",
305 true // mark as an advanced option
306 );
307 argList::addOption
308 (
309 "cellZone",
310 "name",
311 "Convert mesh subset corresponding to specified cellZone",
312 true // mark as an advanced option
313 );
314 argList::addOption
315 (
316 "faceSet",
317 "name",
318 "Convert specified faceSet only",
319 true // mark as an advanced option
320 );
321 argList::addOption
322 (
323 "pointSet",
324 "name",
325 "Convert specified pointSet only",
326 true // mark as an advanced option
327 );
328 argList::addOption
329 (
330 "faceZones",
331 "wordRes",
332 "Specify single or multiple faceZones to write\n"
333 "Eg, 'cells' or '( slice \"mfp-.*\" )'.",
334 true // mark as an advanced option
335 );
336 argList::addOption
337 (
338 "fields",
339 "wordRes",
340 "Specify single or multiple fields to write (all by default)\n"
341 "Eg, 'T' or '(p T U \"alpha.*\")'"
342 );
343 argList::addOption
344 (
345 "exclude-fields",
346 "wordRes",
347 "Exclude single or multiple fields",
348 true // mark as an advanced option
349 );
350 argList::addBoolOption
351 (
352 "no-fields",
353 "Suppress conversion of fields"
354 );
355
356 argList::addBoolOption
357 (
358 "processor-fields",
359 "Write field values on processor boundaries only",
360 true // mark as an advanced option
361 );
362 argList::addBoolOption
363 (
364 "surfaceFields",
365 "Write surfaceScalarFields (eg, phi)",
366 true // mark as an advanced option
367 );
368 argList::addBoolOption
369 (
370 "no-finite-area",
371 "Suppress output of finite-area mesh/fields",
372 true // mark as an advanced option
373 );
374 argList::ignoreOptionCompat
375 (
376 {"finite-area", 2112}, // use -no-finite-area to disable
377 false // bool option, no argument
378 );
379 argList::ignoreOptionCompat
380 (
381 {"finiteAreaFields", 2012}, // use -no-finite-area to disable
382 false // bool option, no argument
383 );
384
385 argList::addBoolOption
386 (
387 "nearCellValue",
388 "Use cell value on patches instead of patch value itself",
389 true // mark as an advanced option
390 );
391 argList::addBoolOption
392 (
393 "no-boundary",
394 "Suppress output for boundary patches"
395 );
396 argList::addBoolOption
397 (
398 "no-internal",
399 "Suppress output for internal volume mesh"
400 );
401 argList::addBoolOption
402 (
403 "no-lagrangian", // noLagrangian
404 "Suppress writing lagrangian positions and fields"
405 );
406 argList::addOptionCompat("no-lagrangian", {"noLagrangian", 1806});
407
408 argList::addBoolOption
409 (
410 "no-point-data", // noPointValues
411 "Suppress conversion of pointFields. No interpolated PointData."
412 );
413 argList::addOptionCompat("no-point-data", {"noPointValues", 1806});
414
415 argList::addBoolOption
416 (
417 "with-ids",
418 "Additional mesh id fields (cellID, procID, patchID)",
419 true // mark as an advanced option
420 );
421
422 argList::addBoolOption
423 (
424 "with-point-ids",
425 "Additional pointID field for internal mesh",
426 true // mark as an advanced option
427 );
428
429 argList::addBoolOption
430 (
431 "one-boundary", // allPatches
432 "Combine all patches into a single file"
433 );
434 argList::addOptionCompat("one-boundary", {"allPatches", 1806});
435
436 #include "addAllRegionOptions.H"
437 #include "addAllFaRegionOptions.H"
438
439 argList::addOption
440 (
441 "patches",
442 "wordRes",
443 "Specify single patch or multiple patches to write\n"
444 "Eg, 'top' or '( front \".*back\" )'"
445 );
446 argList::addOption
447 (
448 "exclude-patches",
449 "wordRes",
450 "Exclude single or multiple patches from writing\n"
451 "Eg, 'outlet' or '( inlet \".*Wall\" )'",
452 true // mark as an advanced option
453 );
454 argList::addOptionCompat("exclude-patches", {"excludePatches", 2112});
455
456 argList::ignoreOptionCompat
457 (
458 {"noFaceZones", 1806}, // faceZones are only enabled on demand
459 false // bool option, no argument
460 );
461 argList::ignoreOptionCompat
462 (
463 {"noLinks", 1806}, // ignore never make any links
464 false // bool option, no argument
465 );
466 argList::ignoreOptionCompat
467 (
468 {"useTimeName", 1806}, // ignore - works poorly with VTM formats
469 false // bool option, no argument
470 );
471 argList::addBoolOption
472 (
473 "overwrite",
474 "Remove any existing VTK output directory"
475 );
476 argList::addOption
477 (
478 "name",
479 "subdir",
480 "Directory name for VTK output (default: 'VTK')"
481 );
482
483 // Prevent volume BCs from triggering finite-area
484 regionModels::allowFaModels(false);
485
486 #include "setRootCase.H"
487
488 // ------------------------------------------------------------------------
489 // Configuration
490
492 const bool decomposePoly = args.found("poly-decomp");
493 const bool doBoundary = !args.found("no-boundary");
494 const bool doInternal = !args.found("no-internal");
495 const bool doLagrangian = !args.found("no-lagrangian");
496 const bool doFiniteArea = !args.found("no-finite-area");
497 const bool doSurfaceFields = args.found("surfaceFields");
498 const bool oneBoundary = args.found("one-boundary") && doBoundary;
499 const bool nearCellValue = args.found("nearCellValue") && doBoundary;
500
501 const vtk::outputOptions writeOpts = getOutputOptions(args);
502
503 bool processorFieldsOnly = false;
504
505 if (args.found("processor-fields"))
506 {
507 if (!UPstream::parRun())
508 {
509 Info<< "Ignoring processor patch writing in serial"
510 << nl << endl;
511 }
512 else if (writeOpts.legacy())
513 {
514 Info<< "Ignoring processor patch writing in legacy format"
515 << nl << endl;
516 }
517 else
518 {
519 processorFieldsOnly = true;
520
521 Info<< "Writing processor patch fields only"
522 << nl << endl;
523 }
524 }
525
526 if (nearCellValue)
527 {
528 Info<< "Using neighbouring cell value instead of patch value"
529 << nl << endl;
530 }
531
532 bool doPointValues = !args.found("no-point-data");
533 if (!doPointValues)
534 {
535 Info<< "Point fields and interpolated point data"
536 << " disabled with the '-no-point-data' option"
537 << nl;
538 }
539
540 const bool withPointIds = args.found("with-point-ids");
541 if (withPointIds)
542 {
543 Info<< "Write point ids requested";
544
545 if (!doPointValues)
546 {
547 Info<< ", but ignored due to the '-no-point-data' option";
548 }
549
550 Info<< nl;
551 }
552
553 const bool withMeshIds = args.found("with-ids");
554 if (withMeshIds)
555 {
556 Info<< "Writing mesh ids (cell, patch, proc) requested" << nl;
557 }
558
559 // Patch selection/deselection
560 polyBoundaryPatchSelector patchSelector;
561
562 if (doBoundary)
563 {
564 if
565 (
566 auto& slot = patchSelector.allow_;
567 args.readListIfPresent<wordRe>("patches", slot)
568 )
569 {
570 Info<< "Including patches " << flatOutput(slot) << nl << endl;
571 }
572 if
573 (
574 auto& slot = patchSelector.deny_;
575 args.readListIfPresent<wordRe>("exclude-patches", slot)
576 )
577 {
578 Info<< "Excluding patches " << flatOutput(slot) << nl << endl;
579 }
580 }
581
582 // Field selection/deselection
583 wordRes includedFields, excludedFields;
584 bool doConvertFields = !args.found("no-fields");
585 if (doConvertFields)
586 {
587 if (args.readListIfPresent<wordRe>("fields", includedFields))
588 {
589 Info<< "Including fields "
590 << flatOutput(includedFields) << nl << endl;
591
592 if (includedFields.empty())
593 {
594 // Compat: Can be specified as empty (ie, no fields)
595 // Same as "block everything"
596
597 doConvertFields = false;
598 Info<< "Field conversion disabled by '-fields ()' option" << nl
599 << "Should use -no-fields instead" << endl;
600 }
601 }
602 if (args.readListIfPresent<wordRe>("exclude-fields", excludedFields))
603 {
604 Info<< "Excluding fields "
605 << flatOutput(excludedFields) << nl << endl;
606 }
607
608 if (!doConvertFields)
609 {
610 includedFields.clear();
611 excludedFields.clear();
612 }
613 }
614 else
615 {
616 Info<< "Field conversion disabled with the '-no-fields' option" << nl;
617 }
618
619 const wordRes::filter fieldSelector(includedFields, excludedFields);
620
621 // Non-mandatory
622 const wordRes selectedFaceZones(args.getList<wordRe>("faceZones", false));
623
624 #include "createTime.H"
625
626 instantList timeDirs = timeSelector::select0(runTime, args);
627
628 // Information for file series
629 HashTable<vtk::seriesWriter, fileName> vtkSeries;
630
631 // Handle volume region selections
632 #include "getAllRegionOptions.H"
633
634 // Handle area region selections
635 #include "getAllFaRegionOptions.H"
636
637 if (!doFiniteArea)
638 {
639 areaRegionNames.clear(); // For consistency
640 }
641
642 // ------------------------------------------------------------------------
643
644 // Names for sets and zones
645 word cellSelectionName;
646 word faceSetName;
647 word pointSetName;
648
649 fvMeshSubsetProxy::subsetType cellSubsetType = fvMeshSubsetProxy::NONE;
650
651 string vtkName = args.globalCaseName();
652
653 if (regionNames.size() == 1)
654 {
655 if (args.readIfPresent("cellSet", cellSelectionName))
656 {
657 vtkName = cellSelectionName;
658 cellSubsetType = fvMeshSubsetProxy::SET;
659
660 Info<< "Converting cellSet " << cellSelectionName
661 << " only. New outside faces as \"oldInternalFaces\"."
662 << nl;
663 }
664 else if (args.readIfPresent("cellZone", cellSelectionName))
665 {
666 vtkName = cellSelectionName;
667 cellSubsetType = fvMeshSubsetProxy::ZONE;
668
669 Info<< "Converting cellZone " << cellSelectionName
670 << " only. New outside faces as \"oldInternalFaces\"."
671 << nl;
672 }
673
674 args.readIfPresent("faceSet", faceSetName);
675 args.readIfPresent("pointSet", pointSetName);
676 }
677 else
678 {
679 for
680 (
681 const char * const opt
682 : { "cellSet", "cellZone", "faceSet", "pointSet" }
683 )
684 {
685 if (args.found(opt))
686 {
687 Info<< "Ignoring -" << opt << " for multi-regions" << nl;
688 }
689 }
690 }
691
692 // ------------------------------------------------------------------------
693 // Directory management
694
695 // Sub-directory for output
696 const word vtkDirName = args.getOrDefault<word>("name", "VTK");
697
698 const fileName outputDir(args.globalPath()/vtkDirName);
699
700 if (UPstream::master())
701 {
702 // Overwrite or create the VTK/regionName directories.
703 // For the default region, this is simply "VTK/"
704
705 for (const word& regionName : regionNames)
706 {
707 fileName regionOutDir(outputDir/polyMesh::regionName(regionName));
708
709 if (args.found("overwrite") && Foam::isDir(regionOutDir))
710 {
711 Info<< "Removing old directory "
712 << args.relativePath(regionOutDir)
713 << nl << endl;
714 Foam::rmDir(regionOutDir);
715 }
716 Foam::mkDir(regionOutDir);
717 }
718 }
719
720 // ------------------------------------------------------------------------
721
722 cpuTime timer;
723 Info<< "Initial memory " << Foam::memInfo{}.size() << " kB" << endl;
724
725 #include "createNamedMeshes.H"
726 #include "createMeshAccounting.H"
727
728 Info<< "VTK mesh topology: "
729 << timer.cpuTimeIncrement() << " s, "
730 << Foam::memInfo{}.size() << " kB" << endl;
731
732
733 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
734
735 forAll(timeDirs, timei)
736 {
737 runTime.setTime(timeDirs[timei], timei);
738
739 const word timeDesc = "_" + Foam::name(runTime.timeIndex());
740 const scalar timeValue = runTime.value();
741
742 Info<< "Time: " << runTime.timeName() << endl;
743
744
745 // Accumulate information for multi-region VTM
746 vtk::vtmWriter vtmMultiRegion;
747
748 // vtmMultiRegion.set(vtkDir/vtkName + timeDesc)
749
750 forAll(regionNames, regioni)
751 {
752 const word& regionName = regionNames[regioni];
753 const word& regionDir = polyMesh::regionName(regionName);
754
755 if (regionNames.size() > 1)
756 {
757 Info<< "region = " << regionName << nl;
758 }
759
760 auto& meshProxy = meshProxies[regioni];
761 auto& vtuMeshCells = vtuMappings[regioni];
762
763 // polyMesh::readUpdateState meshState = mesh.readUpdate();
764
765 // Check for new polyMesh/ and update mesh, fvMeshSubset
766 // and cell decomposition.
767 polyMesh::readUpdateState meshState =
768 meshProxy.readUpdate();
769
770 const fvMesh& mesh = meshProxy.mesh();
771
772 if
773 (
774 meshState == polyMesh::TOPO_CHANGE
775 || meshState == polyMesh::TOPO_PATCH_CHANGE
776 )
777 {
778 // Trigger change for vtk cells too
779 vtuMeshCells.clear();
780 }
781
782 // Write topoSets before attempting anything else
783 {
784 #include "convertTopoSet.H"
785 if (wroteTopoSet)
786 {
787 continue;
788 }
789 }
790
791 // fvMesh fields
792 IOobjectList objects;
793
794 // faMesh fields (multiple finite-area regions per volume region)
795 HashTable<IOobjectList> faObjects;
796
797 if (doConvertFields)
798 {
799 // List of volume mesh objects for this instance
800 objects =
801 IOobjectList(meshProxy.baseMesh(), runTime.timeName());
802
803 objects.prune_0(); // Remove restart fields
804
805 if (fieldSelector)
806 {
807 objects.filterObjects(fieldSelector);
808 }
809 if (!doPointValues)
810 {
811 // Prune point fields if disabled
812 objects.filterClasses(Foam::fieldTypes::is_point, true);
813 }
814
815
816 // Lists of finite-area fields
817 faObjects.reserve(areaRegionNames.size());
818
819 for (const word& areaName : areaRegionNames)
820 {
821 // The finite-area objects for given area region.
822
823 // finite-area : scan without yet having a mesh
824 IOobjectList objs
825 (
826 faMesh::Registry(meshProxy.baseMesh()),
827 runTime.timeName(),
828 polyMesh::regionName(areaName),
829 IOobjectOption::NO_REGISTER
830 );
831
832 objs.prune_0(); // Remove restart fields
833 if (fieldSelector)
834 {
835 objs.filterObjects(fieldSelector);
836 }
837
838 if (!objs.empty())
839 {
840 faObjects.emplace_set(areaName, std::move(objs));
841 }
842 }
843 }
844
845
846 if (processorFieldsOnly)
847 {
848 // Processor-patches only and continue
850 continue;
851 }
852
853 // Volume, internal, point fields
854 #include "convertVolumeFields.H"
855
856 // Surface fields
857 #include "convertSurfaceFields.H"
858
859 // Finite-area mesh and fields - need not exist
860 #include "convertAreaFields.H"
861
862 // Write lagrangian data
863 #include "convertLagrangian.H"
864 }
865
866 // Emit multi-region vtm
867 if (UPstream::master() && regionNames.size() > 1)
868 {
869 fileName outputName
870 (
871 outputDir/vtkName + "-regions" + timeDesc + ".vtm"
872 );
873
874 vtmMultiRegion.setTime(timeValue);
875 vtmMultiRegion.write(outputName);
876
877 fileName seriesName(vtk::seriesWriter::base(outputName));
878
879 vtk::seriesWriter& series = vtkSeries(seriesName);
880
881 // First time?
882 // Load from file, verify against filesystem,
883 // prune time >= currentTime
884 if (series.empty())
885 {
886 series.load(seriesName, true, timeValue);
887 }
888
889 series.append(timeValue, outputName);
890 series.write(seriesName);
891 }
892
893 Info<< "Wrote in "
894 << timer.cpuTimeIncrement() << " s, "
895 << Foam::memInfo{}.size() << " kB" << endl;
896 }
897
898
899 Info<< "\nEnd: "
900 << timer.elapsedCpuTime() << " s, "
901 << Foam::memInfo{}.peak() << " kB (peak)\n" << endl;
902
903 return 0;
904}
905
906
907// ************************************************************************* //
Required Classes.
Required Classes.
Helper routines for reading a field or fields, optionally with a mesh subset (using fvMeshSubsetProxy...
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
Memory usage information for the current process, and the system memory that is free.
Definition memInfo.H:59
int64_t peak() const noexcept
Peak memory at last update - (VmPeak in /proc/PID/status).
Definition memInfo.H:119
int64_t size() const noexcept
Memory size at last update - (VmSize in /proc/PID/status).
Definition memInfo.H:124
bool wroteTopoSet
dynamicFvMesh & mesh
engineTime & runTime
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
Required Variables.
word outputName("finiteArea-edges.obj")
Foam::faceZoneMesh.
const word & regionDir
PtrList< fvMeshSubsetProxy > meshProxies(meshes.size())
PtrList< vtk::vtuCells > vtuMappings(meshes.size())
Write topoSet in VTK format.
wordList areaRegionNames
wordList regionNames
surface1 clear()
#define WarningInFunction
Report a warning using Foam::Warning.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition BitOps.H:73
bool is_point(const word &clsName)
Test if the class name appears to be a point field.
Definition pointFields.C:94
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Definition POSIX.C:616
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Definition instantList.H:41
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition FlatOutput.H:217
bool rmDir(const fileName &directory, const bool silent=false, const bool emptyOnly=false)
Remove a directory and its contents recursively,.
Definition POSIX.C:1435
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition POSIX.C:862
cpuTimePosix cpuTime
Selection of preferred clock mechanism for the elapsed cpu time.
Definition cpuTimeFwd.H:38
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299