atmPlantCanopyTurbSource.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2020 ENERCON GmbH
9  Copyright (C) 2020-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 
32 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
38  defineTypeNameAndDebug(atmPlantCanopyTurbSource, 0);
39  addToRunTimeSelectionTable(option, atmPlantCanopyTurbSource, dictionary);
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
45 
47 Foam::fv::atmPlantCanopyTurbSource::calcPlantCanopyTerm
48 (
49  const volVectorField::Internal& U
50 ) const
51 {
52  // (SP:Eq. 42)
53  return 12.0*Foam::sqrt(Cmu_)*plantCd_()*leafAreaDensity_()*mag(U);
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
60 (
61  const word& sourceName,
62  const word& modelType,
63  const dictionary& dict,
64  const fvMesh& mesh
65 )
66 :
67  fv::cellSetOption(sourceName, modelType, dict, mesh),
68  isEpsilon_(true),
69  rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
70  Cmu_(Zero),
71  C1_(Zero),
72  C2_(Zero),
73  plantCd_
74  (
75  IOobject
76  (
77  "plantCd",
78  mesh.time().timeName(),
79  mesh,
82  ),
83  mesh
84  ),
85  leafAreaDensity_
86  (
87  IOobject
88  (
89  "leafAreaDensity",
90  mesh.time().timeName(),
91  mesh,
94  ),
95  mesh
96  )
97 {
98  const auto* turbPtr =
99  mesh_.findObject<turbulenceModel>
100  (
102  );
103 
104  if (!turbPtr)
105  {
107  << "Unable to find a turbulence model."
108  << abort(FatalError);
109  }
110 
111  fieldNames_.resize(1);
112 
113  tmp<volScalarField> tepsilon = turbPtr->epsilon();
114  tmp<volScalarField> tomega = turbPtr->omega();
115 
116  if (!tepsilon.isTmp())
117  {
118  fieldNames_[0] = tepsilon().name();
119 
120  const dictionary& turbDict = turbPtr->coeffDict();
121  Cmu_.read("Cmu", turbDict);
122  C1_.read("C1", turbDict);
123  C2_.read("C2", turbDict);
124  }
125  else if (!tomega.isTmp())
126  {
127  isEpsilon_ = false;
128  fieldNames_[0] = tomega().name();
129 
130  const dictionary& turbDict = turbPtr->coeffDict();
131  Cmu_.read("betaStar", turbDict);
132  }
133  else
134  {
136  << "Unable to find neither epsilon nor omega field." << nl
137  << "atmPlantCanopyTurbSource needs either epsilon or omega field."
138  << abort(FatalError);
139  }
140 
142 
143  Log << " Applying atmPlantCanopyTurbSource to: " << fieldNames_[0]
144  << endl;
145 }
146 
147 
148 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
149 
151 (
152  fvMatrix<scalar>& eqn,
153  const label fieldi
154 )
155 {
156  if (isEpsilon_)
157  {
158  atmPlantCanopyTurbSourceEpsilon
159  (
162  eqn,
163  fieldi
164  );
165  }
166  else
167  {
168  atmPlantCanopyTurbSourceOmega
169  (
172  eqn,
173  fieldi
174  );
175  }
176 }
177 
178 
180 (
181  const volScalarField& rho,
182  fvMatrix<scalar>& eqn,
183  const label fieldi
184 )
185 {
186  if (isEpsilon_)
187  {
188  atmPlantCanopyTurbSourceEpsilon(geometricOneField(), rho, eqn, fieldi);
189  }
190  else
191  {
192  atmPlantCanopyTurbSourceOmega(geometricOneField(), rho, eqn, fieldi);
193  }
194 }
195 
196 
198 (
199  const volScalarField& alpha,
200  const volScalarField& rho,
201  fvMatrix<scalar>& eqn,
202  const label fieldi
203 )
204 {
205  if (isEpsilon_)
206  {
207  atmPlantCanopyTurbSourceEpsilon(alpha, rho, eqn, fieldi);
208  }
209  else
210  {
211  atmPlantCanopyTurbSourceOmega(alpha, rho, eqn, fieldi);
212  }
213 }
214 
215 
216 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
Log
#define Log
Definition: PDRblock.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fv::cellSetOption
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Definition: cellSetOption.H:163
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::fv::option::resetApplied
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:48
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:100
Foam::geometricOneField
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
Definition: geometricOneField.H:55
Foam::fv::atmPlantCanopyTurbSource::addSup
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Definition: atmPlantCanopyTurbSource.C:151
Foam::tmp::isTmp
bool isTmp() const noexcept
Identical to is_pointer()
Definition: tmp.H:295
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
rho
rho
Definition: readInitialConditions.H:88
Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSource
atmPlantCanopyTurbSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: atmPlantCanopyTurbSource.C:60
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:63
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
atmPlantCanopyTurbSource.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::dictionary::read
bool read(Istream &is)
Read dictionary from Istream. Discards the header.
Definition: dictionaryIO.C:141
fv
labelList fv(nPoints)
U
U
Definition: pEqn.H:72
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::IOobject::MUST_READ
Definition: IOobject.H:185