Changed: Keep track of the partId as VTF class member

This commit is contained in:
Knut Morten Okstad
2021-03-07 20:30:10 +01:00
parent cbb008cbee
commit a7987649e4
3 changed files with 20 additions and 24 deletions

View File

@@ -346,7 +346,7 @@ bool SIMoutput::writeGlvG (int& nBlock, const char* inpFile, bool doClear)
return false;
sprintf(pname,"Patch %zu",pch->idx+1);
if (!myVtf->writeGrid(lvb,pname,pch->idx+1,++nBlock))
if (!myVtf->writeGrid(lvb,pname,++nBlock))
return false;
}
@@ -355,7 +355,7 @@ bool SIMoutput::writeGlvG (int& nBlock, const char* inpFile, bool doClear)
if ((lvb = pch->immersedGeometry()))
{
sprintf(pname,"Immersed boundary %zu",pch->idx+1);
if (!myVtf->writeGrid(lvb,pname,nGlPatches+pch->idx+1,++nBlock))
if (!myVtf->writeGrid(lvb,pname,++nBlock))
return false;
}
@@ -367,7 +367,7 @@ bool SIMoutput::writeGlvG (int& nBlock, const char* inpFile, bool doClear)
for (const ResultPoint& pt : points.second)
lvb->merge(CubeBlock(pt.X,myPtSize));
if (!myVtf->writeGrid(lvb,"Result points",2*nGlPatches+1,++nBlock))
if (!myVtf->writeGrid(lvb,"Result points",++nBlock))
return false;
}
@@ -378,7 +378,7 @@ bool SIMoutput::writeGlvG (int& nBlock, const char* inpFile, bool doClear)
for (const IdxVec3& pt : myTopPts)
lvb->merge(CubeBlock(pt.second,myPtSize));
if (!myVtf->writeGrid(lvb,"Extra points",2*nGlPatches+2,++nBlock))
if (!myVtf->writeGrid(lvb,"Extra points",++nBlock))
return false;
}

View File

