}
}
+bool MEDCouplingDefinitionTimeSlice::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
+{
+ if(_mesh_id!=other._mesh_id)
+ return false;
+ if(_array_id!=other._array_id)
+ return false;
+ if(_field_id!=other._field_id)
+ return false;
+ return true;
+}
+
int MEDCouplingDefinitionTimeSlice::getStartId() const
{
return _array_id;
return (o1<t1+eps && o2<t1+eps);
}
+bool MEDCouplingDefinitionTimeSliceInst::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
+{
+}
+
+void MEDCouplingDefinitionTimeSliceInst::getHotSpotsTime(std::vector<double>& ret) const
+{
+ ret.resize(1);
+ ret[0]=_instant;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
+{
+ meshId=_mesh_id;
+ arrId=_array_id;
+ arrIdInField=0;
+ fieldId=_field_id;
+}
+
bool MEDCouplingDefinitionTimeSliceInst::isContaining(double tmp, double eps) const
{
return fabs(tmp-_instant)<eps;
_instant=t1;
}
+bool MEDCouplingDefinitionTimeSliceCstOnTI::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
+{
+}
+
+void MEDCouplingDefinitionTimeSliceCstOnTI::getHotSpotsTime(std::vector<double>& ret) const
+{
+ ret.resize(1);
+ ret[0]=(_start+_end)/2.;
+}
+
+void MEDCouplingDefinitionTimeSliceCstOnTI::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
+{
+ meshId=_mesh_id;
+ arrId=_array_id;
+ arrIdInField=0;
+ fieldId=_field_id;
+}
+
bool MEDCouplingDefinitionTimeSliceCstOnTI::isContaining(double tmp, double eps) const
{
- return _start-eps>tmp && _end+eps<tmp;
+ return _start-eps<tmp && _end+eps>tmp;
}
void MEDCouplingDefinitionTimeSliceCstOnTI::appendRepr(std::ostream& stream) const
_end=t2;
}
+bool MEDCouplingDefinitionTimeSliceLT::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
+{
+}
+
+void MEDCouplingDefinitionTimeSliceLT::getHotSpotsTime(std::vector<double>& ret) const
+{
+ ret.resize(2);
+ ret[0]=_start;
+ ret[1]=_end;
+}
+
+void MEDCouplingDefinitionTimeSliceLT::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
+{
+ if(fabs(tm-_start)<eps)
+ {
+ meshId=_mesh_id;
+ arrId=_array_id;
+ arrIdInField=0;
+ fieldId=_field_id;
+ return ;
+ }
+ if(fabs(tm-_end)<eps)
+ {
+ meshId=_mesh_id;
+ arrId=_array_id_end;
+ arrIdInField=1;
+ fieldId=_field_id;
+ return ;
+ }
+ throw INTERP_KERNEL::Exception("LinearTime request not in boundary of this ! use hot spots !");
+}
+
bool MEDCouplingDefinitionTimeSliceLT::isContaining(double tmp, double eps) const
{
- return _start-eps>tmp && _end+eps<tmp;
+ return _start-eps<tmp && _end+eps>tmp;
}
void MEDCouplingDefinitionTimeSliceLT::appendRepr(std::ostream& stream) const
int sz=ids.size();
if(sz>2)
throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime::getIdsOnTime : Too many slices match this time !");
- //tony
+ //
+ meshIds.resize(sz);
+ arrIds.resize(sz);
+ arrIdsInField.resize(sz);
+ fieldIds.resize(sz);
+ for(int i=0;i<sz;i++)
+ _slices[ids[i]]->getIdsOnTime(tm,_eps,meshIds[i],arrIds[i],arrIdsInField[i],fieldIds[i]);
+}
+
+std::vector<double> MEDCouplingDefinitionTime::getHotSpotsTime() const
+{
+ std::vector<double> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++)
+ {
+ std::vector<double> tmp;
+ (*it)->getHotSpotsTime(tmp);
+ if(!ret.empty())
+ {
+ if(fabs(ret.back()-tmp.front())>_eps)
+ ret.insert(ret.end(),tmp.begin(),tmp.end());
+ else
+ ret.insert(ret.end(),tmp.begin()+1,tmp.end());
+ }
+ else
+ ret.insert(ret.end(),tmp.begin(),tmp.end());
+ }
+ return ret;
}
void MEDCouplingDefinitionTime::appendRepr(std::ostream& stream) const
public:
static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception);
int getArrayId() const { return _array_id; }
+ virtual bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ virtual void getHotSpotsTime(std::vector<double>& ret) const = 0;
+ virtual void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) = 0;
virtual bool isContaining(double tmp, double eps) const = 0;
virtual int getStartId() const;
virtual int getEndId() const;
class MEDCouplingDefinitionTimeSliceInst : public MEDCouplingDefinitionTimeSlice
{
public:
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& ret) const;
+ void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
bool isContaining(double tmp, double eps) const;
void appendRepr(std::ostream& stream) const;
double getStartTime() const;
class MEDCouplingDefinitionTimeSliceCstOnTI : public MEDCouplingDefinitionTimeSlice
{
public:
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& ret) const;
+ void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
bool isContaining(double tmp, double eps) const;
void appendRepr(std::ostream& stream) const;
double getStartTime() const;
class MEDCouplingDefinitionTimeSliceLT : public MEDCouplingDefinitionTimeSlice
{
public:
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& ret) const;
+ void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
bool isContaining(double tmp, double eps) const;
void appendRepr(std::ostream& stream) const;
double getStartTime() const;
{
public:
MEDCouplingDefinitionTime();
+ bool isEqual(const MEDCouplingDefinitionTime& other, double eps) const;
MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& arrRefs) throw(INTERP_KERNEL::Exception);
double getTimeResolution() const { return _eps; }
void getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
void getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
+ std::vector<double> getHotSpotsTime() const;
void appendRepr(std::ostream& stream) const;
private:
void getIdsOnTime(double tm, std::vector<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception);
}
/*!
- *
+ * This method works only for arrays having single component.
+ * If this contains the array a1 containing [9,10,0,6,4,11,3,7] this method returns an array a2 [5,6,0,3,2,7,1,4].
+ * By doing a1.renumber(a2) the user will obtain array a3 equal to a1 sorted.
+ * This method is useful for renumbering (in MED file for example). This method is used by MEDCouplingFieldDouble::renumberCells when check is set to true.
+ * This method throws an exception if more 2 or more elements in 'this' are same.
*/
DataArrayInt *DataArrayInt::checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception)
{
}
}
+/*!
+ * This method is very close too MEDCouplingUMesh::buildPartOfMySelfNode. The difference is that it returns directly ids.
+ */
+DataArrayInt *MEDCouplingUMesh::getCellIdsLyingOnNodes(const int *begin, const int *end, bool fullyIn) const
+{
+ std::vector<int> cellIdsKept;
+ fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(cellIdsKept.size(),1);
+ std::copy(cellIdsKept.begin(),cellIdsKept.end(),ret->getPointer());
+ ret->setName(getName());
+ return ret;
+}
+
/*!
* Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end').
* The return newly allocated mesh will share the same coordinates as 'this'.
return ret;
}
+/*!
+ * This method returns a newly created DataArrayInt instance containing ids of cells located in boundary.
+ * A cell is detected to be on boundary if it contains one or more than one face having only one father.
+ * This method makes the assumption that 'this' is fully defined (coords,connectivity). If not an exception will be thrown.
+ */
+DataArrayInt *MEDCouplingUMesh::findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception)
+{
+ checkFullyDefined();
+ DataArrayInt *desc=DataArrayInt::New();
+ DataArrayInt *descIndx=DataArrayInt::New();
+ DataArrayInt *revDesc=DataArrayInt::New();
+ DataArrayInt *revDescIndx=DataArrayInt::New();
+ //
+ MEDCouplingUMesh *meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
+ //
+ revDescIndx->decrRef();
+ revDesc->decrRef();
+ desc->decrRef();
+ descIndx->decrRef();
+}
+
/*!
* This methods returns set of nodes lying on the boundary of this.
*/
MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const;
+ MEDCOUPLING_EXPORT DataArrayInt *getCellIdsLyingOnNodes(const int *begin, const int *end, bool fullyIn) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector<int>& nodes) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
+ MEDCOUPLING_EXPORT DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
MEDCOUPLING_EXPORT void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes);
MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
%newobject ParaMEDMEM::MEDCouplingUMesh::buildPartOrthogonalField;
%newobject ParaMEDMEM::MEDCouplingUMesh::keepCellIdsByType;
%newobject ParaMEDMEM::MEDCouplingUMesh::Build0DMeshFromCoords;
+%newobject ParaMEDMEM::MEDCouplingUMesh::findCellsIdsOnBoundary;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes;
%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New;
%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh;
%newobject ParaMEDMEM::MEDCouplingCMesh::New;
void computeTypes() throw(INTERP_KERNEL::Exception);
std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception);
//tools
+ DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception);
bool checkConsecutiveCellTypes() const throw(INTERP_KERNEL::Exception);
DataArrayInt *rearrange2ConsecutiveCellTypes() throw(INTERP_KERNEL::Exception);
DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
ret->setName(da->getName().c_str());
return ret;
}
+
+ DataArrayInt *getCellIdsLyingOnNodes(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->getCellIdsLyingOnNodes(tmp,((const int *)tmp)+size,fullyIn);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->getCellIdsLyingOnNodes(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn);
+ }
+ }
}
void convertToPolyTypes(const std::vector<int>& cellIdsToConvert) throw(INTERP_KERNEL::Exception);
void unPolyze() throw(INTERP_KERNEL::Exception);
mfs2=mfs.deepCpy();
self.assertTrue(mfs.isEqual(mfs2,1e-12,1e-12))
pass
+
+ def testDAICheckAndPreparePermutation1(self):
+ vals1=[9,10,0,6,4,11,3,7];
+ expect1=[5,6,0,3,2,7,1,4];
+ vals2=[9,10,0,6,10,11,3,7];
+ da=DataArrayInt.New();
+ da.setValues(vals1,8,1);
+ da2=da.checkAndPreparePermutation();
+ self.assertEqual(8,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ for i in xrange(8):
+ self.assertEqual(expect1[i],da2.getIJ(i,0));
+ pass
+ #
+ da=DataArrayInt.New();
+ da.alloc(8,1);
+ da.iota(0);
+ da2=da.checkAndPreparePermutation();
+ self.assertEqual(8,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ self.assertTrue(da2.isIdentity());
+ #
+ da=DataArrayInt.New();
+ da.alloc(8,1);
+ da.setValues(vals2,8,1);
+ self.assertRaises(InterpKernelException,da.checkAndPreparePermutation);
+ pass
def setUp(self):
pass