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
53 minSize_(Polynomial::nTerms(dim_))
56 if (linearLimitFactor <= SMALL || linearLimitFactor > 3)
59 <<
"linearLimitFactor requested = " << linearLimitFactor
60 <<
" should be between zero and 3"
68 template<
class FitDataType,
class ExtendedStencil,
class Polynomial>
82 # ifndef SPHERICAL_GEOMETRY
100 const face&
f = mesh.
faces()[facei];
111 kdir -= (idir & kdir)*idir;
113 scalar magk =
mag(kdir);
117 FatalErrorIn(
"findFaceDirs(..)") <<
" calculated kdir = zero"
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_;
153 point p0 = this->
mesh().faceCentres()[facei];
167 for(label ip = 0; ip < C.
size(); ip++)
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.n(); i++)
204 label stencilSize = C.
size();
207 bool goodFit =
false;
208 for(
int iIt = 0; iIt < 8 && !goodFit; iIt++)
215 for(label i=0; i<stencilSize; i++)
217 coeffsi[i] = wts[0]*wts[i]*svd.
VSinvUt()[0][i];
218 if (
mag(coeffsi[i]) > maxCoeff)
220 maxCoeff =
mag(coeffsi[i]);
225 if (linearCorrection_)
228 (
mag(coeffsi[0] - wLin) < linearLimitFactor_*wLin)
229 && (
mag(coeffsi[1] - (1 - wLin)) < linearLimitFactor_*(1 - wLin))
236 (
mag(coeffsi[0] - 1.0) < linearLimitFactor_*1.0)
268 if (linearCorrection_)
273 for(label j = 0; j < B.m(); j++)
279 for(label i = 0; i < B.n(); i++)
289 if (linearCorrection_)
293 coeffsi[1] -= 1 - wLin;
307 "FitData<Polynomial>::calcFit(..)"
308 ) <<
"Could not fit face " << facei
309 <<
" Weights = " << coeffsi
310 <<
", reverting to linear." <<
nl
311 <<
" Linear weights " << wLin <<
" " << 1 - wLin <<
endl;
319 template<
class FitDataType,
class ExtendedStencil,
class Polynomial>