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.
This commit is contained in:
Knut Morten Okstad 2022-09-20 14:35:25 +02:00
parent f9370d3e67
commit 6d42ff4e22
3 changed files with 21 additions and 4 deletions

View File

@ -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<double>& getScalars() const { return c; }
//! \brief Returns a pointer to the nodal reaction forces, if any.
const std::vector<double>* getReactions() const { return R.empty() ? 0 : &R; }

View File

@ -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<int,Ipairs>& node : nodeInfo)
for (const std::pair<const int,Ipairs>& 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

View File

@ -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