From a8afaae01966f282a42d3425317a2c938c343dc2 Mon Sep 17 00:00:00 2001 From: Knut Morten Okstad Date: Tue, 10 Apr 2018 08:52:19 +0200 Subject: [PATCH] Added: Number of values to print per line in the result point output --- src/ASM/IntegrandBase.h | 3 +++ src/SIM/SIMoutput.C | 31 ++++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/ASM/IntegrandBase.h b/src/ASM/IntegrandBase.h index 98cf9073..0f6d67aa 100644 --- a/src/ASM/IntegrandBase.h +++ b/src/ASM/IntegrandBase.h @@ -191,6 +191,9 @@ public: //! \brief Returns an evaluated principal direction vector field for plotting. virtual bool getPrincipalDir(Matrix&, size_t, size_t) const { return false; } + //! \brief Returns max number of 2ndary solution components to print per line. + virtual size_t getNo2ndSolPerLine() const { return 999; } + // Various service methods // ======================= diff --git a/src/SIM/SIMoutput.C b/src/SIM/SIMoutput.C index e510ae99..99ca9347 100644 --- a/src/SIM/SIMoutput.C +++ b/src/SIM/SIMoutput.C @@ -595,8 +595,8 @@ int SIMoutput::writeGlvS1 (const Vector& psol, int iStep, int& nBlock, if (mySol->getScalarSol()) { const RealFunc* psSol; - size_t r = pSol.dim() + 1; - for (size_t k = 0; (psSol = mySol->getScalarSol(k)) && r <= field.rows(); k++, r++) + size_t k = 0, r = pSol.dim(); + while ((psSol = mySol->getScalarSol(k++)) && r++ < field.rows()) { cit = grid->begin_XYZ(); const RealFunc& sSol = *psSol; @@ -855,9 +855,9 @@ bool SIMoutput::writeGlvP (const Vector& ssol, int iStep, int& nBlock, Vector lovec; std::vector sID(myProblem->getNoFields(2)); - size_t i, j; + Vector::const_iterator ssolIt = ssol.begin(); + size_t i, j, nComp = myProblem->getNoFields(2); int geomID = myGeomID; - size_t projOfs = 0; for (i = 0; i < myModel.size(); i++) { if (myModel[i]->empty()) continue; // skip empty patches @@ -865,16 +865,18 @@ bool SIMoutput::writeGlvP (const Vector& ssol, int iStep, int& nBlock, if (msgLevel > 1) IFEM::cout <<"Writing projected solution for patch "<< i+1 << std::endl; - if (this->fieldProjections()) { - size_t ndof = myModel[i]->getNoProjectionNodes() * myProblem->getNoFields(2); - lovec.resize(ndof); - std::copy(ssol.begin()+projOfs, ssol.begin()+projOfs+ndof, lovec.begin()); - projOfs += ndof; - } else + if (this->fieldProjections()) + { + size_t nval = nComp*myModel[i]->getNoProjectionNodes(); + lovec.resize(nval); + std::copy(ssolIt,ssolIt+nval,lovec.begin()); + ssolIt += nval; + } + else this->extractPatchSolution(ssol,lovec,i,sID.size(),1); // Evaluate the solution variables at the visualization points - if (!myModel[i]->evalProjSolution(field,lovec,opt.nViz,myProblem->getNoFields(2))) + if (!myModel[i]->evalProjSolution(field,lovec,opt.nViz,nComp)) return false; // Write out to VTF-file as scalar fields @@ -1432,10 +1434,13 @@ bool SIMoutput::dumpResults (const Vector& psol, double time, if (opt.discretization >= ASM::Spline) { - if (formatted && sol2.rows() > 0) - os <<"\n\t\tsol2 ="; + int isol = 1; for (k = 1; k <= sol2.rows(); k++) + { + if (formatted && k%myProblem->getNo2ndSolPerLine() == 1) + os <<"\n\t\tsol"<< ++isol <<" ="; os << std::setw(flWidth) << utl::trunc(sol2(k,j+1)); + } if (ssolScl || ssolVec || ssolStr) os <<"\n\t\texact2";