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 | Copyright (C) 2011-2016 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  // Private Member Functions
64 
65  //- Disallow default bitwise copy construct
67 
68  //- Disallow default bitwise assignment
69  void operator=(const skewCorrected&);
70 
71 
72 public:
73 
74  //- Runtime type information
75  TypeName("skewCorrected");
76 
77 
78  // Constructors
79 
80  //- Construct from mesh and Istream
82  (
83  const fvMesh& mesh,
84  Istream& is
85  )
86  :
87  surfaceInterpolationScheme<Type>(mesh),
88  tScheme_
89  (
90  surfaceInterpolationScheme<Type>::New(mesh, is)
91  )
92  {}
93 
94 
95  //- Construct from mesh, faceFlux and Istream
97  (
98  const fvMesh& mesh,
99  const surfaceScalarField& faceFlux,
100  Istream& is
101  )
102  :
103  surfaceInterpolationScheme<Type>(mesh),
104  tScheme_
105  (
106  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
107  )
108  {}
109 
110 
111  // Member Functions
112 
113  //- Return the interpolation weighting factors
115  (
117  ) const
118  {
119  return tScheme_().weights(vf);
120  }
121 
122  //- Return true if this scheme uses an explicit correction
123  virtual bool corrected() const
124  {
125  return
126  tScheme_().corrected()
127  || skewCorrectionVectors::New(this->mesh()).skew();
128  }
129 
132  (
134  ) const
135  {
136  const fvMesh& mesh = this->mesh();
137 
139 
141  (
143  (
144  IOobject
145  (
146  "skewCorrected::skewCorrection(" + vf.name() + ')',
147  mesh.time().timeName(),
148  mesh
149  ),
150  mesh,
152  (
153  vf.name(),
154  vf.dimensions(),
155  Zero
156  )
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  NULL
213  );
214  }
215  }
216 };
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
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.
uint8_t direction
Definition: direction.H:46
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
const fvMesh & mesh() const
Return mesh reference.
dimensionedTensor skew(const dimensionedTensor &dt)
Central-differencing interpolation scheme class.
Definition: linear.H:50
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Traits class for primitives.
Definition: pTraits.H:50
Basic second-order gradient scheme using face-interpolation and Gauss&#39; theorem.
Definition: gaussGrad.H:57
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:715
Generic dimensioned Type class.
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
static const skewCorrectionVectors & New(const fvMesh &mesh)
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
static const zero Zero
Definition: zero.H:91
const dimensionSet & dimensions() const
Return dimensions.
Skewness-corrected interpolation scheme that applies an explicit correction to given scheme...
Definition: skewCorrected.H:53
bool skew() const
Return whether mesh is skew or not.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > skewCorrection(const GeometricField< Type, fvPatchField, volMesh > &vf) const
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.
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:461
Skew-correction vectors for the skewness-corrected interpolation scheme.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A class for managing temporary objects.
Definition: PtrList.H:54
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Abstract base class for surface interpolation schemes.
const word & name() const
Return name.
Definition: IOobject.H:260
Namespace for OpenFOAM.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243