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 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 Description
14  Additional mesh accounting (Ensight)
15 
16 \*---------------------------------------------------------------------------*/
17 
18 PtrList<ensightCase> ensightCases(regionNames.size());
19 PtrList<ensightMesh> ensightMeshes(regionNames.size());
20 
21 PtrList<faMesh> meshesFa(regionNames.size());
22 PtrList<ensightCase> ensightCasesFa(regionNames.size());
23 PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
24 
25 {
26  forAll(regionNames, regioni)
27  {
28  const fvMesh& mesh = meshes[regioni];
29 
30  const word& regionName = regionNames[regioni];
31  const word& regionDir =
32  (
33  regionName != polyMesh::defaultRegion
34  ? regionName
35  : word::null
36  );
37 
38  fileName ensCasePath(outputDir);
39  word ensCaseName(args.globalCaseName());
40 
41  if (!regionDir.empty())
42  {
43  ensCaseName = regionName;
44  ensCasePath /= regionName;
45 
46  // Handle very rare naming collision with Ensight directories
47  if (regionName == "data")
48  {
49  ensCasePath += "-region";
50  }
51  }
52 
53  ensightMeshes.set
54  (
55  regioni,
56  new ensightMesh(mesh, writeOpts)
57  );
58 
59  // New ensight case file, initialize header etc.
60  ensightCases.set
61  (
62  regioni,
63  new ensightCase(ensCasePath, ensCaseName, caseOpts)
64  );
65 
66  if (doFiniteArea)
67  {
68  autoPtr<faMesh> faMeshPtr;
69 
70  const bool oldThrowingError = FatalError.throwing(true);
71  try
72  {
73  faMeshPtr.reset(new faMesh(mesh));
74  }
75  catch (const Foam::error& err)
76  {
77  faMeshPtr.reset(nullptr);
78  }
79  FatalError.throwing(oldThrowingError);
80 
81  if (faMeshPtr)
82  {
83  ensightCasesFa.set
84  (
85  regioni,
86  new ensightCase
87  (
88  ensCasePath/"finite-area",
89  "finite-area",
90  caseOpts
91  )
92  );
93 
94  meshesFa.set(regioni, faMeshPtr);
95 
96  ensightMeshesFa.set
97  (
98  regioni,
99  new ensightFaMesh(meshesFa[regioni])
100  );
101  }
102  }
103  }
104 }
105 
106 
107 // ************************************************************************* //
Foam::error::throwing
bool throwing() const noexcept
Return the current exception throwing state (on or off)
Definition: error.H:169
Foam::argList::globalCaseName
const fileName & globalCaseName() const noexcept
Return global case name.
Definition: argListI.H:75
regionNames
wordList regionNames
Definition: getAllRegionOptions.H:37
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
ensightMeshes
PtrList< ensightMesh > ensightMeshes(regionNames.size())
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
meshes
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
meshesFa
PtrList< faMesh > meshesFa(regionNames.size())
ensightMeshesFa
PtrList< ensightFaMesh > ensightMeshesFa(regionNames.size())
ensightCases
PtrList< ensightCase > ensightCases(regionNames.size())
regionDir
const word & regionDir
Definition: findMeshDefinitionDict.H:34
args
Foam::argList args(argc, argv)
Foam::error
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:73
ensightCasesFa
PtrList< ensightCase > ensightCasesFa(regionNames.size())