cubic.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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::cubic
28
29Group
30 grpFvSurfaceInterpolationSchemes
31
32Description
33 Cubic interpolation scheme class derived from linear and returns
34 linear weighting factors but also applies an explicit correction.
35
36SourceFiles
37 cubic.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef cubic_H
42#define cubic_H
43
44#include "linear.H"
45#include "gaussGrad.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52/*---------------------------------------------------------------------------*\
53 Class cubic Declaration
54\*---------------------------------------------------------------------------*/
55
56template<class Type>
57class cubic
58:
59 public linear<Type>
60{
61 // Private Member Functions
62
63 //- No copy construct
64 cubic(const cubic&) = delete;
65
66 //- No copy assignment
67 void operator=(const cubic&) = delete;
68
69
70public:
71
72 //- Runtime type information
73 TypeName("cubic");
74
75
76 // Constructors
77
78 //- Construct from mesh
79 cubic(const fvMesh& mesh)
80 :
81 linear<Type>(mesh)
82 {}
83
84 //- Construct from mesh and Istream
85 cubic
86 (
87 const fvMesh& mesh,
88 Istream&
89 )
90 :
91 linear<Type>(mesh)
92 {}
93
94 //- Construct from mesh, faceFlux and Istream
95 cubic
96 (
97 const fvMesh& mesh,
98 const surfaceScalarField&,
99 Istream&
100 )
101 :
102 linear<Type>(mesh)
103 {}
104
105
106 // Member Functions
107
108 //- Return true if this scheme uses an explicit correction
109 virtual bool corrected() const
110 {
111 return true;
112 }
113
114 //- Return the explicit correction to the face-interpolate
117 (
119 ) const
120 {
121 const fvMesh& mesh = this->mesh();
122
123 // calculate the appropriate interpolation factors
125
126 const surfaceScalarField kSc
127 (
128 lambda*(scalar(1) - lambda*(scalar(3) - scalar(2)*lambda))
129 );
130
131 const surfaceScalarField kVecP(sqr(scalar(1) - lambda)*lambda);
132 const surfaceScalarField kVecN(sqr(lambda)*(lambda - scalar(1)));
133
135 (
137 (
139 (
140 "cubic::correction(" + vf.name() +')',
141 mesh.time().timeName(),
142 mesh,
145 false
146 ),
148 )
149 );
151 tsfCorr.ref();
152
153 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
154 {
155 sfCorr.replace
156 (
157 cmpt,
158 sfCorr.component(cmpt)
159 + (
161 <
162 typename outerProduct
163 <
164 vector,
166 >::type
168 (
170 <typename pTraits<Type>::cmptType>(mesh)
171 .grad(vf.component(cmpt)),
172 kVecP,
173 kVecN
174 ) & mesh.Sf()
175 )/mesh.magSf()/mesh.surfaceInterpolation::deltaCoeffs()
176 );
177 }
178
180 Boundary& sfCorrbf = sfCorr.boundaryFieldRef();
181
182 forAll(sfCorrbf, pi)
183 {
184 if (!sfCorrbf[pi].coupled())
185 {
186 sfCorrbf[pi] = Zero;
187 }
188 }
189
190 return tsfCorr;
191 }
192};
193
194
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197} // End namespace Foam
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201#endif
202
203// ************************************************************************* //
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Cubic interpolation scheme class derived from linear and returns linear weighting factors but also ap...
Definition: cubic.H:59
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: cubic.H:108
TypeName("cubic")
Runtime type information.
cubic(const fvMesh &mesh)
Construct from mesh.
Definition: cubic.H:78
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Definition: cubic.H:116
cubic(const fvMesh &mesh, const surfaceScalarField &, Istream &)
Construct from mesh, faceFlux and Istream.
Definition: cubic.H:95
cubic(const fvMesh &mesh, Istream &)
Construct from mesh and Istream.
Definition: cubic.H:85
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
const surfaceVectorField & Sf() const
Return cell face area vectors.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
Basic second-order gradient scheme using face-interpolation and Gauss' theorem.
Definition: gaussGrad.H:66
Central-differencing interpolation scheme class.
Definition: linear.H:58
Abstract base class for surface interpolation schemes.
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.
const fvMesh & mesh() const
Return mesh reference.
virtual const surfaceScalarField & weights() const
Return reference to linear difference weighting factors.
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
uint8_t direction
Definition: direction.H:56
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73