dynamicFvMeshNew.C
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) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2019-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "staticFvMesh.H"
31#include "argList.H"
32
33// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
34
36{
37 // Note: - do not register the dictionary since dynamicFvMeshes themselves
38 // do this.
39 // - defaultRegion (region0) gets loaded from constant, other ones
40 // get loaded from constant/<regionname>. Normally we'd use
41 // polyMesh::dbDir() but we haven't got a polyMesh yet ...
42 IOobject dictHeader
43 (
44 "dynamicMeshDict",
45 io.time().constant(),
47 io.db(),
50 false // Do not register
51 );
52
53 if (dictHeader.typeHeaderOk<IOdictionary>(true))
54 {
55 IOdictionary dict(dictHeader);
56
57 const word modelType(dict.get<word>("dynamicFvMesh"));
58
59 Info<< "Selecting dynamicFvMesh " << modelType << endl;
60
61 io.time().libs().open
62 (
63 dict,
64 "dynamicFvMeshLibs",
65 IOobjectConstructorTablePtr_
66 );
67
68 if (!IOobjectConstructorTablePtr_)
69 {
71 << "dynamicFvMesh table is empty"
72 << exit(FatalError);
73 }
74
75 auto* doInitCtor = doInitConstructorTable(modelType);
76 if (doInitCtor)
77 {
79 << "Constructing dynamicFvMesh with explicit initialisation"
80 << endl;
81
82 // Two-step constructor
83 // 1. Construct mesh, do not initialise
84 autoPtr<dynamicFvMesh> meshPtr(doInitCtor(io, false));
85
86 // 2. Initialise parents and itself
87 meshPtr().init(true);
88
89 return meshPtr;
90 }
91
92 auto* ctorPtr = IOobjectConstructorTable(modelType);
93
94 if (!ctorPtr)
95 {
97 (
98 dict,
99 "dynamicFvMesh",
100 modelType,
101 *IOobjectConstructorTablePtr_
102 ) << exit(FatalIOError);
103 }
104
105 return autoPtr<dynamicFvMesh>(ctorPtr(io));
106 }
107
109 << "Constructing staticFvMesh with explicit initialisation" << endl;
110
111 // 1. Construct mesh, do not initialise
113
114 // 2. Initialise parents and itself
115 meshPtr().init(true);
116
117 return meshPtr;
118}
119
120
122(
123 const argList& args,
124 const Time& runTime
125)
126{
127 const IOobject meshIO
128 (
131 runTime,
133 );
134
135 if (args.dryRun() || args.found("dry-run-write"))
136 {
137 Info
138 << "Operating in 'dry-run' mode: case will run for 1 time step. "
139 << "All checks assumed OK on a clean exit" << endl;
140
142
143 // Stop after 1 iteration of the simplified mesh
144
145 if (args.found("dry-run-write"))
146 {
147 // Using saWriteNow triggers function objects execute(), write()
149 }
150 else
151 {
152 // Using saNoWriteNow triggers function objects execute(),
153 // but not write()
155 }
156
157 functionObject::outputPrefix = "postProcessing-dry-run";
158
160 }
161
162 return New(meshIO);
163}
164
165
166// ************************************************************************* //
static bool allowConstructFromLargerSize
Permit read construct from a larger size.
Definition: FieldBase.H:63
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
const Time & time() const
Return Time associated with the objectRegistry.
Definition: IOobject.C:506
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (uses typeFilePath to find file) and check its info.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:500
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:180
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
@ saNoWriteNow
Adjust endTime to stop immediately w/o writing.
Definition: Time.H:100
@ saWriteNow
adjust endTime to stop immediately w/ writing
Definition: Time.H:101
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
virtual stopAtControls stopAt() const
Return the stop control information.
Definition: Time.C:873
dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
Definition: Time.H:510
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:124
int dryRun() const noexcept
Return the dry-run flag.
Definition: argListI.H:116
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool open(bool verbose=true)
static word outputPrefix
Directory prefix.
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:321
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
Definition: polyMesh.C:854
Foam::staticFvMesh.
Definition: staticFvMesh.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define DebugInfo
Report an information message using Foam::Info.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict
Foam::argList args(argc, argv)