Loading...
Searching...
No Matches
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-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13Description
14 Search for the appropriate blockMeshDict dictionary...
15
16\*---------------------------------------------------------------------------*/
17
18// Search for the appropriate blockMesh dictionary....
19const word dictName("blockMeshDict");
20
21autoPtr<IOdictionary> meshDictPtr;
23{
24 fileName dictPath;
25 const word& regionDir = polyMesh::regionName(regionName);
26
27 if (args.readIfPresent("dict", dictPath))
28 {
29 // Dictionary specified on the command-line ...
31 if (isDir(dictPath))
32 {
34 }
35 }
36 else if
37 (
38 exists
39 (
40 runTime.path()/runTime.constant()
41 / polyMesh::meshDir(regionName)/dictName
42 )
43 )
44 {
45 // Dictionary present in constant polyMesh directory (old-style)
46
47 dictPath =
48 (
49 runTime.constant()
50 / polyMesh::meshDir(regionName)/dictName
51 );
52
53
54 // Warn that constant/polyMesh/blockMeshDict was used
55 // instead of system/blockMeshDict
56 WarningIn(args.executable())
57 << "Using the old blockMeshDict location: "
58 << dictPath << nl
59 << " instead of the default location: "
60 << runTime.system()/regionDir/dictName << nl
61 << endl;
62 }
63 else
64 {
65 // Assume dictionary is to be found in the system directory
68 }
69
70 IOobject meshDictIO
71 (
74 IOobject::MUST_READ,
75 IOobject::NO_WRITE,
76 IOobject::NO_REGISTER
77 );
78
79 if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
80 {
82 << meshDictIO.objectPath() << nl
83 << exit(FatalError);
84 }
85
86 Info<< "Creating block mesh from "
87 << meshDictIO.objectRelPath() << endl;
88
89 meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
90}
91
92const IOdictionary& meshDict = *meshDictPtr;
93
94
95// ************************************************************************* //
engineTime & runTime
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
const word dictName("blockMeshDict")
const IOdictionary & meshDict
IOobject meshDictIO(dictPath, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)
autoPtr< IOdictionary > meshDictPtr
const word dictName("faMeshDefinition")
const word & regionDir
IOobject meshDictIO(dictPath, runTime, IOobjectOption::MUST_READ, IOobjectOption::NO_WRITE, IOobjectOption::NO_REGISTER, true)
fileName dictPath(runTime.system()/regionDir/faMesh::prefix()/areaRegionDir/dictName)
#define WarningIn(functionName)
Report a warning using Foam::Warning.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Foam::argList args(argc, argv)