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.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 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:165
Foam::fv::option::name
const word & name() const noexcept
Definition: fvOptionI.H:24
Log
#define Log
Definition: PDRblock.C:28
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::fv::cellSetOption
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Definition: cellSetOption.H:159
Foam::List::resize
void resize(const label len)
Definition: ListI.H:132
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:57
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::fv::option::resetApplied
void resetApplied()
Definition: fvOption.C:41
Foam::turbulenceModel::propertiesName
static const word propertiesName
Definition: turbulenceModel.H:96
Foam::tmp::isTmp
bool isTmp() const noexcept
Definition: tmp.H:291
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::fv::option::mesh_
const fvMesh & mesh_
Definition: fvOption.H:135
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
atmNutSource.H
Foam::compressible::turbulenceModel
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
Definition: turbulentFluidThermoModel.H:59
Foam::fv::option::fieldNames_
wordList fieldNames_
Definition: fvOption.H:144
field
rDeltaTY field()
timeName
word timeName
Definition: getTimeIndex.H:3
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:59
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:36
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:81
Foam
Definition: atmBoundaryLayer.C:26
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:139
fv
labelList fv(nPoints)
Foam::fv::atmNutSource::atmNutSource
atmNutSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Definition: atmNutSource.C:40
FatalErrorInFunction
#define FatalErrorInFunction
Definition: error.H:465
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:44
Foam::objectRegistry::findObject
const Type * findObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:394
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::name
word name(const expressions::valueTypeCode typeCode)
Definition: exprTraits.C:52
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:49
Foam::fv::atmNutSource::correct
virtual void correct(volScalarField &field)
Definition: atmNutSource.C:108