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 {
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, scalar>(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_);
175  writeEntry("value", os);
176 }
177 
178 
179 // * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
180 
181 namespace Foam
182 {
184  (
186  semiPermeableBaffleVelocityFvPatchVectorField
187  );
188 }
189 
190 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:47
Foam::fvPatchScalarField
fvPatchField< scalar > fvPatchScalarField
Definition: fvPatchFieldsFwd.H:33
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Definition: fvPatchField.C:377
Foam::fvPatchField::operator==
virtual void operator==(const fvPatchField< Type > &)
Foam::Ostream::writeEntryIfDifferent
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Definition: Ostream.H:244
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:46
Foam::basicMultiComponentMixture::Y
PtrList< volScalarField > & Y()
Definition: basicMultiComponentMixtureI.H:62
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::semiPermeableBaffleMassFractionFvPatchScalarField
This is a mass-fraction boundary condition for a semi-permeable baffle.
Definition: semiPermeableBaffleMassFractionFvPatchScalarField.H:123
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::basicSpecieMixture
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
Definition: basicSpecieMixture.H:54
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::basicThermo::dictName
static const word dictName
Definition: basicThermo.H:252
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
composition
basicSpecieMixture & composition
Definition: createFieldRefs.H:6
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:48
Foam::semiPermeableBaffleVelocityFvPatchVectorField
This is a velocity boundary condition for a semi-permeable baffle.
Definition: semiPermeableBaffleVelocityFvPatchVectorField.H:79
Foam::semiPermeableBaffleVelocityFvPatchVectorField::semiPermeableBaffleVelocityFvPatchVectorField
semiPermeableBaffleVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Definition: semiPermeableBaffleVelocityFvPatchVectorField.C:61
rhoReactionThermo.H
Foam::Field
Generic templated field type.
Definition: Field.H:59
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
semiPermeableBaffleVelocityFvPatchVectorField.H
semiPermeableBaffleMassFractionFvPatchScalarField.H
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:55
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:53
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Definition: atmBoundaryLayer.C:26
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
Foam::fvPatchVectorField
fvPatchField< vector > fvPatchVectorField
Definition: fvPatchFieldsFwd.H:36
FatalErrorInFunction
#define FatalErrorInFunction
Definition: error.H:465
Foam::semiPermeableBaffleVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Definition: semiPermeableBaffleVelocityFvPatchVectorField.C:162
psiReactionThermo.H
Foam::foamVersion::patch
const std::string patch
Foam::semiPermeableBaffleVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Definition: semiPermeableBaffleVelocityFvPatchVectorField.C:125
Foam::name
word name(const expressions::valueTypeCode typeCode)
Definition: exprTraits.C:52
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:41
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:141
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50