alphatPhaseChangeWallFunctionFvPatchScalarField.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) 2026 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 
27 #include "wallPhaseChange.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
33 Foam::alphatPhaseChangeWallFunctionFvPatchScalarField::models() const
34 {
35  if (models_.size()) return models_;
36 
37  const Foam::fvModels& fvModels =
38  Foam::fvModels::New(internalField().mesh());
39 
40  forAll(fvModels, fvModeli)
41  {
42  if (!isA<fv::wallPhaseChange>(fvModels[fvModeli])) continue;
43 
44  const fv::wallPhaseChange& model =
45  refCast<const fv::wallPhaseChange>(fvModels[fvModeli]);
46 
47  if
48  (
49  &internalField() == &model.alphats().first()
50  || &internalField() == &model.alphats().second()
51  )
52  {
53  models_.append(&model);
54  }
55  }
56 
57  if (models_.empty())
58  {
60  << "No wall phase-change models found for " << typeName
61  << " boundary condition of field " << internalField().name()
62  << " on patch " << patch().name() << exit(FatalError);
63  }
64 
65  return models_;
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * /
70 
73 (
74  const fvPatch& p,
76  const dictionary& dict
77 )
78 :
79  fixedValueFvPatchScalarField(p, iF, dict),
80  models_()
81 {}
82 
83 
86 (
88  const fvPatch& p,
90  const fieldMapper& mapper
91 )
92 :
93  fixedValueFvPatchScalarField(psf, p, iF, mapper),
94  models_()
95 {}
96 
97 
100 (
103 )
104 :
105  fixedValueFvPatchScalarField(psf, iF),
106  models_()
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
113 {
114  if (updated())
115  {
116  return;
117  }
118 
119  const UPtrList<const fv::wallPhaseChange>& models = this->models();
120 
121  // Apply the first model to the entire patch, and subsequent models only to
122  // the active portion of the patch. This assumes that the models active
123  // regions do not overlap. If it turns out that we do need to support
124  // multiple models simultaneously causing phase-change on the same face,
125  // then these models will need to get more collaborative and we have to
126  // think about how to do that.
127  forAll(models, modeli)
128  {
129  const fv::wallPhaseChange& model = models[modeli];
130 
131  const scalarField& alphat =
132  &internalField() == &model.alphats().first()
133  ? model.alphats(patch().index()).first()
134  : model.alphats(patch().index()).second();
135 
136  if (modeli == 0)
137  {
138  operator==(alphat);
139  }
140  else
141  {
142  const scalarField& active = model.active(patch().index());
143  operator==((1 - active)*(*this) + active*alphat);
144  }
145  }
146 
147  fixedValueFvPatchScalarField::updateCoeffs();
148 }
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 namespace Foam
154 {
156  (
159  );
160 }
161 
162 
163 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
static fvModels & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
This boundary condition provides a thermal wall function or the turbulent thermal diffusivity for wal...
alphatPhaseChangeWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
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
Finite volume models.
Definition: fvModels.H:69
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
Base class for fvModels that represent phase change at a wall.
virtual const scalarField & active(const label patchi) const =0
Return a mask indicating whether phase change is occurring.
const Pair< const volScalarField & > & alphats() const
Access the turbulent thermal diffusivities.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
error FatalError
dictionary dict
volScalarField & p