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-2021 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 )
42 :
44  rhoName_("rho")
45 {}
46 
47 
50 (
51  const fvPatch& p,
53  const dictionary& dict
54 )
55 :
57  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
58 {}
59 
60 
63 (
65  const fvPatch& p,
67  const fvPatchFieldMapper& mapper
68 )
69 :
71  rhoName_(ptf.rhoName_)
72 {}
73 
74 
77 (
80 )
81 :
83  rhoName_(ptf.rhoName_)
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
91 {
94 
95  // Sum up the phiYp-s from all the species
96  tmp<scalarField> tPhip(new scalarField(this->size(), 0));
97  scalarField& phip = tPhip.ref();
98  forAll(Y, i)
99  {
100  const fvPatchScalarField& Yp = Y[i].boundaryField()[patch().index()];
101 
102  if (!isA<YBCType>(Yp))
103  {
105  << "The mass-fraction condition on patch " << patch().name()
106  << " is not of type " << YBCType::typeName << "."
107  << exit(FatalError);
108  }
109 
110  phip += refCast<const YBCType>(Yp).phiYp();
111  }
112 
113  return tPhip;
114 }
115 
116 
118 {
119  if (updated())
120  {
121  return;
122  }
123 
124  // Get the density
125  const scalarField& rhop =
126  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
127 
128  // Set the normal component of the velocity to match the computed flux
129  const vectorField nf(patch().nf());
130  const tensorField Tau(tensor::I - sqr(nf));
131  this->operator==((Tau & *this) + nf*phip()/(rhop*patch().magSf()));
132 
134 }
135 
136 
138 (
139  Ostream& os
140 ) const
141 {
143  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
144  writeEntry(os, "value", *this);
145 }
146 
147 
148 // * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
149 
150 namespace Foam
151 {
153  (
156  );
157 }
158 
159 // ************************************************************************* //
Foam::surfaceFields.
dictionary dict
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:175
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
bool updated() const
Return true if the boundary condition has already been updated.
Definition: fvPatchField.H:369
basicSpecieMixture & composition
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:243
Macros for easy insertion into run-time selection tables.
virtual void operator==(const fvPatchField< Type > &)
Definition: fvPatchField.C:424
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:58
A class for handling words, derived from string.
Definition: word.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Foam::fvPatchFieldMapper.
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:351
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
specieTransferVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
static const Tensor I
Definition: Tensor.H:83
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
const GeometricField::Patch & lookupPatchField(const word &name) const
Lookup and return the patchField of the named field from the.
Abstract base class for specie-transferring mass fraction boundary conditions.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:216
PtrList< volScalarField > & Y
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const objectRegistry & db() const
Return local objectRegistry.
Definition: fvPatchField.C:147
virtual const word & name() const
Return name.
Definition: fvPatch.H:145
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
label size() const
Return the number of elements in the UList.
Definition: ListI.H:171
Namespace for OpenFOAM.
const tmp< scalarField > phip() const
Return the flux.
This is a velocity boundary condition for a specie-transferring wall.