skewCorrected.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 Class
25  Foam::skewCorrected
26 
27 Description
28  Skewness-corrected interpolation scheme that applies an explicit
29  correction to given scheme.
30 
31 SourceFiles
32  skewCorrected.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef skewCorrected_H
37 #define skewCorrected_H
38 
40 #include "skewCorrectionVectors.H"
41 #include "linear.H"
42 #include "gaussGrad.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class skewCorrected Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Type>
54 class skewCorrected
55 :
56  public surfaceInterpolationScheme<Type>
57 {
58  // Private member data
59 
61 
62 
63 public:
64 
65  //- Runtime type information
66  TypeName("skewCorrected");
67 
68 
69  // Constructors
70 
71  //- Construct from mesh and Istream
73  (
74  const fvMesh& mesh,
75  Istream& is
76  )
77  :
78  surfaceInterpolationScheme<Type>(mesh),
79  tScheme_
80  (
81  surfaceInterpolationScheme<Type>::New(mesh, is)
82  )
83  {}
84 
85 
86  //- Construct from mesh, faceFlux and Istream
88  (
89  const fvMesh& mesh,
90  const surfaceScalarField& faceFlux,
91  Istream& is
92  )
93  :
94  surfaceInterpolationScheme<Type>(mesh),
95  tScheme_
96  (
97  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
98  )
99  {}
100 
101  //- Disallow default bitwise copy construction
102  skewCorrected(const skewCorrected&) = delete;
103 
104 
105  // Member Functions
106 
107  //- Return the interpolation weighting factors
109  (
111  ) const
112  {
113  return tScheme_().weights(vf);
114  }
115 
116  //- Return true if this scheme uses an explicit correction
117  virtual bool corrected() const
118  {
119  return
120  tScheme_().corrected()
121  || skewCorrectionVectors::New(this->mesh()).skew();
122  }
123 
126  (
128  ) const
129  {
130  const fvMesh& mesh = this->mesh();
131 
133 
135  (
137  (
138  "skewCorrected::skewCorrection(" + vf.name() + ')',
139  mesh,
141  (
142  vf.name(),
143  vf.dimensions(),
144  Zero
145  )
146  )
147  );
148 
149  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
150  {
151  tsfCorr.ref().replace
152  (
153  cmpt,
154  scv() & linear
155  <
156  typename outerProduct
157  <
158  vector,
159  typename pTraits<Type>::cmptType
160  >::type
161  > (mesh).interpolate
162  (
164  (mesh).grad(vf.component(cmpt))
165  )
166  );
167  }
168 
169  return tsfCorr;
170  }
171 
172 
173  //- Return the explicit correction to the face-interpolate
176  (
178  ) const
179  {
180  if
181  (
182  tScheme_().corrected()
183  && skewCorrectionVectors::New(this->mesh()).skew()
184  )
185  {
186  return tScheme_().correction(vf) + skewCorrection(vf);
187  }
188  else if (tScheme_().corrected())
189  {
190  return tScheme_().correction(vf);
191  }
192  else if (skewCorrectionVectors::New(this->mesh()).skew())
193  {
194  return skewCorrection(vf);
195  }
196  else
197  {
198  return
200  (
201  nullptr
202  );
203  }
204  }
205 
206 
207  // Member Operators
208 
209  //- Disallow default bitwise assignment
210  void operator=(const skewCorrected&) = delete;
211 };
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
TypeName("skewCorrected")
Runtime type information.
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
const word & name() const
Return name.
Definition: IOobject.H:315
dimensionedTensor skew(const dimensionedTensor &dt)
Centred interpolation interpolation scheme class.
Definition: linear.H:50
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
Traits class for primitives.
Definition: pTraits.H:50
Basic second-order gradient scheme using face-interpolation and Gauss&#39; theorem.
Definition: gaussGrad.H:57
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Generic dimensioned Type class.
const fvMesh & mesh() const
Return mesh reference.
void operator=(const skewCorrected &)=delete
Disallow default bitwise assignment.
const dimensionSet & dimensions() const
Return dimensions.
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > skewCorrection(const GeometricField< Type, fvPatchField, volMesh > &vf) const
static const zero Zero
Definition: zero.H:97
Skewness-corrected interpolation scheme that applies an explicit correction to given scheme...
Definition: skewCorrected.H:53
static skewCorrectionVectors & New(fvMesh &mesh)
Definition: MeshObject.C:54
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &, const tmp< surfaceScalarField > &, const tmp< surfaceScalarField > &)
Return the face-interpolate of the given cell field.
Skew-correction vectors for the skewness-corrected interpolation scheme.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
bool skew() const
Return whether mesh is skew or not.
skewCorrected(const fvMesh &mesh, Istream &is)
Construct from mesh and Istream.
Definition: skewCorrected.H:72
A class for managing temporary objects.
Definition: PtrList.H:53
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Abstract base class for surface interpolation schemes.
Namespace for OpenFOAM.