}
}
-void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(const char *pflName, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
{
if(pflName)
_profile=pflName;
{
case ON_NODES:
{
- _nval=globIds->getNumberOfTuples();
+ _nval=idsInPfl->getNumberOfTuples();
_arr=da->deepCpy();
break;
}
case ON_CELLS:
{
- _nval=globIds->getNumberOfTuples();
- _arr=da->selectByTupleId(globIds->getConstPointer(),globIds->getConstPointer()+_nval);
+ _nval=idsInPfl->getNumberOfTuples();
+ _arr=da->selectByTupleId(idsInPfl->getConstPointer(),idsInPfl->getConstPointer()+_nval);
break;
}
case ON_GAUSS_NE:
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=globIds->buildExplicitArrByRanges(arr);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->getConstPointer(),multiTypePfl->getConstPointer()+multiTypePfl->getNumberOfTuples());
+ arr3->computeOffsets2();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
int trueNval=tmp->getNumberOfTuples();
- _nval=globIds->getNumberOfTuples();
- _arr=da->selectByTupleId(tmp->getConstPointer(),tmp->getConstPointer()+trueNval);
+ _nval=idsInPfl->getNumberOfTuples();
+ _arr=da->selectByTupleIdSafe(tmp->getConstPointer(),tmp->getConstPointer()+trueNval);
break;
}
case ON_GAUSS_PT:
_field_pm_pt_pd[*it]->assignFieldNoProfile(offset,nbOfCells,field,glob);
}
-void MEDFileFieldPerMeshPerType::assignFieldProfile(const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::assignFieldProfile(const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
{
- std::vector<int> pos=addNewEntryIfNecessary(field,globIds);
+ std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
if(locIds)
{
//
glob.appendProfile(locIds);
//
for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
- _field_pm_pt_pd[*it]->assignFieldProfile(oss.str().c_str(),globIds,field,mesh,glob);
+ _field_pm_pt_pd[*it]->assignFieldProfile(oss.str().c_str(),multiTypePfl,idsInPfl,globIds,field,mesh,glob);
}
else
{
for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
- _field_pm_pt_pd[*it]->assignFieldProfile(0,globIds,field,mesh,glob);
+ _field_pm_pt_pd[*it]->assignFieldProfile(0,multiTypePfl,idsInPfl,globIds,field,mesh,glob);
}
}
//
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
- _field_pm_pt_pd[0]->assignFieldProfile(oss.str().c_str(),pfl2,field,0,glob);//mesh is not requested so 0 is send.
+ _field_pm_pt_pd[0]->assignFieldProfile(oss.str().c_str(),pfl,pfl2,0,field,0,glob);//mesh is not requested so 0 is send. Idem for globIds no requested here.
}
std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
mesh->getTime(_mesh_iteration,_mesh_order);
}
-void MEDFileFieldPerMesh::assignFieldProfile(const std::vector<int>& code, const std::vector<DataArrayInt *>& globIdsPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::assignFieldProfile(const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& globIdsPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
{
int nbOfTypes=code.size()/3;
bool isProfile=false;
isProfile=true;
if(!isProfile)
{
- if(globIdsPerType.empty())
+ if(idsInPflPerType.empty())
assignFieldNoProfileNoRenum(code,field,glob);
else
- assignFieldProfileGeneral(code,globIdsPerType,idsPerType,field,field->getMesh(),glob);
+ assignFieldProfileGeneral(multiTypePfl,code,idsInPflPerType,globIdsPerType,idsPerType,field,mesh,glob);
}
else
- assignFieldProfileGeneral(code,globIdsPerType,idsPerType,field,mesh,glob);
+ assignFieldProfileGeneral(multiTypePfl,code,idsInPflPerType,globIdsPerType,idsPerType,field,mesh,glob);
}
void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
/*!
* This method is the most general one. No optimization is done here.
*/
-void MEDFileFieldPerMesh::assignFieldProfileGeneral(const std::vector<int>& code, const std::vector<DataArrayInt *>& globIdsPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::assignFieldProfileGeneral(const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& globIdsPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
{
int nbOfTypes=code.size()/3;
for(int i=0;i<nbOfTypes;i++)
DataArrayInt *pfl=0;
if(code[3*i+2]!=-1)
pfl=idsPerType[code[3*i+2]];
- _field_pm_pt[pos]->assignFieldProfile(globIdsPerType[i],pfl,field,mesh,glob);
+ _field_pm_pt[pos]->assignFieldProfile(multiTypePfl,idsInPflPerType[i],globIdsPerType[i],pfl,field,mesh,glob);
}
}
}
/*!
- * geoTypes,dads,pfls,locs are input parameters. They should have the same size.
+ * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
* Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
* It returns 2 output vectors :
* - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
* - '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 MEDFieldFieldGlobs *glob, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector<const DataArrayDouble *>& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
+void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobs *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector<const DataArrayDouble *>& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
{
int notNullPflsSz=0;
int nbOfArrs=geoTypes.size();
std::vector<const DataArrayInt *> 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+1]=ComputeNbOfElems(glob,tmpDads,tmpLocs);
+ code[3*i+1]=ComputeNbOfElems(glob,type,refType,tmpDads,tmpLocs);
if(notNullTmp.empty())
code[3*i+2]=-1;
else
/*!
* 'dads' and 'locs' are input parameters that should have same size sz. sz should be >=1.
*/
-int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobs *glob, const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception)
+int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobs *glob, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception)
{
int sz=dads.size();
int ret=0;
for(int i=0;i<sz;i++)
{
if(locs[i]==-1)
- ret+=dads[i]->getNumberOfTuples();
+ {
+ if(type!=ON_GAUSS_NE)
+ ret+=dads[i]->getNumberOfTuples();
+ else
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoType);
+ ret+=dads[i]->getNumberOfTuples()/cm.getNumberOfNodes();
+ }
+ }
else
{
int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
// Sort by types
- SortArraysPerType(glob,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
+ SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
if(code.empty())
{
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
// Sort by types
- SortArraysPerType(glob,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
+ SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
if(code.empty())
{
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
for(int i=0;i<nbOfArrs;i++)
{
std::vector<const DataArrayDouble *> dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
- int nbOfElems=ComputeNbOfElems(glob,dads2,locs2);
+ int nbOfElems=ComputeNbOfElems(glob,type,INTERP_KERNEL::NORM_ERROR,dads2,locs2);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
di->alloc(nbOfElems,1);
di->iota(offset);
if(da->isIdentity())
{
int nbOfTuples=da->getNumberOfTuples();
- if(nbOfTuples==ComputeNbOfElems(glob,dads,locs))
+ if(nbOfTuples==ComputeNbOfElems(glob,type,INTERP_KERNEL::NORM_ERROR,dads,locs))//No problem for NORM_ERROR because it is in context of node
return finishField(type,glob,dads,locs,mesh,isPfl);
}
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,mesh,isPfl);
if(da->isIdentity())
{
int nbOfTuples=da->getNumberOfTuples();
- if(nbOfTuples==ComputeNbOfElems(glob,dads,locs))
+ if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,INTERP_KERNEL::NORM_ERROR,dads,locs))//No problem for NORM_ERROR because it is in context of node
return finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
}
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
std::vector<int> code=MEDFileField1TSWithoutDAS::CheckSBTMesh(mesh);
//
int pos=addNewEntryIfNecessary(mesh);
- _field_per_mesh[pos]->assignFieldProfile(code,dummy,dummy,field,0,glob);//mesh is set to 0 because no external mesh is needed to be sent because no profile.
+ _field_per_mesh[pos]->assignFieldProfile(0,code,dummy,dummy,dummy,field,0,glob);//mesh is set to 0 because no external mesh is needed to be sent because no profile.
}
else
{
{
TypeOfField type=field->getTypeOfField();
copyTinyInfoFrom(field);
+ std::vector<DataArrayInt *> idsInPflPerType;
std::vector<DataArrayInt *> globIdsPerType;
std::vector<DataArrayInt *> idsPerType;
std::vector<int> code;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
if(type!=ON_NODES)
{
- m->splitProfilePerType(profile,code,globIdsPerType,idsPerType);
+ m->splitProfilePerType(profile,code,idsInPflPerType,globIdsPerType,idsPerType);
//
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
+ for(std::size_t i=0;i<idsInPflPerType.size();i++)
+ idsInPflPerType2[i]=idsInPflPerType[i];
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > globIdsPerType2(globIdsPerType.size());
for(std::size_t i=0;i<globIdsPerType.size();i++)
globIdsPerType2[i]=globIdsPerType[i];
idsPerType2[i]=idsPerType[i];
//
int pos=addNewEntryIfNecessary(m);
- _field_per_mesh[pos]->assignFieldProfile(code,globIdsPerType,idsPerType,field,m,glob);
+ _field_per_mesh[pos]->assignFieldProfile(profile,code,idsInPflPerType,globIdsPerType,idsPerType,field,m,glob);
}
else
{
static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception);
static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId);
void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
- void assignFieldProfile(const char *pflName, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldProfile(const char *pflName, const DataArrayInt *globIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldProfile(const char *pflName, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMeshPerType *getFather() const;
int getIteration() const;
public:
static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
- void assignFieldProfile(const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const DataArrayInt *globIds, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMesh *getFather() const;
static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh);
static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder);
void copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
- void assignFieldProfile(const std::vector<int>& code, const std::vector<DataArrayInt *>& globIdsPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
- void assignFieldProfileGeneral(const std::vector<int>& code, const std::vector<DataArrayInt *>& globIdsPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& globIdsPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfileGeneral(const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& globIdsPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
void assignFieldNoProfileNoRenum(const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs,
const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *finishField4(const std::vector<const DataArrayDouble *>& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception);
- static void SortArraysPerType(const MEDFieldFieldGlobs *glob,
+ static void SortArraysPerType(const MEDFieldFieldGlobs *glob, TypeOfField type,
const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector<const DataArrayDouble *>& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs,
std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls);
- static int ComputeNbOfElems(const MEDFieldFieldGlobs *glob, const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception);
+ static int ComputeNbOfElems(const MEDFieldFieldGlobs *glob, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception);
MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder);
MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh);
private:
m1=MEDLoaderDataForTest.build2DMesh_1()
m1.renumberCells([0,1,4,2,3,5],False)
tmp=m1.getName();
- m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp)
+ m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
mm1.write(fname,2)
ff1=MEDFileField1TS.New()
da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt")
#
ff1.setFieldProfile(f1,mm1,0,da)
- ## ff1.write(fname,0)
+ ff1.write(fname,0)
#
- ## vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1)
- ## print pfl
- ## print da
- ## self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
- ## self.assertTrue(vals.isEqual(d,1e-14))
- ## #
- ## ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
- ## vals,pfl=ff2.getFieldWithProfile(GAUSS_NE,0,mm1)
- ## self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
- ## self.assertTrue(vals.isEqual(d,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
+ vals,pfl=ff2.getFieldWithProfile(ON_GAUSS_NE,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField14(self):
+ fname="Pyfile35.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ tmp=m1.getName();
+ m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileFieldMultiTS.New()
+ f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F4Node")
+ d=DataArrayDouble.New() ; d.alloc(2*11,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt")
+ #
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ #
+ ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
pass
pass