PhiScheme.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 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 
26 #include "volFields.H"
27 #include "surfaceFields.H"
28 #include "fvcGrad.H"
29 #include "coupledFvPatchFields.H"
30 #include "surfaceInterpolate.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 template<class Type, class PhiLimiter>
37 (
39 ) const
40 {
41  const fvMesh& mesh = this->mesh();
42 
44  (
46  (
47  IOobject
48  (
49  "PhiLimiter",
50  mesh.time().timeName(),
51  mesh
52  ),
53  mesh,
54  dimless
55  )
56  );
57  surfaceScalarField& Limiter = tLimiter();
58 
59  const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
60 
61  const surfaceVectorField& Sf = mesh.Sf();
62  const surfaceScalarField& magSf = mesh.magSf();
63 
64  const labelUList& owner = mesh.owner();
65  const labelUList& neighbour = mesh.neighbour();
66 
67  tmp<surfaceScalarField> tUflux = this->faceFlux_;
68 
69  if (this->faceFlux_.dimensions() == dimDensity*dimVelocity*dimArea)
70  {
71  const volScalarField& rho =
72  phi.db().objectRegistry::template lookupObject<volScalarField>
73  ("rho");
74 
75  tUflux = this->faceFlux_/fvc::interpolate(rho);
76  }
77  else if (this->faceFlux_.dimensions() != dimVelocity*dimArea)
78  {
80  (
81  "PhiScheme<PhiLimiter>::limiter"
82  "(const GeometricField<Type, fvPatchField, volMesh>& phi)"
83  ) << "dimensions of faceFlux are not correct"
84  << exit(FatalError);
85  }
86 
87  const surfaceScalarField& Uflux = tUflux();
88 
89  scalarField& pLimiter = Limiter.internalField();
90 
91  forAll(pLimiter, face)
92  {
93  pLimiter[face] = PhiLimiter::limiter
94  (
95  CDweights[face],
96  Uflux[face],
97  phi[owner[face]],
98  phi[neighbour[face]],
99  Sf[face],
100  magSf[face]
101  );
102  }
103 
104 
105  surfaceScalarField::GeometricBoundaryField& bLimiter =
106  Limiter.boundaryField();
107 
108  forAll(bLimiter, patchI)
109  {
110  scalarField& pLimiter = bLimiter[patchI];
111 
112  if (bLimiter[patchI].coupled())
113  {
114  const scalarField& pCDweights = CDweights.boundaryField()[patchI];
115  const vectorField& pSf = Sf.boundaryField()[patchI];
116  const scalarField& pmagSf = magSf.boundaryField()[patchI];
117  const scalarField& pFaceFlux = Uflux.boundaryField()[patchI];
118 
119  const Field<Type> pphiP
120  (
121  phi.boundaryField()[patchI].patchInternalField()
122  );
123  const Field<Type> pphiN
124  (
125  phi.boundaryField()[patchI].patchNeighbourField()
126  );
127 
128  forAll(pLimiter, face)
129  {
130  pLimiter[face] = PhiLimiter::limiter
131  (
132  pCDweights[face],
133  pFaceFlux[face],
134  pphiP[face],
135  pphiN[face],
136  pSf[face],
137  pmagSf[face]
138  );
139  }
140  }
141  else
142  {
143  pLimiter = 1.0;
144  }
145  }
146 
147  return tLimiter;
148 }
149 
150 
151 // ************************************************************************* //
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::surfaceFields.
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
const surfaceVectorField & Sf() const
Return cell face area vectors.
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
virtual tmp< surfaceScalarField > limiter(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
Definition: PhiScheme.C:37
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:282
Surface Interpolation.
tmp< surfaceScalarField > interpolate(const RhoType &rho)
dynamicFvMesh & mesh
const dimensionSet dimDensity
Calculate the gradient of the given field.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define forAll(list, i)
Definition: UList.H:421
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
Generic GeometricField class.
error FatalError
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:288
void limiter(scalarField &allLambda, const RdeltaTType &rDeltaT, const RhoType &rho, const volScalarField &psi, const surfaceScalarField &phiBD, const surfaceScalarField &phiCorr, const SpType &Sp, const SuType &Su, const scalar psiMax, const scalar psiMin)
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:245
const dimensionSet dimVelocity
A class for managing temporary objects.
Definition: PtrList.H:118