skewCorrected.H
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-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::skewCorrected
28 
29 Group
30  grpFvSurfaceInterpolationSchemes
31 
32 Description
33  Skewness-corrected interpolation scheme that applies an explicit
34  correction to given scheme.
35 
36 SourceFiles
37  skewCorrected.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef skewCorrected_H
42 #define skewCorrected_H
43 
45 #include "skewCorrectionVectors.H"
46 #include "linear.H"
47 #include "gaussGrad.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class skewCorrected Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Type>
59 class skewCorrected
60 :
61  public surfaceInterpolationScheme<Type>
62 {
63  // Private member data
64 
66 
67 
68  // Private Member Functions
69 
70  //- No copy construct
71  skewCorrected(const skewCorrected&) = delete;
72 
73  //- No copy assignment
74  void operator=(const skewCorrected&) = delete;
75 
76 
77 public:
78 
79  //- Runtime type information
80  TypeName("skewCorrected");
81 
82 
83  // Constructors
84 
85  //- Construct from mesh and Istream
87  (
88  const fvMesh& mesh,
89  Istream& is
90  )
91  :
93  tScheme_
94  (
96  )
97  {}
98 
99 
100  //- Construct from mesh, faceFlux and Istream
102  (
103  const fvMesh& mesh,
104  const surfaceScalarField& faceFlux,
105  Istream& is
106  )
107  :
109  tScheme_
110  (
111  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
112  )
113  {}
114 
115 
116  // Member Functions
117 
118  //- Return the interpolation weighting factors
120  (
122  ) const
123  {
124  return tScheme_().weights(vf);
125  }
126 
127  //- Return true if this scheme uses an explicit correction
128  virtual bool corrected() const
129  {
130  return
131  tScheme_().corrected()
132  || skewCorrectionVectors::New(this->mesh()).skew();
133  }
134 
137  (
139  ) const
140  {
141  const fvMesh& mesh = this->mesh();
142 
144 
146  (
148  (
149  IOobject
150  (
151  "skewCorrected::skewCorrection(" + vf.name() + ')',
152  mesh.time().timeName(),
153  mesh
154  ),
155  mesh,
156  dimensioned<Type>(vf.dimensions(), Zero)
157  )
158  );
159 
160  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
161  {
162  tsfCorr.ref().replace
163  (
164  cmpt,
165  scv() & linear
166  <
167  typename outerProduct
168  <
169  vector,
170  typename pTraits<Type>::cmptType
171  >::type
172  > (mesh).interpolate
173  (
175  (mesh).grad(vf.component(cmpt))
176  )
177  );
178  }
179 
180  return tsfCorr;
181  }
182 
183 
184  //- Return the explicit correction to the face-interpolate
187  (
189  ) const
190  {
191  if
192  (
193  tScheme_().corrected()
194  && skewCorrectionVectors::New(this->mesh()).skew()
195  )
196  {
197  return tScheme_().correction(vf) + skewCorrection(vf);
198  }
199  else if (tScheme_().corrected())
200  {
201  return tScheme_().correction(vf);
202  }
203  else if (skewCorrectionVectors::New(this->mesh()).skew())
204  {
205  return skewCorrection(vf);
206  }
207  else
208  {
209  return
211  (
212  nullptr
213  );
214  }
215  }
216 };
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
skewCorrectionVectors.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::surfaceInterpolationScheme::New
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
Definition: surfaceInterpolationScheme.C:40
Foam::GeometricField::component
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
Foam::skewCorrectionVectors::skew
bool skew() const
Return whether mesh is skew or not.
Definition: skewCorrectionVectors.H:87
Foam::skew
dimensionedTensor skew(const dimensionedTensor &dt)
Definition: dimensionedTensor.C:138
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::surfaceInterpolationScheme::interpolate
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.
Definition: surfaceInterpolationScheme.C:126
Foam::fv::gaussGrad
Basic second-order gradient scheme using face-interpolation and Gauss' theorem.
Definition: gaussGrad.H:63
Foam::MeshObject< fvMesh, MoveableMeshObject, skewCorrectionVectors >::New
static const skewCorrectionVectors & New(const fvMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::fac::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:56
gaussGrad.H
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::skewCorrected
Skewness-corrected interpolation scheme that applies an explicit correction to given scheme.
Definition: skewCorrected.H:58
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:42
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::skewCorrectionVectors
Skew-correction vectors for the skewness-corrected interpolation scheme.
Definition: skewCorrectionVectors.H:54
Foam::skewCorrected::weights
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
Definition: skewCorrected.H:119
Foam::skewCorrected::TypeName
TypeName("skewCorrected")
Runtime type information.
Foam::Vector< scalar >
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::surfaceInterpolationScheme
Abstract base class for surface interpolation schemes.
Definition: surfaceInterpolationScheme.H:57
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::surfaceInterpolationScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: surfaceInterpolationScheme.H:144
Foam::skewCorrected::corrected
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: skewCorrected.H:127
Foam::linear
Central-differencing interpolation scheme class.
Definition: linear.H:55
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::skewCorrected::correction
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Definition: skewCorrected.H:186
Foam::outerProduct
Definition: products.H:106
surfaceInterpolationScheme.H
Foam::skewCorrected::skewCorrection
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > skewCorrection(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Definition: skewCorrected.H:136