findMeshDefinitionDict.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-2024 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 Description
14  Search for the appropriate faMeshDefinition dictionary...
15 
16 Required Classes
17  - Foam::polyMesh
18  - Foam::IOdictionary
19 
20 Required Variables
21  - regionName [word] (the polyMesh region)
22  - areaRegionName [word] (the areaMesh region)
23  - args [argList]
24  - runTime [Time]
25 
26 Provided Variables
27  - meshDefDict [IOdictionary]
28  - meshDictPtr [autoPtr<IOdictionary>]
29 
30 \*---------------------------------------------------------------------------*/
31 
32 const word dictName("faMeshDefinition");
33 
34 autoPtr<IOdictionary> meshDictPtr;
35 
36 {
37  fileName dictPath;
40 
41  if (args.readIfPresent("dict", dictPath))
42  {
43  // Dictionary specified on the command-line ...
44 
45  if (isDir(dictPath))
46  {
47  dictPath /= dictName;
48  }
49  }
50  else if
51  (
52  // Dictionary under system/faMeshDefinition ?
53  // (v2312 and earlier)
54 
55  areaRegionDir.empty()
56  && exists
57  (
58  runTime.path()/runTime.caseSystem()
59  / regionDir/faMesh::meshSubDir/dictName
60  )
61  )
62  {
63  // Dictionary present directly in system/ (v2312 and earlier)
64 
65  dictPath = runTime.system()/regionDir/dictName;
66  }
67  else
68  {
69  // Use system/finite-area/ directory, with region qualifications
70 
71  dictPath =
72  (
73  runTime.system()/regionDir
74  / faMesh::prefix()/areaRegionDir/dictName
75  );
76  }
77 
78  IOobject meshDictIO
79  (
80  dictPath,
81  runTime,
82  IOobject::MUST_READ,
83  IOobject::NO_WRITE,
84  IOobject::NO_REGISTER,
85  true // is globalObject
86  );
87 
88  if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
89  {
91  << meshDictIO.objectPath() << nl
92  << exit(FatalError);
93  }
94 
95  Info<< "Creating faMesh from definition: "
96  << meshDictIO.objectRelPath() << endl;
97 
99 }
100 
101 IOdictionary& meshDefDict = *meshDictPtr;
102 
103 
104 // ************************************************************************* //
IOdictionary & meshDefDict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
Definition: polyMesh.C:847
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
const word dictName("faMeshDefinition")
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
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 word & areaRegionDir
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition: POSIX.C:860
autoPtr< IOdictionary > meshDictPtr
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Definition: POSIX.C:835
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
const word & regionDir
IOobject meshDictIO(dictPath, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER, true)
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.
Definition: argListI.H:316
Foam::word areaRegionName(args.getOrDefault< word >("area-region", Foam::polyMesh::defaultRegion))
Foam::argList args(argc, argv)