Go to the documentation of this file.
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()),
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>
79 idir =
mesh.faceAreas()[facei];
82 #ifndef SPHERICAL_GEOMETRY
83 if (
mesh.nGeometricD() <= 2)
85 if (
mesh.geometricD()[0] == -1)
89 else if (
mesh.geometricD()[1] == -1)
101 kdir =
mesh.points()[
f[0]] -
mesh.faceCentres()[facei];
105 kdir =
mesh.faceCentres()[facei];
108 if (
mesh.nGeometricD() == 3)
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_;
153 point p0 = this->
mesh().faceCentres()[facei];
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)
265 if (linearCorrection_)
270 for (
label j = 0; j < B.
m(); j++)
276 for (
label i = 0; i < B.
n(); i++)
286 if (linearCorrection_)
290 coeffsi[1] -= 1 - wLin;
303 <<
"Could not fit face " << facei
304 <<
" Weights = " << coeffsi
305 <<
", reverting to linear." <<
nl
306 <<
" Linear weights " << wLin <<
" " << 1 - wLin <<
endl;
314 template<
class FitDataType,
class ExtendedStencil,
class Polynomial>
label m() const
Return the number of columns.
#define forAll(list, i)
Loop across all elements in list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void findFaceDirs(vector &idir, vector &jdir, vector &kdir, const label faci)
Find the normal direction (i) and j and k directions for face faci.
dimensioned< scalar > mag(const dimensioned< Type > &)
label n() const
Return the number of rows.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool movePoints()
Recalculate weights (but not stencil) when the mesh moves.
Mesh data needed to do the Finite Volume discretisation.
Vector< scalar > vector
A scalar version of the templated Vector.
errorManipArg< error, int > exit(error &err, const int errNo=1)
FitData(const fvMesh &mesh, const ExtendedStencil &stencil, const bool linearCorrection, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
void setSize(const label)
Reset size of List.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void calcFit()=0
Calculate the fit for all the faces.
const scalarRectangularMatrix & VSinvUt() const
Return VSinvUt (the pseudo inverse)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Singular value decomposition of a rectangular matrix.
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
A face is a list of labels corresponding to mesh vertices.
Graphite solid properties.
#define WarningInFunction
Report a warning using Foam::Warning.