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::reset()
54 {
55  porosityPtr_.reset
56  (
58  (
59  name(),
60  mesh(),
61  coeffs()
62  ).ptr()
63  );
64 }
65 
66 
67 void Foam::fv::porosityForce::readCoeffs()
68 {
69  if (coeffs().found("UNames"))
70  {
71  UNames_ = wordList(coeffs().lookup("UNames"));
72  }
73  else
74  {
75  UNames_ = wordList(1, coeffs().lookupOrDefault<word>("U", "U"));
76  }
77 
78  reset();
79 }
80 
81 
82 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
83 
85 (
86  const word& name,
87  const word& modelType,
88  const fvMesh& mesh,
89  const dictionary& dict
90 )
91 :
92  fvModel(name, modelType, mesh, dict),
93  UNames_(),
94  porosityPtr_(nullptr)
95 {
96  readCoeffs();
97 }
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 {
104  return UNames_;
105 }
106 
107 
109 (
110  const volVectorField& U,
111  fvMatrix<vector>& eqn
112 ) const
113 {
114  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
115  porosityPtr_->addResistance(porosityEqn);
116  eqn -= porosityEqn;
117 }
118 
119 
121 (
122  const volScalarField& rho,
123  const volVectorField& U,
124  fvMatrix<vector>& eqn
125 ) const
126 {
127  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
128  porosityPtr_->addResistance(porosityEqn);
129  eqn -= porosityEqn;
130 }
131 
132 
134 (
135  const volScalarField& alpha,
136  const volScalarField& rho,
137  const volVectorField& U,
138  fvMatrix<vector>& eqn
139 ) const
140 {
141  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
142  porosityPtr_->addResistance(porosityEqn);
143  eqn -= alpha*porosityEqn;
144 }
145 
146 
148 {
149  // Currently there is no mechanism to update the porous media orientation
150  return true;
151 }
152 
153 
155 {
156  reset();
157 }
158 
159 
161 {
162  reset();
163 }
164 
165 
167 (
168  const polyDistributionMap& map
169 )
170 {
171  reset();
172 }
173 
174 
176 {
177  if (fvModel::read(dict))
178  {
179  readCoeffs();
180  return true;
181  }
182  else
183  {
184  return false;
185  }
186 }
187 
188 
189 // ************************************************************************* //
bool found
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
A list of keyword definitions, which are a keyword followed by any number of values (e....
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:99
Finite volume model abstract base class.
Definition: fvModel.H:59
const dictionary & coeffs() const
Return dictionary.
Definition: fvModelI.H:59
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:199
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:53
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:47
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.
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:85
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
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 bool)
Return a word representation of a bool.
Definition: boolIO.C:39
labelList fv(nPoints)
dictionary dict