From 4145b709ff344a8e157a3609d2abc691c6708c23 Mon Sep 17 00:00:00 2001 From: akva Date: Thu, 22 Sep 2011 11:52:16 +0000 Subject: [PATCH] added: storage of element wise data in VTFx git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@1176 e10b68d5-8a6e-419e-a041-bce267b0401d --- src/SIM/SIMbase.C | 2 +- src/Utility/VTF.C | 24 ++++++++++++++---------- src/Utility/VTF.h | 8 +++++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/SIM/SIMbase.C b/src/SIM/SIMbase.C index 54cd4823..d54921f9 100644 --- a/src/SIM/SIMbase.C +++ b/src/SIM/SIMbase.C @@ -1385,7 +1385,7 @@ bool SIMbase::writeGlvN (const Matrix& norms, int iStep, int& nBlock) { while (!NormBase::hasElementContributions(k)) k++; - if (!myVtf->writeSblk(sID[j],NormBase::getName(k),++idBlock,iStep)) + if (!myVtf->writeSblk(sID[j],NormBase::getName(k),++idBlock,iStep,true)) return false; } diff --git a/src/Utility/VTF.C b/src/Utility/VTF.C index 9059a53b..7ebe5489 100644 --- a/src/Utility/VTF.C +++ b/src/Utility/VTF.C @@ -255,25 +255,29 @@ bool VTF::writeEres (const std::vector& elementResult, else if (nres < myBlocks[geomID-1]->getNoElms()) showError("Warning: Fewer element results that anticipated",nres); -#if HAS_VTFAPI == 1 // Cast to float float* resVec = new float[nres]; for (size_t i = 0; i < nres; i++) resVec[i] = elementResult[i]; +#if HAS_VTFAPI == 1 VTFAResultBlock dBlock(idBlock,VTFA_DIM_SCALAR,VTFA_RESMAP_ELEMENT,0); if (VTFA_FAILURE(dBlock.SetResults1D(resVec,nres))) return showError("Error defining result block",idBlock); - delete[] resVec; dBlock.SetMapToBlockID(geomID); if (VTFA_FAILURE(myFile->WriteBlock(&dBlock))) return showError("Error writing result block",idBlock); #elif HAS_VTFAPI == 2 - showError("Note: Element-wise results are not yet implemented for VTFx"); + VTFXAResultValuesBlock dBlock(idBlock,VTFXA_DIM_SCALAR,VTFXA_FALSE); + dBlock.SetMapToBlockID(geomID,VTFXA_ELEMENTS); + dBlock.SetResultValues1D(resVec,nres); + if (VTFA_FAILURE(myDatabase->WriteBlock(&dBlock))) + return showError("Error writing result block",idBlock); #endif + delete[] resVec; return true; } @@ -303,7 +307,7 @@ bool VTF::writeNres (const std::vector& nodalResult, if (VTFA_FAILURE(myFile->WriteBlock(&dBlock))) return showError("Error writing result block",idBlock); #elif HAS_VTFAPI == 2 - VTFXAResultValuesBlock dBlock(idBlock,VTFXA_DIM_SCALAR,VTFXA_RESMAP_NODE); + VTFXAResultValuesBlock dBlock(idBlock,VTFXA_DIM_SCALAR,VTFXA_FALSE); dBlock.SetMapToBlockID(geomID,VTFXA_NODES); dBlock.SetResultValues1D(resVec,nres); if (VTFA_FAILURE(myDatabase->WriteBlock(&dBlock))) @@ -476,7 +480,7 @@ bool VTF::writeVblk (const std::vector& vBlockIDs, const char* resultName, bool VTF::writeSblk (int sBlockID, const char* resultName, - int idBlock, int iStep) + int idBlock, int iStep, bool elementData) { #if HAS_VTFAPI == 1 if ((int)mySBlock.size() < idBlock) mySBlock.resize(idBlock,0); @@ -493,9 +497,9 @@ bool VTF::writeSblk (int sBlockID, const char* resultName, if (!mySBlock[--idBlock]) { + int type = elementData?VTFXA_RESMAP_ELEMENT:VTFXA_RESMAP_NODE; mySBlock[idBlock] = new VTFXAResultBlock(idBlock+1, - VTFXA_RESTYPE_SCALAR, - VTFXA_RESMAP_NODE); + VTFXA_RESTYPE_SCALAR,type); if (resultName) mySBlock[idBlock]->SetName(resultName); } mySBlock[idBlock]->SetResultID(idBlock); @@ -508,7 +512,7 @@ bool VTF::writeSblk (int sBlockID, const char* resultName, bool VTF::writeSblk (const std::vector& sBlockIDs, const char* resultName, - int idBlock, int iStep) + int idBlock, int iStep, bool elementData) { if ((int)mySBlock.size() < idBlock) mySBlock.resize(idBlock,0); @@ -524,9 +528,9 @@ bool VTF::writeSblk (const std::vector& sBlockIDs, const char* resultName, #elif HAS_VTFAPI == 2 if (!mySBlock[--idBlock]) { + int type = elementData?VTFXA_RESMAP_ELEMENT:VTFXA_RESMAP_NODE; mySBlock[idBlock] = new VTFXAResultBlock(idBlock+1, - VTFXA_RESTYPE_SCALAR, - VTFXA_RESMAP_NODE); + VTFXA_RESTYPE_SCALAR,type); if (resultName) mySBlock[idBlock]->SetName(resultName); } mySBlock[idBlock]->SetResultID(idBlock); diff --git a/src/Utility/VTF.h b/src/Utility/VTF.h index fe20af27..e3399c5a 100644 --- a/src/Utility/VTF.h +++ b/src/Utility/VTF.h @@ -93,16 +93,18 @@ public: //! \param[in] resultName Name of the result quantity //! \param[in] idBlock Scalar block identifier //! \param[in] iStep Load/Time step identifier - bool writeSblk(int sBlockID, - const char* resultName = 0, int idBlock = 1, int iStep = 1); + //! \param[in] elementData false -> data per node, true -> data per element + bool writeSblk(int sBlockID, const char* resultName = 0, int idBlock = 1, + int iStep = 1, bool elementData=false); //! \brief Writes a scalar block definition to the VTF-file. //! \param[in] sBlockIDs All result blocks that make up this scalar block //! \param[in] resultName Name of the result quantity //! \param[in] idBlock Scalar block identifier //! \param[in] iStep Load/Time step identifier + //! \param[in] elementData false -> data per node, true -> data per element virtual bool writeSblk(const std::vector& sBlockIDs, const char* resultName = 0, - int idBlock = 1, int iStep = 1); + int idBlock = 1, int iStep = 1, bool elementData=false); //! \brief Writes a vector block definition to the VTF-file. //! \param[in] vBlockID The result block that makes up this vector block //! \param[in] resultName Name of the result quantity