return mesh->getNumberOfCells();
}
+DataArrayInt *MEDCouplingFieldDiscretizationP0::getOffsetArr(const MEDCouplingMesh *mesh) const
+{
+ int nbOfTuples=mesh->getNumberOfCells();
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples+1,1);
+ ret->iota(0);
+ return ret;
+}
+
void MEDCouplingFieldDiscretizationP0::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
{
return mesh->getNumberOfNodes();
}
+DataArrayInt *MEDCouplingFieldDiscretizationP1::getOffsetArr(const MEDCouplingMesh *mesh) const
+{
+ int nbOfTuples=mesh->getNumberOfNodes();
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples+1,1);
+ ret->iota(0);
+ return ret;
+}
+
DataArrayDouble *MEDCouplingFieldDiscretizationP1::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
{
return mesh->getCoordinatesAndOwner();
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells : presence of orphan cells !");
}
+const DataArrayInt *MEDCouplingFieldDiscretizationPerCell::getArrayOfDiscIds() const
+{
+ return _discr_per_cell;
+}
+
MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss()
{
}
return mesh->getNumberOfCells();
}
+DataArrayInt *MEDCouplingFieldDiscretizationGauss::getOffsetArr(const MEDCouplingMesh *mesh) const
+{
+ int nbOfTuples=mesh->getNumberOfCells();
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples+1,1);
+ int *retPtr=ret->getPointer();
+ const int *start=_discr_per_cell->getConstPointer();
+ retPtr[0]=0;
+ for(int i=0;i<nbOfTuples;i++,start++)
+ retPtr[i+1]=retPtr[i]+_loc[*start].getNumberOfGaussPt();
+ return ret;
+}
+
void MEDCouplingFieldDiscretizationGauss::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
{
for(int i=0;i<nbOfLoc;i++)
{
std::vector<int> tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta);
- MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo(dim,tmp);
+ MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp);
_loc.push_back(elt);
}
}
return mesh->getNumberOfCells();
}
+DataArrayInt *MEDCouplingFieldDiscretizationGaussNE::getOffsetArr(const MEDCouplingMesh *mesh) const
+{
+ int nbOfTuples=mesh->getNumberOfCells();
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples+1,1);
+ int *retPtr=ret->getPointer();
+ retPtr[0]=0;
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(i);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ if(cm.isDynamic())
+ throw INTERP_KERNEL::Exception("Not implemented yet Gauss node on elements for polygons and polyedrons !");
+ retPtr[i+1]=retPtr[i]+cm.getNumberOfNodes();
+ }
+ return ret;
+}
+
void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
{
virtual const char *getStringRepr() const = 0;
virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0;
+ virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0;
virtual void normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
virtual void normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
virtual void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
+ DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
+ DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
*/
class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationPerCell : public MEDCouplingFieldDiscretization
{
+ public:
+ const DataArrayInt *getArrayOfDiscIds() const;
protected:
MEDCouplingFieldDiscretizationPerCell();
MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other);
const char *getStringRepr() const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
+ DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
+ DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
{
if(_type!=other._type)
return false;
- if(!areAlmostEqual(_ref_coord,other._ref_coord,eps))
+ if(!AreAlmostEqual(_ref_coord,other._ref_coord,eps))
return false;
- if(!areAlmostEqual(_gauss_coord,other._gauss_coord,eps))
+ if(!AreAlmostEqual(_gauss_coord,other._gauss_coord,eps))
return false;
- if(!areAlmostEqual(_weight,other._weight,eps))
+ if(!AreAlmostEqual(_weight,other._weight,eps))
return false;
return true;
}
/*!
* The format of 'tinyData' parameter is the same than pushed in method ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo.
*/
-ParaMEDMEM::MEDCouplingGaussLocalization ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo(int dim, const std::vector<int>& tinyData)
+ParaMEDMEM::MEDCouplingGaussLocalization ParaMEDMEM::MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(int dim, const std::vector<int>& tinyData)
{
std::vector<double> v1(dim*tinyData[1]),v2(dim*tinyData[2]),v3(tinyData[2]);
return ParaMEDMEM::MEDCouplingGaussLocalization((INTERP_KERNEL::NormalizedCellType)tinyData[0],v1,v2,v3);
return dim;
}
-bool ParaMEDMEM::MEDCouplingGaussLocalization::areAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps)
+bool ParaMEDMEM::MEDCouplingGaussLocalization::AreAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps)
{
int sz=v1.size();
if(sz!=(int)v2.size())
void setGaussCoord(int gaussPtIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception);
void setWeight(int gaussPtIdInCell, double newVal) throw(INTERP_KERNEL::Exception);
//
- static MEDCouplingGaussLocalization buildNewInstanceFromTinyInfo(int dim, const std::vector<int>& tinyData);
+ static MEDCouplingGaussLocalization BuildNewInstanceFromTinyInfo(int dim, const std::vector<int>& tinyData);
+ static bool AreAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps);
private:
int checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception);
- static bool areAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps);
private:
INTERP_KERNEL::NormalizedCellType _type;
std::vector<double> _ref_coord;
%feature("autodoc", "1");
%feature("docstring");
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr;
%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
self.assertEqual([4,4,3,0,4,4,3,3,0,0,2,2],da.getValues())
pass
+ def testSwigDAIOp2(self):
+ da=DataArrayInt.New()
+ st=da.getHiddenCppPointer()
+ da.alloc(10,3)
+ da.rearrange(1)
+ da.iota(0)
+ da.rearrange(3)
+ da[:,1]+=4
+ da[-2:,2]+=10
+ da[-2:,2]+=10
+ da[:,2]+=da[:,0]
+ da[da[0],:]=7
+ self.assertEqual(st,da.getHiddenCppPointer())
+ self.assertEqual(da.getValues(),[7,7,7,3,8,8,7,7,7,9,14,20,12,17,26,7,7,7,18,23,38,21,26,44,24,29,70,27,32,76])
+ pass
+
def testDAIAggregateMulti1(self):
a=DataArrayInt.New()
a.setValues(range(4),2,2)