phaseHydrostaticPressureFvPatchScalarField.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 | Copyright (C) 2011-2012 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  phaseName_("alpha"),
44  rho_(0.0),
45  pRefValue_(0.0),
46  pRefPoint_(vector::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  phaseName_(dict.lookupOrDefault<word>("phaseName", "alpha")),
64  rho_(readScalar(dict.lookup("rho"))),
65  pRefValue_(readScalar(dict.lookup("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  phaseName_(ptf.phaseName_),
98  rho_(ptf.rho_),
99  pRefValue_(ptf.pRefValue_),
100  pRefPoint_(ptf.pRefPoint_)
101 {}
102 
103 
106 (
108 )
109 :
110  mixedFvPatchScalarField(ptf),
111  phaseName_(ptf.phaseName_)
112 {}
113 
114 
117 (
120 )
121 :
122  mixedFvPatchScalarField(ptf, iF),
123  phaseName_(ptf.phaseName_),
124  rho_(ptf.rho_),
125  pRefValue_(ptf.pRefValue_),
126  pRefPoint_(ptf.pRefPoint_)
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
133 {
134  if (this->updated())
135  {
136  return;
137  }
138 
139  const scalarField& alphap =
140  patch().lookupPatchField<volScalarField, scalar>
141  (
142  phaseName_
143  );
144 
146  db().lookupObject<uniformDimensionedVectorField>("g");
147 
148  // scalar rhor = 1000;
149  // scalarField alphap1 = max(min(alphap, 1.0), 0.0);
150  // valueFraction() = alphap1/(alphap1 + rhor*(1.0 - alphap1));
151  valueFraction() = max(min(alphap, scalar(1.0)), scalar(0.0));
152 
153  refValue() =
154  pRefValue_
155  + rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_));
156 
157  mixedFvPatchScalarField::updateCoeffs();
158 }
159 
160 
162 {
164  if (phaseName_ != "alpha")
165  {
166  os.writeKeyword("phaseName")
167  << phaseName_ << token::END_STATEMENT << nl;
168  }
169  os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl;
170  os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl;
171  os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl;
172  writeEntry("value", os);
173 }
174 
175 
176 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
177 
178 void Foam::phaseHydrostaticPressureFvPatchScalarField::operator=
179 (
180  const fvPatchScalarField& ptf
181 )
182 {
184  (
185  valueFraction()*refValue()
186  + (1 - valueFraction())*ptf
187  );
188 }
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 namespace Foam
194 {
196  (
199  );
200 }
201 
202 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchField::operator
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
g
const dimensionedVector & g
Definition: setRegionFluidFields.H:33
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::phaseHydrostaticPressureFvPatchScalarField::pRefPoint_
vector pRefPoint_
Reference pressure location.
Definition: phaseHydrostaticPressureFvPatchScalarField.H:159
Foam::UniformDimensionedField< vector >
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::phaseHydrostaticPressureFvPatchScalarField
This boundary condition provides a phase-based hydrostatic pressure condition, calculated as:
Definition: phaseHydrostaticPressureFvPatchScalarField.H:140
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::phaseHydrostaticPressureFvPatchScalarField::phaseHydrostaticPressureFvPatchScalarField
phaseHydrostaticPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: phaseHydrostaticPressureFvPatchScalarField.C:37
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::phaseHydrostaticPressureFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: phaseHydrostaticPressureFvPatchScalarField.C:132
readScalar
#define readScalar
Definition: doubleScalar.C:38
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
uniformDimensionedFields.H
phaseHydrostaticPressureFvPatchScalarField.H
scalarField
volScalarField scalarField(fieldObject, mesh)
Foam::phaseHydrostaticPressureFvPatchScalarField::rho_
scalar rho_
Constant density in the far-field.
Definition: phaseHydrostaticPressureFvPatchScalarField.H:153
Foam::phaseHydrostaticPressureFvPatchScalarField::pRefValue_
scalar pRefValue_
Reference pressure.
Definition: phaseHydrostaticPressureFvPatchScalarField.H:156
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::phaseHydrostaticPressureFvPatchScalarField::phaseName_
word phaseName_
Name of phase-fraction field.
Definition: phaseHydrostaticPressureFvPatchScalarField.H:150
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::phaseHydrostaticPressureFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: phaseHydrostaticPressureFvPatchScalarField.C:161
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51