saturationModels.H
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) 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 Namespace
25  Foam::saturationModels
26 
27 Description
28  Namespace containing common functionality for saturationPressureModel and
29  saturationTemperatureModel
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #ifndef saturationModels_H
34 #define saturationModels_H
35 
36 #include "volFields.H"
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 namespace saturationModels
43 {
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 //- Structure to store a dimensioned coefficient of the saturation model
49 :
50  public dimensionedScalar
51 {
52  //- Inherit Constructors
54 
55  //- Cast to a scalar
56  operator scalar() const
57  {
58  return dimensionedScalar::value();
59  }
60 };
61 
62 //- Construct a scalar field from a uniform value
64 (
65  const scalarField& argument,
66  const word& name,
67  const dimensionedScalar& value
68 )
69 {
70  return tmp<scalarField>(new scalarField(argument.size(), value.value()));
71 }
72 
73 //- Construct a volScalarField::Internal or a volScalarField field from a
74 // uniform value
75 template<class FieldType>
77 (
78  const FieldType& argument,
79  const word& name,
80  const dimensionedScalar& value
81 )
82 {
83  return FieldType::New(name, argument.mesh(), value);
84 }
85 
86 //- Use a model's scalarField method to construct a volScalarField::Internal
87 template<class Model>
89 (
91  const word& name,
92  const dimensionSet& dimensions,
93  const Model& model,
94  tmp<scalarField> (Model::*method)(const scalarField&) const
95 )
96 {
98  (
100  );
101 
102  volScalarField::Internal& result = tResult.ref();
103 
104  result.primitiveFieldRef() = (model.*method)(p.primitiveField());
105 
106  return tResult;
107 }
108 
109 //- Use a model's scalarField method to construct a volScalarField
110 template<class Model>
112 (
113  const volScalarField& p,
114  const word& name,
115  const dimensionSet& dimensions,
116  const Model& model,
117  tmp<scalarField> (Model::*method)(const scalarField&) const
118 )
119 {
120  tmp<volScalarField> tResult
121  (
123  );
124 
125  volScalarField& result = tResult.ref();
126 
127  result.primitiveFieldRef() = (model.*method)(p.primitiveField());
128 
129  volScalarField::Boundary& resultBf = result.boundaryFieldRef();
130 
131  forAll(result.boundaryField(), patchi)
132  {
133  resultBf[patchi] = (model.*method)(p.boundaryField()[patchi]);
134  }
135 
136  return tResult;
137 }
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 } // End namespace saturationModels
142 } // End namespace Foam
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
PrimitiveField< Type > & primitiveFieldRef()
Return a reference to the internal field.
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Mesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
Generic GeometricBoundaryField class.
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Internal::FieldType & primitiveFieldRef()
Return a reference to the primitive field.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Dimension set for the base types.
Definition: dimensionSet.H:125
const scalar & value() const
Return const reference to value.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
A class for handling words, derived from string.
Definition: word.H:62
label patchi
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
tmp< scalarField > evaluate(const scalarField &argument, const word &name, const dimensionedScalar &value)
Construct a scalar field from a uniform value.
Namespace for OpenFOAM.
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Definition: dimensionSets.C:96
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
volScalarField & p
Structure to store a dimensioned coefficient of the saturation model.