All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FitData.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-2019 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::FitData
26 
27 Description
28  Data for the upwinded and centred polynomial fit interpolation schemes.
29  The linearCorrection_ determines whether the fit is for a corrected
30  linear scheme (first two coefficients are corrections for owner and
31  neighbour) or a pure upwind scheme (first coefficient is correction for
32  owner; weight on face taken as 1).
33 
34 SourceFiles
35  FitData.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef FitData_H
40 #define FitData_H
41 
42 #include "MeshObject.H"
43 #include "fvMesh.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class FitData Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 template<class FitDataType, class ExtendedStencil, class Polynomial>
55 class FitData
56 :
57  public MeshObject<fvMesh, MoveableMeshObject, FitDataType>
58 {
59  // Private Data
60 
61  //- The stencil the fit is based on
62  const ExtendedStencil& stencil_;
63 
64  //- Is scheme correction on linear (true) or on upwind (false)
65  const bool linearCorrection_;
66 
67  //- Factor the fit is allowed to deviate from the base scheme
68  // (linear or pure upwind)
69  // This limits the amount of high-order correction and increases
70  // stability on bad meshes
71  const scalar linearLimitFactor_;
72 
73  //- Weights for central stencil
74  const scalar centralWeight_;
75 
76  //- Dimensionality of the geometry
77  const label dim_;
78 
79  //- Minimum stencil size
80  const label minSize_;
81 
82 
83 protected:
84 
85  //- Find the normal direction (i) and j and k directions for face faci
86  void findFaceDirs
87  (
88  vector& idir, // value changed in return
89  vector& jdir, // value changed in return
90  vector& kdir, // value changed in return
91  const label faci
92  );
93 
94 public:
95 
96  // Constructors
97 
98  //- Construct from components
99  FitData
100  (
101  const fvMesh& mesh,
102  const ExtendedStencil& stencil,
103  const bool linearCorrection,
104  const scalar linearLimitFactor,
105  const scalar centralWeight
106  );
107 
108 
109  //- Destructor
110  virtual ~FitData()
111  {}
112 
113 
114  // Member Functions
115 
116  //- Return reference to the stencil
117  const ExtendedStencil& stencil() const
118  {
119  return stencil_;
120  }
121 
122  //- Factor the fit is allowed to deviate from the base scheme
123  scalar linearLimitFactor() const
124  {
125  return linearLimitFactor_;
126  }
127 
128  //- Return weight for central stencil
129  scalar centralWeight() const
130  {
131  return centralWeight_;
132  }
133 
134  //- Dimensionality of the geometry
135  label dim() const
136  {
137  return dim_;
138  }
139 
140  //- Minimum stencil size
141  label minSize() const
142  {
143  return minSize_;
144  }
146  bool linearCorrection() const
147  {
148  return linearCorrection_;
149  }
150 
151  //- Calculate the fit for the specified face and set the coefficients
152  void calcFit
153  (
154  scalarList& coeffsi, // coefficients to be set
155  const List<point>&, // Stencil points
156  const scalar wLin, // Weight for linear approximation (weights
157  // nearest neighbours)
158  const label faci // Current face index
159  );
160 
161  //- Calculate the fit for all the faces
162  virtual void calcFit() = 0;
163 
164  //- Recalculate weights (but not stencil) when the mesh moves
165  bool movePoints();
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #ifdef NoRepository
176  #include "FitData.C"
177 #endif
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
label dim() const
Dimensionality of the geometry.
Definition: FitData.H:134
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual void calcFit()=0
Calculate the fit for all the faces.
const ExtendedStencil & stencil() const
Return reference to the stencil.
Definition: FitData.H:116
bool linearCorrection() const
Definition: FitData.H:145
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:86
label minSize() const
Minimum stencil size.
Definition: FitData.H:140
virtual ~FitData()
Destructor.
Definition: FitData.H:109
scalar centralWeight() const
Return weight for central stencil.
Definition: FitData.H:128
scalar linearLimitFactor() const
Factor the fit is allowed to deviate from the base scheme.
Definition: FitData.H:122
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:70
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
FitData(const fvMesh &mesh, const ExtendedStencil &stencil, const bool linearCorrection, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
Definition: FitData.C:35
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:54
bool movePoints()
Recalculate weights (but not stencil) when the mesh moves.
Definition: FitData.C:316
Namespace for OpenFOAM.