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 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 \*---------------------------------------------------------------------------*/
17 
18 const word dictName("faMeshDefinition");
19 
20 autoPtr<IOdictionary> meshDictPtr;
21 
22 {
23  fileName dictPath;
24 
25  const word& regionDir =
26  (regionName == polyMesh::defaultRegion ? word::null : regionName);
27 
28  if (args.readIfPresent("dict", dictPath))
29  {
30  // Dictionary specified on the command-line ...
31 
32  if (isDir(dictPath))
33  {
34  dictPath /= dictName;
35  }
36  }
37  else if
38  (
39  // Check global location
40  exists
41  (
42  runTime.path()/runTime.caseConstant()
43  /regionDir/faMesh::meshSubDir/dictName
44  )
45  )
46  {
47  // Dictionary present in constant faMesh directory (old-style)
48 
49  dictPath =
50  runTime.constant()
51  /regionDir/faMesh::meshSubDir/dictName;
52 
53  // Warn that constant/faMesh/faMeshDefinition was used
54  // instead of system/faMeshDefinition
55  #if 0
57  << "Using the old faMeshDefinition location: "
58  << dictPath << nl
59  << " instead of default location: "
60  << runTime.system()/regionDir/dictName << nl
61  << endl;
62  #endif
63  }
64  else
65  {
66  // Assume dictionary is in the system directory
67 
68  dictPath = runTime.system()/regionDir/dictName;
69  }
70 
71  IOobject meshDictIO
72  (
73  dictPath,
75  IOobject::MUST_READ,
76  IOobject::NO_WRITE,
77  false, // no registerObject
78  true // is globalObject
79  );
80 
81  if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
82  {
84  << meshDictIO.objectPath() << nl
85  << exit(FatalError);
86  }
87 
88  Info<< "Creating faMesh from definition: "
89  << meshDictIO.objectRelPath() << endl;
90 
92 }
93 
94 IOdictionary& meshDefDict = *meshDictPtr;
95 
96 
97 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::exists
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: MSwindows.C:625
dictName
const word dictName("faMeshDefinition")
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
meshDictPtr
autoPtr< IOdictionary > meshDictPtr
Definition: findMeshDefinitionDict.H:29
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:323
meshDefDict
IOdictionary & meshDefDict
Definition: findMeshDefinitionDict.H:103
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
meshDictIO
IOobject meshDictIO(dictPath, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, false, true)
Foam::FatalError
error FatalError
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::argList::executable
const word & executable() const noexcept
Name of executable without the path.
Definition: argListI.H:51
WarningIn
#define WarningIn(functionName)
Report a warning using Foam::Warning.
Definition: messageStream.H:323
regionDir
const word & regionDir
Definition: findMeshDefinitionDict.H:34
args
Foam::argList args(argc, argv)
Foam::isDir
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition: MSwindows.C:643