atmPlantCanopyUSource.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 
29 #include "atmPlantCanopyUSource.H"
31 
32 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
38  defineTypeNameAndDebug(atmPlantCanopyUSource, 0);
39  addToRunTimeSelectionTable(option, atmPlantCanopyUSource, dictionary);
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  const word& sourceName,
49  const word& modelType,
50  const dictionary& dict,
51  const fvMesh& mesh
52 )
53 :
54  fv::cellSetOption(sourceName, modelType, dict, mesh),
55  rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
56  plantCd_
57  (
58  IOobject
59  (
60  "plantCd",
61  mesh.time().timeName(),
62  mesh,
63  IOobject::MUST_READ,
64  IOobject::AUTO_WRITE
65  ),
66  mesh
67  ),
68  leafAreaDensity_
69  (
70  IOobject
71  (
72  "leafAreaDensity",
73  mesh.time().timeName(),
74  mesh,
75  IOobject::MUST_READ,
76  IOobject::AUTO_WRITE
77  ),
78  mesh
79  )
80 {
81  fieldNames_.resize(1, "U");
82 
83  fv::option::resetApplied();
84 
85  Log << " Applying atmPlantCanopyUSource to: " << fieldNames_[0] << endl;
86 }
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
92 (
93  fvMatrix<vector>& eqn,
94  const label fieldi
95 )
96 {
97  const volVectorField& U = eqn.psi();
98 
99  if (V_ > VSMALL)
100  {
101  // (SP:Eq. 42)
102  eqn -= (plantCd_*leafAreaDensity_*mag(U))*U;
103  }
104 }
105 
106 
108 (
109  const volScalarField& rho,
110  fvMatrix<vector>& eqn,
111  const label fieldi
112 )
113 {
114  const volVectorField& U = eqn.psi();
115 
116  if (V_ > VSMALL)
117  {
118  eqn -= rho*(plantCd_*leafAreaDensity_*mag(U))*U;
119  }
120 }
121 
122 
124 (
125  const volScalarField& alpha,
126  const volScalarField& rho,
127  fvMatrix<vector>& eqn,
128  const label fieldi
129 )
130 {
131  const volVectorField& U = eqn.psi();
132 
133  if (V_ > VSMALL)
134  {
135  eqn -= alpha*rho*(plantCd_*leafAreaDensity_*mag(U))*U;
136  }
137 }
138 
139 
140 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
atmPlantCanopyUSource.H
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::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::fv::atmPlantCanopyUSource::atmPlantCanopyUSource
atmPlantCanopyUSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: atmPlantCanopyUSource.C:47
rho
rho
Definition: readInitialConditions.H:88
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fvMatrix::psi
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
Definition: fvMatrix.H:399
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.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::atmPlantCanopyUSource::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add explicit contribution to momentum equation.
Definition: atmPlantCanopyUSource.C:92
fv
labelList fv(nPoints)
U
U
Definition: pEqn.H:72
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< vector, fvPatchField, volMesh >