FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/MeshObject.H>
43 #include <finiteVolume/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, 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  // Private member functions
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  //TypeName("FitData");
97 
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()
114  {}
115 
116 
117  // Member functions
118 
119  //- Return reference to the stencil
120  const ExtendedStencil& stencil() const
121  {
122  return stencil_;
123  }
124 
125  bool linearCorrection() const
126  {
127  return linearCorrection_;
128  }
129 
130  //- Calculate the fit for the specified face and set the coefficients
131  void calcFit
132  (
133  scalarList& coeffsi, // coefficients to be set
134  const List<point>&, // Stencil points
135  const scalar wLin, // Weight for linear approximation (weights
136  // nearest neighbours)
137  const label faci // Current face index
138  );
139 
140  //- Calculate the fit for all the faces
141  virtual void calcFit() = 0;
142 
143 
144  //- Recalculate weights (but not stencil) when the mesh moves
145  bool movePoints();
146 };
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #ifdef NoRepository
156 # include "FitData.C"
157 #endif
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************ vim: set sw=4 sts=4 et: ************************ //