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-2020 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 :
43  fixedValueFvPatchVectorField(p, iF),
44  rhoName_("rho")
45 {}
46 
47 
50 (
51  const fvPatch& p,
53  const dictionary& dict,
54  const bool readValue
55 )
56 :
57  fixedValueFvPatchVectorField(p, iF),
58  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
59 {
60  if (readValue)
61  {
62  fvPatchVectorField::operator==(vectorField("value", dict, p.size()));
63  }
64 }
65 
66 
69 (
71  const fvPatch& p,
73  const fvPatchFieldMapper& mapper
74 )
75 :
76  fixedValueFvPatchVectorField(ptf, p, iF, mapper),
77  rhoName_(ptf.rhoName_)
78 {}
79 
80 
83 (
86 )
87 :
88  fixedValueFvPatchVectorField(ptf, iF),
89  rhoName_(ptf.rhoName_)
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
97 {
100 
101  // Sum up the phiYp-s from all the species
102  tmp<scalarField> tPhip(new scalarField(this->size(), 0));
103  scalarField& phip = tPhip.ref();
104  forAll(Y, i)
105  {
106  const fvPatchScalarField& Yp = Y[i].boundaryField()[patch().index()];
107 
108  if (!isA<YBCType>(Yp))
109  {
111  << "The mass-fraction condition on patch " << patch().name()
112  << " is not of type " << YBCType::typeName << "."
113  << exit(FatalError);
114  }
115 
116  phip += refCast<const YBCType>(Yp).phiYp();
117  }
118 
119  return tPhip;
120 }
121 
122 
124 {
125  if (updated())
126  {
127  return;
128  }
129 
130  // Get the density
131  const scalarField& rhop =
132  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
133 
134  // Set the normal component of the velocity to match the computed flux
135  const vectorField nf(patch().nf());
136  const tensorField Tau(tensor::I - sqr(nf));
137  this->operator==((Tau & *this) + nf*phip()/(rhop*patch().magSf()));
138 
139  fixedValueFvPatchVectorField::updateCoeffs();
140 }
141 
142 
144 (
145  Ostream& os
146 ) const
147 {
149  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
150  writeEntry(os, "value", *this);
151 }
152 
153 
154 // * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
155 
156 namespace Foam
157 {
159  (
162  );
163 }
164 
165 // ************************************************************************* //
Foam::surfaceFields.
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
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:323
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:62
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
volVectorField vectorField(fieldObject, mesh)
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:260
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
Definition: word.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Foam::fvPatchFieldMapper.
virtual label size() const
Return size.
Definition: fvPatch.H:156
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
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
PtrList< volScalarField > & Y
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A class for managing temporary objects.
Definition: PtrList.H:53
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.
const tmp< scalarField > phip() const
Return the flux.
This is a velocity boundary condition for a specie-transferring wall.