33 template<
class Polynomial>
38 const scalar linearLimitFactor,
39 const scalar centralWeight
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];
119 Polynomial::addCoeffs(
B[ip], d, wts[ip], this->dim());
123 for (
label i = 0; i <
B.m(); i++)
130 label stencilSize =
C.size();
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>
211 const fvMesh& mesh = this->mesh();
217 this->stencil().collectData(mesh.
C(), stencilPoints);
229 stencilPoints[facei],
253 stencilPoints[facei],
static const Foam::dimensionedScalar B("B", Foam::dimless, 18.678)
#define forAll(list, i)
Loop across all elements in list.
Graphite solid properties.
Data for centred fit snGrad schemes.
void calcFit()
Calculate the fit for all the faces.
CentredFitSnGradData(const fvMesh &mesh, const extendedCentredCellToFaceStencil &stencil, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Generic GeometricBoundaryField class.
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void setSize(const label)
Reset size of List.
Polynomial templated on size (order):
Singular value decomposition of a rectangular matrix.
scalarRectangularMatrix VSinvUt() const
Return the matrix product V S^(-1) U^T (the pseudo inverse)
const scalarDiagonalMatrix & S() const
Return the singular values.
Mesh data needed to do the Finite Volume discretisation.
const volVectorField & C() const
Return cell centres.
virtual label start() const
Return start label of this patch in the polyMesh face list.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
virtual bool coupled() const
Return true if this patch field is coupled.
const fvPatch & patch() const
Return patch.
label nInternalFaces() const
const surfaceScalarField & nonOrthDeltaCoeffs() const
Return reference to non-orthogonal cell-centre difference.
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
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)