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 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 (
85 )
86 :
87  fixedValueFvPatchVectorField(ptf),
88  rhoName_(ptf.rhoName_)
89 {}
90 
91 
94 (
97 )
98 :
99  fixedValueFvPatchVectorField(ptf, iF),
100  rhoName_(ptf.rhoName_)
101 {}
102 
103 
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 
108 {
111 
112  // Sum up the phiYp-s from all the species
113  tmp<scalarField> tPhip(new scalarField(this->size(), 0));
114  scalarField& phip = tPhip.ref();
115  forAll(Y, i)
116  {
117  const fvPatchScalarField& Yp = Y[i].boundaryField()[patch().index()];
118 
119  if (!isA<YBCType>(Yp))
120  {
122  << "The mass-fraction condition on patch " << patch().name()
123  << " is not of type " << YBCType::typeName << "."
124  << exit(FatalError);
125  }
126 
127  phip += refCast<const YBCType>(Yp).phiYp();
128  }
129 
130  return tPhip;
131 }
132 
133 
135 {
136  if (updated())
137  {
138  return;
139  }
140 
141  // Get the density
142  const scalarField& rhop =
143  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
144 
145  // Set the normal component of the velocity to match the computed flux
146  const vectorField nf(patch().nf());
147  const tensorField Tau(tensor::I - sqr(nf));
148  this->operator==((Tau & *this) + nf*phip()/(rhop*patch().magSf()));
149 
150  fixedValueFvPatchVectorField::updateCoeffs();
151 }
152 
153 
155 (
156  Ostream& os
157 ) const
158 {
160  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
161  writeEntry(os, "value", *this);
162 }
163 
164 
165 // * * * * * * * * * * * * * * Build Macro Function * * * * * * * * * * * * //
166 
167 namespace Foam
168 {
170  (
173  );
174 }
175 
176 // ************************************************************************* //
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:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
basicSpecieMixture & composition
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
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:280
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:155
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.