Loading...
Searching...
No Matches
fvOptions.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-2025 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 "fvOptions.H"
30#include "fvMesh.H"
31#include "Time.H"
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
37 namespace fv
38 {
40 }
41}
42
43
44// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
45
46namespace
47{
48
49// Create IO object if dictionary is present
50Foam::IOobject createIOobject
51(
52 const Foam::fvMesh& mesh,
53 const Foam::word& baseName // eg, fvOptions
54)
55{
56 using namespace Foam;
57
59 (
60 baseName,
61 mesh.time().constant(),
62 mesh.thisDb(),
66 );
67
68 if (io.typeHeaderOk<IOdictionary>(true))
69 {
71 }
72 else
73 {
74 // Check if the fvOptions file is in system
75 io.instance() = mesh.time().system();
76
77 if (io.typeHeaderOk<IOdictionary>(true))
78 {
80 }
81 else
82 {
84 }
85 }
86
87 if (io.isAnyRead())
88 {
89 Info<< "Creating finite-volume options from "
90 << io.instance()/io.name() << nl
91 << endl;
92 }
93
94 return io;
95}
96
97} // End anonymous namespace
98
99
100// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
101
102Foam::fv::options::options
103(
104 const fvMesh& mesh,
105 const IOobject& io
107:
109 fv::optionList(mesh, *this)
110{}
111
112
113Foam::fv::options::options
114(
115 const fvMesh& mesh
117:
118 IOdictionary(createIOobject(mesh, typeName)),
119 fv::optionList(mesh, *this)
120{}
121
122
124{
125 auto* ptr = mesh.thisDb().getObjectPtr<fv::options>(typeName);
126
127 if (!ptr)
128 {
130 << "Constructing " << typeName
131 << " for region " << mesh.name() << nl;
132
133 ptr = new fv::options(mesh);
135 }
136
137 return *ptr;
138}
139
140
142{
143 if (IOdictionary::regIOobject::read())
144 {
146 return true;
147 }
148
149 return false;
150}
151
152
153// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
@ REGISTER
Request registration (bool: true).
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
virtual bool read(const dictionary &dict)
Read dictionary.
optionList(const optionList &)=delete
No copy construct.
Finite-volume options, which is an IOdictionary of values and a fv::optionList.
Definition fvOptions.H:69
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present otherwise lookup and return.
Definition fvOptions.C:116
virtual bool read()
Read dictionary.
Definition fvOptions.C:134
bool store()
Register object with its registry and transfer ownership to the registry.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
const auto & io
#define DebugInFunction
Report an information message using Foam::Info.
Namespace for finite-volume.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
labelList fv(nPoints)