Fixed: The commit d451b1cd5d was no good.

It broke the nonlinear shell VTF output in that the sqrt(u^2+v^2+w^2)
quantity disappeared. Now doing this a different way instead not relying
on the nf-parameter, but using a separate ID-array for the exact fields.
This commit is contained in:
Knut Morten Okstad 2018-07-20 10:06:10 +02:00 committed by Arne Morten Kvarving
parent d451b1cd5d
commit 26499b6685
2 changed files with 22 additions and 18 deletions

View File

@ -529,8 +529,9 @@ int SIMoutput::writeGlvS1 (const Vector& psol, int iStep, int& nBlock,
} }
std::array<IntVec,2> vID; std::array<IntVec,2> vID;
std::vector<IntVec> sID; std::vector<IntVec> sID, xID;
sID.reserve(haveXsol ? nf+nf : nf); sID.reserve(nf);
if (haveXsol) xID.reserve(nf);
Matrix field; Matrix field;
Vector lovec; Vector lovec;
@ -564,8 +565,7 @@ int SIMoutput::writeGlvS1 (const Vector& psol, int iStep, int& nBlock,
if (myProblem) // Compute application-specific primary solution quantities if (myProblem) // Compute application-specific primary solution quantities
myProblem->primaryScalarFields(field); myProblem->primaryScalarFields(field);
size_t k = 0; if (!this->writeScalarFields(field,geomID,nBlock,sID))
if (!this->writeScalarFields(field,geomID,k,nBlock,sID))
return -3; return -3;
if (haveXsol) if (haveXsol)
@ -607,7 +607,7 @@ int SIMoutput::writeGlvS1 (const Vector& psol, int iStep, int& nBlock,
} }
if (haveXsol) if (haveXsol)
if (!this->writeScalarFields(field,geomID,k,nBlock,sID)) if (!this->writeScalarFields(field,geomID,nBlock,xID))
return false; return false;
if (!myVtf->writeVres(field,++nBlock,geomID,nVcomp)) if (!myVtf->writeVres(field,++nBlock,geomID,nVcomp))
@ -619,7 +619,7 @@ int SIMoutput::writeGlvS1 (const Vector& psol, int iStep, int& nBlock,
// Write result block identifications // Write result block identifications
size_t i, j; size_t i;
bool ok = true; bool ok = true;
std::string pname(pvecName ? pvecName : "Solution"); std::string pname(pvecName ? pvecName : "Solution");
for (i = 0; i < 2 && ok; i++) for (i = 0; i < 2 && ok; i++)
@ -638,18 +638,18 @@ int SIMoutput::writeGlvS1 (const Vector& psol, int iStep, int& nBlock,
std::vector<std::string> xname; std::vector<std::string> xname;
if (haveXsol) xname.reserve(nf); if (haveXsol) xname.reserve(nf);
if (nf > 1) pname += "_w"; if (nf > 1) pname += "_w";
for (i = j = 0; i < nf && j < sID.size() && !sID[j].empty() && ok; i++) for (i = 0; i < sID.size() && !sID[i].empty() && ok; i++)
{ {
if (myProblem && (!pvecName || nf > nVcomp)) if (myProblem && (!pvecName || nf > nVcomp))
pname = myProblem->getField1Name(i); pname = myProblem->getField1Name(i);
else if (nf > 1) else if (nf > 1)
(*pname.rbegin()) ++; (*pname.rbegin()) ++;
ok = myVtf->writeSblk(sID[j++],pname.c_str(),idBlock++,iStep); ok = myVtf->writeSblk(sID[i],pname.c_str(),idBlock++,iStep);
if (haveXsol) xname.push_back("Exact " + pname); if (haveXsol) xname.push_back("Exact " + pname);
} }
for (i = 0; i < xname.size() && j < sID.size() && !sID[j].empty() && ok; i++) for (i = 0; i < xname.size() && i < xID.size() && !xID[i].empty() && ok; i++)
ok = myVtf->writeSblk(sID[j++],xname[i].c_str(),idBlock++,iStep); ok = myVtf->writeSblk(xID[i],xname[i].c_str(),idBlock++,iStep);
return ok ? idBlock : -4; return ok ? idBlock : -4;
} }
@ -714,7 +714,7 @@ bool SIMoutput::writeGlvS2 (const Vector& psol, int iStep, int& nBlock,
size_t k = 0; size_t k = 0;
myModel[i]->filterResults(field,myVtf->getBlock(++geomID)); myModel[i]->filterResults(field,myVtf->getBlock(++geomID));
if (!this->writeScalarFields(field,geomID,k,nBlock,sID)) if (!this->writeScalarFields(field,geomID,nBlock,sID,&k))
return false; return false;
// Write principal directions, if any, as vector fields // Write principal directions, if any, as vector fields
@ -738,7 +738,7 @@ bool SIMoutput::writeGlvS2 (const Vector& psol, int iStep, int& nBlock,
return false; return false;
myModel[i]->filterResults(field,myVtf->getBlock(geomID)); myModel[i]->filterResults(field,myVtf->getBlock(geomID));
if (!this->writeScalarFields(field,geomID,k,nBlock,sID)) if (!this->writeScalarFields(field,geomID,nBlock,sID,&k))
return false; return false;
} }
@ -769,7 +769,7 @@ bool SIMoutput::writeGlvS2 (const Vector& psol, int iStep, int& nBlock,
} }
if (haveAsol) if (haveAsol)
if (!this->writeScalarFields(field,geomID,k,nBlock,sID)) if (!this->writeScalarFields(field,geomID,nBlock,sID,&k))
return false; return false;
} }
} }
@ -872,7 +872,7 @@ bool SIMoutput::writeGlvP (const Vector& ssol, int iStep, int& nBlock,
size_t j = 1; // Write out to VTF-file as scalar fields size_t j = 1; // Write out to VTF-file as scalar fields
const ElementBlock* grid = myVtf->getBlock(++geomID); const ElementBlock* grid = myVtf->getBlock(++geomID);
if (!this->writeScalarFields(field,geomID,j,nBlock,sID)) if (!this->writeScalarFields(field,geomID,nBlock,sID,&j))
return false; return false;
if (maxVal) // Update extremal values if (maxVal) // Update extremal values
@ -897,9 +897,12 @@ bool SIMoutput::writeGlvP (const Vector& ssol, int iStep, int& nBlock,
} }
bool SIMoutput::writeScalarFields (const Matrix& field, int geomID, size_t& k, bool SIMoutput::writeScalarFields (const Matrix& field, int geomID,
int& nBlock, std::vector<IntVec>& sID) int& nBlock, std::vector<IntVec>& sID,
size_t* i)
{ {
size_t nS = 0;
size_t& k = i ? *i : nS;
for (size_t j = 1; j <= field.rows(); j++, k++) for (size_t j = 1; j <= field.rows(); j++, k++)
if (!myVtf->writeNres(field.getRow(j),++nBlock,geomID)) if (!myVtf->writeNres(field.getRow(j),++nBlock,geomID))
return false; return false;

View File

@ -304,8 +304,9 @@ protected:
private: private:
//! \brief Private helper to write out scalar fields to VTF-file. //! \brief Private helper to write out scalar fields to VTF-file.
bool writeScalarFields(const Matrix& field, int geomID, size_t& k, bool writeScalarFields(const Matrix& field, int geomID,
int& nBlock, std::vector< std::vector<int> >& sID); int& nBlock, std::vector< std::vector<int> >& sID,
size_t* i = nullptr);
//! \brief Struct defining a result sampling point. //! \brief Struct defining a result sampling point.
struct ResultPoint struct ResultPoint