From: Anthony Geay Date: Fri, 3 Feb 2017 08:01:44 +0000 (+0100) Subject: New information key GAUSS_DATA to forward advanced Gauss Info along pipeline X-Git-Tag: SHAPER_2.7.0~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8eee5f83695054c724ce15d311157a02290c340e;p=modules%2Fparavis.git New information key GAUSS_DATA to forward advanced Gauss Info along pipeline --- diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index 4e9abe86..9a0b3388 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -78,7 +78,7 @@ const char MEDFileFieldRepresentationTree::ROOT_OF_FAM_IDS_IN_TREE[]="zeFamIds"; const char MEDFileFieldRepresentationTree::COMPO_STR_TO_LOCATE_MESH_DA[]="-@?|*_"; -vtkIdTypeArray *ELGACmp::findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew) const +vtkIdTypeArray *ELGACmp::findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew, ExportedTinyInfo *internalInfo) const { vtkIdTypeArray *try0(isExisting(locsReallyUsed,vtkd)); if(try0) @@ -89,7 +89,7 @@ vtkIdTypeArray *ELGACmp::findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal * else { isNew=true; - return createNew(globs,locsReallyUsed,vtkd,ds); + return createNew(globs,locsReallyUsed,vtkd,ds,internalInfo); } } @@ -109,7 +109,7 @@ vtkIdTypeArray *ELGACmp::isExisting(const std::vector& locsReallyUs return ret; } -vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const +vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const { const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; std::vector< std::vector > locNames(_loc_names); @@ -129,11 +129,14 @@ vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *glo vtkQuadratureSchemeDefinition *def(vtkQuadratureSchemeDefinition::New()); const MEDFileFieldLoc& loc(globs->getLocalization((*it).c_str())); INTERP_KERNEL::NormalizedCellType ct(loc.getGeoType()); + unsigned char vtkType(MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[ct]); const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(ct)); int nbGaussPt(loc.getNbOfGaussPtPerCell()),nbPtsPerCell((int)cm.getNumberOfNodes()),dimLoc(loc.getDimension()); // WARNING : these 2 lines are a workaround, due to users that write a ref element with dimension not equal to dimension of the geometric element. std::vector gsCoods2(INTERP_KERNEL::GaussInfo::NormalizeCoordinatesIfNecessary(ct,dimLoc,loc.getGaussCoords())); std::vector refCoods2(INTERP_KERNEL::GaussInfo::NormalizeCoordinatesIfNecessary(ct,dimLoc,loc.getRefCoords())); + if(internalInfo) + internalInfo->pushGaussAdditionnalInfo(vtkType,dimLoc,gsCoods2,refCoods2); double *shape(new double[nbPtsPerCell*nbGaussPt]); INTERP_KERNEL::GaussInfo calculator(ct,gsCoods2,nbGaussPt,refCoods2,nbPtsPerCell); calculator.initLocalInfo(); @@ -149,7 +152,6 @@ vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *glo shape[nbPtsPerCell*i+j]=pt0[MEDMeshMultiLev::HEXA27_PERM_ARRAY[j]]; } } - unsigned char vtkType(MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[ct]); m[vtkType]=nbGaussPt; def->Initialize(vtkType,nbPtsPerCell,nbGaussPt,shape,const_cast(&wgths[0])); delete [] shape; @@ -318,7 +320,7 @@ bool MEDFileFieldRepresentationLeavesArrays::setStatus(bool status) const return ret; } -void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshStruct *mst, vtkDataSet *ds) const +void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshStruct *mst, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const { const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; tr->setNumberOfTS((operator->())->getNumberOfTS()); @@ -385,7 +387,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, if(discs[0]==ON_GAUSS_PT) { bool tmp; - _elga_cmp.findOrCreate(globs,f1ts->getLocsReallyUsed(),vtkd,ds,tmp); + _elga_cmp.findOrCreate(globs,f1ts->getLocsReallyUsed(),vtkd,ds,tmp,internalInfo); } if(discs[0]==ON_GAUSS_NE) { @@ -649,7 +651,7 @@ std::string MEDFileFieldRepresentationLeaves::getHumanReadableOverviewOfTS() con return oss.str(); } -void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshes *meshes, vtkDataSet *ds) const +void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshes *meshes, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const { if(_arrays.size()<1) throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeaves::appendFields : internal error !"); @@ -657,7 +659,7 @@ void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) if((*it).getStatus()) { - (*it).appendFields(tr,globs,mml,mst,ds); + (*it).appendFields(tr,globs,mml,mst,ds,internalInfo); (*it).appendELGAIfAny(ds); } } @@ -788,7 +790,7 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter return ret; } -vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDFileMeshes *meshes) const +vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDFileMeshes *meshes, ExportedTinyInfo *internalInfo) const { vtkDataSet *ret(0); //_fsp->isDataSetSupportEqualToThePreviousOne(i,globs); @@ -824,7 +826,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio ret->ShallowCopy(_cached_ds); } // - appendFields(tr,globs,mml,meshes,ret); + appendFields(tr,globs,mml,meshes,ret,internalInfo); // The arrays links to mesh DataArrayInt *famCells(0),*numCells(0); bool noCpyFamCells(false),noCpyNumCells(false); @@ -1331,7 +1333,7 @@ std::vector MEDFileFieldRepresentationTree::getTimeSteps(int& lev0, cons return leaf.getTimeSteps(tk); } -vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk) const +vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk, ExportedTinyInfo *internalInfo) const { int lev0,lev1,lev2; const MEDFileFieldRepresentationLeaves& leaf(getTheSingleActivated(lev0,lev1,lev2)); @@ -1387,7 +1389,7 @@ vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, d tr=new MEDStdTimeReq((int)zeTimeId); else tr=new MEDModeTimeReq(tk.getTheVectOfBool(),tk.getPostProcessedTime()); - vtkDataSet *ret(leaf.buildVTKInstanceNoTimeInterpolation(tr,_fields,_ms)); + vtkDataSet *ret(leaf.buildVTKInstanceNoTimeInterpolation(tr,_fields,_ms,internalInfo)); delete tr; return ret; } diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx index 800e8c47..47ba43ad 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx @@ -42,16 +42,17 @@ class vtkDataSet; class TimeKeeper; class MEDTimeReq; +class ExportedTinyInfo; class ELGACmp { public: - vtkIdTypeArray *findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew) const; + vtkIdTypeArray *findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew, ExportedTinyInfo *internalInfo) const; void appendELGAIfAny(vtkDataSet *ds) const; ~ELGACmp(); private: vtkIdTypeArray *isExisting(const std::vector& locsReallyUsed, vtkDoubleArray *vtkd) const; - vtkIdTypeArray *createNew(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const; + vtkIdTypeArray *createNew(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const; private: //! size of _loc_names is equal to _elgas. mutable std::vector< std::vector > _loc_names; @@ -75,7 +76,7 @@ public: bool setStatus(bool status) const; std::string getZeName() const; const char *getZeNameC() const; - void appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshStruct *mst, vtkDataSet *ds) const; + void appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshStruct *mst, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const; void appendELGAIfAny(vtkDataSet *ds) const; public: static const char ZE_SEP[]; @@ -118,12 +119,12 @@ public: std::vector getTimeSteps(const TimeKeeper& tk) const; std::vector< std::pair > getTimeStepsInCoarseMEDFileFormat(std::vector& ts) const; std::string getHumanReadableOverviewOfTS() const; - vtkDataSet *buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDFileMeshes *meshes) const; + vtkDataSet *buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDFileMeshes *meshes, ExportedTinyInfo *internalInfo=0) const; private: vtkUnstructuredGrid *buildVTKInstanceNoTimeInterpolationUnstructured(MEDCoupling::MEDUMeshMultiLev *mm) const; vtkRectilinearGrid *buildVTKInstanceNoTimeInterpolationCartesian(MEDCoupling::MEDCMeshMultiLev *mm) const; vtkStructuredGrid *buildVTKInstanceNoTimeInterpolationCurveLinear(MEDCoupling::MEDCurveLinearMeshMultiLev *mm) const; - void appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshes *meshes, vtkDataSet *ds) const; + void appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshes *meshes, vtkDataSet *ds, ExportedTinyInfo *internalInfo=0) const; private: std::vector _arrays; MEDCoupling::MCAuto _fsp; @@ -150,7 +151,7 @@ public: // std::string getDftMeshName() const; std::vector getTimeSteps(int& lev0, const TimeKeeper& tk) const; - vtkDataSet *buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk) const; + vtkDataSet *buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk, ExportedTinyInfo *internalInfo=0) const; void printMySelf(std::ostream& os) const; std::map dumpState() const; //non const methods diff --git a/src/Plugins/MEDReader/IO/MEDUtilities.cxx b/src/Plugins/MEDReader/IO/MEDUtilities.cxx index 5eca66c8..22eaf376 100644 --- a/src/Plugins/MEDReader/IO/MEDUtilities.cxx +++ b/src/Plugins/MEDReader/IO/MEDUtilities.cxx @@ -23,5 +23,30 @@ #include "vtkInformationIntegerKey.h" #include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" +#include + vtkInformationKeyMacro(MEDUtilities,ELGA,Integer); vtkInformationKeyMacro(MEDUtilities,ELNO,Integer); + +void ExportedTinyInfo::pushGaussAdditionnalInfo(int ct, int dim, const std::vector& refCoo, const std::vector& posInRefCoo) +{ + prepareForAppend(); + std::vector tmp(1,(double)ct); + tmp.push_back((double)dim); + tmp.insert(tmp.end(),refCoo.begin(),refCoo.end()); + tmp.insert(tmp.end(),posInRefCoo.begin(),posInRefCoo.end()); + _data.push_back((double)tmp.size()); + _data.insert(_data.end(),tmp.begin(),tmp.end()); +} + +void ExportedTinyInfo::prepareForAppend() +{ + if(_data.empty()) + _data.push_back(1.); + else + { + double val(_data[0]); + int val2((int) val); + _data[0]=++val2; + } +} diff --git a/src/Plugins/MEDReader/IO/MEDUtilities.hxx b/src/Plugins/MEDReader/IO/MEDUtilities.hxx index 767820ce..fbbbebfe 100644 --- a/src/Plugins/MEDReader/IO/MEDUtilities.hxx +++ b/src/Plugins/MEDReader/IO/MEDUtilities.hxx @@ -22,6 +22,9 @@ #define __MEDUTILITIES_HXX__ #include "MEDLoaderForPV.h" +#include "vtkCellType.h" + +#include class vtkInformationIntegerKey; @@ -32,4 +35,25 @@ public: static vtkInformationIntegerKey *ELNO(); }; +class ExportedTinyInfo +{ +public: + void pushGaussAdditionnalInfo(int ct, int dim, const std::vector& refCoo, const std::vector& posInRefCoo); + const std::vector& getData() const { return _data; } + bool empty() const { return _data.empty(); } +private: + void prepareForAppend(); +private: + // first place is nb of ct + // 2nd place is the size of first ct def (this 2nd place included) + // 3rd place is the VTK cell type of first ct def + // 4th place is the dimension of first ct def + // 5th->n th : ref Coo + // nth -> n+p th : posInRefCoo + // n+p+1 -> size of second ct def (this n+p+1 place included) + // n+p+2 -> VTK cell type of second ct def + // ... + std::vector _data; +}; + #endif diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx index 1c185555..7f5f07a9 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx @@ -20,6 +20,7 @@ #include "vtkMEDReader.h" #include "vtkGenerateVectors.h" +#include "MEDUtilities.hxx" #include "vtkMultiBlockDataSet.h" #include "vtkInformation.h" @@ -37,6 +38,7 @@ #include "vtkMultiTimeStepAlgorithm.h" #include "vtkUnstructuredGrid.h" #include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" +#include "vtkInformationDoubleVectorKey.h" #include "vtkQuadratureSchemeDefinition.h" #include "vtkPointData.h" #include "vtkCellData.h" @@ -231,6 +233,21 @@ vtkInformationDataObjectMetaDataKey *vtkMEDReader::META_DATA() } return ret; } + +static vtkInformationDoubleVectorKey *vtkMEDReader_GAUSS_DATA=new vtkInformationDoubleVectorKey("GAUSS_DATA","vtkMEDReader"); + +vtkInformationDoubleVectorKey *vtkMEDReader::GAUSS_DATA() +{ + static const char ZE_KEY[]="vtkMEDReader::GAUSS_DATA"; + vtkInformationDoubleVectorKey *ret(vtkMEDReader_GAUSS_DATA); + MEDCoupling::GlobalDict *gd(MEDCoupling::GlobalDict::GetInstance()); + if(!gd->hasKey(ZE_KEY)) + {// here META_DATA is put on global var to be exchanged with other filters without dependancy of MEDReader. Please do not change ZE_KEY ! + std::ostringstream oss; oss << ret; + gd->setKeyValue(ZE_KEY,oss.str()); + } + return ret; +} // end of overload of vtkInformationKeyMacro vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal(this)) @@ -419,7 +436,14 @@ int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector **in if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) reqTS=outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); #ifndef MEDREADER_USE_MPI - this->FillMultiBlockDataSetInstance(output,reqTS); + ExportedTinyInfo ti; + this->FillMultiBlockDataSetInstance(output,reqTS,&ti); + if(!ti.empty()) + { + const std::vector& data(ti.getData()); + outInfo->Set(vtkMEDReader::GAUSS_DATA(),&data[0],data.size()); + request->Append(vtkExecutive::KEYS_TO_COPY(),vtkMEDReader::GAUSS_DATA());// Thank you to SciberQuest and DIPOLE_CENTER ! Don't understand why ! In RequestInformation it does not work ! + } #else if(this->Internal->GCGCP) { @@ -639,21 +663,21 @@ double vtkMEDReader::PublishTimeStepsIfNeeded(vtkInformation *outInfo, bool& isU return tsteps.front(); } -void vtkMEDReader::FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS) +void vtkMEDReader::FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS, ExportedTinyInfo *internalInfo) { if( !this->Internal ) return; - vtkDataSet *ret(RetrieveDataSetAtTime(reqTS)); + vtkDataSet *ret(RetrieveDataSetAtTime(reqTS,internalInfo)); output->SetBlock(0,ret); ret->Delete(); } -vtkDataSet *vtkMEDReader::RetrieveDataSetAtTime(double reqTS) +vtkDataSet *vtkMEDReader::RetrieveDataSetAtTime(double reqTS, ExportedTinyInfo *internalInfo) { if( !this->Internal ) return 0; std::string meshName; - vtkDataSet *ret(this->Internal->Tree.buildVTKInstance(this->Internal->IsStdOrMode,reqTS,meshName,this->Internal->TK)); + vtkDataSet *ret(this->Internal->Tree.buildVTKInstance(this->Internal->IsStdOrMode,reqTS,meshName,this->Internal->TK,internalInfo)); if(this->Internal->GenerateVect) { vtkGenerateVectors::Operate(ret->GetPointData()); diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.h b/src/Plugins/MEDReader/IO/vtkMEDReader.h index db9b842f..9193e147 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.h +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.h @@ -28,6 +28,8 @@ class vtkDataSet; class vtkMutableDirectedGraph; class vtkInformationDataObjectMetaDataKey; +class vtkInformationDoubleVectorKey; +class ExportedTinyInfo; class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm { @@ -69,6 +71,7 @@ class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm // Description // Static information key used to transfer the meta data graph along the pipeline static vtkInformationDataObjectMetaDataKey* META_DATA(); + static vtkInformationDoubleVectorKey* GAUSS_DATA(); protected: vtkMEDReader(); @@ -78,8 +81,8 @@ class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm private: void UpdateSIL(vtkInformation *request, vtkInformation *info); virtual double PublishTimeStepsIfNeeded(vtkInformation*, bool& isUpdated); - virtual void FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS); - vtkDataSet *RetrieveDataSetAtTime(double reqTS); + virtual void FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS, ExportedTinyInfo *internalInfo=0); + vtkDataSet *RetrieveDataSetAtTime(double reqTS, ExportedTinyInfo *internalInfo); private: //BTX //ETX