semiPermeableBaffleVelocityFvPatchVectorField.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) 2017 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
32 #include "fvPatchFieldMapper.H"
33 #include "volFields.H"
34 #include "surfaceFields.H"
35 #include "psiReactionThermo.H"
36 #include "rhoReactionThermo.H"
37 
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 
41 Foam::semiPermeableBaffleVelocityFvPatchVectorField::composition() const
42 {
43  const word& name = basicThermo::dictName;
44 
45  if (db().foundObject<psiReactionThermo>(name))
46  {
47  return db().lookupObject<psiReactionThermo>(name).composition();
48  }
49  else if (db().foundObject<rhoReactionThermo>(name))
50  {
51  return db().lookupObject<rhoReactionThermo>(name).composition();
52  }
53  else
54  {
56  << "Could not find a multi-component thermodynamic model."
57  << exit(FatalError);
58 
59  return NullObjectRef<basicSpecieMixture>();
60  }
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
65 
68 (
69  const fvPatch& p,
71 )
72 :
73  fixedValueFvPatchVectorField(p, iF),
74  rhoName_("rho")
75 {}
76 
77 
80 (
81  const fvPatch& p,
83  const dictionary& dict
84 )
85 :
86  fixedValueFvPatchVectorField(p, iF),
87  rhoName_(dict.getOrDefault<word>("rho", "rho"))
88 {
89  this->readValueEntry(dict, IOobjectOption::MUST_READ);
90 }
91 
92 
95 (
97  const fvPatch& p,
99  const fvPatchFieldMapper& mapper
100 )
101 :
102  fixedValueFvPatchVectorField(ptf, p, iF, mapper),
103  rhoName_(ptf.rhoName_)
104 {}
105 
106 
109 (
111 )
112 :
113  fixedValueFvPatchVectorField(ptf),
114  rhoName_(ptf.rhoName_)
115 {}
116 
117 
120 (
123 )
124 :
125  fixedValueFvPatchVectorField(ptf, iF),
126  rhoName_(ptf.rhoName_)
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
133 {
134  if (updated())
135  {
136  return;
137  }
138 
139  typedef semiPermeableBaffleMassFractionFvPatchScalarField YBCType;
140 
141  const scalarField& rhop =
142  patch().lookupPatchField<volScalarField>(rhoName_);
143 
144  const PtrList<volScalarField>& Y = composition().Y();
145 
146  scalarField phip(patch().size(), Zero);
147  forAll(Y, i)
148  {
149  const fvPatchScalarField& Yp = Y[i].boundaryField()[patch().index()];
150 
151  if (!isA<YBCType>(Yp))
152  {
154  << "The mass-fraction condition on patch " << patch().name()
155  << " is not of type " << YBCType::typeName << "."
156  << exit(FatalError);
157  }
158 
159  phip += refCast<const YBCType>(Yp).phiY();
160  }
161 
162  this->operator==(patch().nf()*phip/(rhop*patch().magSf()));
163 
164  fixedValueFvPatchVectorField::updateCoeffs();
165 }
166 
167 
169 (
170  Ostream& os
171 ) const
172 {
174  os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
176 }
177 
178 
179 // * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
180 
181 namespace Foam
182 {
184  (
186  semiPermeableBaffleVelocityFvPatchVectorField
187  );
188 }
189 
190 // ************************************************************************* //
Foam::surfaceFields.
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionaryI.H:53
dictionary dict
fvPatchField< vector > fvPatchVectorField
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
basicSpecieMixture & composition
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
Definition: fvPatchField.H:375
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:372
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
PtrList< volScalarField > & Y()
Return the mass-fraction fields.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
Definition: word.H:63
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A FieldMapper for finite-volume patch fields.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:336
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
semiPermeableBaffleVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
This is a velocity boundary condition for a semi-permeable baffle.
PtrList< volScalarField > & Y
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const std::string patch
OpenFOAM patch number as a std::string.
volScalarField & p
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127