From bebf8c1313e60d5ac70c8b4f9a58a67f520e7d66 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 4 Oct 2022 12:27:50 +0200 Subject: [PATCH] added: SAM::getUniqueEqns this returns the unique equations for a given element. in particular it resolves MPC couplings --- src/LinAlg/SAM.C | 26 ++++++++++++++++++++++++++ src/LinAlg/SAM.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/src/LinAlg/SAM.C b/src/LinAlg/SAM.C index 30450306..e49f4aa7 100644 --- a/src/LinAlg/SAM.C +++ b/src/LinAlg/SAM.C @@ -720,6 +720,32 @@ bool SAM::getElmEqns (IntVec& meen, int iel, int nedof) const } +bool SAM::getUniqueEqns (IntSet& meen, int iel) const +{ + meen.clear(); + + IntVec meenTmp; + if (!this->getElmEqns(meenTmp, iel)) + return false; + + for (int jeq : meenTmp) + { + if (jeq < 0) + { + int jpmceq1 = mpmceq[-jeq-1]; + int jpmceq2 = mpmceq[-jeq]-1; + for (int jp = jpmceq1; jp < jpmceq2; ++jp) + if (mmceq[jp] > 0) + meen.insert(meqn[mmceq[jp]-1]); + } + else if (jeq != 0) + meen.insert(jeq); + } + + return true; +} + + size_t SAM::getNoElmEqns (int iel) const { size_t result = 0; diff --git a/src/LinAlg/SAM.h b/src/LinAlg/SAM.h index 47daba47..2b1e54c4 100644 --- a/src/LinAlg/SAM.h +++ b/src/LinAlg/SAM.h @@ -196,6 +196,8 @@ public: //! \brief Returns the number equations for an element. //! \param[in] iel Identifier for the element to get number of equations for size_t getNoElmEqns(int iel) const; + //! \brief Finds the matrix of unique equation numbers for an element. + bool getUniqueEqns(IntSet& meen, int iel) const; //! \brief Finds the matrix of equation numbers for a node. //! \param[out] mnen Matrix of node equation numbers