mixedEnergyFvPatchScalarField.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2012 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "fvPatchFieldMapper.H"
32 #include "volFields.H"
33 #include "basicThermo.H"
34 
35 #include "fvMatrix.H"
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
41 (
42  const fvPatch& p,
44 )
45 :
46  mixedFvPatchScalarField(p, iF)
47 {
48  valueFraction() = 0.0;
49  refValue() = 0.0;
50  refGrad() = 0.0;
51  source() = 0.0;
52 }
53 
54 
57 (
59  const fvPatch& p,
61  const fvPatchFieldMapper& mapper
62 )
63 :
64  mixedFvPatchScalarField(ptf, p, iF, mapper)
65 {}
66 
67 
70 (
71  const fvPatch& p,
73  const dictionary& dict
74 )
75 :
76  mixedFvPatchScalarField(p, iF, dict)
77 {}
78 
79 
82 (
84 )
85 :
86  mixedFvPatchScalarField(tppsf)
87 {}
88 
89 
92 (
93  const mixedEnergyFvPatchScalarField& tppsf,
95 )
96 :
97  mixedFvPatchScalarField(tppsf, iF)
98 {}
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
104 {
105  if (updated())
106  {
107  return;
108  }
110  const label patchi = patch().index();
111 
112  const scalarField& pw = thermo.p().boundaryField()[patchi];
113  mixedFvPatchScalarField& Tw = refCast<mixedFvPatchScalarField>
114  (
115  const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi])
116  );
117 
118  Tw.evaluate();
119 
120  valueFraction() = Tw.valueFraction();
121  refValue() = thermo.he(pw, Tw.refValue(), patchi);
122  refGrad() =
123  thermo.Cpv(pw, Tw, patchi)*Tw.refGrad()
124  + patch().deltaCoeffs()*
125  (
126  thermo.he(pw, Tw, patchi)
127  - thermo.he(pw, Tw, patch().faceCells())
128  );
129 
130  mixedFvPatchScalarField::updateCoeffs();
131 }
132 
133 
135 (
136  fvMatrix<scalar>& matrix,
137  const label mat,
138  const direction cmpt
139 )
140 {
142 
143  label index = this->patch().index();
144 
145  const label nbrPatchId = this->patch().patch().neighbPolyPatchID();
146 
147  const label globalPatchID =
148  matrix.lduMeshAssembly().patchLocalToGlobalMap()[mat][index];
149 
150  const label meshNrbId = matrix.lduMeshAssembly().findNbrMeshId
151  (
152  this->patch().patch(),
153  mat
154  );
155 
156  const mixedFvPatchField<scalar>& fPatch =
157  refCast<const mixedFvPatchField>(thermo.T().boundaryField()[index]);
158 
159  const Field<scalar> intCoeffsCmpt
160  (
161  matrix.internalCoeffs()[globalPatchID].component(cmpt)
162  );
163 
164  const scalarField sourceCorr(fPatch.source());
165 
166  const labelList& faceMap =
167  matrix.lduMeshAssembly().faceBoundMap()[mat][index];
168 
169  const labelList& myCells =
170  matrix.lduMeshAssembly().cellBoundMap()[meshNrbId][nbrPatchId];
171 
172  const labelList& nbrCells =
173  matrix.lduMeshAssembly().cellBoundMap()[mat][index];
174 
175  forAll(faceMap, j)
176  {
177  label globalFaceI = faceMap[j];
178 
179  label myCellI = myCells[j];
180  label nbrCellI = nbrCells[j];
181 
182  const scalar intCorr = -intCoeffsCmpt[j];
183  const scalar srcCorr = -sourceCorr[j];
184 
185  if (this->patch().patch().masterImplicit())
186  {
187  if (myCellI > nbrCellI)
188  {
189  if (matrix.asymmetric())
190  {
191  matrix.lower()[globalFaceI] += intCorr;
192  }
193  }
194  else
195  {
196  matrix.upper()[globalFaceI] += intCorr;
197  }
198 
199  matrix.diag()[myCellI] -= intCorr;
200  matrix.source()[myCellI] += srcCorr;
201  }
202  else
203  {
204  if (myCellI < nbrCellI)
205  {
206  matrix.upper()[globalFaceI] += intCorr;
207  }
208  else
209  {
210  if (matrix.asymmetric())
211  {
212  matrix.lower()[globalFaceI] += intCorr;
213  }
214  }
215 
216  matrix.diag()[myCellI] -= intCorr;
217  matrix.source()[myCellI] += srcCorr;
218  }
219 
220 
221 // if (globalFaceI != -1)
222 // {
223 // const scalar intCorr = -intCoeffsCmpt[j];
224 // const scalar srcCorr = -sourceCorr[j];
225 //
226 // if (this->patch().patch().masterImplicit())
227 // {
228 // matrix.diag()[u[globalFaceI]] -= intCorr;
229 // if (matrix.asymmetric())
230 // {
231 // matrix.lower()[globalFaceI] += intCorr;
232 // }
233 // matrix.source()[u[globalFaceI]] += srcCorr;
234 // }
235 // else
236 // {
237 // matrix.diag()[l[globalFaceI]] -= intCorr;
238 // matrix.upper()[globalFaceI] += intCorr;
239 // matrix.source()[l[globalFaceI]] += srcCorr;
240 // }
241 // }
242  }
243 }
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 namespace Foam
248 {
250  (
253  );
254 }
255 
256 // ************************************************************************* //
Foam::fvPatchField< scalar >
volFields.H
Foam::fvMatrix::lduMeshAssembly
const lduPrimitiveMeshAssembly & lduMeshAssembly()
Return optional lduAdressing.
Definition: fvMatrix.H:392
p
volScalarField & p
Definition: createFieldRefs.H:8
basicThermo.H
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
Foam::lduPrimitiveMeshAssembly::patchLocalToGlobalMap
const labelListList & patchLocalToGlobalMap() const
Return patchLocalToGlobalMap.
Definition: lduPrimitiveMeshAssembly.H:172
Foam::mixedEnergyFvPatchScalarField::mixedEnergyFvPatchScalarField
mixedEnergyFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: mixedEnergyFvPatchScalarField.C:41
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::basicThermo
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:63
fvMatrix.H
fvPatchFieldMapper.H
Foam::basicThermo::lookupThermo
static const basicThermo & lookupThermo(const fvPatchScalarField &pf)
Definition: basicThermo.C:446
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Field< scalar >
Foam::mixedEnergyFvPatchScalarField::manipulateMatrix
virtual void manipulateMatrix(fvMatrix< scalar > &m, const label iMatrix, const direction cmpt)
Manipulate matrix.
Definition: mixedEnergyFvPatchScalarField.C:135
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::mixedEnergyFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: mixedEnergyFvPatchScalarField.C:103
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::mixedEnergyFvPatchScalarField
This boundary condition provides a mixed condition for internal energy.
Definition: mixedEnergyFvPatchScalarField.H:57
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::mixedFvPatchField< scalar >
mixedEnergyFvPatchScalarField.H
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
Foam::fvMatrix::source
Field< Type > & source()
Definition: fvMatrix.H:445
Foam::lduPrimitiveMeshAssembly::faceBoundMap
const labelListListList & faceBoundMap() const
Return boundary face map.
Definition: lduPrimitiveMeshAssembly.H:178
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::lduPrimitiveMeshAssembly::cellBoundMap
const labelListListList & cellBoundMap() const
Return patch local sub-face to nbrCellId map.
Definition: lduPrimitiveMeshAssembly.H:184
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::mixedFvPatchField::source
virtual Field< Type > & source()
Definition: mixedFvPatchField.H:260
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Foam::fvMatrix::internalCoeffs
const FieldField< Field, Type > & internalCoeffs() const
Definition: fvMatrix.H:457
Foam::lduPrimitiveMeshAssembly::findNbrMeshId
label findNbrMeshId(const polyPatch &pp, const label iMesh) const
Find nrb mesh Id for mapped patches.
Definition: lduPrimitiveMeshAssembly.C:137
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54