LimitedScheme.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-2013 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 
31 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
32 
33 template<class Type, class Limiter, template<class> class LimitFunc>
35 (
37  surfaceScalarField& limiterField
38 ) const
39 {
40  const fvMesh& mesh = this->mesh();
41 
43  tlPhi = LimitFunc<Type>()(phi);
44 
46  lPhi = tlPhi();
47 
49  tgradc(fvc::grad(lPhi));
51  gradc = tgradc();
52 
53  const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
54 
55  const labelUList& owner = mesh.owner();
56  const labelUList& neighbour = mesh.neighbour();
57 
58  const vectorField& C = mesh.C();
59 
60  scalarField& pLim = limiterField.internalField();
61 
62  forAll(pLim, face)
63  {
64  label own = owner[face];
65  label nei = neighbour[face];
66 
67  pLim[face] = Limiter::limiter
68  (
69  CDweights[face],
70  this->faceFlux_[face],
71  lPhi[own],
72  lPhi[nei],
73  gradc[own],
74  gradc[nei],
75  C[nei] - C[own]
76  );
77  }
78 
80  limiterField.boundaryField();
81 
82  forAll(bLim, patchi)
83  {
84  scalarField& pLim = bLim[patchi];
85 
86  if (bLim[patchi].coupled())
87  {
88  const scalarField& pCDweights = CDweights.boundaryField()[patchi];
89  const scalarField& pFaceFlux =
90  this->faceFlux_.boundaryField()[patchi];
91 
93  (
94  lPhi.boundaryField()[patchi].patchInternalField()
95  );
97  (
98  lPhi.boundaryField()[patchi].patchNeighbourField()
99  );
101  (
102  gradc.boundaryField()[patchi].patchInternalField()
103  );
105  (
106  gradc.boundaryField()[patchi].patchNeighbourField()
107  );
108 
109  // Build the d-vectors
110  vectorField pd(CDweights.boundaryField()[patchi].patch().delta());
111 
112  forAll(pLim, face)
113  {
114  pLim[face] = Limiter::limiter
115  (
116  pCDweights[face],
117  pFaceFlux[face],
118  plPhiP[face],
119  plPhiN[face],
120  pGradcP[face],
121  pGradcN[face],
122  pd[face]
123  );
124  }
125  }
126  else
127  {
128  pLim = 1.0;
129  }
130  }
131 }
132 
133 
134 // * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * //
135 
136 template<class Type, class Limiter, template<class> class LimitFunc>
139 (
141 ) const
142 {
143  const fvMesh& mesh = this->mesh();
144 
145  const word limiterFieldName(type() + "Limiter(" + phi.name() + ')');
146 
147  if (this->mesh().cache("limiter"))
148  {
149  if (!mesh.foundObject<surfaceScalarField>(limiterFieldName))
150  {
151  surfaceScalarField* limiterField
152  (
154  (
155  IOobject
156  (
157  limiterFieldName,
158  mesh.time().timeName(),
159  mesh,
160  IOobject::NO_READ,
161  IOobject::NO_WRITE
162  ),
163  mesh,
164  dimless
165  )
166  );
167 
168  mesh.objectRegistry::store(limiterField);
169  }
170 
171  surfaceScalarField& limiterField =
172  const_cast<surfaceScalarField&>
173  (
174  mesh.lookupObject<surfaceScalarField>
175  (
176  limiterFieldName
177  )
178  );
179 
180  calcLimiter(phi, limiterField);
181 
182  return limiterField;
183  }
184  else
185  {
186  tmp<surfaceScalarField> tlimiterField
187  (
189  (
190  IOobject
191  (
192  limiterFieldName,
193  mesh.time().timeName(),
194  mesh
195  ),
196  mesh,
197  dimless
198  )
199  );
200 
201  calcLimiter(phi, tlimiterField());
202 
203  return tlimiterField;
204  }
205 }
206 
207 
208 // ************************************************************************* //
volFields.H
Foam::LimitedScheme::calcLimiter
void calcLimiter(const GeometricField< Type, fvPatchField, volMesh > &phi, surfaceScalarField &limiterField) const
Calculate the limiter.
Definition: LimitedScheme.C:35
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::MULES::limiter
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)
Definition: MULESTemplates.C:159
Foam::LimitedScheme::limiter
virtual tmp< surfaceScalarField > limiter(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
Definition: LimitedScheme.C:139
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
surfaceFields.H
Foam::surfaceFields.
coupledFvPatchFields.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvcGrad.H
Calculate the gradient of the given field.
Foam::UList
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
patchi
label patchi
Definition: getPatchFieldScalar.H:1
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Foam::C
Graphite solid properties.
Definition: C.H:57
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::GeometricField::GeometricBoundaryField
Definition: GeometricField.H:105