35template<
class Form,
class ExtendedStencil,
class Polynomial>
39 const ExtendedStencil& stencil,
40 const bool linearCorrection,
41 const scalar linearLimitFactor,
42 const scalar centralWeight
47 linearCorrection_(linearCorrection),
48 linearLimitFactor_(linearLimitFactor),
49 centralWeight_(centralWeight),
50 #ifdef SPHERICAL_GEOMETRY
53 dim_(
mesh.nGeometricD()),
58 if (linearLimitFactor <= SMALL || linearLimitFactor > 3)
62 <<
" should be between zero and 3"
70template<
class FitDataType,
class ExtendedStencil,
class Polynomial>
83 #ifndef SPHERICAL_GEOMETRY
112 kdir -= (idir & kdir)*idir;
114 scalar magk =
mag(kdir);
131template<
class FitDataType,
class ExtendedStencil,
class Polynomial>
143 findFaceDirs(idir, jdir, kdir, facei);
147 wts[0] = centralWeight_;
148 if (linearCorrection_)
150 wts[1] = centralWeight_;
172 d.
x() = (
p -
p0)&idir;
173 d.
y() = (
p -
p0)&jdir;
174 #ifndef SPHERICAL_GEOMETRY
175 d.
z() = (
p -
p0)&kdir;
198 for (label i = 0; i <
B.m(); i++)
205 label stencilSize =
C.
size();
208 bool goodFit =
false;
209 for (
int iIt = 0; iIt < 8 && !goodFit; iIt++)
217 for (label i=0; i<stencilSize; i++)
219 coeffsi[i] = wts[0]*wts[i]*invB(0, i);
220 if (
mag(coeffsi[i]) > maxCoeff)
222 maxCoeff =
mag(coeffsi[i]);
227 if (linearCorrection_)
230 (
mag(coeffsi[0] - wLin) < linearLimitFactor_*wLin)
231 && (
mag(coeffsi[1] - (1 - wLin)) < linearLimitFactor_*(1 - wLin))
238 (
mag(coeffsi[0] - 1.0) < linearLimitFactor_*1.0)
267 if (linearCorrection_)
272 for (label j = 0; j <
B.n(); j++)
278 for (label i = 0; i <
B.m(); i++)
288 if (linearCorrection_)
292 coeffsi[1] -= 1 - wLin;
305 <<
"Could not fit face " << facei
306 <<
" Weights = " << coeffsi
307 <<
", reverting to linear." <<
nl
308 <<
" Linear weights " << wLin <<
" " << 1 - wLin <<
endl;
316template<
class FitDataType,
class ExtendedStencil,
class Polynomial>
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
Graphite solid properties.
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
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.
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 n)
Alias for resize()
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Polynomial templated on size (order):
void size(const label n)
Older name for setAddressableSize.
const Cmpt & z() const
Access to the vector z component.
const Cmpt & y() const
Access to the vector y component.
const Cmpt & x() const
Access to the vector x component.
static void addCoeffs(scalar *coeffs, const vector &d, const scalar weight, const direction dim)
A face is a list of labels corresponding to mesh vertices.
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
const volScalarField & p0
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
RectangularMatrix< scalar > scalarRectangularMatrix
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0)
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.