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 -------------------------------------------------------------------------------
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 "atmNutSource.H"
31 
32 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
38  defineTypeNameAndDebug(atmNutSource, 0);
39  addToRunTimeSelectionTable(option, atmNutSource, 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  artNutName_(dict.getOrDefault<word>("nut", "artNut")),
56  artNut_
57  (
58  IOobject
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.is_reference())
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 
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 // ************************************************************************* //
dictionary dict
rDeltaTY field()
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: fvOption.H:157
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:160
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOption.H:142
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
virtual void correct(volScalarField &field)
Correct the turbulent viscosity.
Definition: atmNutSource.C:108
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
bool headerOk()
Read and check header info. Does not check the headerClassName.
Definition: regIOobject.C:505
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Macros for easy insertion into run-time selection tables.
word timeName
Definition: getTimeIndex.H:3
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
static const word propertiesName
Default name of the turbulence properties dictionary.
atmNutSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: atmNutSource.C:40
A class for handling words, derived from Foam::string.
Definition: word.H:63
labelList fv(nPoints)
errorManip< error > abort(error &err)
Definition: errorManip.H:139
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:41
#define Log
Definition: PDRblock.C:28
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127