-// Copyright (C) 2010-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2010-2016 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
#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h"
#include "vtkInformationIntegerKey.h"
#include "vtkInformation.h"
+#include "vtkDataArrayTemplate.h"
#include "vtkIdTypeArray.h"
#include "vtkDoubleArray.h"
#include "vtkIntArray.h"
const char MEDFileFieldRepresentationTree::COMPO_STR_TO_LOCATE_MESH_DA[]="-@?|*_";
-vtkIdTypeArray *ELGACmp::findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector<std::string>& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew) const
+vtkIdTypeArray *ELGACmp::findOrCreate(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector<std::string>& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, bool& isNew, ExportedTinyInfo *internalInfo) const
{
vtkIdTypeArray *try0(isExisting(locsReallyUsed,vtkd));
if(try0)
else
{
isNew=true;
- return createNew(globs,locsReallyUsed,vtkd,ds);
+ return createNew(globs,locsReallyUsed,vtkd,ds,internalInfo);
}
}
return ret;
}
-vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector<std::string>& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds) const
+vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *globs, const std::vector<std::string>& locsReallyUsed, vtkDoubleArray *vtkd, vtkDataSet *ds, ExportedTinyInfo *internalInfo) const
{
const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
std::vector< std::vector<std::string> > locNames(_loc_names);
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<double> gsCoods2(INTERP_KERNEL::GaussInfo::NormalizeCoordinatesIfNecessary(ct,dimLoc,loc.getGaussCoords()));
std::vector<double> refCoods2(INTERP_KERNEL::GaussInfo::NormalizeCoordinatesIfNecessary(ct,dimLoc,loc.getRefCoords()));
+ if(internalInfo)
+ internalInfo->pushGaussAdditionnalInfo(vtkType,dimLoc,refCoods2,gsCoods2);
double *shape(new double[nbPtsPerCell*nbGaussPt]);
INTERP_KERNEL::GaussInfo calculator(ct,gsCoods2,nbGaussPt,refCoods2,nbPtsPerCell);
calculator.initLocalInfo();
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<double *>(&wgths[0]));
delete [] shape;
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<double>::VTK_DATA_ARRAY_DELETE;
tr->setNumberOfTS((operator->())->getNumberOfTS());
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)
{
vtkQuadratureSchemeDefinition *def(vtkQuadratureSchemeDefinition::New());
double *shape(new double[nbGaussPt*nbGaussPt]);
std::size_t dummy;
- const double *gsCoords(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(ct,dummy));
+ const double *gsCoords(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(ct,dummy));//GetLocsFromGeometricType
const double *refCoords(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(ct,dummy));
const double *weights(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(ct,dummy));
std::vector<double> gsCoords2(gsCoords,gsCoords+nbGaussPt*dim),refCoords2(refCoords,refCoords+nbGaussPt*dim);
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 !");
for(std::vector<MEDFileFieldRepresentationLeavesArrays>::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);
}
}
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);
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);
}
}
+std::string MEDFileFieldRepresentationTree::getActiveMeshName() const
+{
+ int dummy0(0),dummy1(0),dummy2(0);
+ const MEDFileFieldRepresentationLeaves& leaf(getTheSingleActivated(dummy0,dummy1,dummy2));
+ return leaf.getMeshName();
+}
+
std::string MEDFileFieldRepresentationTree::feedSILForFamsAndGrps(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector<std::string>& names) const
{
int dummy0(0),dummy1(0),dummy2(0);
/*!
*
*/
-void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileName, bool isMEDOrSauv, int iPart, int nbOfParts)
+void MEDFileFieldRepresentationTree::loadInMemory(MEDCoupling::MEDFileFields *fields, MEDCoupling::MEDFileMeshes *meshes)
{
- 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);
- int nbMeshes(_ms->getNumberOfMeshes());
- for(int i=0;i<nbMeshes;i++)
- {
- MEDCoupling::MEDFileMesh *tmp(_ms->getMeshAtPos(i));
- MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast<MEDCoupling::MEDFileUMesh *>(tmp));
- if(tmp2)
- MCAuto<DataArrayInt> tmp3(tmp2->zipCoords());
- }
- _fields=MEDFileFields::LoadPartOf(fileName,false,_ms);//false is important to not read the values
-#else
- 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
- {
- MCAuto<MEDCoupling::SauvReader> sr(MEDCoupling::SauvReader::New(fileName));
- MCAuto<MEDCoupling::MEDFileData> mfd(sr->loadInMEDFileDS());
- _ms=mfd->getMeshes(); _ms->incrRef();
- int nbMeshes(_ms->getNumberOfMeshes());
- for(int i=0;i<nbMeshes;i++)
- {
- MEDCoupling::MEDFileMesh *tmp(_ms->getMeshAtPos(i));
- MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast<MEDCoupling::MEDFileUMesh *>(tmp));
- if(tmp2)
- tmp2->forceComputationOfParts();
- }
- _fields=mfd->getFields();
- if((MEDCoupling::MEDFileFields *)_fields)
- _fields->incrRef();
- }
- if(!((MEDCoupling::MEDFileFields *)_fields))
+ _fields=fields; _ms=meshes;
+ if(_fields.isNotNull())
+ _fields->incrRef();
+ if(_ms.isNotNull())
+ _ms->incrRef();
+ //
+ if(_fields.isNull())
{
_fields=BuildFieldFromMeshes(_ms);
}
this->computeFullNameInLeaves();
}
+void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileName, bool isMEDOrSauv, int iPart, int nbOfParts)
+{
+ MCAuto<MEDFileMeshes> ms;
+ MCAuto<MEDFileFields> fields;
+ if(isMEDOrSauv)
+ {
+ if((iPart==-1 && nbOfParts==-1) || (iPart==0 && nbOfParts==1))
+ {
+ MCAuto<MEDFileMeshSupports> msups(MEDFileMeshSupports::New(fileName));
+ MCAuto<MEDFileStructureElements> mse(MEDFileStructureElements::New(fileName,msups));
+ ms=MEDFileMeshes::New(fileName);
+ fields=MEDFileFields::NewWithDynGT(fileName,mse,false);//false is important to not read the values
+ if(ms->presenceOfStructureElements())
+ {// pre traitement
+ fields->loadArrays();
+ fields->blowUpSE(ms,mse);
+ }
+ int nbMeshes(ms->getNumberOfMeshes());
+ for(int i=0;i<nbMeshes;i++)
+ {
+ MEDCoupling::MEDFileMesh *tmp(ms->getMeshAtPos(i));
+ MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast<MEDCoupling::MEDFileUMesh *>(tmp));
+ if(tmp2)
+ tmp2->forceComputationOfParts();
+ }
+ }
+ else
+ {
+#ifdef MEDREADER_USE_MPI
+ ms=ParaMEDFileMeshes::New(iPart,nbOfParts,fileName);
+ int nbMeshes(ms->getNumberOfMeshes());
+ for(int i=0;i<nbMeshes;i++)
+ {
+ MEDCoupling::MEDFileMesh *tmp(ms->getMeshAtPos(i));
+ MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast<MEDCoupling::MEDFileUMesh *>(tmp));
+ if(tmp2)
+ MCAuto<DataArrayInt> tmp3(tmp2->zipCoords());
+ }
+ fields=MEDFileFields::LoadPartOf(fileName,false,ms);//false is important to not read the values
+#else
+ 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
+ {
+ MCAuto<MEDCoupling::SauvReader> sr(MEDCoupling::SauvReader::New(fileName));
+ MCAuto<MEDCoupling::MEDFileData> mfd(sr->loadInMEDFileDS());
+ ms=mfd->getMeshes(); ms->incrRef();
+ int nbMeshes(ms->getNumberOfMeshes());
+ for(int i=0;i<nbMeshes;i++)
+ {
+ MEDCoupling::MEDFileMesh *tmp(ms->getMeshAtPos(i));
+ MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast<MEDCoupling::MEDFileUMesh *>(tmp));
+ if(tmp2)
+ tmp2->forceComputationOfParts();
+ }
+ fields=mfd->getFields();
+ if(fields.isNotNull())
+ fields->incrRef();
+ }
+ loadInMemory(fields,ms);
+}
+
void MEDFileFieldRepresentationTree::removeEmptyLeaves()
{
std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > > newSD;
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));
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;
}