specieTransferVelocityFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2019-2023 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 
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 #include "basicSpecieMixture.H"
32 #include "basicThermo.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
38 (
39  const fvPatch& p,
41  const dictionary& dict
42 )
43 :
45  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
46 {}
47 
48 
51 (
53  const fvPatch& p,
55  const fvPatchFieldMapper& mapper
56 )
57 :
58  fixedValueInletOutletFvPatchField<vector>(ptf, p, iF, mapper),
59  rhoName_(ptf.rhoName_)
60 {}
61 
62 
65 (
68 )
69 :
71  rhoName_(ptf.rhoName_)
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
79 {
82 
83  // Sum up the phiYp-s from all the species
84  tmp<scalarField> tPhip(new scalarField(this->size(), 0));
85  scalarField& phip = tPhip.ref();
86  forAll(Y, i)
87  {
88  const fvPatchScalarField& Yp = Y[i].boundaryField()[patch().index()];
89 
90  if (!isA<YBCType>(Yp))
91  {
93  << "The mass-fraction condition on patch " << patch().name()
94  << " is not of type " << YBCType::typeName << "."
95  << exit(FatalError);
96  }
97 
98  phip += refCast<const YBCType>(Yp).phiYp();
99  }
100 
101  return tPhip;
102 }
103 
104 
106 {
107  if (updated())
108  {
109  return;
110  }
111 
112  // Get the density
113  const scalarField& rhop =
114  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
115 
116  // Set the normal component of the velocity to match the computed flux
117  const vectorField nf(patch().nf());
118  const tensorField Tau(tensor::I - sqr(nf));
119  this->operator==((Tau & *this) + nf*phip()/(rhop*patch().magSf()));
120 
122 }
123 
124 
126 (
127  Ostream& os
128 ) const
129 {
131  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
132  writeEntry(os, "value", *this);
133 }
134 
135 
136 // * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
137 
138 namespace Foam
139 {
141  (
144  );
145 }
146 
147 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:57
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
static const Tensor I
Definition: Tensor.H:83
PtrList< volScalarField > & Y()
Return the mass-fraction fields.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
This boundary condition sets a fixed value. When the flow direction is inwards this acts exactly like...
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:231
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:204
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Abstract base class for specie-transferring mass fraction boundary conditions.
This is a velocity boundary condition for a specie-transferring wall.
const tmp< scalarField > phip() const
Return the flux.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
specieTransferVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:61
error FatalError
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
dictionary dict
basicSpecieMixture & composition
volScalarField & p
PtrList< volScalarField > & Y
Foam::surfaceFields.