FreeFOAM The Cross-Platform CFD Toolkit
PureUpwindFitScheme.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::PureUpwindFitScheme
26 
27 Description
28  Upwind biased fit surface interpolation scheme that applies an explicit
29  correction to upwind.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #ifndef PureUpwindFitScheme_H
34 #define PureUpwindFitScheme_H
35 
37 #include <finiteVolume/upwind.H>
38 #include <OpenFOAM/Switch.H>
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class PureUpwindFitScheme Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 template<class Type, class Polynomial, class Stencil>
51 :
52  public upwind<Type>
53 {
54  // Private Data
55 
56  //- Factor the fit is allowed to deviate from linear.
57  // This limits the amount of high-order correction and increases
58  // stability on bad meshes
59  const scalar linearLimitFactor_;
60 
61  //- Weights for central stencil
62  const scalar centralWeight_;
63 
64 
65  // Private Member Functions
66 
67  //- Disallow default bitwise copy construct
69 
70  //- Disallow default bitwise assignment
71  void operator=(const PureUpwindFitScheme&);
72 
73 
74 public:
75 
76  //- Runtime type information
77  TypeName("PureUpwindFitScheme");
78 
79 
80  // Constructors
81 
82  //- Construct from mesh and Istream
83  // The name of the flux field is read from the Istream and looked-up
84  // from the mesh objectRegistry
86  :
87  upwind<Type>
88  (
89  mesh,
90  mesh.lookupObject<surfaceScalarField>(word(is))
91  ),
92  linearLimitFactor_(readScalar(is)),
93  centralWeight_(1000)
94  {}
95 
96 
97  //- Construct from mesh, faceFlux and Istream
99  (
100  const fvMesh& mesh,
101  const surfaceScalarField& faceFlux,
102  Istream& is
103  )
104  :
105  upwind<Type>(mesh, faceFlux),
106  linearLimitFactor_(readScalar(is)),
107  centralWeight_(1000)
108  {}
109 
110 
111  // Member Functions
112 
113  //- Return true if this scheme uses an explicit correction
114  virtual bool corrected() const
115  {
116  return true;
117  }
118 
119  //- Return the explicit correction to the face-interpolate
121  correction
122  (
124  ) const
125  {
126  const fvMesh& mesh = this->mesh();
127 
128  // Use the owner/neighbour splitting constructor
129  const extendedUpwindCellToFaceStencil& stencil = Stencil::New(mesh);
130 
131  const UpwindFitData<Polynomial>& ufd =
133  (
134  mesh,
135  stencil,
136  false, //offset to upwind
137  linearLimitFactor_,
138  centralWeight_
139  );
140 
141  const List<scalarList>& fo = ufd.owncoeffs();
142  const List<scalarList>& fn = ufd.neicoeffs();
143 
144  return stencil.weightedSum(this->faceFlux_, vf, fo, fn);
145  }
146 };
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 // Add the patch constructor functions to the hash tables
156 
157 #define makePureUpwindFitSurfaceInterpolationTypeScheme(SS, POLYNOMIAL, STENCIL, TYPE) \
158  \
159 typedef PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL> \
160  PureUpwindFitScheme##TYPE##POLYNOMIAL##STENCIL##_; \
161 defineTemplateTypeNameAndDebugWithName \
162  (PureUpwindFitScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0); \
163  \
164 surfaceInterpolationScheme<TYPE>::addMeshConstructorToTable \
165 <PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL> > \
166  add##SS##STENCIL##TYPE##MeshConstructorToTable_; \
167  \
168 surfaceInterpolationScheme<TYPE>::addMeshFluxConstructorToTable \
169 <PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL> > \
170  add##SS##STENCIL##TYPE##MeshFluxConstructorToTable_;
171 
172 #define makePureUpwindFitSurfaceInterpolationScheme(SS, POLYNOMIAL, STENCIL) \
173  \
174 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,scalar) \
175 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,vector) \
176 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,sphericalTensor) \
177 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor) \
178 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 #endif
184 
185 // ************************ vim: set sw=4 sts=4 et: ************************ //