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-2020 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,
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  return io;
67  }
68  else
69  {
70  // Check if the faOptions file is in system
71  io.instance() = mesh.time().system();
72 
73  if (io.typeHeaderOk<IOdictionary>(true))
74  {
75  Info<< "Creating finite area options from "
76  << io.instance()/io.name() << nl
77  << endl;
78 
79  io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
80  return io;
81  }
82  else
83  {
84  io.readOpt() = IOobject::NO_READ;
85  return io;
86  }
87  }
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
92 
93 Foam::fa::options::options
94 (
95  const fvPatch& p
96 )
97 :
98  IOdictionary(createIOobject(p.boundaryMesh().mesh())),
99  optionList(p, *this)
100 {}
101 
102 
104 {
105  const fvMesh& mesh = p.boundaryMesh().mesh();
106 
107  if (mesh.thisDb().foundObject<options>(typeName))
108  {
109  return const_cast<options&>
110  (
111  mesh.lookupObject<options>(typeName)
112  );
113  }
114  else
115  {
116  if (debug)
117  {
119  << "Constructing " << typeName
120  << " for region " << mesh.name() << endl;
121  }
122 
123  options* objectPtr = new options(p);
124  regIOobject::store(objectPtr);
125  return *objectPtr;
126  }
127 }
128 
129 
131 {
133  {
134  optionList::read(*this);
135  return true;
136  }
137  else
138  {
139  return false;
140  }
141 }
142 
143 
144 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:325
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::fa::options::New
static options & New(const fvPatch &p)
Definition: faOptions.C:103
Foam::IOdictionary::IOdictionary
IOdictionary(const IOobject &)
Construct given an IOobject.
Definition: IOdictionary.C:35
Foam::fa::optionList
List of finite volume options.
Definition: faOptionList.H:66
faOptions.H
Foam::IOobject::IOobject
IOobject(const IOobject &)=default
Copy construct.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
faMesh.H
Foam::regIOobject::store
bool store()
Definition: regIOobjectI.H:37
Foam::fa::options::read
virtual bool read()
Read dictionary.
Definition: faOptions.C:130
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Time.H
Foam::fa::options
Finite-area options.
Definition: faOptions.H:54
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::fa::defineTypeNameAndDebug
defineTypeNameAndDebug(faceSetOption, 0)
Foam::fa::optionList::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: faOptionList.C:147
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
Foam::IOobject::NO_READ
Definition: IOobject.H:123
Foam::IOobject::MUST_READ
Definition: IOobject.H:120