Loading...
Searching...
No Matches
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"
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 {
72 FatalErrorInFunction
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.is_reference())
96 {
97 fieldNames_[0] = tnut().name();
98 }
99 else
100 {
101 FatalErrorInFunction
102 << "Unable to find nut field." << nl
103 << "atmNutSource requires nut field."
104 << abort(FatalError);
105 }
106
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:28
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
if(patchID !=-1)
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Adds/subtracts a given artificial turbulent viscosity field to/from nut for atmospheric boundary laye...
atmNutSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
virtual void correct(volScalarField &field)
Correct the turbulent viscosity.
cellSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Base abstract class for handling finite volume options (i.e. fvOption).
Definition fvOption.H:124
const fvMesh & mesh_
Reference to the mesh database.
Definition fvOption.H:142
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition fvOption.H:157
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition fvOption.C:41
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition fvOptionI.H:30
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.
A class for managing temporary objects.
Definition tmp.H:75
bool is_reference() const noexcept
True if this is a reference (not a pointer).
Definition tmpI.H:206
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:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
rDeltaTY field()
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
auto & name
word timeName
Definition getTimeIndex.H:3
Namespace for finite-volume.
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict