phaseChangeModel.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) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "phaseChangeModel.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace regionModels
35 {
36 namespace surfaceFilmModels
37 {
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
46 phaseChangeModel::phaseChangeModel
47 (
49 )
50 :
52  latestMassPC_(0.0),
53  totalMassPC_(0.0)
54 {}
55 
56 
57 phaseChangeModel::phaseChangeModel
58 (
59  const word& modelType,
61  const dictionary& dict
62 )
63 :
64  filmSubModelBase(film, dict, typeName, modelType),
65  latestMassPC_(0.0),
66  totalMassPC_(0.0)
67 {}
68 
69 
70 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
71 
73 {}
74 
75 
76 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
77 
79 (
80  const scalar dt,
81  scalarField& availableMass,
82  volScalarField& dMass,
83  volScalarField& dEnergy
84 )
85 {
86  if (!active())
87  {
88  return;
89  }
90 
92  (
93  dt,
94  availableMass,
95  dMass,
96  dEnergy
97  );
98 
99  latestMassPC_ = sum(dMass.primitiveField());
101 
102  availableMass -= dMass;
104 
105  if (writeTime())
106  {
107  scalar phaseChangeMass = getModelProperty<scalar>("phaseChangeMass");
108  phaseChangeMass += returnReduce(totalMassPC_, sumOp<scalar>());
109  setModelProperty<scalar>("phaseChangeMass", phaseChangeMass);
110  totalMassPC_ = 0.0;
111  }
112 }
113 
114 
115 void phaseChangeModel::info(Ostream& os) const
116 {
117  const scalar massPCRate =
120 
121  scalar phaseChangeMass = getModelProperty<scalar>("phaseChangeMass");
122  phaseChangeMass += returnReduce(totalMassPC_, sumOp<scalar>());
123 
124  os << indent << "mass phase change = " << phaseChangeMass << nl
125  << indent << "vapourisation rate = " << massPCRate << nl;
126 }
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace surfaceFilmModels
132 } // End namespace regionModels
133 } // End namespace Foam
134 
135 // ************************************************************************* //
dictionary dict
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:493
virtual void info(Ostream &os) const
Provide some feedback.
scalar deltaTValue() const noexcept
Return time step value.
Definition: TimeStateI.H:49
scalar latestMassPC_
Latest mass transfer due to phase change.
Base class for surface film sub-models.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
scalar totalMassPC_
Total mass transfer due to phase change.
virtual bool writeTime() const
Flag to indicate when to write a property.
Base class for surface film phase change models.
virtual void correctModel(const scalar dt, scalarField &availableMass, scalarField &dMass, scalarField &dEnergy)=0
Correct.
A class for handling words, derived from Foam::string.
Definition: word.H:63
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
defineRunTimeSelectionTable(filmThermoModel, dictionary)
void correctBoundaryConditions()
Correct boundary field.
surfaceFilmRegionModel & filmModel_
Reference to the film surface film model.
virtual void correct(const scalar dt, scalarField &availableMass, volScalarField &dMass, volScalarField &dEnergy)
Correct.
virtual bool active() const
Return the model &#39;active&#39; status - default active = true.
Definition: subModelBase.C:149
defineTypeNameAndDebug(kinematicSingleLayer, 0)
const Time & time() const noexcept
Return the reference to the time database.
Definition: regionModel.H:244
Namespace for OpenFOAM.