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,
70  runTime,
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)
Definition: POSIX.C:750
meshDictPtr
autoPtr< IOdictionary > meshDictPtr
Definition: findBlockMeshDict.H:24
dictName
const word dictName("blockMeshDict")
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Definition: argListI.H:316
Foam::Info
messageStream Info
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:125
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Definition: DimensionedFieldReuseFunctions.H:100
FatalErrorInFunction
#define FatalErrorInFunction
Definition: error.H:465
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::argList::executable
const word & executable() const noexcept
Definition: argListI.H:44
WarningIn
#define WarningIn(functionName)
Definition: messageStream.H:345
args
Foam::argList args(argc, argv)
meshDict
const IOdictionary & meshDict
Definition: findBlockMeshDict.H:92
Foam::isDir
bool isDir(const fileName &name, const bool followLink=true)
Definition: POSIX.C:775