All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
porosityModelList.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-2018 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 "porosityModelList.H"
27 #include "volFields.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 (
33  const fvMesh& mesh,
34  const dictionary& dict
35 )
36 :
38  mesh_(mesh)
39 {
40  reset(dict);
41 
42  active(true);
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
47 
49 {}
50 
51 
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53 
54 bool Foam::porosityModelList::active(const bool warn) const
55 {
56  bool a = false;
57  forAll(*this, i)
58  {
59  a = a || this->operator[](i).active();
60  }
61 
62  if (warn && this->size() && !a)
63  {
64  Info<< "No porosity models active" << endl;
65  }
66 
67  return a;
68 }
69 
70 
72 {
73  label count = 0;
74  forAllConstIter(dictionary, dict, iter)
75  {
76  if (iter().isDict())
77  {
78  count++;
79  }
80  }
81 
82  this->setSize(count);
83  label i = 0;
84  forAllConstIter(dictionary, dict, iter)
85  {
86  if (iter().isDict())
87  {
88  const word& name = iter().keyword();
89  const dictionary& modelDict = iter().dict();
90 
91  this->set
92  (
93  i++,
94  porosityModel::New(name, mesh_, modelDict)
95  );
96  }
97  }
98 }
99 
100 
102 {
103  bool allOk = true;
104  forAll(*this, i)
105  {
106  porosityModel& pm = this->operator[](i);
107  bool ok = pm.read(dict.subDict(pm.name()));
108  allOk = (allOk && ok);
109  }
110  return allOk;
111 }
112 
113 
115 {
116  forAll(*this, i)
117  {
118  os << nl;
119  this->operator[](i).writeData(os);
120  }
121 
122  return os.good();
123 }
124 
125 
127 (
128  fvVectorMatrix& UEqn
129 )
130 {
131  forAll(*this, i)
132  {
133  this->operator[](i).addResistance(UEqn);
134  }
135 }
136 
137 
139 (
140  fvVectorMatrix& UEqn,
141  const volScalarField& rho,
142  const volScalarField& mu
143 )
144 {
145  forAll(*this, i)
146  {
147  this->operator[](i).addResistance(UEqn, rho, mu);
148  }
149 }
150 
151 
153 (
154  const fvVectorMatrix& UEqn,
155  volTensorField& AU,
156  bool correctAUprocBC
157 )
158 {
159  forAll(*this, i)
160  {
161  this->operator[](i).addResistance(UEqn, AU, correctAUprocBC);
162  }
163 }
164 
165 
166 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
167 
168 Foam::Ostream& Foam::operator<<
169 (
170  Ostream& os,
171  const porosityModelList& models
172 )
173 {
174  models.writeData(os);
175  return os;
176 }
177 
178 
179 // ************************************************************************* //
bool writeData(Ostream &os) const
Write data to Ostream.
bool read(const dictionary &dict)
Read dictionary.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
const fvMesh & mesh_
Reference to the mesh database.
const T & operator[](const label) const
Return element const reference.
Definition: UPtrListI.H:96
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
porosityModelList(const fvMesh &mesh, const dictionary &dict)
~porosityModelList()
Destructor.
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:934
A class for handling words, derived from string.
Definition: word.H:59
void reset(const dictionary &dict)
Reset the source list.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:131
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
const word & name() const
Return const access to the porosity model name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
List container for porosity models.
messageStream Info
static autoPtr< porosityModel > New(const word &name, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName=word::null)
Selector.
bool active(const bool active=false) const
Return active status.
void addResistance(fvVectorMatrix &UEqn)
Add resistance.
virtual bool read(const dictionary &dict)
Read porosity dictionary.
Top level model for porosity models.
Definition: porosityModel.H:55