OpenFOAM
v2406
The open source CFD toolbox
faOptions.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) 2019-2022 OpenCFD Ltd.
9
------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM.
12
13
OpenFOAM is free software: you can redistribute it and/or modify it
14
under the terms of the GNU General Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26
\*---------------------------------------------------------------------------*/
27
28
#include "
faOptions.H
"
29
#include "
faMesh.H
"
30
#include "
Time.H
"
31
32
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34
namespace
Foam
35
{
36
namespace
fa
37
{
38
defineTypeNameAndDebug
(options, 0);
39
}
40
}
41
42
43
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
44
45
Foam::IOobject
Foam::fa::options::createIOobject
46
(
47
const
fvMesh&
mesh
48
)
const
49
{
50
IOobject
io
51
(
52
typeName,
53
mesh
.time().constant(),
54
mesh
,
55
IOobject::MUST_READ
,
56
IOobject::NO_WRITE
57
);
58
59
if
(
io
.typeHeaderOk<
IOdictionary
>(
true
))
60
{
61
Info
<<
"Creating finite area options from "
62
<<
io
.instance()/
io
.name() <<
nl
63
<<
endl
;
64
65
io
.readOpt(
IOobject::MUST_READ_IF_MODIFIED
);
66
}
67
else
68
{
69
// Check if the faOptions file is in system
70
io
.instance() =
mesh
.time().system();
71
72
if
(
io
.typeHeaderOk<
IOdictionary
>(
true
))
73
{
74
Info
<<
"Creating finite area options from "
75
<<
io
.instance()/
io
.name() <<
nl
76
<<
endl
;
77
78
io
.readOpt(
IOobject::MUST_READ_IF_MODIFIED
);
79
}
80
else
81
{
82
io
.readOpt(
IOobject::NO_READ
);
83
}
84
}
85
86
return
io
;
87
}
88
89
90
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91
92
Foam::fa::options::options
93
(
94
const
fvMesh
&
mesh
95
)
96
:
97
IOdictionary
(createIOobject(
mesh
)),
98
optionList
(
mesh
, *this)
99
{}
100
101
102
Foam::fa::options
&
Foam::fa::options::New
(
const
fvMesh
&
mesh
)
103
{
104
options
* ptr =
mesh
.thisDb().getObjectPtr<
options
>(typeName);
105
106
if
(!ptr)
107
{
108
DebugInFunction
109
<<
"Constructing "
<< typeName
110
<<
" for region "
<<
mesh
.name() <<
endl
;
111
112
ptr =
new
options
(
mesh
);
113
regIOobject::store
(ptr);
114
}
115
116
return
*ptr;
117
}
118
119
120
bool
Foam::fa::options::read
()
121
{
122
if
(
IOdictionary::regIOobject::read
())
123
{
124
optionList::read
(*
this
);
125
return
true
;
126
}
127
128
return
false
;
129
}
130
131
132
// ************************************************************************* //
Foam::IOdictionary::IOdictionary
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
Definition:
IOdictionary.C:30
Time.H
Foam::fa::optionList
List of finite volume options.
Definition:
faOptionList.H:61
Foam::nl
constexpr char nl
The newline '\n' character (0x0a)
Definition:
Ostream.H:50
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition:
Ostream.H:531
Foam::regIOobject::store
bool store()
Register object with its registry and transfer ownership to the registry.
Definition:
regIOobjectI.H:36
Foam::IOobjectOption::NO_WRITE
Ignore writing from objectRegistry::writeObject()
Definition:
IOobjectOption.H:86
Foam::fa::options::read
virtual bool read()
Read dictionary.
Definition:
faOptions.C:113
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition:
IOdictionary.H:50
mesh
dynamicFvMesh & mesh
Definition:
createDynamicFvMesh.H:6
Foam::fa::options::New
static options & New(const fvMesh &mesh)
Construct faOptions and register to database if not present otherwise lookup and return.
Definition:
faOptions.C:95
Foam::fa::options
Finite-area options.
Definition:
faOptions.H:50
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition:
messageStream.H:556
Foam::IOobjectOption::MUST_READ_IF_MODIFIED
Definition:
IOobjectOption.H:71
Foam::fa::defineTypeNameAndDebug
defineTypeNameAndDebug(limitHeight, 0)
Foam::IOobjectOption::MUST_READ
Reading required.
Definition:
IOobjectOption.H:63
Foam::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition:
blockMeshTools.C:44
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition:
fvMesh.H:78
Foam::IOobject::IOobject
IOobject(const IOobject &)=default
Copy construct.
Foam::IOobjectOption::NO_READ
Nothing to be read.
Definition:
IOobjectOption.H:60
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::fa::optionList::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition:
faOptionList.C:141
faMesh.H
faOptions.H
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition:
IOobject.H:180
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:26
src
faOptions
faOption
faOptions.C
Generated by
1.8.14