findBlockMeshDict.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 blockMeshDict dictionary...
15 
16 \*---------------------------------------------------------------------------*/
17 
18 // Search for the appropriate blockMesh dictionary....
19 const word dictName("blockMeshDict");
20 
21 autoPtr<IOdictionary> meshDictPtr;
22 
23 {
24  fileName dictPath;
25 
26  if (args.readIfPresent("dict", dictPath))
27  {
28  // Dictionary specified on the command-line ...
29 
30  if (isDir(dictPath))
31  {
32  dictPath /= dictName;
33  }
34  }
35  else if
36  (
37  exists
38  (
39  runTime.path()/runTime.constant()
40  /regionPath/polyMesh::meshSubDir/dictName
41  )
42  )
43  {
44  // Dictionary present in constant polyMesh directory (old-style)
45 
46  dictPath =
47  runTime.constant()
48  /regionPath/polyMesh::meshSubDir/dictName;
49 
50 
51  // Warn that constant/polyMesh/blockMeshDict was used
52  // instead of system/blockMeshDict
54  << "Using the old blockMeshDict location: "
55  << dictPath << nl
56  << " instead of the default location: "
57  << runTime.system()/regionPath/dictName << nl
58  << endl;
59  }
60  else
61  {
62  // Assume dictionary is to be found in the system directory
63 
64  dictPath = runTime.system()/regionPath/dictName;
65  }
66 
67  IOobject meshDictIO
68  (
69  dictPath,
71  IOobject::MUST_READ,
72  IOobject::NO_WRITE,
73  false
74  );
75 
76  if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
77  {
79  << meshDictIO.objectPath() << nl
80  << exit(FatalError);
81  }
82 
83  Info<< "Creating block mesh from "
84  << meshDictIO.objectRelPath() << endl;
85 
87 }
88 
89 const IOdictionary& meshDict = *meshDictPtr;
90 
91 
92 // ************************************************************************* //
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
meshDictPtr
autoPtr< IOdictionary > meshDictPtr
Definition: findBlockMeshDict.H:30
dictName
const word dictName("blockMeshDict")
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:323
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
meshDictIO
IOobject meshDictIO(dictPath, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, false)
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
args
Foam::argList args(argc, argv)
meshDict
const IOdictionary & meshDict
Definition: findBlockMeshDict.H:98
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