FitData.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 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::FitData
29
30Description
31 Data for the upwinded and centred polynomial fit interpolation schemes.
32 The linearCorrection_ determines whether the fit is for a corrected
33 linear scheme (first two coefficients are corrections for owner and
34 neighbour) or a pure upwind scheme (first coefficient is correction for
35 owner; weight on face taken as 1).
36
37SourceFiles
38 FitData.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef FitData_H
43#define FitData_H
44
45#include "MeshObject.H"
46#include "fvMesh.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53/*---------------------------------------------------------------------------*\
54 Class FitData Declaration
55\*---------------------------------------------------------------------------*/
56
57template<class FitDataType, class ExtendedStencil, class Polynomial>
58class FitData
59:
60 public MeshObject<fvMesh, MoveableMeshObject, FitDataType>
61{
62 // Private data
63
64 //- The stencil the fit is based on
65 const ExtendedStencil& stencil_;
66
67 //- Is scheme correction on linear (true) or on upwind (false)
68 const bool linearCorrection_;
69
70 //- Factor the fit is allowed to deviate from the base scheme
71 // (linear or pure upwind)
72 // This limits the amount of high-order correction and increases
73 // stability on bad meshes
74 const scalar linearLimitFactor_;
75
76 //- Weights for central stencil
77 const scalar centralWeight_;
78
79 //- Dimensionality of the geometry
80 const label dim_;
81
82 //- Minimum stencil size
83 const label minSize_;
84
85
86protected:
87
88 //- Find the normal direction (i) and j and k directions for face faci
89 void findFaceDirs
90 (
91 vector& idir, // value changed in return
92 vector& jdir, // value changed in return
93 vector& kdir, // value changed in return
94 const label faci
95 );
96
97public:
98
99 // Constructors
100
101 //- Construct from components
102 FitData
103 (
104 const fvMesh& mesh,
105 const ExtendedStencil& stencil,
106 const bool linearCorrection,
107 const scalar linearLimitFactor,
108 const scalar centralWeight
109 );
110
111
112 //- Destructor
113 virtual ~FitData() = default;
114
115
116 // Member functions
117
118 //- Return reference to the stencil
119 const ExtendedStencil& stencil() const
120 {
121 return stencil_;
122 }
123
124 //- Factor the fit is allowed to deviate from the base scheme
125 scalar linearLimitFactor() const
126 {
127 return linearLimitFactor_;
128 }
129
130 //- Return weight for central stencil
131 scalar centralWeight() const
132 {
133 return centralWeight_;
134 }
135
136 //- Dimensionality of the geometry
137 label dim() const
138 {
139 return dim_;
140 }
141
142 //- Minimum stencil size
143 label minSize() const
144 {
145 return minSize_;
146 }
148 bool linearCorrection() const
149 {
150 return linearCorrection_;
151 }
152
153 //- Calculate the fit for the specified face and set the coefficients
154 void calcFit
155 (
156 scalarList& coeffsi, // coefficients to be set
157 const List<point>&, // Stencil points
158 const scalar wLin, // Weight for linear approximation (weights
159 // nearest neighbours)
160 const label faci // Current face index
161 );
162
163 //- Calculate the fit for all the faces
164 virtual void calcFit() = 0;
165
166 //- Recalculate weights (but not stencil) when the mesh moves
167 bool movePoints();
168};
169
170
171// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172
173} // End namespace Foam
174
175// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176
177#ifdef NoRepository
178 #include "FitData.C"
179#endif
180
181// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182
183#endif
184
185// ************************************************************************* //
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:60
bool movePoints()
Recalculate weights (but not stencil) when the mesh moves.
Definition: FitData.C:317
label minSize() const
Minimum stencil size.
Definition: FitData.H:142
virtual ~FitData()=default
Destructor.
label dim() const
Dimensionality of the geometry.
Definition: FitData.H:136
scalar linearLimitFactor() const
Factor the fit is allowed to deviate from the base scheme.
Definition: FitData.H:124
const ExtendedStencil & stencil() const
Return reference to the stencil.
Definition: FitData.H:118
bool linearCorrection() const
Definition: FitData.H:147
scalar centralWeight() const
Return weight for central stencil.
Definition: FitData.H:130
virtual void calcFit()=0
Calculate the fit for all the faces.
void findFaceDirs(vector &idir, vector &jdir, vector &kdir, const label faci)
Find the normal direction (i) and j and k directions for face faci.
Definition: FitData.C:72
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:91
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Namespace for OpenFOAM.