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-2021 OpenCFD Ltd.
9------------------------------------------------------------------------------
10License
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
34namespace Foam
35{
36 namespace fa
37 {
39 }
40}
41
42
43// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
44
45Foam::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,
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
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
79 }
80 else
81 {
83 }
84 }
85
86 return io;
87}
88
89
90// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91
93(
94 const fvPatch& p
95)
96:
97 IOdictionary(createIOobject(p.boundaryMesh().mesh())),
98 optionList(p, *this)
99{}
100
101
103{
104 const fvMesh& mesh = p.boundaryMesh().mesh();
105
106 if (mesh.thisDb().foundObject<options>(typeName))
107 {
108 return const_cast<options&>
109 (
110 mesh.lookupObject<options>(typeName)
111 );
112 }
113 else
114 {
115 if (debug)
116 {
118 << "Constructing " << typeName
119 << " for region " << mesh.name() << endl;
120 }
121
122 options* objectPtr = new options(p);
123 regIOobject::store(objectPtr);
124 return *objectPtr;
125 }
126}
127
128
130{
131 if (IOdictionary::regIOobject::read())
132 {
133 optionList::read(*this);
134 return true;
135 }
136 else
137 {
138 return false;
139 }
140}
141
142
143// ************************************************************************* //
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
readOption readOpt() const noexcept
The read option.
Definition: IOobjectI.H:164
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 fileName & instance() const noexcept
Read access to instance path component.
Definition: IOobjectI.H:196
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:180
virtual bool read()
Re-read model coefficients if they have changed.
const word & system() const
Return system name.
Definition: TimePathsI.H:102
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:63
List of finite volume options.
Definition: faOptionList.H:70
Finite-area options.
Definition: faOptions.H:58
virtual bool read()
Read dictionary.
Definition: faOptions.C:129
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
dynamicFvMesh & mesh
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define InfoInFunction
Report an information message using Foam::Info.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53