Loading...
Searching...
No Matches
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
60 }
61}
62
63
64// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
65
68(
69 const fvPatch& p,
70 const DimensionedField<vector, volMesh>& iF
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
101:
102 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
103 rhoName_(ptf.rhoName_)
104{}
105
106
109(
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 }
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_);
177
178
179// * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
180
181namespace Foam
182{
184 (
186 semiPermeableBaffleVelocityFvPatchVectorField
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...
@ MUST_READ
Reading required.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
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
The dictionary name ("thermophysicalProperties").
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A FieldMapper for finite-volume patch fields.
virtual void write(Ostream &) const
Write.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
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.
semiPermeableBaffleVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
A class for handling words, derived from Foam::string.
Definition word.H:66
basicSpecieMixture & composition
volScalarField & p
PtrList< volScalarField > & Y
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Define a concrete fvPatchField type and add to run-time tables Example, (fvPatchScalarField,...
auto & name
Namespace for OpenFOAM.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
const T & NullObjectRef() noexcept
Const reference (of type T) to the nullObject.
Definition nullObject.H:228
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
fvPatchField< vector > fvPatchVectorField
fvPatchField< scalar > fvPatchScalarField
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
Foam::surfaceFields.