33 template<
class Polynomial>
37 const extendedCentredCellToFaceStencil& stencil,
38 const scalar linearLimitFactor,
39 const scalar centralWeight
44 CentredFitSnGradData<Polynomial>,
45 extendedCentredCellToFaceStencil,
49 mesh, stencil,
true, linearLimitFactor, centralWeight
51 coeffs_(mesh.nFaces())
56 <<
"Constructing CentredFitSnGradData<Polynomial>" <<
endl;
63 Info<<
" Finished constructing polynomialFit data" <<
endl;
70 template<
class Polynomial>
76 const scalar deltaCoeff,
83 this->findFaceDirs(idir, jdir, kdir, facei);
87 wts[0] = this->centralWeight();
88 wts[1] = this->centralWeight();
91 point p0 = this->
mesh().faceCentres()[facei];
105 const vector p0p = p - p0;
119 Polynomial::addCoeffs(B[ip], d, wts[ip], this->dim());
123 for (
label i = 0; i < B.m(); i++)
133 bool goodFit =
false;
134 for (
int iIt = 0; iIt < 8 && !goodFit; iIt++)
139 for (
label i=0; i<stencilSize; i++)
141 coeffsi[i] = wts[1]*wts[i]*invB(1, i)/scale;
146 mag(wts[0]*wts[0]*invB(0, 0) - wLin)
147 < this->linearLimitFactor()*wLin)
148 && (
mag(wts[0]*wts[1]*invB(0, 1) - (1 - wLin)
149 ) < this->linearLimitFactor()*(1 - wLin))
150 && coeffsi[0] < 0 && coeffsi[1] > 0
151 &&
mag(coeffsi[0] + deltaCoeff) < 0.5*deltaCoeff
152 &&
mag(coeffsi[1] - deltaCoeff) < 0.5*deltaCoeff;
160 <<
"Cannot fit face " << facei <<
" iteration " << iIt
161 <<
" with sum of weights " <<
sum(coeffsi) <<
nl 162 <<
" Weights " << coeffsi <<
nl 163 <<
" Linear weights " << wLin <<
" " << 1 - wLin <<
nl 164 <<
" deltaCoeff " << deltaCoeff <<
nl 165 <<
" sing vals " << svd.
S() <<
nl 166 <<
"Components of goodFit:\n" 167 <<
" wts[0]*wts[0]*invB(0, 0) = " 168 << wts[0]*wts[0]*invB(0, 0) <<
nl 169 <<
" wts[0]*wts[1]*invB(0, 1) = " 170 << wts[0]*wts[1]*invB(0, 1)
171 <<
" dim = " << this->dim() <<
endl;
176 for (
label j = 0; j < B.n(); j++)
182 for (
label i = 0; i < B.m(); i++)
193 coeffsi[0] += deltaCoeff;
194 coeffsi[1] -= deltaCoeff;
199 <<
"Could not fit face " << facei
200 <<
" Coefficients = " << coeffsi
201 <<
", reverting to uncorrected." <<
endl;
208 template<
class Polynomial>
217 this->stencil().collectData(mesh.
C(), stencilPoints);
229 stencilPoints[facei],
237 const surfaceScalarField::Boundary& bdC = dC.
boundaryField();
253 stencilPoints[facei],
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual label start() const
Return start label of this patch in the polyMesh face list.
label nInternalFaces() const
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
CentredFitSnGradData(const fvMesh &mesh, const extendedCentredCellToFaceStencil &stencil, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const surfaceScalarField & nonOrthDeltaCoeffs() const
Return reference to non-orthogonal cell-centre difference.
const scalarDiagonalMatrix & S() const
Return the singular values.
virtual bool coupled() const
Return true if this patch field is coupled.
Singular value decomposition of a rectangular matrix.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
void calcFit()
Calculate the fit for all the faces.
scalarRectangularMatrix VSinvUt() const
Return the matrix product V S^(-1) U^T (the pseudo inverse)
const fvPatch & patch() const
Return patch.
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
Polynomial templated on size (order):
Mesh data needed to do the Finite Volume discretisation.
dimensioned< scalar > mag(const dimensioned< Type > &)
const volVectorField & C() const
Return cell centres as volVectorField.
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
#define InfoInFunction
Report an information message using Foam::Info.