From ab6d03b14136c56858c3f445e30a95cfdd18895d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 9 Feb 2022 09:33:49 +0100 Subject: [PATCH] added: extend element matrix cache support to mixed --- src/ASM/ASMs2Dmx.C | 6 +++--- src/ASM/ASMs3Dmx.C | 6 +++--- src/ASM/GlbL2projector.C | 4 +++- src/ASM/GlbL2projector.h | 7 +++++++ src/ASM/Integrand.h | 11 +++++++++++ src/ASM/IntegrandBase.C | 10 ++++++++++ src/ASM/IntegrandBase.h | 27 +++++++++++++++++++++++++++ src/ASM/LR/ASMu2Dmx.C | 2 +- src/ASM/LR/ASMu3Dmx.C | 2 +- 9 files changed, 66 insertions(+), 9 deletions(-) diff --git a/src/ASM/ASMs2Dmx.C b/src/ASM/ASMs2Dmx.C index 61e97719..428d94ba 100644 --- a/src/ASM/ASMs2Dmx.C +++ b/src/ASM/ASMs2Dmx.C @@ -589,7 +589,7 @@ bool ASMs2Dmx::integrate (Integrand& integrand, // Initialize element quantities LocalIntegral* A = integrand.getLocalIntegral(elem_size,fe.iel,false); - if (!integrand.initElement(MNPC[iel-1],elem_size,nb,*A)) + if (!integrand.initElement(MNPC[iel-1],fe,elem_size,nb,*A)) { A->destruct(); ok = false; @@ -914,7 +914,7 @@ bool ASMs2Dmx::integrate (Integrand& integrand, // Initialize element quantities LocalIntegral* A = integrand.getLocalIntegral(elem_size,fe.iel); - bool ok = integrand.initElement(MNPC[iel],elem_size,nb,*A); + bool ok = integrand.initElement(MNPC[iel],fe,elem_size,nb,*A); size_t origSize = A->vec.size(); // Loop over the element edges with contributions @@ -935,7 +935,7 @@ bool ASMs2Dmx::integrate (Integrand& integrand, // initialize neighbor element LocalIntegral* A_neigh = integrand.getLocalIntegral(elem_size,kel+1); - ok &= integrand.initElement(MNPC[kel],elem_size,nb,*A_neigh); + ok &= integrand.initElement(MNPC[kel],fe,elem_size,nb,*A_neigh); if (!A_neigh->vec.empty()) { A->vec.resize(origSize+A_neigh->vec.size()); std::copy(A_neigh->vec.begin(), A_neigh->vec.end(), A->vec.begin()+origSize); diff --git a/src/ASM/ASMs3Dmx.C b/src/ASM/ASMs3Dmx.C index ce2b3c97..e5bfd133 100644 --- a/src/ASM/ASMs3Dmx.C +++ b/src/ASM/ASMs3Dmx.C @@ -547,7 +547,7 @@ bool ASMs3Dmx::integrate (Integrand& integrand, // Initialize element quantities LocalIntegral* A = integrand.getLocalIntegral(elem_size,fe.iel,false); - if (!integrand.initElement(MNPC[iel-1],elem_size,nb,*A)) + if (!integrand.initElement(MNPC[iel-1],fe,elem_size,nb,*A)) { A->destruct(); ok = false; @@ -922,7 +922,7 @@ bool ASMs3Dmx::integrate (Integrand& integrand, // Initialize element quantities LocalIntegral* A = integrand.getLocalIntegral(elem_size,fe.iel); - bool ok = integrand.initElement(MNPC[iel],elem_size,nb,*A); + bool ok = integrand.initElement(MNPC[iel],fe,elem_size,nb,*A); size_t origSize = A->vec.size(); // Loop over the element edges with contributions @@ -953,7 +953,7 @@ bool ASMs3Dmx::integrate (Integrand& integrand, // initialize neighbor element LocalIntegral* A_neigh = integrand.getLocalIntegral(elem_size,kel+1); - ok &= integrand.initElement(MNPC[kel],elem_size,nb,*A_neigh); + ok &= integrand.initElement(MNPC[kel],fe,elem_size,nb,*A_neigh); if (!A_neigh->vec.empty()) { A->vec.resize(origSize+A_neigh->vec.size()); std::copy(A_neigh->vec.begin(), A_neigh->vec.end(), A->vec.begin()+origSize); diff --git a/src/ASM/GlbL2projector.C b/src/ASM/GlbL2projector.C index b25fca2a..19a7a269 100644 --- a/src/ASM/GlbL2projector.C +++ b/src/ASM/GlbL2projector.C @@ -315,7 +315,9 @@ bool GlbL2::initElement (const IntVec& MNPC, const FiniteElement& fe, bool GlbL2::initElement (const IntVec& MNPC1, - const uIntVec& elem_sizes, const uIntVec& basis_sizes, + const MxFiniteElement& fe, + const uIntVec& elem_sizes, + const uIntVec& basis_sizes, LocalIntegral& elmInt) { L2Mats& gl2 = static_cast(elmInt); diff --git a/src/ASM/GlbL2projector.h b/src/ASM/GlbL2projector.h index e851fab7..77878e78 100644 --- a/src/ASM/GlbL2projector.h +++ b/src/ASM/GlbL2projector.h @@ -147,15 +147,22 @@ public: LocalIntegral& elmInt); //! \brief Initializes current element for numerical integration (mixed). //! \param[in] MNPC1 Matrix of nodal point correspondance for current element + //! \param[in] fe Nodal and integration point data for current element //! \param[in] elem_sizes Size of each basis on the element //! \param[in] basis_sizes Size of each basis on the patch //! \param elmInt Local integral for element virtual bool initElement(const IntVec& MNPC1, + const MxFiniteElement& fe, const uIntVec& elem_sizes, const uIntVec& basis_sizes, LocalIntegral& elmInt); //! \brief Dummy implementation. + virtual bool initElement(const IntVec& MNPC1, + const uIntVec& elem_sizes, + const uIntVec& basis_sizes, + LocalIntegral& elmInt) { return false; } + //! \brief Dummy implementation. virtual bool initElement(const IntVec&, LocalIntegral&) { return false; } //! \brief Dummy implementation. virtual bool initElementBou(const IntVec&, LocalIntegral&) { return false; } diff --git a/src/ASM/Integrand.h b/src/ASM/Integrand.h index 09470a37..d07c0373 100644 --- a/src/ASM/Integrand.h +++ b/src/ASM/Integrand.h @@ -121,6 +121,17 @@ public: const std::vector& elem_sizes, const std::vector& basis_sizes, LocalIntegral& elmInt) = 0; + //! \brief Initializes current element for numerical integration (mixed). + //! \param[in] MNPC Nodal point correspondance for the bases + //! \param[in] fe Nodal and integration point data for current element + //! \param[in] elem_sizes Size of each basis on the element + //! \param[in] basis_sizes Size of each basis on the patch level + //! \param elmInt Local integral for element + virtual bool initElement(const std::vector& MNPC, + const MxFiniteElement& fe, + const std::vector& elem_sizes, + const std::vector& basis_sizes, + LocalIntegral& elmInt) = 0; //! \brief Initializes current element for boundary integration. //! \param[in] MNPC Matrix of nodal point correspondance for current element diff --git a/src/ASM/IntegrandBase.C b/src/ASM/IntegrandBase.C index f4300152..e047d2df 100644 --- a/src/ASM/IntegrandBase.C +++ b/src/ASM/IntegrandBase.C @@ -159,6 +159,16 @@ bool IntegrandBase::initElement (const std::vector& MNPC, } +bool IntegrandBase::initElement (const std::vector& MNPC, + const MxFiniteElement&, + const std::vector& elem_sizes, + const std::vector& basis_sizes, + LocalIntegral& elmInt) +{ + return this->initElement(MNPC, elem_sizes, basis_sizes, elmInt); +} + + /*! The default implementation extracts the element-level vector only for the first (current) primary solution vector. diff --git a/src/ASM/IntegrandBase.h b/src/ASM/IntegrandBase.h index 86e78775..ba3f9021 100644 --- a/src/ASM/IntegrandBase.h +++ b/src/ASM/IntegrandBase.h @@ -131,6 +131,17 @@ public: const std::vector& elem_sizes, const std::vector& basis_sizes, LocalIntegral& elmInt); + //! \brief Initializes current element for numerical integration (mixed). + //! \param[in] MNPC Matrix of nodal point correspondance for current element + //! \param[in] fe Nodal and integration point data for current element + //! \param[in] elem_sizes Size of each basis on the element + //! \param[in] basis_sizes Size of each basis on the patch + //! \param elmInt Local integral for element + virtual bool initElement(const std::vector& MNPC, + const MxFiniteElement& fe, + const std::vector& elem_sizes, + const std::vector& basis_sizes, + LocalIntegral& elmInt); //! \brief Initializes current element for boundary integration. //! \param[in] MNPC Matrix of nodal point correspondance for current element @@ -359,6 +370,14 @@ public: const std::vector& elem_sizes, const std::vector& basis_sizes, LocalIntegral& elmInt); + //! \brief Initializes current element for numerical integration (mixed). + virtual bool initElement(const std::vector& MNPC, + const MxFiniteElement&, + const std::vector& elem_sizes, + const std::vector& basis_sizes, + LocalIntegral& elmInt) + { return this->initElement(MNPC,elem_sizes,basis_sizes,elmInt); } + //! \brief Initializes current element for boundary integration. virtual bool initElementBou(const std::vector& MNPC, @@ -489,6 +508,14 @@ public: LocalIntegral&) { return false; } + //! \brief Dummy implementation (only boundary integration is relevant). + virtual bool initElement(const std::vector&, + const MxFiniteElement&, + const std::vector&, + const std::vector&, + LocalIntegral&) + { return false; } + //! \brief Initializes current element for boundary integration. virtual bool initElementBou(const std::vector& MNPC, LocalIntegral& elmInt); diff --git a/src/ASM/LR/ASMu2Dmx.C b/src/ASM/LR/ASMu2Dmx.C index 46fb7531..4aa8c8f9 100644 --- a/src/ASM/LR/ASMu2Dmx.C +++ b/src/ASM/LR/ASMu2Dmx.C @@ -363,7 +363,7 @@ bool ASMu2Dmx::integrate (Integrand& integrand, // Initialize element quantities LocalIntegral* A = integrand.getLocalIntegral(elem_sizes,fe.iel,false); - if (!integrand.initElement(MNPC[geoEl-1], elem_sizes, nb, *A)) + if (!integrand.initElement(MNPC[geoEl-1], fe, elem_sizes, nb, *A)) { A->destruct(); ok = false; diff --git a/src/ASM/LR/ASMu3Dmx.C b/src/ASM/LR/ASMu3Dmx.C index 8311165f..82f577da 100644 --- a/src/ASM/LR/ASMu3Dmx.C +++ b/src/ASM/LR/ASMu3Dmx.C @@ -472,7 +472,7 @@ bool ASMu3Dmx::integrate (Integrand& integrand, // Initialize element quantities LocalIntegral* A = integrand.getLocalIntegral(elem_sizes,fe.iel); - if (!integrand.initElement(MNPC[iEl],elem_sizes,nb,*A)) + if (!integrand.initElement(MNPC[iEl],fe,elem_sizes,nb,*A)) { A->destruct(); ok = false;