mixedEnergyFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 #include "fieldMapper.H"
29 #include "volFields.H"
30 #include "basicThermo.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
37  const fvPatch& p,
39 )
40 :
41  mixedFvPatchScalarField(p, iF)
42 {
43  valueFraction() = scalar(0);
44  refValue() = scalar(0);
45  refGrad() = scalar(0);
46 }
47 
48 
50 (
51  const fvPatch& p,
53  const dictionary& dict
54 )
55 :
56  mixedFvPatchScalarField(p, iF, dict)
57 {}
58 
59 
61 (
63  const fvPatch& p,
65  const fieldMapper& mapper
66 )
67 :
68  mixedFvPatchScalarField(ptf, p, iF, mapper, false)
69 {
70  map(ptf, mapper);
71 }
72 
73 
75 (
76  const mixedEnergyFvPatchScalarField& tppsf,
78 )
79 :
80  mixedFvPatchScalarField(tppsf, iF)
81 {}
82 
83 
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 
87 (
89  const fieldMapper& mapper
90 )
91 {
92  // Unmapped faces are considered zero-gradient/adiabatic
93  // until they are corrected later
94  mapper(*this, ptf, [&](){ return patchInternalField(); });
95  mapper(refValue(), ptf.refValue(), [&](){ return patchInternalField(); });
96  mapper(refGrad(), ptf.refGrad(), scalar(0));
97  mapper(valueFraction(), ptf.valueFraction(), scalar(0));
98 }
99 
100 
102 (
103  const fvPatchScalarField& ptf,
104  const fieldMapper& mapper
105 )
106 {
107  map(refCast<const mixedEnergyFvPatchScalarField>(ptf), mapper);
108 }
109 
110 
112 {
113  if (updated())
114  {
115  return;
116  }
117 
119  const label patchi = patch().index();
120 
121  fvPatchScalarField& Tp =
122  const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]);
123 
124  if (isA<mixedFvPatchScalarField>(Tp))
125  {
126  mixedFvPatchScalarField& Tm =
127  refCast<mixedFvPatchScalarField>(Tp);
128 
129  Tm.evaluate();
130 
131  valueFraction() = Tm.valueFraction();
132  refValue() = thermo.he(Tm.refValue(), patchi);
133  refGrad() =
134  thermo.Cpv(Tm, patchi)*Tm.refGrad()
135  + patch().deltaCoeffs()*
136  (
137  thermo.he(Tm, patchi)
138  - thermo.he(Tm, patch().faceCells())
139  );
140  }
141  else if (isA<mixedEnergyCalculatedTemperatureFvPatchScalarField>(Tp))
142  {
144  refCast<mixedEnergyCalculatedTemperatureFvPatchScalarField>(Tp);
145 
146  Tm.evaluate();
147 
148  valueFraction() = Tm.heValueFraction();
149  refValue() = Tm.heRefValue();
150  refGrad() = Tm.heRefGrad();
151  }
152  else
153  {
155  << "Temperature boundary condition not recognised."
156  << "A " << typeName << " condition for energy must be used with a "
157  << mixedFvPatchScalarField::typeName << " or "
158  << mixedEnergyCalculatedTemperatureFvPatchScalarField::typeName
159  << " condition for temperature."
160  << exit(FatalError);
161  }
162 
163  mixedFvPatchScalarField::updateCoeffs();
164 }
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 namespace Foam
170 {
172  (
175  );
176 }
177 
178 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:78
static const basicThermo & lookupThermo(const FieldType &f)
Lookup the thermo associated with the given field.
virtual const volScalarField & T() const =0
Temperature [K].
virtual const volScalarField & Cpv() const =0
Heat capacity at constant pressure/volume [J/kg/K].
virtual const volScalarField & he() const =0
Enthalpy/Internal energy [J/kg].
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:91
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Base class for temperature boundary conditions in which the parameters of the mixed energy condition ...
This boundary condition provides a mixed condition for energy. This is selected when the correspondin...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
void map(const mixedEnergyFvPatchScalarField &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
mixedEnergyFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
makeNullConstructablePatchTypeField(fvPatchVectorField, noSlipFvPatchVectorField)
error FatalError
dictionary dict
volScalarField & p
fluidMulticomponentThermo & thermo
Definition: createFields.H:31