IOporosityModelList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "IOporosityModelList.H"
27 #include "fvMesh.H"
28 #include "Time.H"
29 
30 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
31 
32 Foam::IOobject Foam::IOporosityModelList::createIOobject(const fvMesh& mesh)
33 {
34  typeIOobject<IOdictionary> io
35  (
36  "porosityProperties",
37  mesh.time().constant(),
38  mesh,
41  );
42 
43  if (io.headerOk())
44  {
46  << "Constructing porosity model list from " << io.name() << endl;
47 
48  io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
49  return io;
50  }
51  else
52  {
54  << "No porosity models present" << endl;
55 
56  io.readOpt() = IOobject::NO_READ;
57  return io;
58  }
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
65 (
66  const fvMesh& mesh
67 )
68 :
69  IOdictionary(createIOobject(mesh)),
70  porosityModelList(mesh, *this)
71 {}
72 
73 
75 {
76  if (regIOobject::read())
77  {
79  return true;
80  }
81  else
82  {
83  return false;
84  }
85 }
86 
87 
88 // ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:119
IOporosityModelList(const fvMesh &mesh)
Construct from mesh.
virtual bool read()
Read dictionary.
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.H:297
static const word & constant()
Return constant name.
Definition: TimePaths.H:122
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
List container for porosity models.
bool read(const dictionary &dict)
Read dictionary.
virtual bool read()
Read object.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
Ostream & indentOrNl(Ostream &os)
Indent stream or add newline if indent level == 0.
Definition: Ostream.H:250