*/
int MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
{
- if(!_discr_per_cell || _discr_per_cell->isAllocated() || _discr_per_cell->getNumberOfComponents()!=1)
+ if(!_discr_per_cell || !_discr_per_cell->isAllocated() || _discr_per_cell->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode");
if(code.size()%3!=0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : invalid input code !");
throw INTERP_KERNEL::Exception("Discretization is not initialized!");
const int *dcPtr=_discr_per_cell->getConstPointer();
int nbOfTuples=_discr_per_cell->getNumberOfTuples();
+ int maxSz=(int)_loc.size();
for(const int *w=dcPtr;w!=dcPtr+nbOfTuples;w++)
- ret+=_loc[*w].getNumberOfGaussPt();
+ {
+ if(*w>=0 && *w<maxSz)
+ ret+=_loc[*w].getNumberOfGaussPt();
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::getNumberOfTuples : At cell #" << std::distance(dcPtr,w) << " localization id is " << *w << " should be in [0," << maxSz << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
return ret;
}
m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
- std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
- //int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
- /*if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
+ std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
+ // start of check
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
+ if(type==ON_GAUSS_NE)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
+ field2->setMesh(mPart);
+ }
+ int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
+ if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
{
std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
- }*/
+ }
+ // end of check
int start=copyTinyInfoFrom(field,arrOfVals);
code2=m->getDistributionOfTypes();
//
if ( onAll )
fld->_curMedField->appendFieldNoProfileSBT( timeStamp );
else
- {
- if(fld->getMedType()==ON_GAUSS_NE)
- {
- MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > dimMesh2 = dimMesh->buildPartOfMySelf(support->_medGroup->begin(),support->_medGroup->end(),true);
- timeStamp->setMesh( dimMesh2 );
- }
- fld->_curMedField->appendFieldProfile( timeStamp, mesh, dimRel, support->_medGroup );
- }
+ fld->_curMedField->appendFieldProfile( timeStamp, mesh, dimRel, support->_medGroup );
timeStamp->decrRef();
if ( isNewMedField ) // timeStamp must be added before this
# add a field on 2 faces to pointeMed
ff1=MEDFileFieldMultiTS.New()
f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME)
- #
+ #f1.setMesh( pointeM1D )
f1.setName("Field on 2 faces")
d=DataArrayDouble.New()
d.alloc(3+4,2)
da=DataArrayInt.New()
da.setValues([0,2],2,1)
da.setName("sup2")
- pointeM1D_2=pointeM1D[da]
- f1.setMesh( pointeM1D_2 )
ff1.appendFieldProfile(f1,pointeMedMesh,-1,da)
pointeMed.getFields().pushField( ff1 )
// add a field on 2 faces to pointeMed
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ff1=MEDFileFieldMultiTS::New();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=MEDCouplingFieldDouble::New(ON_GAUSS_NE,ONE_TIME);
+ f1->setMesh( pointeM1D );
f1->setName("Field on 2 faces");
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> d=DataArrayDouble::New();
d->alloc(3+4,2);
{
0,2
};
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> pointeM1D_part=pointeM1D->buildPartOfMySelf(ids,ids+2,true);
- f1->setMesh( pointeM1D_part );
da->alloc(2,1);
std::copy(ids,ids+da->getNbOfElems(),da->getPointer());
da->setName("sup2");