Loading...
Searching...
No Matches
createMeshAccounting.H
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) 2021-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13Description
14 Additional mesh accounting (Ensight)
15
16Note
17 Not every volume region is guaranteed to have any or all area region(s).
18 Manage the ones that do exist by pushing them onto the region-specific
19 list.
20
21\*---------------------------------------------------------------------------*/
22
23// Cases and meshes per volume region
24PtrList<ensightCase> ensightCases(regionNames.size());
25PtrList<ensightMesh> ensightMeshes(regionNames.size());
26
27// Per volume region can have multiple finite-area regions.
28// For the List of PtrList, the first level corresponds to the volume
29// region, the second level to the area region(s).
30// After creation, the indexing of the second-level becomes
31// unrelated to the original list of areaRegionNames.
32
33List<PtrDynList<faMesh>> meshesFa(regionNames.size());
34List<PtrDynList<ensightCase>> ensightCasesFa(regionNames.size());
35List<PtrDynList<ensightFaMesh>> ensightMeshesFa(regionNames.size());
36
37{
38 forAll(regionNames, regioni)
39 {
40 const fvMesh& mesh = meshes[regioni];
41
42 const word& regionName = regionNames[regioni];
43 const word& regionDir = polyMesh::regionName(regionName);
44
45 fileName ensCasePath(outputDir);
46 word ensCaseName(args.globalCaseName());
47
48 if (!regionDir.empty())
49 {
50 ensCaseName = regionName;
51 ensCasePath /= regionName;
52
53 // Handle very rare naming collision with Ensight directories
54 if (regionName == "data")
55 {
56 ensCasePath += "-region";
57 }
58 }
59
60 // Volume mesh
62 (
63 regioni,
64 new ensightMesh(mesh, writeOpts)
65 );
66 ensightMeshes[regioni].verbose(optVerbose);
67
68 // New ensight case file, initialize header etc.
69 ensightCases.set
70 (
71 regioni,
72 new ensightCase(ensCasePath, ensCaseName, caseOpts)
73 );
74
75 if (!doFiniteArea)
76 {
77 continue;
78 }
79
80 // Note: not every volume region is guaranteed to have
81 // any or all area region(s)
82
83 meshesFa[regioni].reserve_exact(areaRegionNames.size());
84
85 for (const word& areaName : areaRegionNames)
86 {
87 auto faMeshPtr = faMesh::TryNew(areaName, mesh);
88
89 if (faMeshPtr)
90 {
91 meshesFa[regioni].push_back(std::move(faMeshPtr));
92 }
93 }
94
95 // Setup the ensight components
96 const label nAreas = meshesFa[regioni].size();
97 ensightCasesFa[regioni].reserve_exact(nAreas);
98 ensightMeshesFa[regioni].reserve_exact(nAreas);
99
100 for (const faMesh& areaMesh : meshesFa[regioni])
101 {
102 // Use regionName() - automatically filters for defaultRegion
103 const word& areaName = areaMesh.regionName();
104
105 if (areaName.empty())
106 {
107 // single-region
108 ensightCasesFa[regioni].emplace_back
109 (
110 ensCasePath/"finite-area",
111 "finite-area",
112 caseOpts
113 );
114 }
115 else
116 {
117 // multi-region
118 ensightCasesFa[regioni].emplace_back
119 (
120 ensCasePath/"finite-area"/areaName,
121 areaName,
122 caseOpts
123 );
124 }
125
126 auto& ensFaMesh = ensightMeshesFa[regioni].emplace_back(areaMesh);
127 ensFaMesh.verbose(optVerbose);
128 }
129 }
130}
131
132
133// ************************************************************************* //
dynamicFvMesh & mesh
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
const word & regionDir
List< PtrDynList< ensightFaMesh > > ensightMeshesFa(regionNames.size())
PtrList< ensightCase > ensightCases(regionNames.size())
PtrList< ensightMesh > ensightMeshes(regionNames.size())
List< PtrDynList< faMesh > > meshesFa(regionNames.size())
List< PtrDynList< ensightCase > > ensightCasesFa(regionNames.size())
wordList areaRegionNames
wordList regionNames
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299