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-2022 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  :
79  tScheme_
80  (
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  :
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  (
110  const VolField<Type>& vf
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  (
127  const VolField<Type>& vf
128  ) const
129  {
130  const fvMesh& mesh = this->mesh();
131 
133 
134  tmp<SurfaceField<Type>> tsfCorr
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
175  correction
176  (
177  const VolField<Type>& vf
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 // ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
Generic GeometricField class.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
const word & name() const
Return name.
Definition: IOobject.H:310
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
Generic dimensioned Type class.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Basic second-order gradient scheme using face-interpolation and Gauss' theorem.
Definition: gaussGrad.H:60
Centred interpolation interpolation scheme class.
Definition: linear.H:53
Traits class for primitives.
Definition: pTraits.H:53
Skewness-corrected interpolation scheme that applies an explicit correction to given scheme.
Definition: skewCorrected.H:56
skewCorrected(const fvMesh &mesh, Istream &is)
Construct from mesh and Istream.
Definition: skewCorrected.H:72
tmp< SurfaceField< Type > > skewCorrection(const VolField< Type > &vf) const
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
void operator=(const skewCorrected &)=delete
Disallow default bitwise assignment.
tmp< surfaceScalarField > weights(const VolField< Type > &vf) const
Return the interpolation weighting factors.
TypeName("skewCorrected")
Runtime type information.
virtual tmp< SurfaceField< Type > > correction(const VolField< Type > &vf) const
Return the explicit correction to the face-interpolate.
Skew-correction vectors for the skewness-corrected interpolation scheme.
bool skew() const
Return whether mesh is skew or not.
Abstract base class for surface interpolation schemes.
const fvMesh & mesh() const
Return mesh reference.
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &, const tmp< surfaceScalarField > &, const tmp< surfaceScalarField > &)
Return the face-interpolate of the given cell field.
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
dimensionedTensor skew(const dimensionedTensor &dt)
uint8_t direction
Definition: direction.H:45
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488