33 template<
class Form,
class ExtendedStencil,
class Polynomial>
37 const ExtendedStencil& stencil,
38 const bool linearCorrection,
39 const scalar linearLimitFactor,
40 const scalar centralWeight
45 linearCorrection_(linearCorrection),
46 linearLimitFactor_(linearLimitFactor),
47 centralWeight_(centralWeight),
48 #ifdef SPHERICAL_GEOMETRY
51 dim_(mesh.nGeometricD()),
56 if (linearLimitFactor <= small || linearLimitFactor > 3)
60 <<
" should be between zero and 3"
68 template<
class FitDataType,
class ExtendedStencil,
class Polynomial>
77 const fvMesh& mesh = this->mesh();
82 #ifndef SPHERICAL_GEOMETRY
100 const face&
f = mesh.
faces()[facei];
111 kdir -= (idir & kdir)*idir;
113 scalar magk =
mag(kdir);
130 template<
class FitDataType,
class ExtendedStencil,
class Polynomial>
142 findFaceDirs(idir, jdir, kdir, facei);
146 wts[0] = centralWeight_;
147 if (linearCorrection_)
149 wts[1] = centralWeight_;
171 d.
x() = (
p - p0)&idir;
172 d.
y() = (
p - p0)&jdir;
173 #ifndef SPHERICAL_GEOMETRY
174 d.
z() = (
p - p0)&kdir;
187 Polynomial::addCoeffs
197 for (
label i = 0; i <
B.m(); i++)
204 label stencilSize =
C.size();
207 bool goodFit =
false;
208 for (
int iIt = 0; iIt < 8 && !goodFit; iIt++)
216 for (
label i=0; i<stencilSize; i++)
218 coeffsi[i] = wts[0]*wts[i]*invB(0, i);
219 if (
mag(coeffsi[i]) > maxCoeff)
221 maxCoeff =
mag(coeffsi[i]);
226 if (linearCorrection_)
229 (
mag(coeffsi[0] - wLin) < linearLimitFactor_*wLin)
230 && (
mag(coeffsi[1] - (1 - wLin)) < linearLimitFactor_*(1 - wLin))
237 (
mag(coeffsi[0] - 1.0) < linearLimitFactor_*1.0)
266 if (linearCorrection_)
271 for (
label j = 0; j <
B.n(); j++)
277 for (
label i = 0; i <
B.m(); i++)
287 if (linearCorrection_)
291 coeffsi[1] -= 1 - wLin;
304 <<
"Could not fit face " << facei
305 <<
" Weights = " << coeffsi
306 <<
", reverting to linear." <<
nl
307 <<
" Linear weights " << wLin <<
" " << 1 - wLin <<
endl;
315 template<
class FitDataType,
class ExtendedStencil,
class Polynomial>
static const Foam::dimensionedScalar B("B", Foam::dimless, 18.678)
static const Foam::dimensionedScalar C("C", Foam::dimTemperature, 234.5)
#define forAll(list, i)
Loop across all elements in list.
Graphite solid properties.
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
bool movePoints()
Recalculate weights (but not stencil) when the mesh moves.
scalar linearLimitFactor() const
Factor the fit is allowed to deviate from the base scheme.
FitData(const fvMesh &mesh, const ExtendedStencil &stencil, const bool linearCorrection, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
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.
void setSize(const label)
Reset size of List.
Polynomial templated on size (order):
Mesh data needed to do the Finite Volume discretisation.
label nGeometricD() const
Return the number of valid geometric dimensions in the mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
const vectorField & faceCentres() const
const vectorField & faceAreas() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
RectangularMatrix< scalar > scalarRectangularMatrix
Ostream & endl(Ostream &os)
Add newline and flush stream.
Vector< scalar > vector
A scalar version of the templated Vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionSet cmptMag(const dimensionSet &)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)