From 6d42ff4e2206ca49e9085319e59fc96bdad6db0b Mon Sep 17 00:00:00 2001 From: Knut Morten Okstad Date: Tue, 20 Sep 2022 14:35:25 +0200 Subject: [PATCH] Added: AlgEqSystem methods addScalar() and getScalars(), and the SIMbase method extractScalars(). The latter is a generalization and replacement of the virtual method getExtLoad() which is no longer needed. --- src/ASM/AlgEqSystem.h | 4 ++++ src/SIM/SIMbase.C | 17 +++++++++++++++-- src/SIM/SIMbase.h | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/ASM/AlgEqSystem.h b/src/ASM/AlgEqSystem.h index 95e75d01..1d06e73e 100644 --- a/src/ASM/AlgEqSystem.h +++ b/src/ASM/AlgEqSystem.h @@ -84,6 +84,10 @@ public: SystemVector* getVector(size_t i = 0) { return i < b.size() ? b[i] : 0; } //! \brief Returns the \a i'th scalar quantity. double getScalar(size_t i = 0) { return i < c.size() ? c[i] : 0.0; } + //! \brief Adds the value \a s to the \a i'th scalar quantity. + void addScalar(double s, size_t i = 0) { if (i < c.size()) c[i] += s; } + //! \brief Returns a const reference to the assembled scalars. + const std::vector& getScalars() const { return c; } //! \brief Returns a pointer to the nodal reaction forces, if any. const std::vector* getReactions() const { return R.empty() ? 0 : &R; } diff --git a/src/SIM/SIMbase.C b/src/SIM/SIMbase.C index 6e7449c6..9ff36f3d 100644 --- a/src/SIM/SIMbase.C +++ b/src/SIM/SIMbase.C @@ -177,7 +177,7 @@ static void printNodalConnectivity (const ASMVec& model, std::ostream& os) for (size_t n = 1; n <= pch->getNoNodes(); n++) nodeInfo[pch->getNodeID(n)].push_back(std::make_pair(pch->idx,n)); - for (const std::pair& node : nodeInfo) + for (const std::pair& node : nodeInfo) if (node.second.size() > 1) { os <<"\nConnectivity for node "<< node.first <<":"; @@ -1170,6 +1170,19 @@ bool SIMbase::extractLoadVec (Vector& loadVec, size_t idx, const char* hd) const } +bool SIMbase::extractScalars (RealArray& values) const +{ + if (!myEqSys) return false; + + values = myEqSys->getScalars(); + for (double v : values) + if (fabs(v) > utl::zero_print_tol) + return true; + + return false; // All scalars are zero +} + + double SIMbase::extractScalar (size_t idx) const { return myEqSys ? myEqSys->getScalar(idx) : 0.0; @@ -1658,7 +1671,7 @@ bool SIMbase::solutionNorms (const TimeDomain& time, gNorm.reserve(norm->getNoFields(0)+1); gNorm.resize(norm->getNoFields(0)); size_t nNorms = 0; - auto proj_idx = opt.project.begin(); + SIMoptions::ProjectionMap::const_iterator proj_idx = opt.project.begin(); // count norms if they are: // 1) associated with the primary solution // 2) associated with a projected secondary solution diff --git a/src/SIM/SIMbase.h b/src/SIM/SIMbase.h index ca9e270b..2fcc092e 100644 --- a/src/SIM/SIMbase.h +++ b/src/SIM/SIMbase.h @@ -291,6 +291,8 @@ public: //! \param[in] hd Header for outprint of resultant bool extractLoadVec(Vector& loadVec, size_t idx = 0, const char* hd = nullptr) const; + //! \brief Extracts the assembled global scalar quantities. + bool extractScalars(RealArray& values) const; //! \brief Extracts an assembled global scalar quantity. double extractScalar(size_t idx = 0) const; @@ -456,8 +458,6 @@ public: bool haveReactions(int pcode = 0) const; //! \brief Returns current reaction force container. virtual const RealArray* getReactionForces() const; - //! \brief Computes the total external load of current time/load step. - virtual bool getExtLoad(RealArray&, const TimeDomain&) const { return false; } //! \brief Performs a generalized eigenvalue analysis of the assembled system. //! \param[in] iop Which eigensolver method to use