-// Copyright (C) 2017 CEA/DEN, EDF R&D
+// Copyright (C) 2017-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDFilterEntity.hxx"
+
#include "CellModel.hxx"
+// From MEDLOader.cxx TU
extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
-extern med_geometry_type typmai3[34];
+extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
using namespace MEDCoupling;
{
med_geometry_type geotype;
med_geometry_type sectiongeotype;
- int nsectionmeshcell;
+ med_int nsectionmeshcell, dim, nb_gauss_pt;
INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
- MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
- _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
+ MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&dim,&nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
+ _dim=FromMedInt<int>(dim);
+ _nb_gauss_pt=FromMedInt<int>(nb_gauss_pt);
+ _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+INTERP_KERNEL::NORM_MAXTYPE,geotype))));
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
_nb_node_per_cell=cm.getNumberOfNodes();
_ref_coo.resize(_dim*_nb_node_per_cell);
{
med_geometry_type geotype;
med_geometry_type sectiongeotype;
- int nsectionmeshcell;
+ med_int nsectionmeshcell,dim,nb_gauss_pt;
INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
- MEDFILESAFECALLERRD0(MEDlocalizationInfo,(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype));
+ MEDFILESAFECALLERRD0(MEDlocalizationInfo,(fid,id+1,locName,&geotype,&dim,&nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype));
+ _dim=FromMedInt<int>(dim);
+ _nb_gauss_pt=FromMedInt<int>(nb_gauss_pt);
_name=locName;
std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
if(sectionName.empty())
{
- _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
+ _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+INTERP_KERNEL::NORM_MAXTYPE,geotype))));
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
_nb_node_per_cell=cm.getNumberOfNodes();
}
const MEDFileUMesh *section(entities2->getSupMeshWithName(sectionName));
_gt=new MEDFileGTKeeperDyn(um,section,se);
{
- int dummy;
- MEDFILESAFECALLERRD0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&_nb_node_per_cell));
+ med_int dummy, nb_node_per_cell;
+ MEDFILESAFECALLERRD0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&nb_node_per_cell));
+ _nb_node_per_cell=FromMedInt<int>(nb_node_per_cell);
}
}
_ref_coo.resize(_dim*_nb_node_per_cell);
}
MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
- const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_gt(new MEDFileGTKeeperSta(geoType)),_ref_coo(refCoo),_gs_coo(gsCoo),_w(w)
+ const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_gt(new MEDFileGTKeeperSta(geoType)),_name(locName),_ref_coo(refCoo),_gs_coo(gsCoo),_w(w)
{
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
_dim=cm.getDimension();
_nb_node_per_cell=cm.getNumberOfNodes();
- _nb_gauss_pt=_w.size();
+ _nb_gauss_pt=(int)_w.size();
}
oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
oss << "\n - Ref coords are : ";
- int sz=_ref_coo.size();
+ std::size_t sz=_ref_coo.size();
if(sz%_dim==0)
{
- int nbOfTuples=sz/_dim;
- for(int i=0;i<nbOfTuples;i++)
+ std::size_t nbOfTuples=sz/_dim;
+ for(std::size_t i=0;i<nbOfTuples;i++)
{
oss << "(";
for(int j=0;j<_dim;j++)
sz=_gs_coo.size();
if(sz%_dim==0)
{
- int nbOfTuples=sz/_dim;
- for(int i=0;i<nbOfTuples;i++)
+ std::size_t nbOfTuples=sz/_dim;
+ for(std::size_t i=0;i<nbOfTuples;i++)
{
oss << "(";
for(int j=0;j<_dim;j++)
return oss.str();
}
-void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(mcIdType& start, mcIdType offset, mcIdType nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
_type=field->getTypeOfField();
_start=start;
}
case ON_GAUSS_NE:
{
- MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
- const int *arrPtr=arr->getConstPointer();
+ MCAuto<DataArrayIdType> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
+ const mcIdType *arrPtr=arr->getConstPointer();
getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
_end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
_nval=nbOfCells;
case ON_GAUSS_PT:
{
const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
- const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
+ const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(FromIdType<int>(_loc_id)));
const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
if(!disc2)
throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
- const DataArrayInt *dai(disc2->getArrayOfDiscIds());
- MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
- const int *dai2Ptr(dai2->getConstPointer());
- int nbi(gsLoc.getWeights().size());
- MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
- MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
- const int *da3Ptr(da3->getConstPointer());
+ const DataArrayIdType *dai(disc2->getArrayOfDiscIds());
+ MCAuto<DataArrayIdType> dai2(disc2->getOffsetArr(field->getMesh()));
+ const mcIdType *dai2Ptr(dai2->getConstPointer());
+ mcIdType nbi(ToIdType(gsLoc.getWeights().size()));
+ MCAuto<DataArrayIdType> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
+ MCAuto<DataArrayIdType> da3(da2->findIdsEqual(_loc_id));
+ const mcIdType *da3Ptr(da3->getConstPointer());
if(da3->getNumberOfTuples()!=nbOfCells)
{//profile : for gauss even in NoProfile !!!
std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
da3->setName(_profile.c_str());
glob.appendProfile(da3);
}
- MCAuto<DataArrayInt> da4(DataArrayInt::New());
+ MCAuto<DataArrayIdType> da4(DataArrayIdType::New());
_nval=da3->getNbOfElems();
da4->alloc(_nval*nbi,1);
- int *da4Ptr(da4->getPointer());
- for(int i=0;i<_nval;i++)
+ mcIdType *da4Ptr(da4->getPointer());
+ for(mcIdType i=0;i<_nval;i++)
{
- int ref=dai2Ptr[offset+da3Ptr[i]];
- for(int j=0;j<nbi;j++)
+ mcIdType ref=dai2Ptr[offset+da3Ptr[i]];
+ for(mcIdType j=0;j<nbi;j++)
*da4Ptr++=ref+j;
}
std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
/*!
* Leaf method of field with profile assignment. This method is the most general one. No optimization is done here.
- * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
+ * \param [in] isPflAlone whether there are several profiles or not
+ * \param [in] start starting ID
* \param [in] multiTypePfl is the end user profile specified in high level API
* \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
* \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
* \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
- * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
+ * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondence with the MEDFileField. The mesh inside the \a field is simply ignored.
*/
-void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, mcIdType& start, const DataArrayIdType *multiTypePfl, const DataArrayIdType *idsInPfl, DataArrayIdType *locIds, mcIdType nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
_profile.clear();
_type=field->getTypeOfField();
}
case ON_GAUSS_NE:
{
- MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
- MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
- MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
+ MCAuto<DataArrayIdType> arr=field->getDiscretization()->getOffsetArr(mesh);
+ MCAuto<DataArrayIdType> arr2=arr->deltaShiftIndex();
+ MCAuto<DataArrayIdType> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
arr3->computeOffsetsFull();
- MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
- int trueNval=tmp->getNumberOfTuples();
+ MCAuto<DataArrayIdType> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
+ mcIdType trueNval=tmp->getNumberOfTuples();
_nval=idsInPfl->getNumberOfTuples();
getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
_end=_start+trueNval;
const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
if(!disc2)
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
- const DataArrayInt *da1=disc2->getArrayOfDiscIds();
- const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
- MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
- MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
- MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
+ const DataArrayIdType *da1=disc2->getArrayOfDiscIds();
+ const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(FromIdType<int>(_loc_id));
+ MCAuto<DataArrayIdType> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
+ MCAuto<DataArrayIdType> da3=da2->findIdsEqual(_loc_id);
+ MCAuto<DataArrayIdType> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
//
MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
- MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
+ MCAuto<DataArrayIdType> arr=disc2->getOffsetArr(mesh2);
//
- MCAuto<DataArrayInt> tmp=DataArrayInt::New();
- int trueNval=0;
- for(const int *pt=da4->begin();pt!=da4->end();pt++)
+ MCAuto<DataArrayIdType> tmp=DataArrayIdType::New();
+ mcIdType trueNval=0;
+ for(const mcIdType *pt=da4->begin();pt!=da4->end();pt++)
trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
tmp->alloc(trueNval,1);
- int *tmpPtr=tmp->getPointer();
- for(const int *pt=da4->begin();pt!=da4->end();pt++)
- for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
+ mcIdType *tmpPtr=tmp->getPointer();
+ for(const mcIdType *pt=da4->begin();pt!=da4->end();pt++)
+ for(mcIdType j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
*tmpPtr++=j;
//
_nval=da4->getNumberOfTuples();
oss << "_loc_" << _loc_id;
if(locIds)
{
- MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
+ MCAuto<DataArrayIdType> da5=locIds->selectByTupleId(da3->begin(),da3->end());
da5->setName(oss.str());
glob.appendProfile(da5);
_profile=oss.str();
start=_end;
}
-void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
+void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
{
_start=start;
_nval=arrr->getNumberOfTuples();
return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, mcIdType locId)
{
return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
}
return ret.retn();
}
-MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
+MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, mcIdType profileIt, const PartDefinition *pd)
try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
{
if(pd)
throw e;
}
-MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
+MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, mcIdType locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
{
}
{
}
-MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
- _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
+MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<mcIdType>::max()),_end(-std::numeric_limits<mcIdType>::max()),
+ _nval(-std::numeric_limits<mcIdType>::max()),_loc_id(-std::numeric_limits<int>::max())
{
}
{
med_entity_type mentiCpy(menti);
INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
- int nbi,tmp1;
+ med_int nbi,tmp1;
med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
if(nbValsInFile==0 && menti==MED_CELL)
{//
if(!_profile.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
- int profilesize,nbi;
- int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
- const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
- if(spd)
- {
- int start,stop,step;
- spd->getSlice(start,stop,step);
- int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
- med_filter filter=MED_FILTER_INIT;
- MEDFILESAFECALLERRD0(MEDfilterBlockOfEntityCr,(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
- MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
- /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
- /*lastblocksize=useless because count=1*/0,&filter));
- MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
- MEDfilterClose(&filter);
- return ;
- }
- const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
- if(dpd)
- {
- dpd->checkConsistencyLight();
- MCAuto<DataArrayInt> myIds(dpd->toDAI());
- int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
- myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
- myIds->applyLin(1,-a);
- int nbOfEltsToLoad(b-a+1);
- med_filter filter=MED_FILTER_INIT;
- {//TODO : manage int32 !
- MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
- tmp->alloc(nbOfEltsToLoad,nbOfCompo);
- MEDFILESAFECALLERRD0(MEDfilterBlockOfEntityCr,(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
- MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
- /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
- /*lastblocksize=useless because count=1*/0,&filter));
- MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
- MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
- feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
- feeder->setContigPartOfSelectedValues(0,tmp,myIds);
- }
- MEDfilterClose(&filter);
- }
- else
- throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
+ med_int profilesize,nbi;
+ med_int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,FromIdType<int>(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
+
+ {//TODO : manage int32 !
+ pd->checkConsistencyLight();
+ MEDFilterEntity filter;
+ filter.fill(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
+ MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
+ pd);
+ MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,filter.getPtr(),startFeedingPtr));
+ }
}
}
return _father;
}
-void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, mcIdType& start, const MEDFileFieldNameScope& nasc)
{
INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
std::string fieldName(nasc.getName()),meshName(getMeshName());
- int iteration(getIteration()),order(getOrder()),profilesize,nbi;
+ med_int iteration(getIteration()),order(getOrder()),profilesize,nbi;
TypeOfField type(getType());
med_geometry_type mgeoti;
med_entity_type menti;
_father->entriesForMEDfile(type,mgeoti,menti);
- int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
+ med_int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,FromIdType<int>(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
if(zeNVal==0 && type==ON_CELLS)
{//eheh maybe there's a surprise :)
- int zeNVal1(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_FACE,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
+ med_int zeNVal1(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_FACE,mgeoti,FromIdType<int>(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
if(zeNVal1==0)
{
- int zeNVal2(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_EDGE,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
+ med_int zeNVal2(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_EDGE,mgeoti,FromIdType<int>(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
if(zeNVal2!=0)
zeNVal=zeNVal2;
}
std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
throw INTERP_KERNEL::Exception(oss.str());
}
- int nbOfCompo(arr->getNumberOfComponents());
+ int nbOfCompo((int)arr->getNumberOfComponents());
DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
if(arrD)
{
goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
return ;
}
- DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
+ DataArrayInt32 *arrI(dynamic_cast<DataArrayInt32 *>(arr));
if(arrI)
{
- int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
+ Int32 *startFeeding(arrI->getPointer()+_start*nbOfCompo);
+ goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
+ return ;
+ }
+ DataArrayInt64 *arrI64(dynamic_cast<DataArrayInt64 *>(arr));
+ if(arrI64)
+ {
+ Int64 *startFeeding(arrI64->getPointer()+_start*nbOfCompo);
goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
return ;
}
goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
return ;
}
- throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 FLOAT32 or INT32 !");
+ throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 FLOAT32 INT32 or INT64 !");
}
+
/*!
* Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
*/
-void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
+void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(mcIdType newValueOfStart)
{
- int delta=_end-_start;
+ mcIdType delta=_end-_start;
_start=newValueOfStart;
_end=_start+delta;
}
return _father->getGeoType();
}
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoTypeStatic() const
+{
+ return _father->getGeoTypeStatic();
+}
+
void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
{
types.insert(_type);
_type=newType;
}
-int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
+std::size_t MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
{
return _father->getNumberOfComponents();
}
-int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
+mcIdType MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
{
return _end-_start;
}
-void MEDFileFieldPerMeshPerTypePerDisc::incrementNbOfVals(int deltaNbVal)
+void MEDFileFieldPerMeshPerTypePerDisc::incrementNbOfVals(mcIdType deltaNbVal)
{
- int nbi((_end-_start)/_nval);
+ mcIdType nbi((_end-_start)/_nval);
_nval+=deltaNbVal;
_end+=nbi*deltaNbVal;
}
}
}
-void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
+void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<const DataArrayIdType *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
{
if(type!=_type)
return ;
- dads.push_back(std::pair<int,int>(_start,_end));
+ dads.push_back(std::pair<mcIdType,mcIdType>(_start,_end));
geoTypes.push_back(getGeoType());
if(_profile.empty())
pfls.push_back(0);
}
}
-void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
+void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, mcIdType& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
{
- entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
+ entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,mcIdType> ,std::pair<mcIdType,mcIdType> >(std::pair<INTERP_KERNEL::NormalizedCellType,mcIdType>(getGeoType(),discId),std::pair<mcIdType,mcIdType>(_start,_end));
startEntryId++;
}
void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
{
- TypeOfField type=getType();
- INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
med_geometry_type mgeoti;
med_entity_type menti;
_father->entriesForMEDfile(getType(),mgeoti,menti);
if(!arr->isAllocated())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
const DataArrayDouble *arrD(dynamic_cast<const DataArrayDouble *>(arr));
- const DataArrayInt *arrI(dynamic_cast<const DataArrayInt *>(arr));
+ const DataArrayInt32 *arrI(dynamic_cast<const DataArrayInt32 *>(arr));
+ const DataArrayInt64 *arrI64(dynamic_cast<const DataArrayInt64 *>(arr));
const DataArrayFloat *arrF(dynamic_cast<const DataArrayFloat *>(arr));
const unsigned char *locToWrite=0;
if(arrD)
locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
else if(arrI)
locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
+ else if(arrI64)
+ locToWrite=reinterpret_cast<const unsigned char *>(arrI64->getConstPointer()+_start*arr->getNumberOfComponents());
else if(arrF)
locToWrite=reinterpret_cast<const unsigned char *>(arrF->getConstPointer()+_start*arr->getNumberOfComponents());
else
- throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 FLOAT32 and INT32 !");
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 FLOAT32 INT32 and INT64 !");
MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
- MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
+ MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,ToMedInt(_nval),
locToWrite));
}
-void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
+void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<mcIdType,mcIdType>& dad, std::string& pfl, std::string& loc) const
{
type=_type;
pfl=_profile;
* \param [out] ptToFill memory zone where the output will be stored.
* \return the size of data pushed into output param \a ptToFill
*/
-int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
+mcIdType MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(mcIdType offset, const std::vector<mcIdType>& codeOfMesh, const MEDFileFieldGlobsReal& glob, mcIdType *ptToFill) const
{
- _loc_id=offset;
+ _loc_id=FromIdType<int>(offset);
std::ostringstream oss;
std::size_t nbOfType=codeOfMesh.size()/3;
int found=-1;
oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
throw INTERP_KERNEL::Exception(oss.str());
}
- int *work=ptToFill;
+ mcIdType *work=ptToFill;
if(_profile.empty())
{
if(_nval!=codeOfMesh[3*found+1])
oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
throw INTERP_KERNEL::Exception(oss.str());
}
- for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
+ for(mcIdType ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
*work++=ii;
}
else
{
- const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
+ const DataArrayIdType *pfl=glob.getProfile(_profile.c_str());
if(pfl->getNumberOfTuples()!=_nval)
{
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
throw INTERP_KERNEL::Exception(oss.str());
}
- int offset2=codeOfMesh[3*found+2];
- for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
+ mcIdType offset2=codeOfMesh[3*found+2];
+ for(const mcIdType *pflId=pfl->begin();pflId!=pfl->end();pflId++)
{
if(*pflId<codeOfMesh[3*found+1])
*work++=offset2+*pflId;
return _nval;
}
-int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
+mcIdType MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(mcIdType *ptToFill) const
{
- for(int i=_start;i<_end;i++)
+ for(mcIdType i=_start;i<_end;i++)
*ptToFill++=i;
return _end-_start;
}
-int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
+int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, mcIdType locId)
{
switch(type)
{
case ON_GAUSS_NE:
return -1;
case ON_GAUSS_PT:
- return locId;
+ return FromIdType<int>(locId);
default:
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
}
/*!
* - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
- *
+ *
* \param [in] offset the offset id used to take into account that \a result is not compulsory empty in input
* \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
* \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
* \param [out] result All new entries will be appended on it.
* \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
*/
-bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
- const DataArrayInt *explicitIdsInMesh,
- const std::vector<int>& newCode,
+bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(mcIdType offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
+ const DataArrayIdType *explicitIdsInMesh,
+ const std::vector<mcIdType>& newCode,
MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
{
if(entriesOnSameDisc.empty())
return false;
TypeOfField type=entriesOnSameDisc[0]->getType();
- int szEntities=0,szTuples=0;
+ mcIdType szEntities=0,szTuples=0;
for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
{ szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
- int nbi=szTuples/szEntities;
+ mcIdType nbi=szTuples/szEntities;
if(szTuples%szEntities!=0)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
- MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
- MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
- std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
- std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
- std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
- std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
- MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
+ MCAuto<DataArrayIdType> renumTuples=DataArrayIdType::New(); renumTuples->alloc(szTuples,1);
+ MCAuto<DataArrayIdType> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
+ std::vector< MCAuto<DataArrayIdType> > newGeoTypesPerChunk(entriesOnSameDisc.size());
+ std::vector< const DataArrayIdType * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
+ std::vector< MCAuto<DataArrayIdType> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
+ std::vector< const DataArrayIdType * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
+ MCAuto<DataArrayIdType> newGeoTypesPerChunk4=DataArrayIdType::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
int id=0;
for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
{
- int startOfEltIdOfChunk=(*it)->_start;
- MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
- MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
- MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
+ mcIdType startOfEltIdOfChunk=(*it)->_start;
+ MCAuto<DataArrayIdType> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
+ MCAuto<DataArrayIdType> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
+ MCAuto<DataArrayIdType> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
//
- MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
+ MCAuto<DataArrayIdType> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
//
newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
}
- MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
- MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
- MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
- MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
+ MCAuto<DataArrayIdType> newGeoTypesEltIdsAllGather=DataArrayIdType::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
+ MCAuto<DataArrayIdType> newGeoTypesEltIdsAllGather2=DataArrayIdType::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
+ MCAuto<DataArrayIdType> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
+ MCAuto<DataArrayIdType> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
//
- MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
+ MCAuto<DataArrayIdType> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
//
MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
arrPart->renumberInPlace(renumTupleIds->begin());
- arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
+ arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,ToIdType(arrPart->getNumberOfComponents()),1);
bool ret=false;
- const int *idIt=diffVals->begin();
+ const mcIdType *idIt=diffVals->begin();
std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
- int offset2=0;
- for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
+ mcIdType offset2=0;
+ for(mcIdType i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
{
- MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
- MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
- int nbEntityElts=subIds->getNumberOfTuples();
+ MCAuto<DataArrayIdType> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
+ MCAuto<DataArrayIdType> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
+ mcIdType nbEntityElts=subIds->getNumberOfTuples();
bool ret2;
MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
* and corresponding entry erased from \a entriesOnSameDisc.
* \return a newly allocated chunk
*/
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
- bool isPfl, int nbi, int offset,
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayIdType *idsOfMeshElt,
+ bool isPfl, mcIdType nbi, mcIdType offset,
std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
MEDFileFieldGlobsReal& glob,
bool ¬InExisting)
{
- int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
+ mcIdType nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
for(;it!=entriesOnSameDisc.end();it++)
{
else
if(!(*it)->_profile.empty())
{
- const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
+ const DataArrayIdType *pfl=glob.getProfile((*it)->_profile.c_str());
if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
break;
}
return ret;
}
-void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(mcIdType& start, mcIdType offset, mcIdType nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
- std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
- for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
+ std::vector<mcIdType> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
+ for(std::vector<mcIdType>::const_iterator it=pos.begin();it!=pos.end();it++)
_field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
}
* \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
* \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
* \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
- * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
+ * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondence with the MEDFileField. The mesh inside the \a field is simply ignored.
*/
-void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, mcIdType& start, const DataArrayIdType *multiTypePfl, const DataArrayIdType *idsInPfl, DataArrayIdType *locIds, mcIdType nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
- std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
- for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
+ std::vector<mcIdType> pos=addNewEntryIfNecessary(field,idsInPfl);
+ for(std::vector<mcIdType>::const_iterator it=pos.begin();it!=pos.end();it++)
_field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
}
-void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
+void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
{
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
_field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
}
-void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(mcIdType& start, const DataArrayIdType *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
- MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
+ MCAuto<DataArrayIdType> pfl2=pfl->deepCopy();
if(!arr || !arr->isAllocated())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
}
-std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells)
+std::vector<mcIdType> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, mcIdType offset, mcIdType nbOfCells)
{
TypeOfField type=field->getTypeOfField();
if(type!=ON_GAUSS_PT)
{
int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
- int sz=_field_pm_pt_pd.size();
+ std::size_t sz=_field_pm_pt_pd.size();
bool found=false;
- for(int j=0;j<sz && !found;j++)
+ for(std::size_t j=0;j<sz && !found;j++)
{
if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
{
_field_pm_pt_pd.resize(sz+1);
_field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
}
- std::vector<int> ret(1,(int)sz);
+ std::vector<mcIdType> ret(1,(mcIdType)sz);
return ret;
}
else
{
- std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
- int sz2=ret2.size();
- std::vector<int> ret3(sz2);
- int k=0;
- for(int i=0;i<sz2;i++)
+ std::vector<mcIdType> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
+ std::size_t sz2=ret2.size();
+ std::vector<mcIdType> ret3(sz2);
+ mcIdType k=0;
+ for(std::size_t i=0;i<sz2;i++)
{
- int sz=_field_pm_pt_pd.size();
- int locIdToFind=ret2[i];
+ mcIdType sz=ToIdType(_field_pm_pt_pd.size());
+ mcIdType locIdToFind=ret2[i];
bool found=false;
- for(int j=0;j<sz && !found;j++)
+ for(mcIdType j=0;j<sz && !found;j++)
{
if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
{
- _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
+ _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,FromIdType<int>(locIdToFind));
ret3[k++]=j;
found=true;
}
if(!found)
{
_field_pm_pt_pd.resize(sz+1);
- _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
+ _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,FromIdType<int>(locIdToFind));
ret3[k++]=sz;
}
}
}
}
-std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells)
+std::vector<mcIdType> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, mcIdType offset, mcIdType nbOfCells)
{
const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
if(!disc2)
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
- const DataArrayInt *da=disc2->getArrayOfDiscIds();
+ const DataArrayIdType *da=disc2->getArrayOfDiscIds();
if(!da)
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
- MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
- MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
+ MCAuto<DataArrayIdType> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
+ MCAuto<DataArrayIdType> retTmp=da2->getDifferentValues();
if(retTmp->presenceOfValue(-1))
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
- std::vector<int> ret(retTmp->begin(),retTmp->end());
+ std::vector<mcIdType> ret(retTmp->begin(),retTmp->end());
return ret;
}
-std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells)
+std::vector<mcIdType> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayIdType *subCells)
{
TypeOfField type=field->getTypeOfField();
if(type!=ON_GAUSS_PT)
{
int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
- int sz=_field_pm_pt_pd.size();
+ std::size_t sz=_field_pm_pt_pd.size();
bool found=false;
- for(int j=0;j<sz && !found;j++)
+ for(std::size_t j=0;j<sz && !found;j++)
{
if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
{
_field_pm_pt_pd.resize(sz+1);
_field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
}
- std::vector<int> ret(1,0);
+ std::vector<mcIdType> ret(1,0);
return ret;
}
else
{
- std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
- int sz2=ret2.size();
- std::vector<int> ret3(sz2);
- int k=0;
- for(int i=0;i<sz2;i++)
+ std::vector<mcIdType> ret2=addNewEntryIfNecessaryGauss(field,subCells);
+ std::size_t sz2=ret2.size();
+ std::vector<mcIdType> ret3(sz2);
+ mcIdType k=0;
+ for(std::size_t i=0;i<sz2;i++)
{
- int sz=_field_pm_pt_pd.size();
- int locIdToFind=ret2[i];
+ mcIdType sz=ToIdType(_field_pm_pt_pd.size());
+ mcIdType locIdToFind=ret2[i];
bool found=false;
- for(int j=0;j<sz && !found;j++)
+ for(mcIdType j=0;j<sz && !found;j++)
{
if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
{
}
}
-std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells)
+std::vector<mcIdType> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayIdType *subCells)
{
const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
if(!disc2)
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
- const DataArrayInt *da=disc2->getArrayOfDiscIds();
+ const DataArrayIdType *da=disc2->getArrayOfDiscIds();
if(!da)
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
- MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
- MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
+ MCAuto<DataArrayIdType> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
+ MCAuto<DataArrayIdType> retTmp=da2->getDifferentValues();
if(retTmp->presenceOfValue(-1))
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
- std::vector<int> ret(retTmp->begin(),retTmp->end());
+ std::vector<mcIdType> ret(retTmp->begin(),retTmp->end());
return ret;
}
}
}
-void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
+void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
{
- int sz=_field_pm_pt_pd.size();
+ std::size_t sz=_field_pm_pt_pd.size();
dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
_field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
}
return _father->getMeshName();
}
-void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
+void MEDFileFieldPerMeshPerTypeCommon::getSizes(mcIdType& globalSz, mcIdType& nbOfEntries) const
{
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
{
globalSz+=(*it)->getNumberOfTuples();
}
- nbOfEntries+=(int)_field_pm_pt_pd.size();
+ nbOfEntries+=(mcIdType)_field_pm_pt_pd.size();
}
-int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
+std::size_t MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
{
return _father->getNumberOfComponents();
}
(*it1)->changeLocsRefsNamesGen(mapOfModif);
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(mcIdType locId)
{
if(_field_pm_pt_pd.empty())
{
std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
throw INTERP_KERNEL::Exception(oss.str());
}
- if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
+ if(locId>=0 && locId<ToIdType(_field_pm_pt_pd.size()))
return _field_pm_pt_pd[locId];
std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
}
-const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
+const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(mcIdType locId) const
{
if(_field_pm_pt_pd.empty())
{
std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
throw INTERP_KERNEL::Exception(oss.str());
}
- if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
+ if(locId>=0 && locId<ToIdType(_field_pm_pt_pd.size()))
return _field_pm_pt_pd[locId];
std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::locIdOfLeaf : not found such a leaf in this !");
}
-void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
+void MEDFileFieldPerMeshPerTypeCommon::fillValues(mcIdType& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
{
int i=0;
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
}
/*!
- * \param [in,out] globalNum a global numbering counter for the renumbering.
+ * \param [in,out] globalNum a global numbering counter for the renumbering.
* \param [out] its - list of pair (start,stop) kept
* \return bool - false if the type of field \a tof is not contained in \a this.
*/
-bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
+bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, mcIdType &globalNum, std::vector< std::pair<mcIdType,mcIdType> >& its)
{
bool ret(false);
std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
if((*it)->getType()==tof)
{
newPmPtPd.push_back(*it);
- std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
+ std::pair<mcIdType,mcIdType> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
(*it)->setNewStart(globalNum);
globalNum=(*it)->getEnd();
its.push_back(bgEnd);
* \param [out] its - list of pair (start,stop) kept
* \return bool - false if the type of field \a tof is not contained in \a this.
*/
-bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
+bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, mcIdType &globalNum, std::vector< std::pair<mcIdType,mcIdType> >& its)
{
if(_field_pm_pt_pd.size()<=idOfDisc)
return false;
MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
- std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
+ std::pair<mcIdType,mcIdType> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
elt->setNewStart(globalNum);
globalNum=elt->getEnd();
its.push_back(bgEnd);
return true;
}
-void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, mcIdType &start, const MEDFileFieldNameScope& nasc)
{
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
(*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
return ret.retn();
}
-void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
+void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<const DataArrayIdType *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
{
if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
{
return _geo_type;
}
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoTypeStatic() const
+{
+ return _geo_type;
+}
+
void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
{
ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
med_geometry_type mgeoti;
med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
- int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
+ med_int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
_field_pm_pt_pd.resize(nbProfiles);
for(int i=0;i<nbProfiles;i++)
{
}
if(type==ON_CELLS)
{
- int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
+ med_int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
for(int i=0;i<nbProfiles2;i++)
_field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
}
return ;
// dark side of the force.
{
- int nbProfiles1(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_FACE,mgeoti,pflName,locName));
- int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_EDGE,mgeoti,pflName,locName));
+ med_int nbProfiles1(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_FACE,mgeoti,pflName,locName));
+ med_int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_EDGE,mgeoti,pflName,locName));
if(nbProfiles1==0 && nbProfiles2==0)
return ;// OK definitely nothing in field
menti=nbProfiles1>=nbProfiles2?MED_DESCENDING_FACE:MED_DESCENDING_EDGE;//not enough words to describe the beauty
}
}
-MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
+MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(mcIdType &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > >& extractInfo)
{
MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
_se.takeRef(se);
INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
+ med_int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
_field_pm_pt_pd.resize(nbProfiles);
for(int i=0;i<nbProfiles;i++)
{
throw INTERP_KERNEL::Exception("not implemented yet !");
}
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoTypeStatic() const
+{
+ return _se->getGeoType();
+}
+
void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
{
const char startLine[]=" ## ";
return ret.retn();
}
-void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
+void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<const DataArrayIdType *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
{
throw INTERP_KERNEL::Exception("not implemented yet !");
}
return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
}
+MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const PartDefinition *pd, const MEDFileEntities *entities)
+{
+ return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,pd,entities);
+}
+
MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
{
return new MEDFileFieldPerMesh(fath,mesh);
mesh->getTime(_mesh_iteration,_mesh_order);
}
-void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(mcIdType& start, const std::vector<mcIdType>& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
- int nbOfTypes=code.size()/3;
- int offset=0;
- for(int i=0;i<nbOfTypes;i++)
+ std::size_t nbOfTypes=code.size()/3;
+ mcIdType offset=0;
+ for(std::size_t i=0;i<nbOfTypes;i++)
{
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
- int nbOfCells=code[3*i+1];
- int pos=addNewEntryIfNecessary(type);
+ mcIdType nbOfCells=code[3*i+1];
+ mcIdType pos=addNewEntryIfNecessary(type);
_field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
offset+=nbOfCells;
}
* \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
* \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
* \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
- * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
+ * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondence with the MEDFileField. The mesh inside the \a field is simply ignored.
*/
-void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMesh::assignFieldProfile(mcIdType& start, const DataArrayIdType *multiTypePfl, const std::vector<mcIdType>& code, const std::vector<mcIdType>& code2, const std::vector<DataArrayIdType *>& idsInPflPerType, const std::vector<DataArrayIdType *>& idsPerType, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
- int nbOfTypes(code.size()/3);
- for(int i=0;i<nbOfTypes;i++)
+ std::size_t nbOfTypes(code.size()/3);
+ for(std::size_t i=0;i<nbOfTypes;i++)
{
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
- int pos=addNewEntryIfNecessary(type);
- DataArrayInt *pfl=0;
+ mcIdType pos=addNewEntryIfNecessary(type);
+ DataArrayIdType *pfl=0;
if(code[3*i+2]!=-1)
pfl=idsPerType[code[3*i+2]];
- int nbOfTupes2=code2.size()/3;
- int found=0;
+ std::size_t nbOfTupes2=code2.size()/3;
+ std::size_t found=0;
for(;found<nbOfTupes2;found++)
if(code[3*i]==code2[3*found])
break;
}
}
-void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
+void MEDFileFieldPerMesh::assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
{
- int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
+ mcIdType pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
_field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
}
-void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMesh::assignNodeFieldProfile(mcIdType& start, const DataArrayIdType *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
- int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
+ mcIdType pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
_field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
}
-void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, mcIdType& start, const MEDFileFieldNameScope& nasc)
{
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
{
- int nbOfTypes=_field_pm_pt.size();
- for(int i=0;i<nbOfTypes;i++)
+ std::size_t nbOfTypes=_field_pm_pt.size();
+ for(std::size_t i=0;i<nbOfTypes;i++)
{
_field_pm_pt[i]->copyOptionsFrom(*this);
_field_pm_pt[i]->writeLL(fid,nasc);
(*it)->fillTypesOfFieldAvailable(types);
}
-std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const
+std::vector< std::vector< std::pair<mcIdType,mcIdType> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const
{
- int sz=_field_pm_pt.size();
- std::vector< std::vector<std::pair<int,int> > > ret(sz);
+ std::size_t sz=_field_pm_pt.size();
+ std::vector< std::vector<std::pair<mcIdType,mcIdType> > > ret(sz);
types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
types[i]=_field_pm_pt[i]->getGeoType();
_field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
return _father->getOrder();
}
-int MEDFileFieldPerMesh::getNumberOfComponents() const
+std::size_t MEDFileFieldPerMesh::getNumberOfComponents() const
{
return _father->getNumberOfComponents();
}
* - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
* 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
*/
-void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
+void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<mcIdType,mcIdType> >& dads, const std::vector<const DataArrayIdType *>& pfls, const std::vector<int>& locs, std::vector<mcIdType>& code, std::vector<DataArrayIdType *>& notNullPfls)
{
int notNullPflsSz=0;
- int nbOfArrs=geoTypes.size();
- for(int i=0;i<nbOfArrs;i++)
+ std::size_t nbOfArrs=geoTypes.size();
+ for(std::size_t i=0;i<nbOfArrs;i++)
if(pfls[i])
notNullPflsSz++;
std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
- int nbOfDiffGeoTypes=geoTypes3.size();
+ std::size_t nbOfDiffGeoTypes=geoTypes3.size();
code.resize(3*nbOfDiffGeoTypes);
notNullPfls.resize(notNullPflsSz);
notNullPflsSz=0;
- int j=0;
- for(int i=0;i<nbOfDiffGeoTypes;i++)
+ std::size_t j=0;
+ for(std::size_t i=0;i<nbOfDiffGeoTypes;i++)
{
- int startZone=j;
+ std::size_t startZone=j;
INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
- std::vector<const DataArrayInt *> notNullTmp;
+ std::vector<const DataArrayIdType *> notNullTmp;
if(pfls[j])
notNullTmp.push_back(pfls[j]);
j++;
}
else
break;
- std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
- std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
+ std::vector< std::pair<mcIdType,mcIdType> > tmpDads(dads.begin()+startZone,dads.begin()+j);
+ std::vector<const DataArrayIdType *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
- code[3*i]=(int)refType;
+ code[3*i]=(mcIdType)refType;
std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
if(notNullTmp.empty())
code[3*i+2]=-1;
else
{
- notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
+ notNullPfls[notNullPflsSz]=DataArrayIdType::Aggregate(notNullTmp);
code[3*i+2]=notNullPflsSz++;
}
}
/*!
* 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
*/
-int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs)
+mcIdType MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<mcIdType,mcIdType> >& dads, const std::vector<int>& locs)
{
- int sz=dads.size();
- int ret=0;
- for(int i=0;i<sz;i++)
+ std::size_t sz=dads.size();
+ mcIdType ret=0;
+ for(std::size_t i=0;i<sz;i++)
{
if(locs[i]==-1)
{
_field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
}
-bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
+bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<mcIdType>& oldCode, const std::vector<mcIdType>& newCode, const DataArrayIdType *renumO2N,
MEDFileFieldGlobsReal& glob)
{
if(getMeshName()!=meshName)
return false;
std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
- std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
+ std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > > entries;
std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
getUndergroundDataArrayExt(entries);
DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
if(!arr0)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
- int sz=0;
+ mcIdType sz=0;
if(!arr)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
- for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
+ for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >::const_iterator it=entries.begin();it!=entries.end();it++)
{
if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
{
else
otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
}
- MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
+ MCAuto<DataArrayIdType> renumDefrag=DataArrayIdType::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
////////////////////
- MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
- int *workI2=explicitIdsOldInMesh->getPointer();
- int sz1=0,sz2=0,sid=1;
+ MCAuto<DataArrayIdType> explicitIdsOldInMesh=DataArrayIdType::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
+ mcIdType *workI2=explicitIdsOldInMesh->getPointer();
+ mcIdType sz1=0,sz2=0,sid=1;
std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
// std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
{
// tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
- MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
- int *workI=explicitIdsOldInArr->getPointer();
+ MCAuto<DataArrayIdType> explicitIdsOldInArr=DataArrayIdType::New(); explicitIdsOldInArr->alloc(sz,1);
+ mcIdType *workI=explicitIdsOldInArr->getPointer();
for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
{
- int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
+ mcIdType delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
(*itL2)->setLocId(sz2);
(*itL2)->_tmp_work1=(*itL2)->getStart();
- int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
+ mcIdType delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
}
renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
}
explicitIdsOldInMesh->reAlloc(sz2);
- int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
+ mcIdType tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
////////////////////
- MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
+ MCAuto<DataArrayIdType> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
// perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
{
MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
- int newStart=elt->getLocId();
+ mcIdType newStart=elt->getLocId();
elt->setLocId((*it)->getGeoType());
elt->setNewStart(newStart);
elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
}
MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
// perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
- MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
+ MCAuto<DataArrayIdType> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
bool ret=false;
for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
* \param [in,out] globalNum a global numbering counter for the renumbering.
* \param [out] its - list of pair (start,stop) kept
*/
-void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
+void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, mcIdType &globalNum, std::vector< std::pair<mcIdType,mcIdType> >& its)
{
std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
- std::vector< std::pair<int,int> > its2;
+ std::vector< std::pair<mcIdType,mcIdType> > its2;
if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
{
ret.push_back(*it);
* \param [in,out] globalNum a global numbering counter for the renumbering.
* \param [out] its - list of pair (start,stop) kept
*/
-void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
+void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, mcIdType &globalNum, std::vector< std::pair<mcIdType,mcIdType> >& its)
{
std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
- std::vector< std::pair<int,int> > its2;
+ std::vector< std::pair<mcIdType,mcIdType> > its2;
if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
{
ret.push_back(*it);
if(_field_pm_pt.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
//
- std::vector< std::pair<int,int> > dads;
- std::vector<const DataArrayInt *> pfls;
- std::vector<DataArrayInt *> notNullPflsPerGeoType;
- std::vector<int> locs,code;
+ std::vector< std::pair<mcIdType,mcIdType> > dads;
+ std::vector<const DataArrayIdType *> pfls;
+ std::vector<DataArrayIdType *> notNullPflsPerGeoType;
+ std::vector<int> locs;
+ std::vector<mcIdType>code;
std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
throw INTERP_KERNEL::Exception(oss.str());
}
//
- std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
- std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
+ std::vector< MCAuto<DataArrayIdType> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
+ std::vector< const DataArrayIdType *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
if(type!=ON_NODES)
{
- DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
+ DataArrayIdType *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
if(!arr)
return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
else
{
- MCAuto<DataArrayInt> arr2(arr);
+ MCAuto<DataArrayIdType> arr2(arr);
return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
}
}
{
if(code.size()!=3)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
- int nb=code[1];
+ mcIdType nb=code[1];
if(code[2]==-1)
{
if(nb!=mesh->getNumberOfNodes())
}
}
-DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
+DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayIdType *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
{
if(_field_pm_pt.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
//
- std::vector<std::pair<int,int> > dads;
- std::vector<const DataArrayInt *> pfls;
- std::vector<DataArrayInt *> notNullPflsPerGeoType;
- std::vector<int> locs,code;
+ std::vector<std::pair<mcIdType,mcIdType> > dads;
+ std::vector<const DataArrayIdType *> pfls;
+ std::vector<DataArrayIdType *> notNullPflsPerGeoType;
+ std::vector<int> locs;
+ std::vector<mcIdType> code;
std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
throw INTERP_KERNEL::Exception(oss.str());
}
- std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
- std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
+ std::vector< MCAuto<DataArrayIdType> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
+ std::vector< const DataArrayIdType *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
if(type!=ON_NODES)
{
- MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
+ MCAuto<DataArrayIdType> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
}
else
{
if(code.size()!=3)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
- int nb=code[1];
+ mcIdType nb=code[1];
if(code[2]==-1)
{
if(nb!=mesh->getNumberOfNodes())
}
}
-void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
+void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
{
- int globalSz=0;
- int nbOfEntries=0;
+ mcIdType globalSz=0;
+ mcIdType nbOfEntries=0;
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
(*it)->getSizes(globalSz,nbOfEntries);
}
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, mcIdType locId)
{
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
throw INTERP_KERNEL::Exception(oss.str());
}
-const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
+const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, mcIdType locId) const
{
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
/*!
* \param [in,out] start - Integer that gives the current position in the final aggregated array
- * \param [in] pms - list of elements to aggregate. integer gives the mesh id
+ * \param [in] pms - list of elements to aggregate. integer gives the mesh id
* \param [in] dts - (Distribution of types) = level 1 : meshes to aggregate. Level 2 : all geo type. Level 3 pair specifying geo type and number of elem in geotype.
* \param [out] extractInfo - Gives information about the where the data comes from. It is a vector of triplet. First element in the triplet the mesh pos. The 2nd one the start pos. The 3rd the end pos.
*/
-MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
+MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(mcIdType &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > >& extractInfo)
{
MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
if(pms.empty())
INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
std::size_t i(0);
std::vector< std::pair<int,int> > filteredDTS;
- for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
- for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
+ for(std::vector< std::vector< std::pair<int,mcIdType> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
+ for(std::vector< std::pair<int,mcIdType> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
if((*it2).first==gt)
filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
if(pms.size()!=filteredDTS.size())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
- int zeStart(start),nval(0);
+ mcIdType zeStart(start),nval(0);
for(;it1!=pms.end();it1++,it2++)
{
if((*it1).first!=(*it2).first)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
- int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
+ mcIdType s1((*it1).second->getStart()),e1((*it1).second->getEnd());
extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
start+=e1-s1;
nval+=((*it1).second)->getNumberOfVals();
return ret;
}
-MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(int &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
+MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(mcIdType &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > >& extractInfo)
{
MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
{
int i=0;
- int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
+ std::size_t pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
{
return i;
else
{
- int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
+ std::size_t pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
if(pos>pos2)
it2=it+1;
}
}
- int ret=std::distance(_field_pm_pt.begin(),it2);
+ std::size_t ret=std::distance(_field_pm_pt.begin(),it2);
_field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
- return ret;
+ return (int)ret;
}
/*!
* \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
*/
MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
- const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
+ const std::vector< std::pair<mcIdType,mcIdType> >& dads, const std::vector<int>& locs,
const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
isPfl=false;
da->setName("");
if(type==ON_GAUSS_PT)
{
- int offset=0;
- int nbOfArrs=dads.size();
- for(int i=0;i<nbOfArrs;i++)
+ mcIdType offset=0;
+ std::size_t nbOfArrs=dads.size();
+ for(std::size_t i=0;i<nbOfArrs;i++)
{
- std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
+ std::vector<std::pair<mcIdType,mcIdType> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
- int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
- MCAuto<DataArrayInt> di=DataArrayInt::New();
+ mcIdType nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
+ MCAuto<DataArrayIdType> di=DataArrayIdType::New();
di->alloc(nbOfElems,1);
di->iota(offset);
const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
/*!
* This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES.
* 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
- * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
+ * No check of this is performed. 'da' array contains an array in old2New style to be applied to mesh to obtain the right support.
* The order of cells in the returned field is those imposed by the profile.
* \param [in] mesh is the global mesh.
*/
MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
- const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
+ const std::vector<std::pair<mcIdType,mcIdType> >& dads, const std::vector<int>& locs,
const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
- const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
+ const MEDCouplingMesh *mesh, const DataArrayIdType *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
if(da->isIota(mesh->getNumberOfCells()))
return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
* This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
*/
MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
- const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
- const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
+ const std::vector<std::pair<mcIdType,mcIdType> >& dads, const std::vector<int>& locs,
+ const MEDCouplingMesh *mesh, const DataArrayIdType *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
if(da->isIota(mesh->getNumberOfNodes()))
return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
if(meshu->getNodalConnectivity()==0)
{
MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
- int nb=da->getNbOfElems();
- const int *ptr=da->getConstPointer();
+ mcIdType nb=da->getNbOfElems();
+ const mcIdType *ptr=da->getConstPointer();
MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
meshuc->allocateCells(nb);
- for(int i=0;i<nb;i++)
+ for(mcIdType i=0;i<nb;i++)
meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
meshuc->finishInsertingCells();
ret->setMesh(meshuc);
//
MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
isPfl=true;
- DataArrayInt *arr2=0;
- MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ DataArrayIdType *arr2=0;
+ MCAuto<DataArrayIdType> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
- MCAuto<DataArrayInt> arr3(arr2);
- int nnodes=mesh2->getNumberOfNodes();
- if(nnodes==(int)da->getNbOfElems())
+ MCAuto<DataArrayIdType> arr3(arr2);
+ mcIdType nnodes=mesh2->getNumberOfNodes();
+ if(nnodes==(mcIdType)da->getNbOfElems())
{
- MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
+ MCAuto<DataArrayIdType> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
arrOut->renumberInPlace(da3->getConstPointer());
mesh2->setName(mesh->getName().c_str());
ret->setMesh(mesh2);
else
{
std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
- oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
+ oss << "So it is impossible to return a well defined MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
/*!
* This method is the most light method of field retrieving.
*/
-DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
+DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<mcIdType,mcIdType> >& dads, const DataArrayIdType *pflIn, mcIdType nbOfElems, DataArrayIdType *&pflOut) const
{
if(!pflIn)
{
- pflOut=DataArrayInt::New();
+ pflOut=DataArrayIdType::New();
pflOut->alloc(nbOfElems,1);
pflOut->iota(0);
}
else
{
- pflOut=const_cast<DataArrayInt*>(pflIn);
+ pflOut=const_cast<DataArrayIdType*>(pflIn);
pflOut->incrRef();
}
- MCAuto<DataArrayInt> safePfl(pflOut);
+ MCAuto<DataArrayIdType> safePfl(pflOut);
MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
const std::vector<std::string>& infos=getInfo();
- int nbOfComp=infos.size();
- for(int i=0;i<nbOfComp;i++)
+ std::size_t nbOfComp=infos.size();
+ for(std::size_t i=0;i<nbOfComp;i++)
da->setInfoOnComponent(i,infos[i].c_str());
safePfl->incrRef();
return da.retn();
/// @cond INTERNAL
-class MFFPMIter
+class MFFPMIter // MEDFileFieldPerMeshIterator
{
public:
static MFFPMIter *NewCell(const MEDFileEntities *entities);
INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
+
+ // for each geometric type inside my mesh, check if there is a field profile ie if the field is defined on this type of cells (whether the discretization is on cells or on gauss_ne)
+ // and if this is the case, retrieve the part to be read and build a new MedFileField from it
for(iter0->begin();!iter0->finished();iter0->next())
{
- int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
+ med_int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
- int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
+ med_int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
if(nbProfile>0 || nbProfile2>0)
{
setMeshName(name1);
}
}
+
+
+ // entities are pairs of a field discretization and geometric type
+ // if no entities have been passed, then it means we can consider nodes by default
if(MFFPMIter::IsPresenceOfNode(entities))
{
- int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
+ // if there is a profile on nodes for the current field, retrieve the part to be read and build a new MedFileField from it
+ med_int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
if(nbProfile>0)
{
const PartDefinition *pd(0);
std::vector<int> dynGT(entities->getDynGTAvail());
for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
{
- int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
+ med_int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
if(nbPfl>0)
{
_field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
iter0=MFFPMIter::NewCell(entities);
for(iter0->begin();!iter0->finished();iter0->next())
{
- int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_FACE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
+ med_int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_FACE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
- int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_EDGE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
+ med_int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_EDGE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
if(nbProfile>0 || nbProfile2>0)
{
}
}
+MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const PartDefinition *pd, const MEDFileEntities *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
+ _father(fath)
+{
+ INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
+ for(iter0->begin();!iter0->finished();iter0->next())
+ {
+ med_int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
+ std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
+ med_int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
+ std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
+ if(nbProfile>0 || nbProfile2>0)
+ {
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
+ if(nbProfile>0)
+ setMeshName(name0);
+ else
+ setMeshName(name1);
+ }
+ }
+
+ if(MFFPMIter::IsPresenceOfNode(entities))
+ {
+ med_int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
+ if(nbProfile>0)
+ {
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
+ setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE));
+ }
+ }
+}
+
+
MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
{
copyTinyInfoFrom(mesh);