ASMu2Dmx: add rational support

This commit is contained in:
Arne Morten Kvarving 2023-05-24 08:52:47 +02:00
parent 6a227741d6
commit 933bc34944
2 changed files with 32 additions and 19 deletions

View File

@ -653,6 +653,14 @@ protected:
//! \brief Generate bezier extraction operators.
void generateBezierExtraction();
//! \brief Write NURBS elements as postscript file.
void writePostscriptElementsNurbs (std::shared_ptr<LR::LRSplineSurface> mesh,
std::ostream& out, bool close = true,
int nu = 2, int nv = 2);
//! \brief Write NURBS elements as postscript file.
void writePostscriptMeshWithControlPointsNurbs (std::shared_ptr<LR::LRSplineSurface> mesh,
std::ostream& out, int nu = 2, int nv = 2);
public:
//! \brief Returns the number of elements on a boundary.
virtual size_t getNoBoundaryElms(char lIndex, char ldim) const;
@ -721,14 +729,6 @@ private:
//! \param[in] derivs Derivative order of the basis functions
bool evaluateBasisNurbs(int iel, FiniteElement& fe,
int derivs) const;
//! \brief Write NURBS elements as postscript file.
void writePostscriptElementsNurbs (std::shared_ptr<LR::LRSplineSurface> mesh,
std::ostream& out, bool close = true,
int nu = 2, int nv = 2);
//! \brief Write NURBS elements as postscript file.
void writePostscriptMeshWithControlPointsNurbs (std::shared_ptr<LR::LRSplineSurface> mesh,
std::ostream& out, int nu = 2, int nv = 2);
};
#endif

View File

@ -201,9 +201,15 @@ bool ASMu2Dmx::generateFEMTopology ()
if (!myMLGN.empty())
return true;
auto createLR = [this](Go::SplineSurface& srf)
{
return srf.rational() ? this->createLRNurbs(srf)
: new LR::LRSplineSurface(&srf);
};
if (tensorPrjBas)
{
projBasis.reset(new LR::LRSplineSurface(tensorPrjBas));
projBasis.reset(createLR(*tensorPrjBas));
delete tensorPrjBas;
tensorPrjBas = nullptr;
}
@ -212,7 +218,7 @@ bool ASMu2Dmx::generateFEMTopology ()
SurfaceVec svec = ASMmxBase::establishBases(tensorspline, ASMmxBase::Type);
m_basis.resize(svec.size());
for (size_t b = 0; b < svec.size(); b++)
m_basis[b].reset(new LR::LRSplineSurface(svec[b].get()));
m_basis[b].reset(createLR(*svec[b]));
// we need to project on something that is not one of our bases
if (ASMmxBase::Type == ASMmxBase::REDUCED_CONT_RAISE_BASIS1 ||
@ -224,14 +230,14 @@ bool ASMu2Dmx::generateFEMTopology ()
otherBasis = ASMmxBase::raiseBasis(tensorspline);
if (ASMmxBase::Type == ASMmxBase::SUBGRID) {
refBasis.reset(new LR::LRSplineSurface(otherBasis));
refBasis.reset(createLR(*otherBasis));
if (!projBasis)
projBasis = m_basis.front();
altProjBasis = refBasis;
}
else {
if (!projBasis)
projBasis.reset(new LR::LRSplineSurface(otherBasis));
projBasis.reset(createLR(*otherBasis));
refBasis = projBasis;
}
delete otherBasis;
@ -242,6 +248,7 @@ bool ASMu2Dmx::generateFEMTopology ()
refBasis = projBasis;
}
is_rational = tensorspline->rational();
delete tensorspline;
tensorspline = nullptr;
}
@ -1183,7 +1190,7 @@ size_t ASMu2Dmx::getNoRefineElms() const
void ASMu2Dmx::storeMesh (const std::string& fName, int fType) const
{
auto&& writeBasis = [fName,fType](const LR::LRSplineSurface* patch,
auto&& writeBasis = [fName,fType,this](std::shared_ptr<LR::LRSplineSurface> patch,
const std::string& tag)
{
std::string fileName = "_patch_" + tag + "_" + fName + ".eps";
@ -1193,6 +1200,9 @@ void ASMu2Dmx::storeMesh (const std::string& fName, int fType) const
}
if ((fType/2)%2) {
std::ofstream meshFile("physical"+fileName);
if (is_rational)
const_cast<ASMu2Dmx*>(this)->writePostscriptElementsNurbs(patch, meshFile);
else
patch->writePostscriptElements(meshFile);
}
if ((fType/4)%2) {
@ -1201,6 +1211,9 @@ void ASMu2Dmx::storeMesh (const std::string& fName, int fType) const
}
if ((fType/8)%2) {
std::ofstream meshFile("physical_dot"+fileName);
if (is_rational)
const_cast<ASMu2Dmx*>(this)->writePostscriptMeshWithControlPointsNurbs(patch, meshFile);
else
patch->writePostscriptMeshWithControlPoints(meshFile);
}
};
@ -1208,11 +1221,11 @@ void ASMu2Dmx::storeMesh (const std::string& fName, int fType) const
std::string btag("basis1");
for (const auto& patch : m_basis)
{
writeBasis(patch.get(), btag);
writeBasis(patch, btag);
++btag.back();
}
writeBasis(projBasis.get(), "proj");
writeBasis(refBasis.get(), "ref");
writeBasis(projBasis, "proj");
writeBasis(refBasis, "ref");
}