From 1d88adf5af1fc5957acdd245ba203f3274d2d3c9 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 25 Apr 2022 09:52:26 +0200 Subject: [PATCH] added: getProjectedField this returns a scalar field over the projection basis with the given coefficients. --- src/ASM/ASMbase.h | 4 ++++ src/ASM/ASMs2D.C | 13 +++++++++++++ src/ASM/ASMs2D.h | 4 ++++ src/ASM/ASMs3D.C | 13 +++++++++++++ src/ASM/ASMs3D.h | 4 ++++ src/ASM/LR/ASMu2D.C | 13 +++++++++++++ src/ASM/LR/ASMu2D.h | 4 ++++ src/ASM/LR/ASMu2Dmx.C | 4 ++-- src/ASM/LR/ASMu3D.C | 13 +++++++++++++ src/ASM/LR/ASMu3D.h | 4 ++++ 10 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/ASM/ASMbase.h b/src/ASM/ASMbase.h index 9aa806cf..03efba45 100644 --- a/src/ASM/ASMbase.h +++ b/src/ASM/ASMbase.h @@ -670,6 +670,10 @@ public: //! \brief Returns the number of elements on refinement basis for this patch. virtual size_t getNoRefineElms() const { return this->getNoElms(); } + //! \brief Returns a field using the projection basis. + virtual Field* getProjectedField(const Vector&) const + { return nullptr; } + //! \brief Returns a field using the projection basis. virtual Fields* getProjectedFields(const Vector&, size_t) const { return nullptr; } diff --git a/src/ASM/ASMs2D.C b/src/ASM/ASMs2D.C index 5a4d4a89..c17789b2 100644 --- a/src/ASM/ASMs2D.C +++ b/src/ASM/ASMs2D.C @@ -26,6 +26,7 @@ #include "CoordinateMapping.h" #include "GaussQuadrature.h" #include "ElementBlock.h" +#include "SplineField2D.h" #include "SplineFields2D.h" #include "SplineUtils.h" #include "Utilities.h" @@ -3126,6 +3127,18 @@ int ASMs2D::getCorner (int I, int J, int basis) const } +Field* ASMs2D::getProjectedField (const Vector& coefs) const +{ + if (this->getNoProjectionNodes() == coefs.size()) + return new SplineField2D(proj,coefs); + + std::cerr <<" *** ASMs2D::getProjectedField: Non-matching coefficent array," + <<" size="<< coefs.size() <<" nnod="<< this->getNoProjectionNodes() + << std::endl; + return nullptr; +} + + Fields* ASMs2D::getProjectedFields (const Vector& coefs, size_t) const { if (proj == this->getBasis(1) || this->getNoProjectionNodes() == 0) diff --git a/src/ASM/ASMs2D.h b/src/ASM/ASMs2D.h index 5ec7014f..8de7abe1 100644 --- a/src/ASM/ASMs2D.h +++ b/src/ASM/ASMs2D.h @@ -698,6 +698,10 @@ public: void extractBasis(double u, double v, int dir, int p, Vector& dN, bool fromRight = true) const; + //! \brief Returns a field using the projection basis. + //! \param[in] coefs The coefficients for the field + virtual Field* getProjectedField(const Vector& coefs) const; + //! \brief Returns a field using the projection basis. //! \param[in] coefs The coefficients for the field virtual Fields* getProjectedFields(const Vector& coefs, size_t = 0) const; diff --git a/src/ASM/ASMs3D.C b/src/ASM/ASMs3D.C index bbfe2d97..e50bf67e 100644 --- a/src/ASM/ASMs3D.C +++ b/src/ASM/ASMs3D.C @@ -25,6 +25,7 @@ #include "CoordinateMapping.h" #include "GaussQuadrature.h" #include "ElementBlock.h" +#include "SplineField3D.h" #include "SplineFields3D.h" #include "SplineUtils.h" #include "Utilities.h" @@ -3636,6 +3637,18 @@ bool ASMs3D::getFaceSize (int& n1, int& n2, int basis, int face) const } +Field* ASMs3D::getProjectedField (const Vector& coefs) const +{ + if (this->getNoProjectionNodes() == coefs.size()) + return new SplineField3D(proj,coefs); + + std::cerr <<" *** ASMs3D::getProjectedField: Non-matching coefficent array," + <<" size="<< coefs.size() <<" nnod="<< this->getNoProjectionNodes() + << std::endl; + return nullptr; +} + + Fields* ASMs3D::getProjectedFields (const Vector& coefs, size_t) const { if (proj == this->getBasis(1) || this->getNoProjectionNodes() == 0) diff --git a/src/ASM/ASMs3D.h b/src/ASM/ASMs3D.h index 339a9b6e..aedee099 100644 --- a/src/ASM/ASMs3D.h +++ b/src/ASM/ASMs3D.h @@ -775,6 +775,10 @@ public: void extractBasis(double u, double v, double w, int dir, int p, Vector& dN, bool fromRight = true) const; + //! \brief Returns a field using the projection basis. + //! \param[in] coefs The coefficients for the field + virtual Field* getProjectedField(const Vector& coefs) const; + //! \brief Returns a field using the projection basis. //! \param[in] coefs The coefficients for the field virtual Fields* getProjectedFields(const Vector& coefs, size_t = 0) const; diff --git a/src/ASM/LR/ASMu2D.C b/src/ASM/LR/ASMu2D.C index 10bca1f0..38169f60 100644 --- a/src/ASM/LR/ASMu2D.C +++ b/src/ASM/LR/ASMu2D.C @@ -26,6 +26,7 @@ #include "CoordinateMapping.h" #include "GaussQuadrature.h" #include "LagrangeInterpolator.h" +#include "LRSplineField2D.h" #include "LRSplineFields2D.h" #include "ElementBlock.h" #include "MPC.h" @@ -2444,6 +2445,18 @@ bool ASMu2D::separateProjectionBasis () const } +Field* ASMu2D::getProjectedField (const Vector& coefs) const +{ + if (coefs.size() == this->getNoProjectionNodes()) + return new LRSplineField2D(projBasis.get(),coefs); + + std::cerr <<" *** ASMu2D::getProjectedFields: Non-matching coefficent array," + <<" size="<< coefs.size() <<" nnod="<< this->getNoProjectionNodes() + << std::endl; + return nullptr; +} + + Fields* ASMu2D::getProjectedFields (const Vector& coefs, size_t) const { if (projBasis.get() == this->getBasis(1)) diff --git a/src/ASM/LR/ASMu2D.h b/src/ASM/LR/ASMu2D.h index 008f72ed..b7f8ea8d 100644 --- a/src/ASM/LR/ASMu2D.h +++ b/src/ASM/LR/ASMu2D.h @@ -413,6 +413,10 @@ public: //! \brief Checks if a separate projection basis is used for this patch. virtual bool separateProjectionBasis() const; + //! \brief Returns a field using the projection basis. + //! \param[in] coefs The coefficients for the field + virtual Field* getProjectedField(const Vector& coefs) const; + //! \brief Returns a field using the projection basis. //! \param[in] coefs The coefficients for the field virtual Fields* getProjectedFields(const Vector& coefs, size_t = 0) const; diff --git a/src/ASM/LR/ASMu2Dmx.C b/src/ASM/LR/ASMu2Dmx.C index 5908412d..87ae4c61 100644 --- a/src/ASM/LR/ASMu2Dmx.C +++ b/src/ASM/LR/ASMu2Dmx.C @@ -1210,8 +1210,8 @@ void ASMu2Dmx::storeMesh (const std::string& fName, int fType) const } -void ASMu2Dmx::copyRefinement(LR::LRSplineSurface* basis, - int multiplicity) const +void ASMu2Dmx::copyRefinement (LR::LRSplineSurface* basis, + int multiplicity) const { for (const LR::Meshline* line : refBasis->getAllMeshlines()) { int mult = line->multiplicity_ > 1 ? line->multiplicity_ : multiplicity; diff --git a/src/ASM/LR/ASMu3D.C b/src/ASM/LR/ASMu3D.C index 9a51175d..fa3055af 100644 --- a/src/ASM/LR/ASMu3D.C +++ b/src/ASM/LR/ASMu3D.C @@ -26,6 +26,7 @@ #include "CoordinateMapping.h" #include "GaussQuadrature.h" #include "LagrangeInterpolator.h" +#include "LRSplineField3D.h" #include "LRSplineFields3D.h" #include "ElementBlock.h" #include "MPC.h" @@ -2119,6 +2120,18 @@ bool ASMu3D::separateProjectionBasis () const } +Field* ASMu3D::getProjectedField (const Vector& coefs) const +{ + if (coefs.size() == this->getNoProjectionNodes()) + return new LRSplineField3D(projBasis.get(),coefs); + + std::cerr <<" *** ASMu3D::getProjectedFields: Non-matching coefficent array," + <<" size="<< coefs.size() <<" nnod="<< this->getNoProjectionNodes() + << std::endl; + return nullptr; +} + + Fields* ASMu3D::getProjectedFields (const Vector& coefs, size_t) const { if (projBasis.get() == this->getBasis(1)) diff --git a/src/ASM/LR/ASMu3D.h b/src/ASM/LR/ASMu3D.h index d267da85..a5084562 100644 --- a/src/ASM/LR/ASMu3D.h +++ b/src/ASM/LR/ASMu3D.h @@ -404,6 +404,10 @@ public: //! \brief Checks if a separate projection basis is used for this patch. virtual bool separateProjectionBasis() const; + //! \brief Returns a field using the projection basis. + //! \param[in] coefs The coefficients for the field + virtual Field* getProjectedField(const Vector& coefs) const; + //! \brief Returns a field using the projection basis. //! \param[in] coefs The coefficients for the field virtual Fields* getProjectedFields(const Vector& coefs, size_t = 0) const;