@@ -39,7 +39,8 @@ VTF::VTF (const char* filename, int type)
myFile = nullptr;
myState = nullptr;
myGBlock = nullptr;
pointGeoID = lastStep = 0;
myPartID = pointGeoID = 0;
lastStep = 0;
if (!filename) return;
#if HAS_VTFAPI == 1
@@ -231,7 +232,7 @@ void VTF::clearGeometryBlocks ()
delete myBlocks[i].second;
myBlocks.clear();
pointGeoID = 0;
myPartID = pointGeoID = 0;
}
@@ -246,8 +247,7 @@ const ElementBlock* VTF::getBlock (int geomID) const
}
bool VTF::writeGrid (const ElementBlock* block, const char* partname,
int partID, int geomID)
bool VTF::writeGrid (const ElementBlock* block, const char* gName, int geomID)
{
if (!myFile) return true;
if (!block) return false;
@@ -257,7 +257,7 @@ bool VTF::writeGrid (const ElementBlock* block, const char* partname,
if (!this->writeNodes(geomID))
return showError("Error writing node block",geomID);
if (!this->writeElements(partname,partID,geomID,geomID))
if (!this->writeElements(gName,++myPartID,geomID,geomID))
return showError("Error writing element block",geomID);
return true;
@@ -467,8 +467,8 @@ bool VTF::writeNfunc (const RealFunc& f, Real time, int idBlock, int geomID)
}
bool VTF::writeVectors (const std::vector<Vec3Pair>& pntResult, int partID,
int& gID, int idBlock, const char* resultName,
bool VTF::writeVectors (const std::vector<Vec3Pair>& pntResult, int& gID,
int idBlock, const char* resultName,
int iStep, int iBlock)
{
#if HAS_VTFAPI == 1
@@ -512,7 +512,7 @@ bool VTF::writeVectors (const std::vector<Vec3Pair>& pntResult, int partID,
// We must define an element block (with point elements) also,
// otherwise GLview does not visualize the vectors
VTFAElementBlock eBlock(pointGeoID,0,0);
eBlock.SetPartID(partID);
eBlock.SetPartID(++myPartID);
eBlock.SetNodeBlockID(pointGeoID);
if (VTFA_FAILURE(eBlock.AddElements(VTFA_POINTS,mnpc.data(),np)))
return showError("Error defining element block",pointGeoID);
@@ -532,7 +532,7 @@ bool VTF::writeVectors (const std::vector<Vec3Pair>& pntResult, int partID,
}
bool VTF::writePoints (const Vec3Vec& points, int partID, int& gID)
bool VTF::writePoints (const Vec3Vec& points, int& gID)
{
#if HAS_VTFAPI == 1
myBlocks.push_back(std::make_pair(++gID,new ElementBlock()));
@@ -555,7 +555,7 @@ bool VTF::writePoints (const Vec3Vec& points, int partID, int& gID)
// We must define an element block (with point elements) also,
// otherwise GLview does not visualize the points
VTFAElementBlock eBlock(gID,0,0);
eBlock.SetPartID(partID);
eBlock.SetPartID(++myPartID);
eBlock.SetNodeBlockID(gID);
if (VTFA_FAILURE(eBlock.AddElements(VTFA_POINTS,mnpc.data(),np)))
return showError("Error defining element block",gID);

View File

@@ -67,11 +67,9 @@ public:
//! \brief Writes the FE geometry to the VTF-file.
//! \param[in] block The FE grid that all results written are referred to
//! \param[in] partname Name of the geometry being written
//! \param[in] partID Part identifier
//! \param[in] gName Name of the geometry being written
//! \param[in] geomID Geometry block identifier
bool writeGrid(const ElementBlock* block, const char* partname,
int partID, int geomID);
bool writeGrid(const ElementBlock* block, const char* gName, int geomID);
//! \brief Writes a transformation matrix to the VTF-file.
//! \param[in] X Position part of the transformation
@@ -111,7 +109,6 @@ public:
int idBlock = 1, int gID = 1);
//! \brief Writes a block of point vector results to the VTF-file.
//! \param[in] pntResult A set of result vectors with associated attack points
//! \param[in] partID Part identifier
//! \param gID Running geometry block identifier
//! \param[in] idBlock Result block identifier
//! \param[in] resultName Name of the result quantity
@@ -121,15 +118,13 @@ public:
//! \details This method creates a separate geometry block consisting of the
//! attack points of the result vectors, since they are independent of the
//! FE geometry created by the writeGrid() method.
bool writeVectors(const std::vector<Vec3Pair>& pntResult,
int partID, int& gID, int idBlock = 1,
const char* resultName = nullptr,
bool writeVectors(const std::vector<Vec3Pair>& pntResult, int& gID,
int idBlock = 1, const char* resultName = nullptr,
int iStep = 0, int iBlock = 1);
//! \brief Writes a block of points (no results) to the VTF-file.
//! \param[in] points Vector of point coordinates
//! \param[in] partID Part identifier
//! \param gID Running geometry block identifier
bool writePoints(const std::vector<Vec3>& points, int partID, int& gID);
bool writePoints(const std::vector<Vec3>& points, int& gID);
//! \brief Writes a scalar block definition to the VTF-file.
//! \param[in] sBlockID The result block that makes up this scalar block
@@ -229,6 +224,7 @@ private:
std::vector<VTFAVectorBlock*> myVBlock; //!< Vector field blocks
std::vector<VTFAScalarBlock*> mySBlock; //!< Scalar field blocks
int myPartID; //!< Internal geometry block part ID
int pointGeoID; //!< ID of point vector geometry block
int lastStep; //!< ID of the last state written to file
std::vector<GridBlock> myBlocks; //!< The FE geometry of the whole model