From c1f855726fa7b4d300ca9d4291a927ec6b928bc4 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 10 Oct 2014 09:23:52 +0200 Subject: [PATCH] Make the // MEDReader working even in builtin mode. --- .../IO/MEDFileFieldRepresentationTree.cxx | 16 ++++++++++++---- src/Plugins/MEDReader/IO/vtkMEDReader.cxx | 19 ++++++++++++++++--- src/Plugins/MEDReader/Test/testMEDReader13.py | 10 +++++----- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index 11bb8031..3669c63c 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -1095,13 +1095,21 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam { if(isMEDOrSauv) { + if((iPart==-1 && nbOfParts==-1) || (iPart==0 && nbOfParts==1)) + { + _ms=MEDFileMeshes::New(fileName); + _fields=MEDFileFields::New(fileName,false);//false is important to not read the values + } + else + { #ifdef MEDREADER_USE_MPI - _ms=ParaMEDFileMeshes::New(iPart,nbOfParts,fileName); - _fields=MEDFileFields::LoadPartOf(fileName,false,_ms);//false is important to not read the values + _ms=ParaMEDFileMeshes::New(iPart,nbOfParts,fileName); + _fields=MEDFileFields::LoadPartOf(fileName,false,_ms);//false is important to not read the values #else - _ms=MEDFileMeshes::New(fileName); - _fields=MEDFileFields::New(fileName,false);//false is important to not read the values + std::ostringstream oss; oss << "MEDFileFieldRepresentationTree::loadMainStructureOfFile : request for iPart/nbOfParts=" << iPart << "/" << nbOfParts << " whereas Plugin not compiled with MPI !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); #endif + } } else { diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx index 602d9695..b8cc95b9 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx @@ -44,6 +44,9 @@ #include "vtkCellArray.h" #include "vtkDoubleArray.h" #include "vtkObjectFactory.h" +#ifdef MEDREADER_USE_MPI +#include "vtkMultiProcessController.h" +#endif #include "MEDFileFieldRepresentationTree.hxx" @@ -259,8 +262,12 @@ void vtkMEDReader::SetFileName(const char *fname) { int iPart(-1),nbOfParts(-1); #ifdef MEDREADER_USE_MPI - MPI_Comm_rank(MPI_COMM_WORLD,&iPart); - MPI_Comm_size(MPI_COMM_WORLD,&nbOfParts); + vtkMultiProcessController *vmpc(vtkMultiProcessController::GetGlobalController()); + if(vmpc) + { + iPart=vmpc->GetLocalProcessId(); + nbOfParts=vmpc->GetNumberOfProcesses(); + } #endif this->Internal->Tree.loadMainStructureOfFile(this->Internal->FileName.c_str(),this->Internal->IsMEDOrSauv,iPart,nbOfParts); if(!this->Internal->PK.arePropertiesOnTreeToSetAfter()) @@ -305,7 +312,13 @@ int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVect } catch(INTERP_KERNEL::Exception& e) { - std::cerr << "Exception has been thrown in vtkMEDReader::RequestInformation : " << e.what() << std::endl; + std::ostringstream oss; + oss << "Exception has been thrown in vtkMEDReader::RequestInformation : " << e.what() << std::endl; + if(this->HasObserver("ErrorEvent") ) + this->InvokeEvent("ErrorEvent",const_cast(oss.str().c_str())); + else + vtkOutputWindowDisplayErrorText(const_cast(oss.str().c_str())); + vtkObject::BreakOnError(); return 0; } return 1; diff --git a/src/Plugins/MEDReader/Test/testMEDReader13.py b/src/Plugins/MEDReader/Test/testMEDReader13.py index 1aac3003..3282274d 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader13.py +++ b/src/Plugins/MEDReader/Test/testMEDReader13.py @@ -55,19 +55,19 @@ RenderView1.CameraClippingRange = [4.276554101433921, 4.384547891874171] ELNOMesh3 = ELNOMesh(Input=testMEDReader13_med) DataRepresentation2 = Show() -DataRepresentation2.ConstantRadius = 1.9999333620071411 +#DataRepresentation2.ConstantRadius = 1.9999333620071411 DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483] -DataRepresentation2.PointSpriteDefaultsInitialized = 1 +#DataRepresentation2.PointSpriteDefaultsInitialized = 1 DataRepresentation2.SelectionPointFieldDataArrayName = 'fieldELNO' DataRepresentation2.SelectionCellFieldDataArrayName = 'FamilyIdCell' -DataRepresentation2.SelectInputVectors = ['POINTS', 'fieldELNO_Vector'] +#DataRepresentation2.SelectInputVectors = ['POINTS', 'fieldELNO_Vector'] DataRepresentation2.ScalarOpacityUnitDistance = 1.7746382108908556 DataRepresentation2.Texture = [] DataRepresentation2.ExtractedBlockIndex = 1 -DataRepresentation2.RadiusRange = [6.666666740784422e-05, 1.9999333620071411] +#DataRepresentation2.RadiusRange = [6.666666740784422e-05, 1.9999333620071411] DataRepresentation2.ScaleFactor = 0.19998666953397334 -DataRepresentation2.RadiusRange = [6.66667e-05, 1.99993] +#DataRepresentation2.RadiusRange = [6.66667e-05, 1.99993] DataRepresentation2.ColorArrayName = ('POINT_DATA', 'fieldELNO_Vector') a3_fieldELNO_Vector_PVLookupTable = GetLookupTableForArray( "fieldELNO_Vector", 3, RGBPoints=[0.3464101615137755, 0.23, 0.299, 0.754, 1.1258330249197703, 0.865, 0.865, 0.865, 1.9052558883257653, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0 ) -- 2.39.2