phaseHydrostaticPressureFvPatchScalarField.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-2020 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 "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
37 (
38  const fvPatch& p,
40 )
41 :
42  mixedFvPatchScalarField(p, iF),
43  phaseFraction_("alpha"),
44  rho_(0.0),
45  pRefValue_(0.0),
46  pRefPoint_(Zero)
47 {
48  this->refValue() = 0.0;
49  this->refGrad() = 0.0;
50  this->valueFraction() = 0.0;
51 }
52 
53 
56 (
57  const fvPatch& p,
59  const dictionary& dict
60 )
61 :
62  mixedFvPatchScalarField(p, iF),
63  phaseFraction_(dict.lookupOrDefault<word>("phaseFraction", "alpha")),
64  rho_(dict.lookup<scalar>("rho")),
65  pRefValue_(dict.lookup<scalar>("pRefValue")),
66  pRefPoint_(dict.lookup("pRefPoint"))
67 {
68  this->refValue() = pRefValue_;
69 
70  if (dict.found("value"))
71  {
72  fvPatchScalarField::operator=
73  (
74  scalarField("value", dict, p.size())
75  );
76  }
77  else
78  {
79  fvPatchScalarField::operator=(this->refValue());
80  }
81 
82  this->refGrad() = 0.0;
83  this->valueFraction() = 0.0;
84 }
85 
86 
89 (
91  const fvPatch& p,
93  const fvPatchFieldMapper& mapper
94 )
95 :
96  mixedFvPatchScalarField(ptf, p, iF, mapper),
97  phaseFraction_(ptf.phaseFraction_),
98  rho_(ptf.rho_),
99  pRefValue_(ptf.pRefValue_),
100  pRefPoint_(ptf.pRefPoint_)
101 {}
102 
103 
106 (
109 )
110 :
111  mixedFvPatchScalarField(ptf, iF),
112  phaseFraction_(ptf.phaseFraction_),
113  rho_(ptf.rho_),
114  pRefValue_(ptf.pRefValue_),
115  pRefPoint_(ptf.pRefPoint_)
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 
122 {
123  if (this->updated())
124  {
125  return;
126  }
127 
128  const scalarField& alphap =
129  patch().lookupPatchField<volScalarField, scalar>
130  (
132  );
133 
135  db().lookupObject<uniformDimensionedVectorField>("g");
136 
137  // scalar rhor = 1000;
138  // scalarField alphap1 = max(min(alphap, 1.0), 0.0);
139  // valueFraction() = alphap1/(alphap1 + rhor*(1.0 - alphap1));
140  valueFraction() = max(min(alphap, scalar(1)), scalar(0));
141 
142  refValue() =
143  pRefValue_
144  + rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_));
145 
146  mixedFvPatchScalarField::updateCoeffs();
147 }
148 
149 
151 {
153  if (phaseFraction_ != "alpha")
154  {
155  writeEntry(os, "phaseFraction", phaseFraction_);
156  }
157  writeEntry(os, "rho", rho_);
158  writeEntry(os, "pRefValue", pRefValue_);
159  writeEntry(os, "pRefPoint", pRefPoint_);
160  writeEntry(os, "value", *this);
161 }
162 
163 
164 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
165 
166 void Foam::phaseHydrostaticPressureFvPatchScalarField::operator=
167 (
168  const fvPatchScalarField& ptf
169 )
170 {
172  (
173  valueFraction()*refValue() + (1 - valueFraction())*ptf
174  );
175 }
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 namespace Foam
181 {
183  (
186  );
187 }
188 
189 // ************************************************************************* //
Foam::surfaceFields.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:643
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:260
Macros for easy insertion into run-time selection tables.
This boundary condition provides a phase-based hydrostatic pressure condition, calculated as: ...
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
phaseHydrostaticPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
static const zero Zero
Definition: zero.H:97
virtual label size() const
Return size.
Definition: fvPatch.H:156
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
volScalarField scalarField(fieldObject, mesh)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionedVector & g
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844