ASMuxD(mx): add an if in ASMuxD basis function cache
this way we avoid duplication of the class in ASMuxDmx
This commit is contained in:
@@ -3112,6 +3112,11 @@ BasisFunctionVals ASMu2D::BasisFunctionCache::calculatePt (size_t el,
|
||||
double u = this->getParam(0,el,gpIdx[0],reduced);
|
||||
double v = this->getParam(1,el,gpIdx[1],reduced);
|
||||
|
||||
if (patch.lrspline.get() != patch.getBasis(basis)) {
|
||||
const LR::Element* el1 = patch.lrspline->getElement(el);
|
||||
el = patch.getBasis(basis)->getElementContaining(el1->midpoint());
|
||||
}
|
||||
|
||||
BasisFunctionVals result;
|
||||
if (nderiv == 1 || reduced) {
|
||||
Go::BasisDerivsSf spline;
|
||||
|
||||
@@ -1226,34 +1226,6 @@ void ASMu2Dmx::getElementsAt (const RealArray& param,
|
||||
}
|
||||
|
||||
|
||||
BasisFunctionVals ASMu2Dmx::BasisFunctionCache::calculatePt (size_t el,
|
||||
size_t gp,
|
||||
bool reduced) const
|
||||
{
|
||||
const std::array<size_t,2> gpIdx = this->gpIndex(gp,reduced);
|
||||
double u = this->getParam(0,el,gpIdx[0],reduced);
|
||||
double v = this->getParam(1,el,gpIdx[1],reduced);
|
||||
|
||||
const ASMu2Dmx& pch = static_cast<const ASMu2Dmx&>(patch);
|
||||
|
||||
const LR::Element* el1 = pch.getBasis(ASMmxBase::itgBasis)->getElement(el);
|
||||
size_t el_b = patch.getBasis(basis)->getElementContaining(el1->midpoint());
|
||||
|
||||
BasisFunctionVals result;
|
||||
if (nderiv == 1 || reduced) {
|
||||
Go::BasisDerivsSf spline;
|
||||
pch.computeBasis(u,v,spline,el_b,patch.getBasis(basis));
|
||||
SplineUtils::extractBasis(spline,result.N,result.dNdu);
|
||||
} else if (nderiv == 2) {
|
||||
Go::BasisDerivsSf2 spline;
|
||||
pch.computeBasis(u,v,spline,el_b,patch.getBasis(basis));
|
||||
SplineUtils::extractBasis(spline,result.N,result.dNdu,result.d2Ndu2);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool ASMu2Dmx::separateProjectionBasis () const
|
||||
{
|
||||
return std::none_of(m_basis.begin(), m_basis.end(),
|
||||
|
||||
@@ -30,33 +30,6 @@
|
||||
|
||||
class ASMu2Dmx : public ASMu2D, private ASMmxBase
|
||||
{
|
||||
protected:
|
||||
//! \brief Implementation of basis function cache.
|
||||
class BasisFunctionCache : public ASMu2D::BasisFunctionCache
|
||||
{
|
||||
public:
|
||||
//! \brief The constructor initializes the class.
|
||||
//! \param pch Patch the cache is for
|
||||
//! \param plcy Cache policy to use
|
||||
//! \param b Basis to use
|
||||
BasisFunctionCache(const ASMu2D& pch,
|
||||
ASM::CachePolicy plcy, int b)
|
||||
: ASMu2D::BasisFunctionCache(pch,plcy,b) {}
|
||||
|
||||
//! \brief Constructor reusing quadrature info from another instance.
|
||||
//! \param cache Instance holding quadrature information
|
||||
//! \param b Basis to use
|
||||
BasisFunctionCache(const BasisFunctionCache& cache, int b)
|
||||
: ASMu2D::BasisFunctionCache(cache,b) {}
|
||||
|
||||
protected:
|
||||
//! \brief Calculates basis function info in a single integration point.
|
||||
//! \param el Element of integration point (0-indexed)
|
||||
//! \param gp Integration point on element (0-indexed)
|
||||
//! \param reduced If true, returns values for reduced integration scheme
|
||||
BasisFunctionVals calculatePt(size_t el, size_t gp, bool reduced) const override;
|
||||
};
|
||||
|
||||
public:
|
||||
//! \brief The constructor initializes the dimension of each basis.
|
||||
ASMu2Dmx(unsigned char n_s, const CharVec& n_f);
|
||||
|
||||
@@ -2568,9 +2568,12 @@ BasisFunctionVals ASMu3D::BasisFunctionCache::calculatePt (size_t el,
|
||||
|
||||
const LR::Element* elm = patch.lrspline->getElement(el);
|
||||
std::array<double,3> du;
|
||||
du[0] = elm->umax() - elm->umin();
|
||||
du[1] = elm->vmax() - elm->vmin();
|
||||
du[2] = elm->wmax() - elm->wmin();
|
||||
du[0] = 0.5*(elm->umax() - elm->umin());
|
||||
du[1] = 0.5*(elm->vmax() - elm->vmin());
|
||||
du[2] = 0.5*(elm->wmax() - elm->wmin());
|
||||
|
||||
if (patch.lrspline.get() != patch.getBasis(basis))
|
||||
el = patch.getBasis(basis)->getElementContaining(elm->midpoint());
|
||||
|
||||
return this->calculatePrm(fe,du,el,gp,reduced);
|
||||
}
|
||||
@@ -2582,20 +2585,19 @@ calculatePrm (FiniteElement& fe,
|
||||
size_t el, size_t gp, bool reduced) const
|
||||
{
|
||||
BasisFunctionVals result;
|
||||
const BezierExtract& b = reduced ? reducedB : mainB;
|
||||
RealArray extrMat;
|
||||
patch.getBasis(basis)->getBezierExtraction(el,extrMat);
|
||||
Matrix C;
|
||||
const LR::Element* elm = patch.getBasis(basis)->getElement(el);
|
||||
C.resize(elm->nBasisFunctions(), b.N.rows());
|
||||
C.fill(extrMat.data(),extrMat.size());
|
||||
|
||||
if (nderiv == 1 || reduced) {
|
||||
const BezierExtract& b = reduced ? reducedB : mainB;
|
||||
RealArray extrMat;
|
||||
patch.getBasis(basis)->getBezierExtraction(el,extrMat);
|
||||
Matrix C;
|
||||
const LR::Element* elm = patch.getBasis(basis)->getElement(el);
|
||||
C.resize(elm->nBasisFunctions(), b.N.rows());
|
||||
C.fill(extrMat.data(),extrMat.size());
|
||||
Matrix B(b.N.rows(), 4);
|
||||
B.fillColumn(1, b.N.getColumn(gp+1));
|
||||
B.fillColumn(2, b.dNdu.getColumn(gp+1)*2.0/du[0]);
|
||||
B.fillColumn(3, b.dNdv.getColumn(gp+1)*2.0/du[1]);
|
||||
B.fillColumn(4, b.dNdw.getColumn(gp+1)*2.0/du[2]);
|
||||
B.fillColumn(2, b.dNdu.getColumn(gp+1) / du[0]);
|
||||
B.fillColumn(3, b.dNdv.getColumn(gp+1) / du[1]);
|
||||
B.fillColumn(4, b.dNdw.getColumn(gp+1) / du[2]);
|
||||
|
||||
patch.evaluateBasis(result.N, result.dNdu, C, B);
|
||||
} else if (nderiv == 2)
|
||||
|
||||
@@ -1037,31 +1037,6 @@ void ASMu3Dmx::getElementsAt (const RealArray& param,
|
||||
}
|
||||
|
||||
|
||||
BasisFunctionVals ASMu3Dmx::BasisFunctionCache::calculatePt (size_t el,
|
||||
size_t gp,
|
||||
bool reduced) const
|
||||
{
|
||||
PROFILE2("Spline evaluation");
|
||||
const std::array<size_t,3> gpIdx = this->gpIndex(gp,reduced);
|
||||
FiniteElement fe;
|
||||
fe.u = this->getParam(0,el,gpIdx[0],reduced);
|
||||
fe.v = this->getParam(1,el,gpIdx[1],reduced);
|
||||
fe.w = this->getParam(2,el,gpIdx[2],reduced);
|
||||
|
||||
const ASMu3Dmx& pch = static_cast<const ASMu3Dmx&>(patch);
|
||||
|
||||
const LR::Element* elm = pch.lrspline->getElement(el);
|
||||
std::array<double,3> du;
|
||||
du[0] = elm->umax() - elm->umin();
|
||||
du[1] = elm->vmax() - elm->vmin();
|
||||
du[2] = elm->wmax() - elm->wmin();
|
||||
|
||||
el = pch.getBasis(basis)->getElementContaining(elm->midpoint());
|
||||
|
||||
return this->calculatePrm(fe,du,el,gp,reduced);
|
||||
}
|
||||
|
||||
|
||||
bool ASMu3Dmx::separateProjectionBasis () const
|
||||
{
|
||||
return std::none_of(m_basis.begin(), m_basis.end(),
|
||||
|
||||
@@ -30,33 +30,6 @@
|
||||
|
||||
class ASMu3Dmx : public ASMu3D, private ASMmxBase
|
||||
{
|
||||
protected:
|
||||
//! \brief Implementation of basis function cache.
|
||||
class BasisFunctionCache : public ASMu3D::BasisFunctionCache
|
||||
{
|
||||
public:
|
||||
//! \brief The constructor initializes the class.
|
||||
//! \param pch Patch the cache is for
|
||||
//! \param plcy Cache policy to use
|
||||
//! \param b Basis to use
|
||||
BasisFunctionCache(const ASMu3D& pch,
|
||||
ASM::CachePolicy plcy, int b)
|
||||
: ASMu3D::BasisFunctionCache(pch,plcy,b) {}
|
||||
|
||||
//! \brief Constructor reusing quadrature info from another instance.
|
||||
//! \param cache Instance holding quadrature information
|
||||
//! \param b Basis to use
|
||||
BasisFunctionCache(const BasisFunctionCache& cache, int b)
|
||||
: ASMu3D::BasisFunctionCache(cache,b) {}
|
||||
|
||||
protected:
|
||||
//! \brief Calculates basis function info in a single integration point.
|
||||
//! \param el Element of integration point (0-indexed)
|
||||
//! \param gp Integratin point on element (0-indexed)
|
||||
//! \param reduced If true, returns values for reduced integration scheme
|
||||
BasisFunctionVals calculatePt(size_t el, size_t gp, bool reduced) const override;
|
||||
};
|
||||
|
||||
public:
|
||||
//! \brief The constructor initializes the dimension of each basis.
|
||||
explicit ASMu3Dmx(const CharVec& n_f);
|
||||
|
||||
Reference in New Issue
Block a user