mappedFlowRateFvPatchVectorField.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 | Copyright (C) 2011-2015 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 
27 #include "volFields.H"
29 #include "fvPatchFieldMapper.H"
30 #include "mappedPatchBase.H"
31 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
37  const fvPatch& p,
39 )
40 :
42  nbrPhiName_("none"),
43  phiName_("phi"),
44  rhoName_("rho")
45 {}
46 
47 
49 (
51  const fvPatch& p,
53  const fvPatchFieldMapper& mapper
54 )
55 :
56  fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
57  nbrPhiName_(ptf.nbrPhiName_),
58  phiName_(ptf.phiName_),
59  rhoName_(ptf.rhoName_)
60 {}
61 
62 
64 (
65  const fvPatch& p,
67  const dictionary& dict
68 )
69 :
71  nbrPhiName_(dict.lookupOrDefault<word>("nbrPhi", "phi")),
72  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
73  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
74 {}
75 
76 
78 (
80 )
81 :
83  nbrPhiName_(ptf.nbrPhiName_),
84  phiName_(ptf.phiName_),
85  rhoName_(ptf.rhoName_)
86 {}
87 
88 
90 (
93 )
94 :
96  nbrPhiName_(ptf.nbrPhiName_),
97  phiName_(ptf.phiName_),
98  rhoName_(ptf.rhoName_)
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
106  if (updated())
107  {
108  return;
109  }
110 
111  // Since we're inside initEvaluate/evaluate there might be processor
112  // comms underway. Change the tag we use.
113  int oldTag = UPstream::msgType();
114  UPstream::msgType() = oldTag+1;
115 
116  // Get the coupling information from the mappedPatchBase
117  const mappedPatchBase& mpp = refCast<const mappedPatchBase>
118  (
119  patch().patch()
120  );
121  const polyMesh& nbrMesh = mpp.sampleMesh();
122  const fvPatch& nbrPatch = refCast<const fvMesh>
123  (
124  nbrMesh
125  ).boundary()[mpp.samplePolyPatch().index()];
126 
127  scalarList phi =
129 
130  mpp.distribute(phi);
131 
132 
133  const surfaceScalarField& phiName =
134  db().lookupObject<surfaceScalarField>(phiName_);
135 
136  scalarField U(-phi/patch().magSf());
137 
138  vectorField n(patch().nf());
139 
140  if (phiName.dimensions() == dimVelocity*dimArea)
141  {
142  // volumetric flow-rate
143  operator==(n*U);
144  }
145  else if (phiName.dimensions() == dimDensity*dimVelocity*dimArea)
146  {
147  const fvPatchField<scalar>& rhop =
148  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
149 
150  // mass flow-rate
151  operator==(n*U/rhop);
152 
153  if (debug)
154  {
155  scalar phi = gSum(rhop*(*this) & patch().Sf());
156  Info<< patch().boundaryMesh().mesh().name() << ':'
157  << patch().name() << ':'
158  << this->dimensionedInternalField().name() << " <- "
159  << nbrMesh.name() << ':'
160  << nbrPatch.name() << ':'
161  << this->dimensionedInternalField().name() << " :"
162  << " mass flux[Kg/s]:" << -phi
163  << endl;
164  }
165  }
166  else
167  {
169  << "dimensions of " << phiName_ << " are incorrect" << nl
170  << " on patch " << this->patch().name()
171  << " of field " << this->dimensionedInternalField().name()
172  << " in file " << this->dimensionedInternalField().objectPath()
173  << nl << exit(FatalError);
174  }
175 
176  // Restore tag
177  UPstream::msgType() = oldTag;
178 
180 }
181 
182 
184 (
185  Ostream& os
186 ) const
187 {
189  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
190  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
191  os.writeKeyword("nbrPhi") << nbrPhiName_ << token::END_STATEMENT << nl;
192  writeEntry("value", os);
193 }
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 namespace Foam
199 {
201  (
204  );
205 }
206 
207 
208 // ************************************************************************* //
Foam::fvPatchField< scalar >
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
Foam::mappedFlowRateFvPatchVectorField::phiName_
word phiName_
Name of the local mass flux.
Definition: mappedFlowRateFvPatchVectorField.H:108
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::dimDensity
const dimensionSet dimDensity
Foam::mappedFlowRateFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: mappedFlowRateFvPatchVectorField.C:184
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
dimensionedInternalField
rDeltaT dimensionedInternalField()
Foam::mappedPatchBase::samplePolyPatch
const polyPatch & samplePolyPatch() const
Get the patch on the region.
Definition: mappedPatchBase.C:1246
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:564
Foam::mappedPatchBase
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
Definition: mappedPatchBase.H:101
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:79
U
U
Definition: pEqn.H:46
Foam::fvPatch::name
const word & name() const
Return name.
Definition: fvPatch.H:149
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::mappedPatchBase::sampleMesh
const polyMesh & sampleMesh() const
Get the region mesh.
Definition: mappedPatchBase.C:1237
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::mappedPatchBase::distribute
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
Definition: mappedPatchBaseTemplates.C:27
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobject.H:273
Foam::mappedFlowRateFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: mappedFlowRateFvPatchVectorField.C:104
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::mappedFlowRateFvPatchVectorField::rhoName_
word rhoName_
Name of the density field used to normalize the mass flux.
Definition: mappedFlowRateFvPatchVectorField.H:111
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::mappedFlowRateFvPatchVectorField::mappedFlowRateFvPatchVectorField
mappedFlowRateFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: mappedFlowRateFvPatchVectorField.C:36
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::fvPatchField< Type >::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:296
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::mappedFlowRateFvPatchVectorField::nbrPhiName_
word nbrPhiName_
Name of the neighbor flux setting the inlet mass flux.
Definition: mappedFlowRateFvPatchVectorField.H:105
Foam::UPstream::msgType
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:452
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::mappedFlowRateFvPatchVectorField
Describes a volumetric/mass flow normal vector boundary condition by its magnitude as an integral ove...
Definition: mappedFlowRateFvPatchVectorField.H:98
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
mappedFlowRateFvPatchVectorField.H
Foam::fvPatch::lookupPatchField
const GeometricField::PatchFieldType & lookupPatchField(const word &name, const GeometricField *=NULL, const Type *=NULL) const
Lookup and return the patchField of the named field from the.
Definition: fvPatchFvMeshTemplates.C:32
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
mappedPatchBase.H