Added: Convenience method SAM::printVector (for debugging)

This commit is contained in:
Knut Morten Okstad
2022-02-18 11:44:20 +01:00
parent 7736de71ca
commit 58e5969947
2 changed files with 16 additions and 11 deletions

View File

@@ -46,6 +46,21 @@ public:
//! \brief Prints out the key data to the given stream.
void print(std::ostream& os) const;
//! \brief Prints out a nodal DOF vector to the given stream.
template<class T> void printVector(T& os, const RealArray& vec,
const char* heading = nullptr) const
{
if (heading)
os <<"\n"<< heading <<":";
for (int inod = 1; inod <= nnod; inod++)
{
os <<"\nNode "<< inod <<":";
for (int idof = madof[inod-1]; idof < madof[inod]; idof++)
os <<" "<< utl::trunc(vec[idof-1]);
}
os << std::endl;
}
//! \brief Returns the number of elements in the model.
int getNoElms() const { return nel; }
//! \brief Returns the number of FE nodes in the model.

View File

@@ -1311,17 +1311,7 @@ void SIMbase::printSolutionSummary (const Vector& solution, int printSol,
// Print entire solution vector if it is small enough
if (mySam && mySam->getNoEquations() < printSol)
{
adm.cout <<"\nSolution vector:";
for (int inod = 1; inod <= mySam->getNoNodes(); inod++)
{
adm.cout <<"\nNode "<< inod <<":";
std::pair<int,int> dofs = mySam->getNodeDOFs(inod);
for (int d = dofs.first-1; d < dofs.second; d++)
adm.cout <<" "<< utl::trunc(solution[d]);
}
adm.cout << std::endl;
}
mySam->printVector(adm.cout,solution,"Solution vector");
}