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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::FitData
29 
30 Description
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 
37 SourceFiles
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 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class FitData Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class FitDataType, class ExtendedStencil, class Polynomial>
58 class FitData
59 :
60  public MeshObject<fvMesh, MoveableMeshObject, FitDataType>
61 {
62  // Private Typedefs
63 
64  typedef MeshObject
65  <
66  fvMesh,
68  FitDataType
70 
71 
72  // Private Data
73 
74  //- The stencil the fit is based on
75  const ExtendedStencil& stencil_;
76 
77  //- Is scheme correction on linear (true) or on upwind (false)
78  const bool linearCorrection_;
79 
80  //- Factor the fit is allowed to deviate from the base scheme
81  // (linear or pure upwind)
82  // This limits the amount of high-order correction and increases
83  // stability on bad meshes
84  const scalar linearLimitFactor_;
85 
86  //- Weights for central stencil
87  const scalar centralWeight_;
88 
89  //- Dimensionality of the geometry
90  const label dim_;
91 
92  //- Minimum stencil size
93  const label minSize_;
94 
95 
96 protected:
97 
98  //- Find the normal direction (i) and j and k directions for face faci
99  void findFaceDirs
100  (
101  vector& idir, // value changed in return
102  vector& jdir, // value changed in return
103  vector& kdir, // value changed in return
104  const label faci
105  );
106 
107 public:
108 
109  // Constructors
110 
111  //- Construct from components
112  FitData
113  (
114  const fvMesh& mesh,
115  const ExtendedStencil& stencil,
116  const bool linearCorrection,
117  const scalar linearLimitFactor,
118  const scalar centralWeight
119  );
120 
121 
122  //- Destructor
123  virtual ~FitData() = default;
124 
125 
126  // Member functions
127 
128  //- Return reference to the stencil
129  const ExtendedStencil& stencil() const
130  {
131  return stencil_;
132  }
133 
134  //- Factor the fit is allowed to deviate from the base scheme
135  scalar linearLimitFactor() const
136  {
137  return linearLimitFactor_;
138  }
139 
140  //- Return weight for central stencil
141  scalar centralWeight() const
142  {
143  return centralWeight_;
144  }
146  //- Dimensionality of the geometry
147  label dim() const
148  {
149  return dim_;
150  }
151 
152  //- Minimum stencil size
153  label minSize() const
154  {
155  return minSize_;
156  }
157 
158  bool linearCorrection() const
159  {
160  return linearCorrection_;
161  }
162 
163  //- Calculate the fit for the specified face and set the coefficients
164  void calcFit
165  (
166  scalarList& coeffsi, // coefficients to be set
167  const List<point>&, // Stencil points
168  const scalar wLin, // Weight for linear approximation (weights
169  // nearest neighbours)
170  const label faci // Current face index
171  );
172 
173  //- Calculate the fit for all the faces
174  virtual void calcFit() = 0;
175 
176  //- Recalculate weights (but not stencil) when the mesh moves
177  bool movePoints();
178 };
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 } // End namespace Foam
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 #ifdef NoRepository
188  #include "FitData.C"
189 #endif
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
194 
195 // ************************************************************************* //
label dim() const
Dimensionality of the geometry.
Definition: FitData.H:169
virtual void calcFit()=0
Calculate the fit for all the faces.
MoveableMeshObject(const word &objName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:328
const ExtendedStencil & stencil() const
Return reference to the stencil.
Definition: FitData.H:145
bool linearCorrection() const
Definition: FitData.H:182
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:152
label minSize() const
Minimum stencil size.
Definition: FitData.H:177
const fvMesh & mesh() const noexcept
Reference to the mesh.
Definition: MeshObject.H:257
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
scalar centralWeight() const
Return weight for central stencil.
Definition: FitData.H:161
scalar linearLimitFactor() const
Factor the fit is allowed to deviate from the base scheme.
Definition: FitData.H:153
virtual ~FitData()=default
Destructor.
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:65
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:30
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:53
bool movePoints()
Recalculate weights (but not stencil) when the mesh moves.
Definition: FitData.C:310
Namespace for OpenFOAM.