From 15daa0ae923c41a56ecb5b20f2b61bb9bc1bde85 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 10 Jul 2020 14:49:05 +0200 Subject: [PATCH] added: write methods to ASMxDLag/Tri (mainly) used for storing the FEM models in HDF5 --- src/ASM/ASMbase.C | 15 +++++++++++++++ src/ASM/ASMbase.h | 3 +++ src/ASM/ASMs1DLag.C | 6 ++++++ src/ASM/ASMs1DLag.h | 3 +++ src/ASM/ASMs2DLag.C | 6 ++++++ src/ASM/ASMs2DLag.h | 3 +++ src/ASM/ASMs2DTri.C | 6 ++++++ src/ASM/ASMs2DTri.h | 3 +++ src/ASM/ASMs3DLag.C | 6 ++++++ src/ASM/ASMs3DLag.h | 3 +++ 10 files changed, 54 insertions(+) diff --git a/src/ASM/ASMbase.C b/src/ASM/ASMbase.C index fe2d67a9..d45e5371 100644 --- a/src/ASM/ASMbase.C +++ b/src/ASM/ASMbase.C @@ -1457,3 +1457,18 @@ bool ASMbase::evaluate (const FunctionBase*, RealArray&, int, double) const { return Aerror("evaluate(const FunctionBase*,RealArray&,int,double)"); } + + +bool ASMbase::writeLagBasis (std::ostream& os, const char* type) const +{ + os << "# LAGRANGIAN nodes=" << this->getNoNodes() + << " elements=" << this->getNoElms() + << " type=" << type << "\n"; + for (size_t i = 1; i <= this->getNoNodes(); ++i) + os << this->getCoord(i) << "\n"; + for (const IntVec& mnpc : MNPC) + for (size_t i = 0; i < mnpc.size(); ++i) + os << mnpc[i] << (i+1 == mnpc.size() ? '\n' : ' '); + + return true; +} diff --git a/src/ASM/ASMbase.h b/src/ASM/ASMbase.h index 2b2c0c00..2c33e1f2 100644 --- a/src/ASM/ASMbase.h +++ b/src/ASM/ASMbase.h @@ -811,6 +811,9 @@ protected: //! is changed into the number of the other node. static bool collapseNodes(ASMbase& pch1, int node1, ASMbase& pch2, int node2); + //! \brief Write a lagrangian basis to given stream. + bool writeLagBasis(std::ostream& os, const char* type) const; + public: static bool fixHomogeneousDirichlet; //!< If \e true, pre-eliminate fixed DOFs diff --git a/src/ASM/ASMs1DLag.C b/src/ASM/ASMs1DLag.C index 3142f65a..9c2fb2f6 100644 --- a/src/ASM/ASMs1DLag.C +++ b/src/ASM/ASMs1DLag.C @@ -554,3 +554,9 @@ bool ASMs1DLag::evalSolution (Matrix& sField, const IntegrandBase& integrand, return true; } + + +bool ASMs1DLag::write(std::ostream& os, int) const +{ + return this->writeLagBasis(os, "line"); +} diff --git a/src/ASM/ASMs1DLag.h b/src/ASM/ASMs1DLag.h index 6b74d121..8deda034 100644 --- a/src/ASM/ASMs1DLag.h +++ b/src/ASM/ASMs1DLag.h @@ -39,6 +39,9 @@ public: // Methods for model generation // ============================ + //! \brief Writes the FEM basis to given stream. + virtual bool write(std::ostream& os, int = 0) const; + //! \brief Generates a beam finite element model for the patch. //! \param[in] Zaxis Vector defining a point in the local XZ-plane virtual bool generateOrientedFEModel(const Vec3& Zaxis); diff --git a/src/ASM/ASMs2DLag.C b/src/ASM/ASMs2DLag.C index f870d805..39d18d0a 100644 --- a/src/ASM/ASMs2DLag.C +++ b/src/ASM/ASMs2DLag.C @@ -765,3 +765,9 @@ void ASMs2DLag::generateThreadGroups (const Integrand&, bool, bool) { threadGroups.calcGroups((nx-1)/(p1-1),(ny-1)/(p2-1),1); } + + +bool ASMs2DLag::write(std::ostream& os, int) const +{ + return this->writeLagBasis(os, "quad"); +} diff --git a/src/ASM/ASMs2DLag.h b/src/ASM/ASMs2DLag.h index 40e6dc46..d4cb896f 100644 --- a/src/ASM/ASMs2DLag.h +++ b/src/ASM/ASMs2DLag.h @@ -39,6 +39,9 @@ public: // Methods for model generation // ============================ + //! \brief Writes the FEM basis to given stream. + virtual bool write(std::ostream& os, int = 0) const; + //! \brief Generates the finite element topology data for the patch. //! \details The data generated are the element-to-node connectivity array, //! the nodal coordinate array, as well as global node and element numbers. diff --git a/src/ASM/ASMs2DTri.C b/src/ASM/ASMs2DTri.C index 7fa74299..749de891 100644 --- a/src/ASM/ASMs2DTri.C +++ b/src/ASM/ASMs2DTri.C @@ -597,3 +597,9 @@ void ASMs2DTri::generateThreadGroups (const Integrand&, bool, bool) #endif } } + + +bool ASMs2DTri::write(std::ostream& os, int) const +{ + return this->writeLagBasis(os, "triangle"); +} diff --git a/src/ASM/ASMs2DTri.h b/src/ASM/ASMs2DTri.h index 5db9ebf1..c47e9507 100644 --- a/src/ASM/ASMs2DTri.h +++ b/src/ASM/ASMs2DTri.h @@ -38,6 +38,9 @@ public: // Methods for model generation // ============================ + //! \brief Writes the FEM basis to given stream. + virtual bool write(std::ostream& os, int = 0) const; + //! \brief Generates the finite element topology data for the patch. //! \details The data generated are the element-to-node connectivity array, //! the nodal coordinate array, as well as global node and element numbers. diff --git a/src/ASM/ASMs3DLag.C b/src/ASM/ASMs3DLag.C index 6d350b64..c3afa624 100644 --- a/src/ASM/ASMs3DLag.C +++ b/src/ASM/ASMs3DLag.C @@ -1090,3 +1090,9 @@ bool ASMs3DLag::getGridParameters (RealArray& prm, int dir, int nSegPerSpan) con return true; } + + +bool ASMs3DLag::write(std::ostream& os, int) const +{ + return this->writeLagBasis(os, "hexahedron"); +} diff --git a/src/ASM/ASMs3DLag.h b/src/ASM/ASMs3DLag.h index b75f6ca7..def594e4 100644 --- a/src/ASM/ASMs3DLag.h +++ b/src/ASM/ASMs3DLag.h @@ -39,6 +39,9 @@ public: // Methods for model generation // ============================ + //! \brief Writes the FEM basis to given stream. + virtual bool write(std::ostream& os, int = 0) const; + //! \brief Generates the finite element topology data for the patch. //! \details The data generated are the element-to-node connectivity array, //! the nodal coordinate array, as well as global node and element numbers.