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-2021 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 {
36  defineTypeNameAndDebug(buoyancyForce, 0);
37 
39  (
40  fvModel,
41  buoyancyForce,
42  dictionary
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 dictionary& dict,
70  const fvMesh& mesh
71 )
72 :
73  fvModel(name, modelType, dict, mesh),
74  phaseName_(word::null),
75  UName_(word::null),
76  g_
77  (
78  IOobject
79  (
80  "g",
81  mesh.time().constant(),
82  mesh,
85  )
86  )
87 {
88  readCoeffs();
89 }
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
95 {
96  return wordList(1, UName_);
97 }
98 
99 
101 (
102  fvMatrix<vector>& eqn,
103  const word& fieldName
104 ) const
105 {
106  eqn += g_;
107 }
108 
109 
111 (
112  const volScalarField& rho,
113  fvMatrix<vector>& eqn,
114  const word& fieldName
115 ) const
116 {
117  eqn += rho*g_;
118 }
119 
120 
122 (
123  const volScalarField& alpha,
124  const volScalarField& rho,
125  fvMatrix<vector>& eqn,
126  const word& fieldName
127 ) const
128 {
129  eqn += alpha*rho*g_;
130 }
131 
132 
134 {
135  if (fvModel::read(dict))
136  {
137  readCoeffs();
138  return true;
139  }
140  else
141  {
142  return false;
143  }
144 }
145 
146 
147 // ************************************************************************* //
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: buoyancyForce.C:94
defineTypeNameAndDebug(fixedTemperatureConstraint, 0)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:158
Finite volume model abstract base class.
Definition: fvModel.H:55
buoyancyForce(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: buoyancyForce.C:66
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:239
virtual bool read(const dictionary &dict)
Read source dictionary.
Macros for easy insertion into run-time selection tables.
dynamicFvMesh & mesh
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
static word groupName(Name name, const word &group)
const word & constant() const
Return constant name.
Definition: TimePaths.H:123
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. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
addToRunTimeSelectionTable(fvConstraint, fixedTemperatureConstraint, dictionary)
List< word > wordList
A List of words.
Definition: fileName.H:54
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A special matrix type and solver, designed for finite volume solutions of scalar equations.
virtual void addSup(fvMatrix< vector > &eqn, const word &fieldName) const
Add explicit contribution to incompressible momentum equation.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.