#include "vtkMEDReader.h"
#include "vtkGenerateVectors.h"
+#include "MEDUtilities.hxx"
#include "vtkMultiBlockDataSet.h"
#include "vtkInformation.h"
#include "vtkMultiTimeStepAlgorithm.h"
#include "vtkUnstructuredGrid.h"
#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h"
+#include "vtkInformationDoubleVectorKey.h"
#include "vtkQuadratureSchemeDefinition.h"
#include "vtkPointData.h"
#include "vtkCellData.h"
#ifdef MEDREADER_USE_MPI
#include "vtkMultiProcessController.h"
+#include "vtkPUnstructuredGridGhostCellsGenerator.h"
#endif
#include "MEDFileFieldRepresentationTree.hxx"
class PropertyKeeper
{
public:
- PropertyKeeper(vtkMEDReader *master):_master(master),IsGVActivated(false),GVValue(0),IsCMActivated(false),CMValue(0) { }
+ PropertyKeeper(vtkMEDReader *master):_master(master),IsGVActivated(false),GVValue(0),IsCMActivated(false),CMValue(0),IsGhostActivated(false),GCGCP(1) { }
void assignPropertiesIfNeeded();
bool arePropertiesOnTreeToSetAfter() const;
//
void pushGenerateVectorsValue(int value);
void pushChangeModeValue(int value);
void pushTimesFlagsStatusEntry(const char* name, int status);
+ void pushGhost(int value);
protected:
// pool of pairs to assign in SetFieldsStatus if needed. The use case is the load using pvsm.
std::vector< std::pair<std::string,int> > SetFieldsStatusPairs;
// change mode
bool IsCMActivated;
int CMValue;
+ // ghost cells
+ bool IsGhostActivated;
+ int GCGCP;
//
std::vector< std::pair<std::string,int> > TimesFlagsStatusPairs;
vtkMEDReader *_master;
_master->ChangeMode(this->CMValue);
this->IsCMActivated=false;
}
+ if(this->IsGhostActivated)
+ {
+ _master->GhostCellGeneratorCallForPara(this->GCGCP);
+ this->IsGhostActivated=false;
+ }
}
void PropertyKeeper::pushFieldStatusEntry(const char* name, int status)
this->CMValue=value;
}
+void PropertyKeeper::pushGhost(int value)
+{
+ this->IsGhostActivated=true;
+ this->GCGCP=value;
+}
+
bool PropertyKeeper::arePropertiesOnTreeToSetAfter() const
{
return !SetFieldsStatusPairs.empty();
{
public:
- vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master),MyMTime(0)
+ vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master),MyMTime(0),GCGCP(true)
{
}
int MyMTime;
std::set<std::string> _wonderful_set;// this set is used by SetFieldsStatus method to detect the fact that SetFieldsStatus has been called for all items ! Great Items are not sorted ! Why ?
std::map<std::string,bool> _wonderful_ref;// this map stores the state before a SetFieldsStatus status.
+ bool GCGCP;
private:
unsigned char FirstCall0;
}
return ret;
}
+
+static vtkInformationGaussDoubleVectorKey *vtkMEDReader_GAUSS_DATA=new vtkInformationGaussDoubleVectorKey("GAUSS_DATA","vtkMEDReader");
+
+vtkInformationGaussDoubleVectorKey *vtkMEDReader::GAUSS_DATA()
+{
+ static const char ZE_KEY[]="vtkMEDReader::GAUSS_DATA";
+ vtkInformationGaussDoubleVectorKey *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 !
+ vtkInformationDoubleVectorKey *ret2(ret);
+ std::ostringstream oss; oss << ret2;
+ gd->setKeyValue(ZE_KEY,oss.str());
+ }
+ return ret;
+}
// end of overload of vtkInformationKeyMacro
vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal(this))
this->Modified();
}
+void vtkMEDReader::GhostCellGeneratorCallForPara(int gcgcp)
+{
+ if ( !this->Internal )
+ return;
+
+ if(this->Internal->FileName.empty())
+ {//pvsm mode
+ this->Internal->PK.pushGhost(gcgcp);
+ return ;
+ }
+ bool newVal(gcgcp!=0);
+ if(newVal!=this->Internal->GCGCP)
+ {
+ this->Internal->GCGCP=newVal;
+ this->Modified();
+ }
+}
+
const char *vtkMEDReader::GetSeparator()
{
return MEDFileFieldRepresentationLeavesArrays::ZE_SEP;
double reqTS(0.);
if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
reqTS=outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
- this->FillMultiBlockDataSetInstance(output,reqTS);
+ ExportedTinyInfo ti;
+#ifndef MEDREADER_USE_MPI
+ this->FillMultiBlockDataSetInstance(output,reqTS,&ti);
+#else
+ if(this->Internal->GCGCP)
+ {
+ vtkSmartPointer<vtkPUnstructuredGridGhostCellsGenerator> gcg(vtkSmartPointer<vtkPUnstructuredGridGhostCellsGenerator>::New());
+ {
+ vtkDataSet *ret(RetrieveDataSetAtTime(reqTS,&ti));
+ gcg->SetInputData(ret);
+ ret->Delete();
+ }
+ gcg->SetUseGlobalPointIds(true);
+ gcg->SetBuildIfRequired(false);
+ gcg->Update();
+ output->SetBlock(0,gcg->GetOutput());
+ }
+ else
+ this->FillMultiBlockDataSetInstance(output,reqTS,&ti);
+#endif
+ if(!ti.empty())
+ {
+ const std::vector<double>& 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 !
+ }
output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),reqTS);
-
// Is it really needed ? TODO
this->UpdateSIL(request, outInfo);
}
{
if(!this->Internal)
return;
- vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::New());
-
- // This Should be more clever, TODO
- std::string meshName(this->BuildSIL(sil));
- if(meshName!=this->Internal->DftMeshName)
+ std::string meshName(this->Internal->Tree.getActiveMeshName());
+ if(!this->Internal->SIL || meshName!=this->Internal->DftMeshName)
{
+ vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::New());
+ this->BuildSIL(sil);
if(this->Internal->SIL)
this->Internal->SIL->Delete();
this->Internal->SIL=sil;
this->Internal->DftMeshName=meshName;
}
- else
- {
- sil->Delete();
- }
}
/*!
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,internalInfo));
+ output->SetBlock(0,ret);
+ ret->Delete();
+}
+
+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());
vtkGenerateVectors::Operate(ret->GetCellData());
vtkGenerateVectors::Operate(ret->GetFieldData());
}
- output->SetBlock(0,ret);
- ret->Delete();
+ return ret;
}
void vtkMEDReader::PrintSelf(ostream& os, vtkIndent indent)