atmNutSource.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-------------------------------------------------------------------------------
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
29#include "atmNutSource.H"
31
32// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33
34namespace Foam
35{
36namespace fv
37{
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 artNutName_(dict.getOrDefault<word>("nut", "artNut")),
56 artNut_
57 (
59 (
60 artNutName_,
61 mesh.time().timeName(),
62 mesh,
63 IOobject::READ_IF_PRESENT,
64 IOobject::AUTO_WRITE
65 ),
66 mesh,
68 )
69{
70 if (!(artNut_.headerOk()))
71 {
73 << "Unable to find artificial turbulent viscosity field." << nl
74 << "atmNutSource requires an artificial nut field."
75 << abort(FatalError);
76 }
77
78 const auto* turbPtr =
80 (
82 );
83
84 if (!turbPtr)
85 {
87 << "Unable to find a turbulence model."
88 << abort(FatalError);
89 }
90
92
93 const tmp<volScalarField>& tnut = turbPtr->nut();
94
95 if (!tnut.isTmp())
96 {
97 fieldNames_[0] = tnut().name();
98 }
99 else
100 {
102 << "Unable to find nut field." << nl
103 << "atmNutSource requires nut field."
104 << abort(FatalError);
105 }
106
108
109 Log << " Applying atmNutSource to: " << fieldNames_[0] << endl;
110}
111
112
113// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114
116{
117 Log << this->name() << ": correcting " << field.name() << endl;
118
119 field += artNut_;
120
121 field.correctBoundaryConditions();
122}
123
124
125// ************************************************************************* //
#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
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Adds/subtracts a given artificial turbulent viscosity field to/from nut for atmospheric boundary laye...
Definition: atmNutSource.H:123
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
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOption.H:139
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
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
bool headerOk()
Read and check header info. Does not check the headerClassName.
Definition: regIOobject.C:438
A class for managing temporary objects.
Definition: tmp.H:65
bool isTmp() const noexcept
Identical to is_pointer()
Definition: tmp.H:295
Abstract base class for turbulence models (RAS, LES and laminar).
static const word propertiesName
Default name of the turbulence properties dictionary.
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
rDeltaTY field()
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
word timeName
Definition: getTimeIndex.H:3
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
labelList fv(nPoints)
dictionary dict