limitedSurfaceInterpolationScheme.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-2017 OpenFOAM Foundation
9  Copyright (C) 2019-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 
30 #include "volFields.H"
31 #include "surfaceFields.H"
32 #include "coupledFvPatchField.H"
33 
34 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
35 
36 template<class Type>
39 (
40  const fvMesh& mesh,
41  Istream& schemeData
42 )
43 {
45  {
47  << "Constructing limitedSurfaceInterpolationScheme<Type>" << endl;
48  }
49 
50  if (schemeData.eof())
51  {
52  FatalIOErrorInFunction(schemeData)
53  << "Discretisation scheme not specified"
54  << endl << endl
55  << "Valid schemes are :" << endl
56  << MeshConstructorTablePtr_->sortedToc()
57  << exit(FatalIOError);
58  }
59 
60  const word schemeName(schemeData);
61 
62  auto* ctorPtr = MeshConstructorTable(schemeName);
63 
64  if (!ctorPtr)
65  {
67  (
68  schemeData,
69  "discretisation",
70  schemeName,
71  *MeshConstructorTablePtr_
72  ) << exit(FatalIOError);
73  }
74 
75  return ctorPtr(mesh, schemeData);
76 }
77 
78 
79 template<class Type>
82 (
83  const fvMesh& mesh,
84  const surfaceScalarField& faceFlux,
85  Istream& schemeData
86 )
87 {
89  {
91  << "Constructing limitedSurfaceInterpolationScheme<Type>"
92  << endl;
93  }
94 
95  if (schemeData.eof())
96  {
97  FatalIOErrorInFunction(schemeData)
98  << "Discretisation scheme not specified"
99  << endl << endl
100  << "Valid schemes are :" << endl
101  << MeshConstructorTablePtr_->sortedToc()
102  << exit(FatalIOError);
103  }
104 
105  const word schemeName(schemeData);
106 
107  auto* ctorPtr = MeshFluxConstructorTable(schemeName);
108 
109  if (!ctorPtr)
110  {
112  (
113  schemeData,
114  "discretisation",
115  schemeName,
116  *MeshFluxConstructorTablePtr_
117  ) << exit(FatalIOError);
118  }
119 
120  return ctorPtr(mesh, faceFlux, schemeData);
121 }
122 
123 
124 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
125 
126 template<class Type>
129 {}
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
134 template<class Type>
137 (
139  const surfaceScalarField& CDweights,
140  tmp<surfaceScalarField> tLimiter
141 ) const
142 {
143  // Note that here the weights field is initialised as the limiter
144  // from which the weight is calculated using the limiter value
145  surfaceScalarField& Weights = tLimiter.ref();
146 
147  scalarField& pWeights = Weights.primitiveFieldRef();
148 
149  forAll(pWeights, face)
150  {
151  pWeights[face] =
152  pWeights[face]*CDweights[face]
153  + (1.0 - pWeights[face])*pos0(faceFlux_[face]);
154  }
155 
156  surfaceScalarField::Boundary& bWeights =
157  Weights.boundaryFieldRef();
158 
159  forAll(bWeights, patchi)
160  {
161  scalarField& pWeights = bWeights[patchi];
162 
163  const scalarField& pCDweights = CDweights.boundaryField()[patchi];
164  const scalarField& pFaceFlux = faceFlux_.boundaryField()[patchi];
165 
166  forAll(pWeights, face)
167  {
168  pWeights[face] =
169  pWeights[face]*pCDweights[face]
170  + (1.0 - pWeights[face])*pos0(pFaceFlux[face]);
171  }
172  }
173 
174  return tLimiter;
175 }
176 
177 template<class Type>
180 (
182 ) const
183 {
184  return this->weights
185  (
186  phi,
187  this->mesh().surfaceInterpolation::weights(),
188  this->limiter(phi)
189  );
190 }
191 
192 template<class Type>
195 (
197 ) const
198 {
199  return faceFlux_*this->interpolate(phi);
200 }
201 
202 
203 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
volFields.H
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:350
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::limitedSurfaceInterpolationScheme::New
static tmp< limitedSurfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
Definition: limitedSurfaceInterpolationScheme.C:39
Foam::limitedSurfaceInterpolationScheme::~limitedSurfaceInterpolationScheme
virtual ~limitedSurfaceInterpolationScheme()
Destructor.
Definition: limitedSurfaceInterpolationScheme.C:128
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
surfaceFields.H
Foam::surfaceFields.
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:188
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Foam::Field< scalar >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::IOstream::eof
bool eof() const noexcept
True if end of input seen.
Definition: IOstream.H:239
Foam::limitedSurfaceInterpolationScheme::flux
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
Definition: limitedSurfaceInterpolationScheme.C:195
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::limitedSurfaceInterpolationScheme::weights
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &, const surfaceScalarField &CDweights, tmp< surfaceScalarField > tLimiter) const
Return the interpolation weighting factors for the given field,.
Definition: limitedSurfaceInterpolationScheme.C:137
limitedSurfaceInterpolationScheme.H
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
coupledFvPatchField.H
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::limiter
tmp< areaScalarField > limiter(const areaScalarField &phi)
Definition: faNVDscheme.C:37
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62