porosityForce.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-2024 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 "porosityForce.H"
27 #include "porosityModel.H"
28 #include "fvMatrices.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace fv
36 {
40  (
41  fvModel,
43  dictionary,
44  explicitPorositySource,
45  "explicitPorositySource"
46  );
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 
53 void Foam::fv::porosityForce::readCoeffs(const dictionary& dict)
54 {
55  if (dict.found("UNames"))
56  {
57  UNames_ = wordList(dict.lookup("UNames"));
58  }
59  else
60  {
61  UNames_ = wordList(1, dict.lookupOrDefault<word>("U", "U"));
62  }
63 
64  porosityPtr_.reset
65  (
67  (
68  name(),
69  mesh(),
70  dict
71  ).ptr()
72  );
73 }
74 
75 
76 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
77 
79 (
80  const word& name,
81  const word& modelType,
82  const fvMesh& mesh,
83  const dictionary& dict
84 )
85 :
86  fvModel(name, modelType, mesh, dict),
87  UNames_(),
88  porosityPtr_(nullptr)
89 {
90  readCoeffs(coeffs(dict));
91 }
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
97 {
98  return UNames_;
99 }
100 
101 
103 (
104  const volVectorField& U,
105  fvMatrix<vector>& eqn
106 ) const
107 {
108  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
109  porosityPtr_->addResistance(porosityEqn);
110  eqn -= porosityEqn;
111 }
112 
113 
115 (
116  const volScalarField& rho,
117  const volVectorField& U,
118  fvMatrix<vector>& eqn
119 ) const
120 {
121  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
122  porosityPtr_->addResistance(porosityEqn);
123  eqn -= porosityEqn;
124 }
125 
126 
128 (
129  const volScalarField& alpha,
130  const volScalarField& rho,
131  const volVectorField& U,
132  fvMatrix<vector>& eqn
133 ) const
134 {
135  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
136  porosityPtr_->addResistance(porosityEqn);
137  eqn -= alpha*porosityEqn;
138 }
139 
140 
142 {
143  porosityPtr_->movePoints();
144 
145  return true;
146 }
147 
148 
150 {
151  porosityPtr_->topoChange(map);
152 }
153 
154 
156 {
157  porosityPtr_->mapMesh(map);
158 }
159 
160 
162 (
163  const polyDistributionMap& map
164 )
165 {
166  porosityPtr_->distribute(map);
167 }
168 
169 
171 {
172  if (fvModel::read(dict))
173  {
174  readCoeffs(coeffs(dict));
175  return true;
176  }
177  else
178  {
179  return false;
180  }
181 }
182 
183 
184 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
VolField< Type > & psi()
Definition: fvMatrix.H:289
const dimensionSet & dimensions() const
Definition: fvMatrix.H:302
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:200
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:57
This model applies the force exerted on the fluid by a porous media.
Definition: porosityForce.H:86
virtual bool movePoints()
Update for mesh motion.
virtual void addSup(const volVectorField &U, fvMatrix< vector > &eqn) const
Add implicit contribution to momentum equation.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: porosityForce.C:96
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read dictionary.
porosityForce(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
Definition: porosityForce.C:79
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
static autoPtr< porosityModel > New(const word &name, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName=word::null)
Selector.
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
A special matrix type and solver, designed for finite volume solutions of scalar equations.
U
Definition: pEqn.H:72
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
addBackwardCompatibleToRunTimeSelectionTable(fvConstraint, fixedTemperature, dictionary, fixedTemperatureConstraint, "fixedTemperatureConstraint")
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
labelList fv(nPoints)
dictionary dict