From: Anthony Geay Date: Wed, 12 Oct 2022 15:58:59 +0000 (+0200) Subject: [EDF24817] : MEDReader deal with file series considered as Spatial aggragation not... X-Git-Tag: V9_10_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=46e8ab674b972ef92e6297b9f393c4d93bc8c18e;p=modules%2Fparavis.git [EDF24817] : MEDReader deal with file series considered as Spatial aggragation not Temporal aggregation. Delivery issue kw65 --- diff --git a/src/Plugins/MEDReader/plugin/MEDReaderIO/CMakeLists.txt b/src/Plugins/MEDReader/plugin/MEDReaderIO/CMakeLists.txt index f42fda29..00b3baf1 100644 --- a/src/Plugins/MEDReader/plugin/MEDReaderIO/CMakeLists.txt +++ b/src/Plugins/MEDReader/plugin/MEDReaderIO/CMakeLists.txt @@ -29,6 +29,7 @@ set(classes vtkGroupAsMultiBlock vtkGroupsNames vtkUgSelectCellIds + vtkFileSeriesGroupReader ) vtk_module_add_module(MEDReaderIO diff --git a/src/Plugins/MEDReader/plugin/MEDReaderIO/vtk.module b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtk.module old mode 100644 new mode 100755 index 6072a2b2..f2b5567c --- a/src/Plugins/MEDReader/plugin/MEDReaderIO/vtk.module +++ b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtk.module @@ -5,7 +5,11 @@ DEPENDS VTK::FiltersExtraction VTK::IOLegacy ParaView::RemotingCore + ParaView::VTKExtensionsIOCore PRIVATE_DEPENDS VTK::IOLegacy ParaView::VTKExtensionsFiltersRendering + ParaView::VTKExtensionsFiltersGeneral ParaView::VTKExtensionsMisc +OPTIONAL_DEPENDS + VTK::FiltersParallelGeometry diff --git a/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkFileSeriesGroupReader.cxx b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkFileSeriesGroupReader.cxx new file mode 100644 index 00000000..dbea2e4f --- /dev/null +++ b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkFileSeriesGroupReader.cxx @@ -0,0 +1,205 @@ +// Copyright (C) 2022 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "vtkFileSeriesGroupReader.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "vtkMEDReader.h" + +#include +#include + +vtkStandardNewMacro(vtkFileSeriesGroupReader); + +//============================================================================= +struct vtkFileSeriesGroupReaderInternals +{ + std::vector FileNames; +}; + +//============================================================================= +vtkFileSeriesGroupReader::vtkFileSeriesGroupReader() + : Internals(new vtkFileSeriesGroupReaderInternals()) +{ + this->SetNumberOfInputPorts(0); + this->SetNumberOfOutputPorts(1); +} + +//----------------------------------------------------------------------------- +vtkFileSeriesGroupReader::~vtkFileSeriesGroupReader() = default; + +//---------------------------------------------------------------------------- +void vtkFileSeriesGroupReader::AddFileName(const char* name) +{ + // Make sure the reader always has a filename set + this->ReaderSetFileName(name); + + this->AddFileNameInternal(name); + this->Modified(); +} + +//---------------------------------------------------------------------------- +void vtkFileSeriesGroupReader::RemoveAllFileNames() +{ + this->RemoveAllFileNamesInternal(); + this->Modified(); +} + +//---------------------------------------------------------------------------- +void vtkFileSeriesGroupReader::RemoveAllFileNamesInternal() +{ + this->Internals->FileNames.clear(); +} + +//---------------------------------------------------------------------------- +void vtkFileSeriesGroupReader::AddFileNameInternal(const char* name) +{ + this->Internals->FileNames.emplace_back(name); +} + +//---------------------------------------------------------------------------- +unsigned int vtkFileSeriesGroupReader::GetNumberOfFileNames() +{ + return static_cast(this->Internals->FileNames.size()); +} + +//---------------------------------------------------------------------------- +const char* vtkFileSeriesGroupReader::GetFileName(unsigned int idx) +{ + if (idx >= this->Internals->FileNames.size()) + { + return nullptr; + } + return this->Internals->FileNames[idx].c_str(); +} + +//---------------------------------------------------------------------------- +int vtkFileSeriesGroupReader::CanReadFile(const char* filename) +{ + if (!this->Reader) + { + return 0; + } + + return this->ReaderCanReadFile(filename); +} + +//---------------------------------------------------------------------------- +int vtkFileSeriesGroupReader::RequestInformation( + vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) +{ + return this->Reader->ProcessRequest(request, inputVector, outputVector); +} + +//---------------------------------------------------------------------------- +int vtkFileSeriesGroupReader::RequestData(vtkInformation* vtkNotUsed(request), + vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) +{ + auto output = vtkMultiBlockDataSet::GetData(outputVector, 0); + unsigned int nBlock = this->GetNumberOfFileNames(); + output->SetNumberOfBlocks(nBlock); + + vtkInformation* info = outputVector->GetInformationObject(0); + double time = info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); + + vtkMultiProcessController *vmpc(vtkMultiProcessController::GetGlobalController()); + unsigned int iProc = vmpc ? vmpc->GetLocalProcessId() : 0; + unsigned int nProc = vmpc ? vmpc->GetNumberOfProcesses() : 1; + + // Simple case, one file/block per proc + if (nBlock == 1 || (nBlock <= nProc && iProc < nBlock)) + { + // Distribute in MEDReader only when reading a single file in a single block + iProc = nBlock == 1 ? 0 : iProc; + vtkMEDReader::SafeDownCast(this->Reader)->SetDistributeWithMPI(nBlock == 1); + + this->ReaderSetFileName(this->GetFileName(iProc)); + + // Needed only when reading a different file on each proc + if (nBlock != 1) + { + vtkMEDReader::SafeDownCast(this->Reader)->ReloadInternals(); + this->Reader->UpdateInformation(); + } + + this->Reader->UpdateTimeStep(time); + vtkDataObject* outputReader = vtkMultiBlockDataSet::SafeDownCast(this->Reader->GetOutputDataObject(0))->GetBlock(0); + output->SetBlock(iProc, outputReader); + } + else + { + // Multiple files/block per proc + unsigned int nFiles = nBlock / nProc; + unsigned int offFile = iProc * nFiles; + unsigned int supFiles = nBlock % nProc; + + // Last proc handle remaining files/block + if (iProc + 1 == nProc) + { + nFiles += supFiles; + } + + for (unsigned int i = 0; i < nFiles; i++) + { + this->ReaderSetFileName(this->GetFileName(i + offFile)); + vtkMEDReader::SafeDownCast(this->Reader)->SetDistributeWithMPI(false); + vtkMEDReader::SafeDownCast(this->Reader)->ReloadInternals(); + this->Reader->UpdateInformation(); + this->Reader->UpdateTimeStep(time); + vtkDataObject* outputReader = vtkMultiBlockDataSet::SafeDownCast(this->Reader->GetOutputDataObject(0))->GetBlock(0); + if (i + 1 == nFiles) + { + // Last reader, just use the reader output directly + output->SetBlock(i + offFile, outputReader); + } + else + { + // Need to deep copy as the reader will be reused + vtkSmartPointer outputLeaf = vtkSmartPointer::Take(outputReader->NewInstance()); + outputLeaf->DeepCopy(outputReader); + output->SetBlock(i + offFile, outputLeaf); + } + } + } + return 1; +} + +//------------------------------------------------------------------------------ +int vtkFileSeriesGroupReader::FillOutputPortInformation( + int vtkNotUsed(port), vtkInformation* info) +{ + info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet"); + return 1; +} + +//----------------------------------------------------------------------------- +void vtkFileSeriesGroupReader::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); + + os << indent << "MetaFileName: " << (this->_MetaFileName ? this->_MetaFileName : "(none)") + << endl; +} diff --git a/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkFileSeriesGroupReader.h b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkFileSeriesGroupReader.h new file mode 100755 index 00000000..fbcb630d --- /dev/null +++ b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkFileSeriesGroupReader.h @@ -0,0 +1,83 @@ +// Copyright (C) 2022 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef vtkFileSeriesGroupReader_h +#define vtkFileSeriesGroupReader_h + +#include "vtkMetaReader.h" + +#include + +struct vtkFileSeriesGroupReaderInternals; + +class VTK_EXPORT vtkFileSeriesGroupReader : public vtkMetaReader +{ +public: + static vtkFileSeriesGroupReader* New(); + vtkTypeMacro(vtkFileSeriesGroupReader, vtkMetaReader); + void PrintSelf(ostream& os, vtkIndent indent) override; + + /** + * CanReadFile is forwarded to the internal reader if it supports it. + */ + virtual int CanReadFile(const char* filename); + + /** + * Adds names of files to be read. The files are read in the order + * they are added. + */ + virtual void AddFileName(const char* fname); + + /** + * Remove all file names. + */ + virtual void RemoveAllFileNames(); + + /** + * Returns the number of file names added by AddFileName. + */ + virtual unsigned int GetNumberOfFileNames(); + + /** + * Returns the name of a file with index idx. + */ + virtual const char* GetFileName(unsigned int idx); + +protected: + vtkFileSeriesGroupReader(); + ~vtkFileSeriesGroupReader() override; + + /** + * Add/Remove filenames without changing the MTime. + */ + void RemoveAllFileNamesInternal(); + void AddFileNameInternal(const char*); + + int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector); + int RequestData(vtkInformation* vtkNotUsed(request), vtkInformationVector** inputVector, vtkInformationVector* outputVector); + int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info); + +private: + vtkFileSeriesGroupReader(const vtkFileSeriesGroupReader&) = delete; + void operator=(const vtkFileSeriesGroupReader&) = delete; + + std::unique_ptr Internals; +}; + +#endif diff --git a/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkMEDReader.cxx b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkMEDReader.cxx old mode 100644 new mode 100755 index 2fba48c2..13fb3a14 --- a/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkMEDReader.cxx +++ b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkMEDReader.cxx @@ -65,7 +65,7 @@ class vtkMEDReader::vtkMEDReaderInternal { public: - vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),GCGCP(true) + vtkMEDReaderInternal(vtkMEDReader *master):TK(0),SIL(0),LastLev0(-1) { } @@ -76,21 +76,13 @@ public: } public: MEDFileFieldRepresentationTree Tree; - vtkNew FieldSelection; - vtkNew TimeFlagSelection; - TimeKeeper TK; - std::string FileName; - //when false -> std, true -> mode. By default std (false). - bool IsStdOrMode; - //when false -> do nothing. When true cut off or extend to nbOfCompo=3 vector arrays. - bool GenerateVect; + std::string DftMeshName; // Store the vtkMutableDirectedGraph that represents links between family, groups and cell types vtkMutableDirectedGraph* SIL; // store the lev0 id in Tree corresponding to the TIME_STEPS in the pipeline. int LastLev0; - bool GCGCP; }; vtkStandardNewMacro(vtkMEDReader) @@ -99,7 +91,7 @@ vtkStandardNewMacro(vtkMEDReader) // start of overload of vtkInformationKeyMacro static vtkInformationDataObjectMetaDataKey *vtkMEDReader_META_DATA=new vtkInformationDataObjectMetaDataKey("META_DATA","vtkMEDReader"); -vtkInformationDataObjectMetaDataKey *vtkMEDReader::META_DATA() +vtkInformationDataObjectMetaDataKey *vtkMEDReader::META_DATA() { static const char ZE_KEY[]="vtkMEDReader::META_DATA"; vtkInformationDataObjectMetaDataKey *ret(vtkMEDReader_META_DATA); @@ -114,7 +106,7 @@ vtkInformationDataObjectMetaDataKey *vtkMEDReader::META_DATA() static vtkInformationGaussDoubleVectorKey *vtkMEDReader_GAUSS_DATA=new vtkInformationGaussDoubleVectorKey("GAUSS_DATA","vtkMEDReader"); -vtkInformationGaussDoubleVectorKey *vtkMEDReader::GAUSS_DATA() +vtkInformationGaussDoubleVectorKey *vtkMEDReader::GAUSS_DATA() { static const char ZE_KEY[]="vtkMEDReader::GAUSS_DATA"; vtkInformationGaussDoubleVectorKey *ret(vtkMEDReader_GAUSS_DATA); @@ -143,21 +135,30 @@ vtkMEDReader::~vtkMEDReader() void vtkMEDReader::Reload() { - std::string fName((const char *)this->GetFileName()); + this->ReloadInternals(); + this->IsStdOrMode = false; + this->GenerateVect = false; + this->GCGCP = true; + this->FieldSelection->RemoveAllArrays(); + this->TimeFlagSelection->RemoveAllArrays(); + this->Modified(); +} +void vtkMEDReader::ReloadInternals() +{ delete this->Internal; this->Internal=new vtkMEDReaderInternal(this); - this->SetFileName(fName.c_str()); + this->Modified(); } void vtkMEDReader::GenerateVectors(int val) { if ( !this->Internal ) return; - + bool val2((bool)val); - if(val2!=this->Internal->GenerateVect) + if(val2!=this->GenerateVect) { - this->Internal->GenerateVect=val2; + this->GenerateVect=val2; this->Modified(); } } @@ -166,8 +167,8 @@ void vtkMEDReader::ChangeMode(int newMode) { if ( !this->Internal ) return; - - this->Internal->IsStdOrMode=newMode!=0; + + this->IsStdOrMode=newMode!=0; this->Modified(); } @@ -175,11 +176,11 @@ void vtkMEDReader::GhostCellGeneratorCallForPara(int gcgcp) { if ( !this->Internal ) return; - + bool newVal(gcgcp!=0); - if(newVal!=this->Internal->GCGCP) + if(newVal!=this->GCGCP) { - this->Internal->GCGCP=newVal; + this->GCGCP=newVal; this->Modified(); } } @@ -195,7 +196,7 @@ void vtkMEDReader::SetFileName(const char *fname) return; try { - this->Internal->FileName=fname; + this->FileName=fname; this->Modified(); } catch(INTERP_KERNEL::Exception& e) @@ -216,7 +217,7 @@ char *vtkMEDReader::GetFileName() { if (!this->Internal) return 0; - return const_cast(this->Internal->FileName.c_str()); + return const_cast(this->FileName.c_str()); } int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVector ** /*inputVector*/, vtkInformationVector *outputVector) @@ -231,22 +232,25 @@ int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVect { int iPart(-1),nbOfParts(-1); #ifdef MEDREADER_USE_MPI - vtkMultiProcessController *vmpc(vtkMultiProcessController::GetGlobalController()); - if(vmpc) + if (this->DistributeWithMPI) + { + vtkMultiProcessController *vmpc(vtkMultiProcessController::GetGlobalController()); + if(vmpc) { iPart=vmpc->GetLocalProcessId(); nbOfParts=vmpc->GetNumberOfProcesses(); } + } #endif - this->Internal->Tree.loadMainStructureOfFile(this->Internal->FileName.c_str(),iPart,nbOfParts); - + this->Internal->Tree.loadMainStructureOfFile(this->FileName.c_str(),iPart,nbOfParts); + // Leaves this->Internal->Tree.activateTheFirst();//This line manually initialize the status of server (this) with the remote client. for (int idLeaveArray = 0; idLeaveArray < this->Internal->Tree.getNumberOfLeavesArrays(); idLeaveArray++) { std::string name = this->Internal->Tree.getNameOf(idLeaveArray); bool status = this->Internal->Tree.getStatusOf(idLeaveArray); - this->Internal->FieldSelection->AddArray(name.c_str(), status); + this->FieldSelection->AddArray(name.c_str(), status); } } @@ -257,24 +261,24 @@ int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVect { std::string name = timeFlagsArray[idTimeFlag].second; bool status = timeFlagsArray[idTimeFlag].first; - this->Internal->TimeFlagSelection->AddArray(name.c_str(), status); + this->TimeFlagSelection->AddArray(name.c_str(), status); } // Make sure internal model are synchronized /// So the SIL is up to date - int nArrays = this->Internal->FieldSelection->GetNumberOfArrays(); + int nArrays = this->FieldSelection->GetNumberOfArrays(); for(int i = nArrays - 1; i >= 0; i--) { try { this->Internal->Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet( - this->Internal->Tree.getIdHavingZeName(this->Internal->FieldSelection->GetArrayName(i)), - this->Internal->FieldSelection->GetArraySetting(i)); + this->Internal->Tree.getIdHavingZeName(this->FieldSelection->GetArrayName(i)), + this->FieldSelection->GetArraySetting(i)); } catch(INTERP_KERNEL::Exception& e) { // Remove the incorrect array - this->Internal->FieldSelection->RemoveArrayByIndex(i); + this->FieldSelection->RemoveArrayByIndex(i); } } @@ -311,22 +315,22 @@ int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector ** / return 0; try { - for(int i = 0; i < this->Internal->FieldSelection->GetNumberOfArrays(); i++) + for(int i = 0; i < this->FieldSelection->GetNumberOfArrays(); i++) { this->Internal->Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet( - this->Internal->Tree.getIdHavingZeName(this->Internal->FieldSelection->GetArrayName(i)), - this->Internal->FieldSelection->GetArraySetting(i)); + this->Internal->Tree.getIdHavingZeName(this->FieldSelection->GetArrayName(i)), + this->FieldSelection->GetArraySetting(i)); } - + auto& timeFlagsArray = this->Internal->TK.getTimesFlagArray(); - if (timeFlagsArray.size() != this->Internal->TimeFlagSelection->GetNumberOfArrays()) + if (timeFlagsArray.size() != this->TimeFlagSelection->GetNumberOfArrays()) { throw INTERP_KERNEL::Exception("Unexpected size of TimeFlagSelection"); } - for(int i = 0; i < this->Internal->TimeFlagSelection->GetNumberOfArrays(); i++) + for(int i = 0; i < this->TimeFlagSelection->GetNumberOfArrays(); i++) { - timeFlagsArray[i] = std::make_pair(this->Internal->TimeFlagSelection->GetArraySetting(i), - this->Internal->TimeFlagSelection->GetArrayName(i)); + timeFlagsArray[i] = std::make_pair(this->TimeFlagSelection->GetArraySetting(i), + this->TimeFlagSelection->GetArrayName(i)); } // request->Print(cout); @@ -340,26 +344,22 @@ int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector ** / #ifndef MEDREADER_USE_MPI this->FillMultiBlockDataSetInstance(output,reqTS,&ti); #else - int nbParts(0); - vtkMultiProcessController *vmpc(vtkMultiProcessController::GetGlobalController()); - if( vmpc ) - nbParts = vmpc->GetNumberOfProcesses(); - if(this->Internal->GCGCP && nbParts>1) - { - vtkSmartPointer gcg(vtkSmartPointer::New()); - { - vtkDataSet *ret(RetrieveDataSetAtTime(reqTS,&ti)); - gcg->SetInputData(ret); - ret->Delete(); - } - // To be checked - // gcg->SetUseGlobalPointIds(true); - gcg->SetBuildIfRequired(false); - gcg->Update(); - output->SetBlock(0,gcg->GetOutput()); - } + if (this->DistributeWithMPI && this->GCGCP) + { + vtkSmartPointer gcg(vtkSmartPointer::New()); + { + vtkDataSet *ret(RetrieveDataSetAtTime(reqTS,&ti)); + gcg->SetInputData(ret); + ret->Delete(); + } + // To be checked + // gcg->SetUseGlobalPointIds(true); + gcg->SetBuildIfRequired(false); + gcg->Update(); + output->SetBlock(0,gcg->GetOutput()); + } else - this->FillMultiBlockDataSetInstance(output,reqTS,&ti); + this->FillMultiBlockDataSetInstance(output,reqTS,&ti); #endif if(!ti.empty()) { @@ -382,19 +382,19 @@ int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector ** / //------------------------------------------------------------------------------ int vtkMEDReader::GetNumberOfFieldsTreeArrays() { - return this->Internal->FieldSelection->GetNumberOfArrays(); + return this->FieldSelection->GetNumberOfArrays(); } //------------------------------------------------------------------------------ const char* vtkMEDReader::GetFieldsTreeArrayName(int index) { - return this->Internal->FieldSelection->GetArrayName(index); + return this->FieldSelection->GetArrayName(index); } //------------------------------------------------------------------------------ int vtkMEDReader::GetFieldsTreeArrayStatus(const char* name) { - return this->Internal->FieldSelection->ArrayIsEnabled(name); + return this->FieldSelection->ArrayIsEnabled(name); } //------------------------------------------------------------------------------ @@ -404,11 +404,11 @@ void vtkMEDReader::SetFieldsStatus(const char* name, int status) { if (status) { - this->Internal->FieldSelection->EnableArray(name); + this->FieldSelection->EnableArray(name); } else { - this->Internal->FieldSelection->DisableArray(name); + this->FieldSelection->DisableArray(name); } this->Modified(); } @@ -417,19 +417,19 @@ void vtkMEDReader::SetFieldsStatus(const char* name, int status) //------------------------------------------------------------------------------ int vtkMEDReader::GetNumberOfTimesFlagsArrays() { - return this->Internal->TimeFlagSelection->GetNumberOfArrays(); + return this->TimeFlagSelection->GetNumberOfArrays(); } //------------------------------------------------------------------------------ const char* vtkMEDReader::GetTimesFlagsArrayName(int index) { - return this->Internal->TimeFlagSelection->GetArrayName(index); + return this->TimeFlagSelection->GetArrayName(index); } //------------------------------------------------------------------------------ int vtkMEDReader::GetTimesFlagsArrayStatus(const char* name) { - return this->Internal->TimeFlagSelection->ArrayIsEnabled(name); + return this->TimeFlagSelection->ArrayIsEnabled(name); } //------------------------------------------------------------------------------ @@ -439,11 +439,11 @@ void vtkMEDReader::SetTimesFlagsStatus(const char* name, int status) { if (status) { - this->Internal->TimeFlagSelection->EnableArray(name); + this->TimeFlagSelection->EnableArray(name); } else { - this->Internal->TimeFlagSelection->DisableArray(name); + this->TimeFlagSelection->DisableArray(name); } this->Modified(); } @@ -513,7 +513,7 @@ double vtkMEDReader::PublishTimeStepsIfNeeded(vtkInformation *outInfo, bool& isU int lev0(-1); std::vector tsteps; - if(!this->Internal->IsStdOrMode) + if(!this->IsStdOrMode) tsteps=this->Internal->Tree.getTimeSteps(lev0,this->Internal->TK); else { tsteps.resize(1); tsteps[0]=0.; } @@ -545,8 +545,8 @@ vtkDataSet *vtkMEDReader::RetrieveDataSetAtTime(double reqTS, ExportedTinyInfo * if( !this->Internal ) return 0; std::string meshName; - vtkDataSet *ret(this->Internal->Tree.buildVTKInstance(this->Internal->IsStdOrMode,reqTS,meshName,this->Internal->TK,internalInfo)); - if(this->Internal->GenerateVect) + vtkDataSet *ret(this->Internal->Tree.buildVTKInstance(this->IsStdOrMode,reqTS,meshName,this->Internal->TK,internalInfo)); + if(this->GenerateVect) { vtkGenerateVectors::Operate(ret->GetPointData()); vtkGenerateVectors::Operate(ret->GetCellData()); diff --git a/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkMEDReader.h b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkMEDReader.h old mode 100644 new mode 100755 index 40d3a4a3..3d76bee1 --- a/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkMEDReader.h +++ b/src/Plugins/MEDReader/plugin/MEDReaderIO/vtkMEDReader.h @@ -25,7 +25,9 @@ #include "vtkMultiBlockDataSetAlgorithm.h" #include "vtkInformationGaussDoubleVectorKey.h" +#include "vtkNew.h" +class vtkDataArraySelection; class vtkDataSet; class vtkMutableDirectedGraph; class vtkInformationDataObjectMetaDataKey; @@ -60,8 +62,13 @@ class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm // Description // Reload will delete the internal reader and recreate it with default properties + // As well as reset public properties to their default values, except for the FileName virtual void Reload(); + // Description + // ReloadInternals will delete the internal reader and recreate it + virtual void ReloadInternals(); + virtual void GenerateVectors(int); virtual void ChangeMode(int); virtual void GhostCellGeneratorCallForPara(int); @@ -72,6 +79,12 @@ class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm static vtkInformationDataObjectMetaDataKey* META_DATA(); static vtkInformationGaussDoubleVectorKey* GAUSS_DATA(); + // Description + // Control if MPI should be used for distribution when using a distributed server + // Only has an effect if MEDREADER_USE_MPI is defined. + vtkSetMacro(DistributeWithMPI, bool); + vtkGetMacro(DistributeWithMPI, bool); + protected: vtkMEDReader(); virtual ~vtkMEDReader(); @@ -88,6 +101,16 @@ class VTK_EXPORT vtkMEDReader : public vtkMultiBlockDataSetAlgorithm class vtkMEDReaderInternal; vtkMEDReaderInternal* Internal; + + vtkNew FieldSelection; + vtkNew TimeFlagSelection; + std::string FileName; + //when false -> std, true -> mode. By default std (false). + bool IsStdOrMode = false; + //when false -> do nothing. When true cut off or extend to nbOfCompo=3 vector arrays. + bool GenerateVect = false; + bool GCGCP = true; + bool DistributeWithMPI = true; }; #endif //__vtkMEDReader_h_ diff --git a/src/Plugins/MEDReader/plugin/ParaViewPlugin/Resources/MEDReaderServer.xml b/src/Plugins/MEDReader/plugin/ParaViewPlugin/Resources/MEDReaderServer.xml index 346d0e80..b1522a2d 100644 --- a/src/Plugins/MEDReader/plugin/ParaViewPlugin/Resources/MEDReaderServer.xml +++ b/src/Plugins/MEDReader/plugin/ParaViewPlugin/Resources/MEDReaderServer.xml @@ -1,6 +1,6 @@ - - + + + + + + + + + + + + + + + + + + + + + + The list of files to be read by the + reader. + + + + + + + + + + + diff --git a/src/Plugins/MEDReader/plugin/Test/TestDataAnalysis.py b/src/Plugins/MEDReader/plugin/Test/TestDataAnalysis.py index 88778869..9b73133b 100644 --- a/src/Plugins/MEDReader/plugin/Test/TestDataAnalysis.py +++ b/src/Plugins/MEDReader/plugin/Test/TestDataAnalysis.py @@ -41,7 +41,7 @@ ROSETTE = True print ("**** Importing MED file") -myResult0 = MEDReader(FileName=MEDFILE) +myResult0 = MEDReader(FileNames=[MEDFILE]) if myResult0 is None : raise "Erreur de fichier MED" # Imposition GenerateVectors à faire diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader0.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader0.py index cf10cf46..04284119 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader0.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader0.py @@ -88,20 +88,20 @@ def test0(baseline_file): fname = GenerateCase() ################### MED write is done -> Go to MEDReader - myMedReader=MEDReader(FileName=fname) + myMedReader=MEDReader(FileNames=[fname]) - myMedReader.AllArrays = ['TS0/mesh/ComSup0/SolutionDEPL@@][@@P1', 'NotAValidName'] + myMedReader.FieldsStatus = ['TS0/mesh/ComSup0/SolutionDEPL@@][@@P1', 'NotAValidName'] myMedReader.UpdatePipeline() - myMedReader.AllArrays = ['TS0/mesh/ComSup0/SolutionDEPL@@][@@P1', 'TS0/mesh/ComSup0/SolutionSIEF_ELGA@@][@@GAUSS', 'TS0/mesh/ComSup0/SolutionSIEQ_ELNO@@][@@GSSNE', 'TS0/mesh/ComSup0/mesh@@][@@P0'] + myMedReader.FieldsStatus = ['TS0/mesh/ComSup0/SolutionDEPL@@][@@P1', 'TS0/mesh/ComSup0/SolutionSIEF_ELGA@@][@@GAUSS', 'TS0/mesh/ComSup0/SolutionSIEQ_ELNO@@][@@GSSNE', 'TS0/mesh/ComSup0/mesh@@][@@P0'] myMedReader.UpdatePipeline() - assert(myMedReader.CellData.GetNumberOfArrays()==4) + assert(myMedReader.CellData.GetNumberOfArrays()==5) # vtkGhostType keys=myMedReader.GetProperty("FieldsTreeInfo")[::2] # list all the names of arrays that can be seen (including their spatial discretization) arr_name_with_dis=[elt.split("/")[-1] for elt in keys] # list all the names of arrays (Equal to those in the MED File) arr_name=[elt.split(myMedReader.GetProperty("Separator").GetData())[0] for elt in arr_name_with_dis] - myMedReader.AllArrays=keys + myMedReader.FieldsStatus=keys if '-D' not in sys.argv: RenderView1 = GetRenderView() diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader10.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader10.py index e87b5429..5d9fcb6e 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader10.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader10.py @@ -63,14 +63,14 @@ def GenerateCase(): def test(baseline_file): fname = GenerateCase() ################### MED write is done -> Go to MEDReader - myMedReader=MEDReader(FileName=fname) + myMedReader=MEDReader(FileNames=[fname]) keys=myMedReader.GetProperty("FieldsTreeInfo")[::2] # list all the names of arrays that can be seen (including their spatial discretization) arr_name_with_dis=[elt.split("/")[-1] for elt in keys] # list all the names of arrays (Equal to those in the MED File) arr_name=[elt.split(myMedReader.GetProperty("Separator").GetData())[0] for elt in arr_name_with_dis] - myMedReader.AllArrays=keys - myMedReader.GenerateVectors=1 + myMedReader.FieldsStatus=keys + myMedReader.VectorsProperty=1 if '-D' not in sys.argv: RenderView1=GetRenderView() @@ -89,7 +89,8 @@ def test(baseline_file): wbv=WarpByVector(Input=myMedReader) wbv.ScaleFactor=0.1 wbv.Vectors=['POINTS','f3NbComp4_Vector'] - assert(list(wbv.PointData.keys())==['f0NbComp1','f1NbComp2','f1NbComp2_Vector','f2NbComp3','f3NbComp4','f3NbComp4_Vector']) + print( list(wbv.PointData.keys()) ) + assert(list(wbv.PointData.keys())==['f0NbComp1','f1NbComp2','f1NbComp2_Vector','f2NbComp3','f3NbComp4','f3NbComp4_Vector','vtkGhostType']) # DataRepresentation2 = Show() DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483] diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader13.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader13.py index 0fbc7015..9285d5e9 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader13.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader13.py @@ -47,10 +47,10 @@ def GenerateCase(): def test(baseline_file): fname = GenerateCase() ################### MED write is done -> Go to MEDReader - testMEDReader13_med = MEDReader( FileName=fname ) + testMEDReader13_med = MEDReader( FileNames=[fname] ) - testMEDReader13_med.GenerateVectors = 1 - testMEDReader13_med.AllArrays = ['TS0/mesh/ComSup0/fieldELNO@@][@@GSSNE'] + testMEDReader13_med.VectorsProperty = 1 + testMEDReader13_med.FieldsStatus = ['TS0/mesh/ComSup0/fieldELNO@@][@@GSSNE'] if '-D' not in sys.argv: RenderView1 = GetRenderView() diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader14.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader14.py index 1c2fe502..7bc42ffc 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader14.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader14.py @@ -131,15 +131,15 @@ def GenerateCase(): @WriteInTmpDir def test(baseline_file): fname = GenerateCase() - reader=MEDReader(FileName=fname) + reader=MEDReader(FileNames=[fname]) ExpectedEntries=['TS0/Mesh/ComSup0/zeField0_MM0@@][@@GAUSS', 'TS0/Mesh/ComSup1/zeField0_MM1@@][@@GAUSS', 'TS0/Mesh/ComSup2/zeField0_MM2@@][@@GAUSS', 'TS0/Mesh/ComSup2/zeField1_MM0@@][@@GAUSS', 'TS0/Mesh/ComSup3/zeField1_MM1@@][@@GAUSS', 'TS0/Mesh/ComSup4/zeField2@@][@@P1', 'TS1/Mesh/ComSup0/Mesh@@][@@P0'] assert(reader.GetProperty("FieldsTreeInfo")[::2]==ExpectedEntries) if '-D' not in sys.argv: renderView1=GetActiveViewOrCreate('RenderView') for entry in [[ExpectedEntries[0]],[ExpectedEntries[1]],[ExpectedEntries[2],ExpectedEntries[3]],[ExpectedEntries[4]]]: - reader=MEDReader(FileName=fname) - reader.AllArrays=entry + reader=MEDReader(FileNames=[fname]) + reader.FieldsStatus=entry gaussPoints=ELGAfieldToPointGaussian(Input=reader) gaussPoints.SelectSourceArray=['CELLS', 'ELGA@0'] Show(gaussPoints,renderView1) @@ -147,8 +147,8 @@ def test(baseline_file): # - readerNodeField=MEDReader(FileName=fname) - readerNodeField.AllArrays=[ExpectedEntries[5]] + readerNodeField=MEDReader(FileNames=[fname]) + readerNodeField.FieldsStatus=[ExpectedEntries[5]] nodeFieldDisplay=Show(readerNodeField,renderView1) ColorBy(nodeFieldDisplay,('POINTS','zeField2')) nodeFieldDisplay.RescaleTransferFunctionToDataRange(True) diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader15.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader15.py index 7aa2a922..33fb7d10 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader15.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader15.py @@ -51,7 +51,7 @@ def GenerateCase(): @WriteInTmpDir def test(baseline_file): fname = GenerateCase() - reader=MEDReader(FileName=fname) + reader=MEDReader(FileNames=[fname]) ExpectedEntries=['TS0/zeName/ComSup0/zeName@@][@@P1','TS0/zeName/ComSup0/MESH@zeName@@][@@P1'] assert(reader.GetProperty("FieldsTreeInfo")[::2]==ExpectedEntries) diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader16.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader16.py index 906bdf24..a497dadf 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader16.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader16.py @@ -51,10 +51,10 @@ def GenerateCase(): def test(): fname,arr2 = GenerateCase() # - reader=MEDReader(FileName=fname) + reader=MEDReader(FileNames=[fname]) ExpectedEntries=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE','TS1/Mesh/ComSup0/Mesh@@][@@P0'] assert(reader.GetProperty("FieldsTreeInfo")[::2]==ExpectedEntries) - reader.AllArrays=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE'] + reader.FieldsStatus=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE'] ExtractGroup1 = ExtractGroup(Input=reader) #ExtractGroup1.UpdatePipelineInformation() ExtractGroup1.AllGroups=["GRP_grp1"] diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader17.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader17.py index 58e533c7..d964583b 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader17.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader17.py @@ -50,10 +50,10 @@ def GenerateCase(): def test(): fname = GenerateCase() # - reader=MEDReader(FileName=fname) + reader=MEDReader(FileNames=[fname]) ExpectedEntries=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE','TS1/Mesh/ComSup0/Mesh@@][@@P0'] assert(reader.GetProperty("FieldsTreeInfo")[::2]==ExpectedEntries) - reader.AllArrays=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE'] + reader.FieldsStatus=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE'] ExtractGroup1 = ExtractGroup(Input=reader) #ExtractGroup1.UpdatePipelineInformation() ExtractGroup1.AllGroups=["GRP_grp1"] diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader18.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader18.py index 81548148..58839809 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader18.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader18.py @@ -48,8 +48,8 @@ def GenerateCase(): @WriteInTmpDir def test(): fname = GenerateCase() - reader=MEDReader(FileName=fname) - reader.AllArrays=['TS0/mesh/ComSup0/mesh@@][@@P0'] + reader=MEDReader(FileNames=[fname]) + reader.FieldsStatus=['TS0/mesh/ComSup0/mesh@@][@@P0'] ExtractGroup1 = ExtractGroup(Input=reader) ExtractGroup1.AllGroups=["GRP_grp0","GRP_grp1"] #ExtractGroup1.UpdatePipelineInformation() diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader19.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader19.py index f0246d40..7003e439 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader19.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader19.py @@ -55,11 +55,11 @@ def GenerateCase(): def test(baseline_file): fname = GenerateCase() # create a new 'MED Reader' - testMEDReader19med = MEDReader(FileName=fname) - testMEDReader19med.AllArrays = ['TS0/mesh/ComSup0/mesh@@][@@P0'] - testMEDReader19med.AllTimeSteps = ['0000'] + testMEDReader19med = MEDReader(FileNames=[fname]) + testMEDReader19med.FieldsStatus = ['TS0/mesh/ComSup0/mesh@@][@@P0'] + testMEDReader19med.TimesFlagsStatus = ['0000'] # Properties modified on testMEDReader19med - testMEDReader19med.AllArrays = ['TS0/mesh/ComSup0/mesh@@][@@P0'] + testMEDReader19med.FieldsStatus = ['TS0/mesh/ComSup0/mesh@@][@@P0'] if '-D' not in sys.argv: # get active view diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader2.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader2.py index fd9ac499..b52709db 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader2.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader2.py @@ -62,10 +62,10 @@ def GenerateCase(): def test(baseline_file): fname = GenerateCase() ################### MED write is done -> Go to MEDReader - testMEDReader1=MEDReader(FileName=fname,registrationName='testMEDReader2.med') - testMEDReader1.AllArrays=['TS0/mesh/ComSup0/ACellField@@][@@P0'] - testMEDReader2=MEDReader(FileName=fname,registrationName='testMEDReader2_bis.med') - testMEDReader2.AllArrays=['TS0/mesh/ComSup1/mesh@@][@@P0'] + testMEDReader1=MEDReader(FileNames=[fname],registrationName='testMEDReader2.med') + testMEDReader1.FieldsStatus=['TS0/mesh/ComSup0/ACellField@@][@@P0'] + testMEDReader2=MEDReader(FileNames=[fname],registrationName='testMEDReader2_bis.med') + testMEDReader2.FieldsStatus=['TS0/mesh/ComSup1/mesh@@][@@P0'] GroupDatasets1=GroupDatasets(Input=[testMEDReader1,testMEDReader2]) #GroupDatasets1.BlockNames = ['testMEDReader2.med', 'testMEDReader2_bis.med'] diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader20.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader20.py index 2e399fbd..d28b5f7b 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader20.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader20.py @@ -74,9 +74,9 @@ def test(baseline_file): fname = GenerateCase() ##################### # create a new 'MED Reader' - testMEDReader20med = MEDReader(FileName=fname) - testMEDReader20med.AllArrays = ['TS0/mesh/ComSup0/Field@@][@@P0'] - testMEDReader20med.AllTimeSteps = ['0000', '0001', '0002', '0003', '0004'] + testMEDReader20med = MEDReader(FileNames=[fname]) + testMEDReader20med.FieldsStatus = ['TS0/mesh/ComSup0/Field@@][@@P0'] + testMEDReader20med.TimesFlagsStatus = ['0000', '0001', '0002', '0003', '0004'] # get animation scene animationScene1 = GetAnimationScene() diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader21.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader21.py index a9bf4640..6dc53a5f 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader21.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader21.py @@ -48,9 +48,9 @@ def GenerateCase(): def test(baseline_file): fname, meshName, fieldName = GenerateCase() ######## - testTotomed = MEDReader(FileName=fname) - testTotomed.AllArrays = ['TS0/%s/ComSup0/%s@@][@@GSSNE'%(meshName,fieldName)] - testTotomed.AllTimeSteps = ['0000'] + testTotomed = MEDReader(FileNames=[fname]) + testTotomed.FieldsStatus = ['TS0/%s/ComSup0/%s@@][@@GSSNE'%(meshName,fieldName)] + testTotomed.TimesFlagsStatus = ['0000'] if '-D' not in sys.argv: # get active view diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader22.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader22.py index 77964463..d3ea9855 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader22.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader22.py @@ -66,9 +66,9 @@ def generateCase(fname): def test(): fname = "testMEDReader22.med" f,f2,grp_BottomLeft,grp_BottomRight,grp_TopLeft,grp_TopRight = generateCase(fname) - reader = MEDReader(FileName=fname) - reader.AllArrays = ['TS0/mesh/ComSup0/field@@][@@P0','TS0/mesh/ComSup0/field2@@][@@P1','TS0/mesh/ComSup0/mesh@@][@@P0'] - reader.AllTimeSteps = ['0000'] + reader = MEDReader(FileNames=[fname]) + reader.FieldsStatus = ['TS0/mesh/ComSup0/field@@][@@P0','TS0/mesh/ComSup0/field2@@][@@P1','TS0/mesh/ComSup0/mesh@@][@@P0'] + reader.TimesFlagsStatus = ['0000'] groupsNames = GroupsNames(Input=reader) groupsNames.UpdatePipeline() @@ -88,7 +88,7 @@ def test(): ds_bl = blocks.GetBlock(0) MyAssert(ds_bl.GetNumberOfCells()==4) bl_ref_conn = np.array([ 1, 0, 6, 7, 2, 1, 7, 8, 7, 6, 12, 13, 8, 7, 13, 14],dtype=np.int32) - MyAssert(ds_bl.GetCellData().GetNumberOfArrays() == 3 )# 3 for field, mesh and FamilyIdCell + MyAssert(ds_bl.GetCellData().GetNumberOfArrays() == 4 )# 3 for field, mesh and FamilyIdCell +1 for vtkGhostType MyAssert(np.all( bl_ref_conn == numpy_support.vtk_to_numpy( ds_bl.GetCells().GetConnectivityArray() )) ) MyAssert( mc.DataArrayDouble(numpy_support.vtk_to_numpy( ds_bl.GetCellData().GetArray("field") )).isEqual(f.getArray()[grp_BottomLeft],1e-12) ) # test of bottom right @@ -111,7 +111,7 @@ def test(): MyAssert( mc.DataArrayDouble(numpy_support.vtk_to_numpy( ds_tr.GetCellData().GetArray("field") )).isEqual(f.getArray()[grp_TopRight],1e-12) ) # for ds in [ds_bl,ds_br,ds_tl,ds_tr]: - MyAssert(ds.GetPointData().GetNumberOfArrays() == 1 )# 1 for field2 + MyAssert(ds.GetPointData().GetNumberOfArrays() == 2 )# 1 for field2 + vtkGhostType MyAssert(ds.GetNumberOfPoints()==36) # for performance reasons all blocks share the same input coordinates MyAssert(mc.DataArrayDouble( numpy_support.vtk_to_numpy( ds.GetPointData().GetArray("field2") ) ).isEqual(f2.getArray(),1e-12) ) diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader23.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader23.py index d3cf0f7a..95b4f02e 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader23.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader23.py @@ -45,11 +45,11 @@ def generateCase(fname,globalNodeIds,coordinates): mm.write(fname,2) generateCase(fname,ids,coo) -myMedReader = MEDReader(registrationName = fname, FileName = fname) -myMedReader.AllArrays = ['TS0/mesh/ComSup0/mesh@@][@@P0'] +myMedReader = MEDReader(registrationName = fname, FileNames = [fname]) +myMedReader.FieldsStatus = ['TS0/mesh/ComSup0/mesh@@][@@P0'] myMedReader.UpdatePipeline() # first important testing here -MyAssert( [myMedReader.PointData.GetArray(i).GetName() for i in range(myMedReader.PointData.GetNumberOfArrays())] == ['GlobalNodeIds'] ) +MyAssert( [myMedReader.PointData.GetArray(i).GetName() for i in range(myMedReader.PointData.GetNumberOfArrays())] == ['GlobalNodeIds','vtkGhostType'] ) ReadUnstructuredGrid = servermanager.Fetch(myMedReader).GetBlock(0) numpy_support.vtk_to_numpy( ReadUnstructuredGrid.GetPointData().GetArray('GlobalNodeIds') ) # check match of coordinates written in testMEDReader23.med file and its representation diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader24.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader24.py index 857603fc..f0d10194 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader24.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader24.py @@ -137,12 +137,12 @@ fs.write(fname,0) from paraview.simple import * -testMEDReader24_med = MEDReader( FileName=fname ) -testMEDReader24_med.AllArrays = ['TS0/Maillage_THYC/ComSup0/ENERGIE RECUE@@][@@P0', 'TS0/Maillage_THYC/ComSup0/ENTHALPIE@@][@@P0', 'TS0/Maillage_THYC/ComSup0/PRESSION@@][@@P0', 'TS0/Maillage_THYC/ComSup0/TEMPERATURE@@][@@P0'] +testMEDReader24_med = MEDReader( FileNames=[fname] ) +testMEDReader24_med.FieldsStatus = ['TS0/Maillage_THYC/ComSup0/ENERGIE RECUE@@][@@P0', 'TS0/Maillage_THYC/ComSup0/ENTHALPIE@@][@@P0', 'TS0/Maillage_THYC/ComSup0/PRESSION@@][@@P0', 'TS0/Maillage_THYC/ComSup0/TEMPERATURE@@][@@P0'] testMEDReader24_med.UpdatePipeline() ds0 = servermanager.Fetch(testMEDReader24_med).GetBlock(0) assert( ds0.GetNumberOfCells() == 224 ) -testMEDReader24_med.AllArrays = ['TS2/Maillage_THYC/ComSup0/Maillage_THYC@@][@@P0'] # test is here. A rectilinear dataset is expected here +testMEDReader24_med.FieldsStatus = ['TS2/Maillage_THYC/ComSup0/Maillage_THYC@@][@@P0'] # test is here. A rectilinear dataset is expected here testMEDReader24_med.UpdatePipeline() ds0 = servermanager.Fetch(testMEDReader24_med).GetBlock(0) assert( ds0.GetNumberOfCells() == 256 ) # test is here 0 means problem in the management of rectilineargrid into MEDReader diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader3.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader3.py index b1bb65ca..66631c1a 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader3.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader3.py @@ -94,8 +94,8 @@ def test(baseline_file): AnimationScene1.AnimationTime = 1.0 AnimationScene1.StartTime = 1.0 - testMEDReader3=MEDReader(FileName=fname) - testMEDReader3.AllArrays=['TS0/mesh/ComSup0/ANodeField@@][@@P1'] + testMEDReader3=MEDReader(FileNames=[fname]) + testMEDReader3.FieldsStatus=['TS0/mesh/ComSup0/ANodeField@@][@@P1'] assert(list(testMEDReader3.TimestepValues)==[1.,2.,3.,4.,5.]) ## <- the test is here - double time steps are too big use dt. diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader4.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader4.py index 2124a004..59da6cfd 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader4.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader4.py @@ -71,9 +71,9 @@ def test(baseline_file): ################### MED write is done -> Go to MEDReader fname = GenerateCase() - testMEDReader4_med=MEDReader(FileName=fname) + testMEDReader4_med=MEDReader(FileNames=[fname]) - testMEDReader4_med.AllArrays=['TS0/mesh/ComSup0/f0NoPfl@@][@@P1','TS0/mesh/ComSup0/mesh@@][@@P1'] + testMEDReader4_med.FieldsStatus=['TS0/mesh/ComSup0/f0NoPfl@@][@@P1','TS0/mesh/ComSup0/mesh@@][@@P1'] #testMEDReader4_med.AllTimeSteps=['0000'] Glyph1=Glyph(Input=testMEDReader4_med,GlyphType='Sphere') diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader6.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader6.py index e0212f79..261b2029 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader6.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader6.py @@ -65,9 +65,9 @@ def test(baseline_file): fname = GenerateCase() ################### MED write is done -> Go to MEDReader - myMedReader=MEDReader(FileName=fname) - myMedReader.AllArrays = ['TS0/mesh/ComSup0/fGauss@@][@@GAUSS'] - myMedReader.AllTimeSteps = ['0000'] + myMedReader=MEDReader(FileNames=[fname]) + myMedReader.FieldsStatus = ['TS0/mesh/ComSup0/fGauss@@][@@GAUSS'] + myMedReader.TimesFlagsStatus = ['0000'] ExtractGroup1 = ExtractGroup(Input=myMedReader) ExtractGroup1.UpdatePipelineInformation() diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader7.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader7.py index 35fbf642..9b3abd17 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader7.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader7.py @@ -75,8 +75,8 @@ def GenerateCase(): def test(baseline_file): fname = GenerateCase() ################### MED write is done -> Go to MEDReader - myMedReader=MEDReader(FileName=fname) - myMedReader.AllArrays = ['TS0/mesh/ComSup0/fNode@@][@@P1'] + myMedReader=MEDReader(FileNames=[fname]) + myMedReader.FieldsStatus = ['TS0/mesh/ComSup0/fNode@@][@@P1'] assert(list(myMedReader.TimestepValues)==[0.,1.,2.,3.]) if '-D' not in sys.argv: diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader8.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader8.py index 49a8cfb0..b78da6f8 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader8.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader8.py @@ -74,8 +74,8 @@ def test(baseline_file): fname = GenerateCase() ################### MED write is done -> Go to MEDReader - myMedReader=MEDReader(FileName=fname) - myMedReader.AllArrays = ['TS0/mesh/ComSup0/fNode@@][@@P1'] + myMedReader=MEDReader(FileNames=[fname]) + myMedReader.FieldsStatus = ['TS0/mesh/ComSup0/fNode@@][@@P1'] assert(list(myMedReader.TimestepValues)==[0.,1.,2.,3.]) myMedReader.UpdatePipeline() diff --git a/src/Plugins/MEDReader/plugin/Test/testMEDReader9.py b/src/Plugins/MEDReader/plugin/Test/testMEDReader9.py index 1c7c4956..6bc16c94 100644 --- a/src/Plugins/MEDReader/plugin/Test/testMEDReader9.py +++ b/src/Plugins/MEDReader/plugin/Test/testMEDReader9.py @@ -47,12 +47,12 @@ def GenerateCase(): def test(): fname = GenerateCase() ################### MED write is done -> Go to MEDReader - myMedReader=MEDReader(FileName=fname) - myMedReader.AllArrays=['TS0/m1/ComSup0/f1@@][@@P0'] + myMedReader=MEDReader(FileNames=[fname]) + myMedReader.FieldsStatus=['TS0/m1/ComSup0/f1@@][@@P0'] ExtractGroup1=ExtractGroup(Input=myMedReader) ExtractGroup1.UpdatePipeline() assert(ExtractGroup1.GetProperty("MeshName")[0]=="m1") - myMedReader.AllArrays=['TS0/m2/ComSup0/f2@@][@@P0'] + myMedReader.FieldsStatus=['TS0/m2/ComSup0/f2@@][@@P0'] ExtractGroup2=ExtractGroup(Input=myMedReader) ExtractGroup2.UpdatePipeline() assert(ExtractGroup2.GetProperty("MeshName")[0]=="m2")