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-------------------------------------------------------------------------------
11License
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
39Foam::mixedEnergyFvPatchScalarField::
40mixedEnergyFvPatchScalarField
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
55Foam::mixedEnergyFvPatchScalarField::
56mixedEnergyFvPatchScalarField
57(
59 const fvPatch& p,
61 const fvPatchFieldMapper& mapper
62)
63:
64 mixedFvPatchScalarField(ptf, p, iF, mapper)
65{}
66
67
68Foam::mixedEnergyFvPatchScalarField::
69mixedEnergyFvPatchScalarField
70(
71 const fvPatch& p,
73 const dictionary& dict
74)
75:
76 mixedFvPatchScalarField(p, iF, dict)
77{}
78
79
80Foam::mixedEnergyFvPatchScalarField::
81mixedEnergyFvPatchScalarField
82(
84)
85:
86 mixedFvPatchScalarField(tppsf)
87{}
88
89
90Foam::mixedEnergyFvPatchScalarField::
91mixedEnergyFvPatchScalarField
92(
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
247namespace Foam
248{
250 (
253 );
254}
255
256// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:66
static const basicThermo & lookupThermo(const fvPatchScalarField &pf)
Definition: basicThermo.C:454
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
const FieldField< Field, Type > & internalCoeffs() const noexcept
Definition: fvMatrix.H:470
const lduPrimitiveMeshAssembly & lduMeshAssembly()
Return optional lduAdressing.
Definition: fvMatrix.H:405
Field< Type > & source() noexcept
Definition: fvMatrix.H:458
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
scalarField & upper()
Definition: lduMatrix.C:203
scalarField & lower()
Definition: lduMatrix.C:174
scalarField & diag()
Definition: lduMatrix.C:192
bool asymmetric() const
Definition: lduMatrix.H:633
const labelListListList & cellBoundMap() const
Return patch local sub-face to nbrCellId map.
const labelListListList & faceBoundMap() const
Return boundary face map.
label findNbrMeshId(const polyPatch &pp, const label iMesh) const
Find nrb mesh Id for mapped patches.
const labelListList & patchLocalToGlobalMap() const
Return patchLocalToGlobalMap.
This boundary condition provides a mixed condition for internal energy.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void manipulateMatrix(fvMatrix< scalar > &m, const label iMatrix, const direction cmpt)
Manipulate matrix.
This boundary condition provides a base class for 'mixed' type boundary conditions,...
virtual Field< Type > & source()
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
volScalarField & p
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Definition: fvPatchField.H:676
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
uint8_t direction
Definition: direction.H:56
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333