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-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::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 "DemandDrivenMeshObject.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 DemandDrivenMeshObject<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  friend class DemandDrivenMeshObject
86  <
87  fvMesh,
89  FitDataType
90  >;
91 
92  // Protected Constructors
93 
94  //- Construct from components
95  FitData
96  (
97  const fvMesh& mesh,
98  const ExtendedStencil& stencil,
99  const bool linearCorrection,
100  const scalar linearLimitFactor,
101  const scalar centralWeight
102  );
103 
104 
105  // Protected Member Functions
106 
107  //- Find the normal direction (i) and j and k directions for face faci
108  void findFaceDirs
109  (
110  vector& idir, // value changed in return
111  vector& jdir, // value changed in return
112  vector& kdir, // value changed in return
113  const label faci
114  );
115 
116 public:
117 
118  //- Destructor
119  virtual ~FitData()
120  {}
121 
122 
123  // Member Functions
124 
125  //- Return reference to the stencil
126  const ExtendedStencil& stencil() const
127  {
128  return stencil_;
129  }
130 
131  //- Factor the fit is allowed to deviate from the base scheme
132  scalar linearLimitFactor() const
133  {
134  return linearLimitFactor_;
135  }
136 
137  //- Return weight for central stencil
138  scalar centralWeight() const
139  {
140  return centralWeight_;
141  }
142 
143  //- Dimensionality of the geometry
144  label dim() const
145  {
146  return dim_;
147  }
148 
149  //- Minimum stencil size
150  label minSize() const
151  {
152  return minSize_;
153  }
154 
155  bool linearCorrection() const
156  {
157  return linearCorrection_;
158  }
159 
160  //- Calculate the fit for the specified face and set the coefficients
161  void calcFit
162  (
163  scalarList& coeffsi, // coefficients to be set
164  const List<point>&, // Stencil points
165  const scalar wLin, // Weight for linear approximation (weights
166  // nearest neighbours)
167  const label faci // Current face index
168  );
169 
170  //- Calculate the fit for all the faces
171  virtual void calcFit() = 0;
172 
173  //- Recalculate weights (but not stencil) when the mesh moves
174  bool movePoints();
175 };
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #ifdef NoRepository
185  #include "FitData.C"
186 #endif
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:57
const ExtendedStencil & stencil() const
Return reference to the stencil.
Definition: FitData.H:125
bool movePoints()
Recalculate weights (but not stencil) when the mesh moves.
Definition: FitData.C:316
label minSize() const
Minimum stencil size.
Definition: FitData.H:149
virtual ~FitData()
Destructor.
Definition: FitData.H:118
label dim() const
Dimensionality of the geometry.
Definition: FitData.H:143
scalar linearLimitFactor() const
Factor the fit is allowed to deviate from the base scheme.
Definition: FitData.H:131
bool linearCorrection() const
Definition: FitData.H:154
FitData(const fvMesh &mesh, const ExtendedStencil &stencil, const bool linearCorrection, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
Definition: FitData.C:35
scalar centralWeight() const
Return weight for central stencil.
Definition: FitData.H:137
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:70
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Namespace for OpenFOAM.
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