DataArrayInt *computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const;
const MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
MEDCouplingFieldDiscretization *getDiscretization() { return _type; }
+ void setDiscretization(MEDCouplingFieldDiscretization *newDisc) { _type=newDisc; }
int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception);
// Gauss point specific methods
return isEqual(other,eps);
}
+/*!
+ * For all field discretization excepted GaussPts the [ \a startCellIds, \a endCellIds ) has no impact on the cloned instance.
+ */
+MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::clonePart(const int *startCellIds, const int *endCellIds) const
+{
+ return clone();
+}
+
/*!
* Excepted for MEDCouplingFieldDiscretizationPerCell no underlying TimeLabel object : nothing to do in generally.
*/
_discr_per_cell->decrRef();
}
-MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other):_discr_per_cell(0)
+MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, const int *startCellIds, const int *endCellIds):_discr_per_cell(0)
{
DataArrayInt *arr=other._discr_per_cell;
if(arr)
- _discr_per_cell=arr->deepCpy();
+ {
+ if(startCellIds==0 && endCellIds==0)
+ _discr_per_cell=arr->deepCpy();
+ else
+ _discr_per_cell=arr->selectByTupleIdSafe(startCellIds,endCellIds);
+ }
}
void MEDCouplingFieldDiscretizationPerCell::updateTime() const
{
}
-MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other):MEDCouplingFieldDiscretizationPerCell(other),_loc(other._loc)
+MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other, const int *startCellIds, const int *endCellIds):MEDCouplingFieldDiscretizationPerCell(other,startCellIds,endCellIds),_loc(other._loc)
{
}
return new MEDCouplingFieldDiscretizationGauss(*this);
}
+MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationGauss::clonePart(const int *startCellIds, const int *endCellIds) const
+{
+ return new MEDCouplingFieldDiscretizationGauss(*this,startCellIds,endCellIds);
+}
+
std::string MEDCouplingFieldDiscretizationGauss::getStringRepr() const
{
std::ostringstream oss; oss << REPR << "." << std::endl;
virtual bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const = 0;
virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
virtual MEDCouplingFieldDiscretization *clone() const = 0;
+ virtual MEDCouplingFieldDiscretization *clonePart(const int *startCellIds, const int *endCellIds) const;
virtual std::string getStringRepr() const = 0;
virtual const char *getRepr() const = 0;
virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
const DataArrayInt *getArrayOfDiscIds() const;
protected:
MEDCouplingFieldDiscretizationPerCell();
- MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other);
+ MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, const int *startCellIds, const int *endCellIds);
~MEDCouplingFieldDiscretizationPerCell();
void updateTime() const;
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
MEDCouplingFieldDiscretization *clone() const;
+ MEDCouplingFieldDiscretization *clonePart(const int *startCellIds, const int *endCellIds) const;
std::string getStringRepr() const;
const char *getRepr() const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< int >& locIds) const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception);
protected:
- MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other);
+ MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other, const int *startCellIds=0, const int *endCellIds=0);
void zipGaussLocalizations();
int getOffsetOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
void checkLocalizationId(int locId) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const int *partBg, const int *partEnd) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *arrSelect;
- MEDCouplingMesh *m=_type->buildSubMeshData(_mesh,partBg,partEnd,arrSelect);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=_type->buildSubMeshData(_mesh,partBg,partEnd,arrSelect);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arrSelect2(arrSelect);
MEDCouplingFieldDouble *ret=clone(false);//quick shallow copy.
+ const MEDCouplingFieldDiscretization *disc=getDiscretization();
+ if(disc)
+ ret->setDiscretization(disc->clonePart(partBg,partEnd));
ret->setMesh(m);
- m->decrRef();
std::vector<DataArrayDouble *> arrays;
_time_discr->getArrays(arrays);
std::vector<DataArrayDouble *> arrs;
%feature("docstring");
%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr;
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clone;
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clonePart;
%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr;
%newobject ParaMEDMEM::MEDCouplingField::computeTupleIdsToSelectFromCellIds;
}
}
+%extend ParaMEDMEM::MEDCouplingFieldDiscretization
+{
+ MEDCouplingFieldDiscretization *clonePart(PyObject *li)
+ {
+ int sz=0,sw=-1,val1=-1;
+ std::vector<int> val2;
+ const int *inp=convertObjToPossibleCpp1_Safe(li,sw,sz,val1,val2);
+ return self->clonePart(inp,inp+sz);
+ }
+}
+
%extend ParaMEDMEM::MEDCouplingFieldDiscretizationPerCell
{
PyObject *getArrayOfDiscIds() const
%ignore ParaMEDMEM::DataArrayInt::getDifferentValues;
%ignore ParaMEDMEM::DataArrayInt::partitionByDifferentValues;
%ignore ParaMEDMEM::MEDCouplingFieldDiscretizationPerCell::getArrayOfDiscIds;
+%ignore ParaMEDMEM::MEDCouplingFieldDiscretization::clonePart;
%include "MEDCouplingMemArray.hxx"
%include "NormalizedUnstructuredMesh.hxx"
int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
+ void setDiscretization(MEDCouplingFieldDiscretization *newDisc);
%extend {
PyObject *getMesh() const throw(INTERP_KERNEL::Exception)
{
}
throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
}
+
+/*!
+ * if python int -> cpp int sw=1
+ * if python list[int] -> cpp vector<int> sw=2
+ * if python tuple[int] -> cpp vector<int> sw=2
+ * if python DataArrayInt -> cpp DataArrayInt sw=3
+ * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4
+ *
+ * switch between (int,vector<int>,DataArrayInt)
+ */
+static const int *convertObjToPossibleCpp1_Safe(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector<int>& stdvecTyypp) throw(INTERP_KERNEL::Exception)
+{
+ sw=-1;
+ if(PyInt_Check(value))
+ {
+ iTyypp=(int)PyInt_AS_LONG(value);
+ sw=1; sz=1;
+ return &iTyypp;
+ }
+ if(PyTuple_Check(value))
+ {
+ int size=PyTuple_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2; sz=size;
+ return &stdvecTyypp[0];
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2; sz=size;
+ return &stdvecTyypp[0];
+ }
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+ if(SWIG_IsOK(status))
+ {
+ ParaMEDMEM::DataArrayInt *daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
+ if(daIntTyypp)
+ {
+ sw=3; sz=daIntTyypp->getNbOfElems();
+ return daIntTyypp->begin();
+ }
+ else
+ {
+ sz=0;
+ return 0;
+ }
+ }
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
+ if(SWIG_IsOK(status))
+ {
+ ParaMEDMEM::DataArrayIntTuple *daIntTuple=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
+ sw=4; sz=daIntTuple->getNumberOfCompo();
+ return daIntTuple->getConstPointer();
+ }
+ throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayInt, DataArrayIntTuple");
+}