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-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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#include "fvmSup.H"
32
33// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
34
35namespace Foam
36{
37namespace fv
38{
41}
42}
43
44
45// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46
48(
49 const word& sourceName,
50 const word& modelType,
51 const dictionary& dict,
52 const fvMesh& mesh
53)
54:
55 fv::cellSetOption(sourceName, modelType, dict, mesh),
56 rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
57 plantCd_
58 (
60 (
61 "plantCd",
62 mesh.time().timeName(),
63 mesh,
64 IOobject::MUST_READ,
65 IOobject::AUTO_WRITE
66 ),
67 mesh
68 ),
69 leafAreaDensity_
70 (
72 (
73 "leafAreaDensity",
74 mesh.time().timeName(),
75 mesh,
76 IOobject::MUST_READ,
77 IOobject::AUTO_WRITE
78 ),
79 mesh
80 )
81{
82 fieldNames_.resize(1, "U");
83
85
86 Log << " Applying atmPlantCanopyUSource to: " << fieldNames_[0] << endl;
87}
88
89
90// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91
93(
95 const label fieldi
96)
97{
98 const volVectorField& U = eqn.psi();
99
100 if (V_ > VSMALL)
101 {
102 // (SP:Eq. 42)
103 eqn -= fvm::Sp(plantCd_*leafAreaDensity_*mag(U), U);
104 }
105}
106
107
109(
110 const volScalarField& rho,
111 fvMatrix<vector>& eqn,
112 const label fieldi
113)
114{
115 const volVectorField& U = eqn.psi();
116
117 if (V_ > VSMALL)
118 {
119 eqn -= fvm::Sp(rho*plantCd_*leafAreaDensity_*mag(U), U);
120 }
121}
122
123
125(
126 const volScalarField& alpha,
127 const volScalarField& rho,
128 fvMatrix<vector>& eqn,
129 const label fieldi
130)
131{
132 const volVectorField& U = eqn.psi();
133
134 if (V_ > VSMALL)
135 {
136 eqn -= fvm::Sp(alpha*rho*plantCd_*leafAreaDensity_*mag(U), U);
137 }
138}
139
140
141// ************************************************************************* //
#define Log
Definition: PDRblock.C:35
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
Definition: fvMatrix.H:412
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Applies sources on velocity, i.e. U, to incorporate effects of plant canopy for atmospheric boundary ...
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add explicit contribution to momentum equation.
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:127
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: fvOption.H:148
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:48
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
U
Definition: pEqn.H:72
dynamicFvMesh & mesh
Calculate the finiteVolume matrix for implicit and explicit sources.
word timeName
Definition: getTimeIndex.H:3
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
labelList fv(nPoints)
volScalarField & alpha
dictionary dict