Changed: Simply VariationDiminishingSplineApproximation() signature

This commit is contained in:
Knut Morten Okstad 2023-01-10 13:32:37 +01:00
parent 90f7129729
commit 747b21b655
4 changed files with 40 additions and 118 deletions

View File

@ -502,47 +502,32 @@ quasiInterpolation(const Go::BsplineBasis& basis_u,
/*!
\brief Local projection method (Variation Diminishing Spline Approximation).
\param[in] basis_u Basis values in the first parameter direction
\param[in] basis_v Basis values in the second parameter direction
\param[in] par_u Grevielle sites in the first parameter direction
\param[in] par_v Grevielle sites in the second parameter direction
\param[in] surf Spline surface to project onto
\param[in] points Secondary solution field evaluated at Greville points
\param[in] dimension Dimension of the secondary solution field
\param[in] rational Value marks NURBS geometry
\param[in] weights NURBS weights for the projective control points
\return Spline surface object representing the projected field
*/
static Go::SplineSurface*
VariationDiminishingSplineApproximation(const Go::BsplineBasis& basis_u,
const Go::BsplineBasis& basis_v,
const RealArray& par_u,
const RealArray& par_v,
const RealArray& points,
int dimension, bool rational,
const RealArray& weights)
VariationDiminishingSplineApproximation(const Go::SplineSurface* surf,
const RealArray& points, int dimension)
{
// Check input
ASSERT(par_u.size()*par_v.size() == points.size()/dimension);
ASSERT(basis_u.numCoefs() == (int)par_u.size());
ASSERT(basis_v.numCoefs() == (int)par_v.size());
if (!surf->rational()) // Make spline surface
return new Go::SplineSurface(surf->basis(0), surf->basis(1),
points.begin(), dimension);
std::vector<double> local_coefs;
if (rational)
RealArray local_coefs, weights;
size_t k = 0, sizepoints = points.size()/dimension;
local_coefs.reserve((dimension+1)*sizepoints);
surf->getWeights(weights);
for (size_t i = 0; i < sizepoints; i++)
{
size_t sizepoints = par_u.size()*par_v.size();
size_t countpoints = 0;
for (size_t i = 0; i < sizepoints; i++)
{
for (int j = 0; j < dimension; j++, countpoints++)
local_coefs.push_back(points[countpoints]*weights[i]);
local_coefs.push_back(weights[i]);
}
for (int j = 0; j < dimension; j++, k++)
local_coefs.push_back(points[k]*weights[i]);
local_coefs.push_back(weights[i]);
}
else
local_coefs = points;
// Make surface
return new Go::SplineSurface(basis_u, basis_v, local_coefs.begin(),
dimension, rational);
// Make rational spline surface
return new Go::SplineSurface(surf->basis(0), surf->basis(1),
local_coefs.begin(), dimension, true);
}

View File

@ -491,8 +491,6 @@ bool ASMs2D::evaluate (const Field* field, RealArray& vec, int basisNum) const
for (double u : gpar[0])
sValues.push_back(field->valueFE(ItgPoint(u,v)));
Go::SplineSurface* surf = this->getBasis(basisNum);
// Project the results onto the spline basis to find control point
// values based on the result values evaluated at the Greville points.
// Note that we here implicitly assume that the number of Greville points
@ -500,16 +498,8 @@ bool ASMs2D::evaluate (const Field* field, RealArray& vec, int basisNum) const
// the result array. Think that is always the case, but beware if trying
// other projection schemes later.
RealArray weights;
if (surf->rational())
surf->getWeights(weights);
Go::SplineSurface* surf_new =
VariationDiminishingSplineApproximation(surf->basis(0),
surf->basis(1),
gpar[0], gpar[1],
sValues, 1, surf->rational(),
weights);
VariationDiminishingSplineApproximation(this->getBasis(basisNum),sValues,1);
vec.assign(surf_new->coefs_begin(),surf_new->coefs_end());
delete surf_new;
@ -616,15 +606,6 @@ Go::SplineSurface* ASMs2D::projectSolutionLocalApprox (const IntegrandBase& inte
if (!this->evalSolution(sValues,integrand,gpar.data()))
return nullptr;
RealArray weights;
if (surf->rational())
surf->getWeights(weights);
return VariationDiminishingSplineApproximation(surf->basis(0),
surf->basis(1),
gpar[0], gpar[1],
sValues,
sValues.rows(),
surf->rational(),
weights);
// Project onto the geometry basis
return VariationDiminishingSplineApproximation(surf,sValues,sValues.rows());
}

View File

@ -724,55 +724,32 @@ quasiInterpolation(const Go::BsplineBasis& basis_u,
/*!
\brief Local projection method (Variation Diminishing Spline Approximation).
\param[in] basis_u Basis values in the first parameter direction
\param[in] basis_v Basis values in the second parameter direction
\param[in] basis_w Basis values in the third parameter direction
\param[in] par_u Grevielle sites in the first parameter direction
\param[in] par_v Grevielle sites in the second parameter direction
\param[in] par_w Grevielle sites in the third parameter direction
\param[in] svol Spline volume to project onto
\param[in] points Secondary solution field evaluated at Greville points
\param[in] dimension Dimension of the secondary solution field
\param[in] rational Value marks NURBS geometry
\param[in] weights NURBS weights for the projective control points
\return Spline volume object representing the projected field
\note VariationDiminishingSplineApproximation only for function values!
*/
static Go::SplineVolume*
VariationDiminishingSplineApproximation(const Go::BsplineBasis& basis_u,
const Go::BsplineBasis& basis_v,
const Go::BsplineBasis& basis_w,
const RealArray& par_u,
const RealArray& par_v,
const RealArray& par_w,
const RealArray& points,
int dimension, bool rational,
const RealArray& weights)
VariationDiminishingSplineApproximation(const Go::SplineVolume* svol,
const RealArray& points, int dimension)
{
// Check input
ASSERT(par_u.size()*par_v.size()*par_w.size() == points.size()/dimension);
ASSERT(basis_u.numCoefs() == (int)par_u.size());
ASSERT(basis_v.numCoefs() == (int)par_v.size());
ASSERT(basis_w.numCoefs() == (int)par_w.size());
if (!svol->rational()) // Make spline surface
return new Go::SplineVolume(svol->basis(0), svol->basis(1), svol->basis(2),
points.begin(), dimension);
std::vector<double> local_coefs;
if (rational)
RealArray local_coefs, weights;
size_t k = 0, sizepoints = points.size()/dimension;
local_coefs.reserve((dimension+1)*sizepoints);
svol->getWeights(weights);
for (size_t i = 0; i < sizepoints; i++)
{
ASSERT(weights.size() == points.size()/dimension);
size_t sizepoints = par_u.size()*par_v.size()*par_w.size();
size_t countpoints = 0;
for (size_t i = 0; i < sizepoints; i++)
{
for (int j = 0; j < dimension; j++, countpoints++)
local_coefs.push_back(points[countpoints]*weights[i]);
local_coefs.push_back(weights[i]);
}
for (int j = 0; j < dimension; j++, k++)
local_coefs.push_back(points[k]*weights[i]);
local_coefs.push_back(weights[i]);
}
else
local_coefs = points;
// Make volume
return new Go::SplineVolume(basis_u, basis_v, basis_w, local_coefs.begin(),
dimension, rational);
// Make rational spline volume
return new Go::SplineVolume(svol->basis(0), svol->basis(1), svol->basis(2),
local_coefs.begin(), dimension, true);
}

View File

@ -337,8 +337,6 @@ bool ASMs3D::evaluate (const Field* field, RealArray& vec, int basisNum) const
for (double u : gpar[0])
sValues.push_back(field->valueFE(ItgPoint(u,v,w)));
Go::SplineVolume* svol = this->getBasis(basisNum);
// Project the results onto the spline basis to find control point
// values based on the result values evaluated at the Greville points.
// Note that we here implicitly assume that the number of Greville points
@ -346,17 +344,8 @@ bool ASMs3D::evaluate (const Field* field, RealArray& vec, int basisNum) const
// the result array. Think that is always the case, but beware if trying
// other projection schemes later.
RealArray weights;
if (svol->rational())
svol->getWeights(weights);
Go::SplineVolume* vol_new =
VariationDiminishingSplineApproximation(svol->basis(0),
svol->basis(1),
svol->basis(2),
gpar[0], gpar[1], gpar[2],
sValues, 1, svol->rational(),
weights);
VariationDiminishingSplineApproximation(this->getBasis(basisNum),sValues,1);
vec.assign(vol_new->coefs_begin(),vol_new->coefs_end());
delete vol_new;
@ -464,16 +453,6 @@ Go::SplineVolume* ASMs3D::projectSolutionLocalApprox(const IntegrandBase& integr
if (!this->evalSolution(sValues,integrand,gpar.data()))
return nullptr;
RealArray weights;
if (svol->rational())
svol->getWeights(weights);
return VariationDiminishingSplineApproximation(svol->basis(0),
svol->basis(1),
svol->basis(2),
gpar[0], gpar[1], gpar[2],
sValues,
sValues.rows(),
svol->rational(),
weights);
// Project onto the geometry basis
return VariationDiminishingSplineApproximation(svol,sValues,sValues.rows());
}