waveAlpha_DimensionedFieldFunction.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 "fvMesh.H"
28 #include "waveSuperposition.H"
29 #include "levelSet.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace DimensionedFieldFunctions
37 {
39  (
40  waveAlpha,
41  0
42  );
43 
47  (
49  waveAlpha,
51  );
52 }
53 }
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
58 (
59  const dictionary& dict,
61 )
62 :
64  liquid_(dict.lookupOrDefault<Switch>("liquid", true))
65 {}
66 
67 
69 (
70  const waveAlpha& dff,
72 )
73 :
74  DimensionedFieldFunction<DimensionedField<scalar, fvMesh>>(dff, field),
75  liquid_(dff.liquid_)
76 {}
77 
78 
80 <
82  <
84  >
85 >
87 (
89 ) const
90 {
92  (
93  new waveAlpha(*this, field)
94  );
95 }
96 
97 
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 
101 {
102  const fvMesh& mesh(this->field_.mesh());
103  const scalar t = mesh.time().value();
104 
106 
107  this->field_.primitiveFieldRef() = levelSetFraction
108  (
109  mesh,
110  waves.height(t, mesh.cellCentres()),
111  waves.height(t, mesh.points()),
112  !liquid_
113  );
114 }
115 
116 
118 (
119  Ostream& os
120 ) const
121 {
122  writeEntryIfDifferent<Switch>(os, "liquid", true, liquid_);
123 }
124 
125 
126 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Base class for run-time selectable internal and patch field initialisation evaluation and update with...
virtual autoPtr< DimensionedFieldFunction< DimensionedField< scalar, fvMesh > > > clone() const
Construct and return a clone for the specified field.
Initialises the phase fraction to that specified by a superposition of wave models....
waveAlpha(const dictionary &dict, DimensionedField< scalar, fvMesh > &field)
Construct with dictionary to initialise given field.
virtual void evaluate()
Evaluate the function and set the field.
virtual void write(Ostream &os) const
Write data to dictionary stream.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Type & value() const
Return const reference to value.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1295
const vectorField & cellCentres() const
A wrapper around a list of wave models. Superimposes the modelled values of elevation and velocity....
virtual tmp< scalarField > height(const scalar t, const vectorField &p) const
Get the height above the waves at a given time and global positions.
static const waveSuperposition & New(const objectRegistry &db)
Return a reference to the wave model on the given database,.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
defineTypeNameAndDebug(externalWallLayersHeatTransferCoefficient, 0)
addToRunTimeSelectionTable(DimensionedFieldFunctionScalarFvPatch, externalWallLayersHeatTransferCoefficient, dictionary)
DimensionedFieldFunction< DimensionedField< scalar, fvMesh > > DimensionedFieldFunctionScalarFvMesh
Namespace for OpenFOAM.
tmp< scalarField > levelSetFraction(const fvMesh &mesh, const scalarField &levelC, const scalarField &levelP, const bool above)
Calculate the volume-fraction that a level set occupies. This gives the.
Definition: levelSet.C:34
dictionary dict