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-------------------------------------------------------------------------------
11License
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
41Foam::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
66Foam::semiPermeableBaffleVelocityFvPatchVectorField::
67semiPermeableBaffleVelocityFvPatchVectorField
68(
69 const fvPatch& p,
71)
72:
73 fixedValueFvPatchVectorField(p, iF),
74 rhoName_("rho")
75{}
76
77
78Foam::semiPermeableBaffleVelocityFvPatchVectorField::
79semiPermeableBaffleVelocityFvPatchVectorField
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
93Foam::semiPermeableBaffleVelocityFvPatchVectorField::
94semiPermeableBaffleVelocityFvPatchVectorField
95(
97 const fvPatch& p,
99 const fvPatchFieldMapper& mapper
100)
101:
102 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
103 rhoName_(ptf.rhoName_)
104{}
105
106
107Foam::semiPermeableBaffleVelocityFvPatchVectorField::
108semiPermeableBaffleVelocityFvPatchVectorField
109(
111)
112:
113 fixedValueFvPatchVectorField(ptf),
114 rhoName_(ptf.rhoName_)
115{}
116
117
118Foam::semiPermeableBaffleVelocityFvPatchVectorField::
119semiPermeableBaffleVelocityFvPatchVectorField
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
140
141 const scalarField& rhop =
142 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
143
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
181namespace Foam
182{
184 (
187 );
188}
189
190// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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:251
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
PtrList< volScalarField > & Y()
Return the mass-fraction fields.
Specialization of basicMultiComponentMixture for a mixture consisting of a number for molecular speci...
static const word dictName
Definition: basicThermo.H:256
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual bool write()
Write the output fields.
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
friend bool operator==(const refineCell &rc1, const refineCell &rc2)
Definition: refineCell.H:97
This is a mass-fraction boundary condition for a semi-permeable baffle.
This is a velocity boundary condition for a semi-permeable baffle.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for handling words, derived from Foam::string.
Definition: word.H:68
basicSpecieMixture & composition
volScalarField & p
PtrList< volScalarField > & Y
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Definition: fvPatchField.H:676
Namespace for OpenFOAM.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
Foam::surfaceFields.