buoyancyForce.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) 2015-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 "buoyancyForce.H"
27 #include "fvMatrices.H"
29 
30 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace fv
35 {
37 
39  (
40  fvModel,
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
50 void Foam::fv::buoyancyForce::readCoeffs()
51 {
52  phaseName_ = coeffs().lookupOrDefault<word>("phase", word::null);
53 
54  UName_ =
55  coeffs().lookupOrDefault<word>
56  (
57  "U",
58  IOobject::groupName("U", phaseName_)
59  );
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
66 (
67  const word& name,
68  const word& modelType,
69  const fvMesh& mesh,
70  const dictionary& dict
71 )
72 :
73  fvModel(name, modelType, mesh, dict),
74  phaseName_(word::null),
75  UName_(word::null),
76  g_
77  (
78  IOobject
79  (
80  "g",
81  mesh.time().constant(),
82  mesh,
83  IOobject::MUST_READ,
84  IOobject::NO_WRITE
85  )
86  )
87 {
88  readCoeffs();
89 }
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
95 {
96  return wordList(1, UName_);
97 }
98 
99 
101 (
102  const volVectorField& U,
103  fvMatrix<vector>& eqn
104 ) const
105 {
106  eqn += g_;
107 }
108 
109 
111 (
112  const volScalarField& rho,
113  const volVectorField& U,
114  fvMatrix<vector>& eqn
115 ) const
116 {
117  eqn += rho*g_;
118 }
119 
120 
122 (
123  const volScalarField& alpha,
124  const volScalarField& rho,
125  const volVectorField& U,
126  fvMatrix<vector>& eqn
127 ) const
128 {
129  eqn += alpha*rho*g_;
130 }
131 
132 
134 {
135  return true;
136 }
137 
138 
140 {}
141 
142 
144 {}
145 
146 
148 {}
149 
150 
152 {
153  if (fvModel::read(dict))
154  {
155  readCoeffs();
156  return true;
157  }
158  else
159  {
160  return false;
161  }
162 }
163 
164 
165 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static word groupName(Name name, const word &group)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, if not found return the given default.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
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
Calculates and applies the buoyancy force rho*g to the momentum equation corresponding to the specifi...
Definition: buoyancyForce.H:66
virtual bool movePoints()
Update for mesh motion.
virtual void addSup(const volVectorField &U, fvMatrix< vector > &eqn) const
Add explicit contribution to incompressible momentum equation.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: buoyancyForce.C:94
buoyancyForce(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Definition: buoyancyForce.C:66
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 source dictionary.
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.
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
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)
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