arrCpy->decrRef();
}
+void MEDCouplingFieldDiscretization::renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg)
+{
+ int nbOfComp=arr->getNumberOfComponents();
+ DataArrayDouble *arrCpy=arr->deepCopy();
+ const double *ptSrc=arrCpy->getConstPointer();
+ arr->reAlloc(new2OldSz);
+ double *ptToFill=arr->getPointer();
+ for(int i=0;i<new2OldSz;i++)
+ {
+ int oldNb=new2OldPtr[i];
+ std::copy(ptSrc+oldNb*nbOfComp,ptSrc+(oldNb+1)*nbOfComp,ptToFill+i*nbOfComp);
+ }
+ arrCpy->decrRef();
+}
+
MEDCouplingFieldDiscretization::~MEDCouplingFieldDiscretization()
{
}
renumberEntitiesFromO2NArr(old2New,arr,"Cell");
}
+void MEDCouplingFieldDiscretizationP0::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
+{
+ renumberEntitiesFromN2OArr(new2old,newSz,arr,"Cell");
+}
+
/*!
* This method returns a submesh of 'mesh' instance constituting cell ids contained in array defined as an interval [start;end).
* @param di is an array returned that specifies entity ids (here cells ids) in mesh 'mesh' of entity in returned submesh.
{
}
+/*!
+ * Nothing to do it's not a bug.
+ */
+void MEDCouplingFieldDiscretizationP1::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
+{
+}
+
/*!
* This method returns a submesh of 'mesh' instance constituting cell ids contained in array defined as an interval [start;end).
* @param di is an array returned that specifies entity ids (here nodes ids) in mesh 'mesh' of entity in returned submesh.
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
+void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
+{
+ throw INTERP_KERNEL::Exception("Number of cells has changed and becomes higher with some cells that have been split ! Unable to conserve the Gauss field !");
+}
+
void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
+void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
+{
+ throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other):MEDCouplingFieldDiscretization(other)
{
}
virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
virtual void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const = 0;
virtual void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0;
+ virtual void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const = 0;
virtual void getSerializationIntArray(DataArrayInt *& arr) const;
virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
protected:
MEDCouplingFieldDiscretization();
static void renumberEntitiesFromO2NArr(const int *old2NewPtr, DataArrayDouble *arr, const char *msg);
+ static void renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg);
protected:
double _precision;
static const double DFLT_PRECISION;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
public:
static const char REPR[];
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
public:
static const char REPR[];
static const TypeOfField TYPE;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
protected:
MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other);
public:
return false;
}
+/*!
+ * This method applyies ParaMEDMEM::MEDCouplingUMesh::simplexize on 'this->_mesh'.
+ * The semantic of 'policy' is given in ParaMEDMEM::MEDCouplingUMesh::simplexize method.
+ */
+bool MEDCouplingFieldDouble::simplexize(int policy) throw(INTERP_KERNEL::Exception)
+{
+ int oldNbOfCells=_mesh->getNumberOfCells();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> meshC2(_mesh->deepCpy());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->simplexize(policy);
+ int newNbOfCells=meshC2->getNumberOfCells();
+ if(oldNbOfCells==newNbOfCells)
+ return false;
+ std::vector<DataArrayDouble *> arrays;
+ _time_discr->getArrays(arrays);
+ for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
+ if(*iter)
+ _type->renumberValuesOnCellsR(_mesh,arr->getConstPointer(),arr->getNbOfElems(),*iter);
+ setMesh(meshC2);
+ return true;
+}
+
MEDCouplingFieldDouble *MEDCouplingFieldDouble::doublyContractedProduct() const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization *td=_time_discr->doublyContractedProduct();
bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception);
bool zipCoords() throw(INTERP_KERNEL::Exception);
bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception);
+ bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception);
_nodal_connec_index->decrRef();
_nodal_connec_index=newConnI;
computeTypes();
+ updateTime();
return ret;
}
_nodal_connec_index->decrRef();
_nodal_connec_index=newConnI;
computeTypes();
+ updateTime();
return ret;
}
da->decrRef();
m->decrRef();
}
+
+void MEDCouplingBasicsTest::testSimplexize2()
+{
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ std::vector<int> v(1);
+ v[0]=3;
+ m->convertToPolyTypes(v);
+ MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f1->setMesh(m);
+ DataArrayDouble *arr=DataArrayDouble::New();
+ const double arr1[10]={10.,110.,20.,120.,30.,130.,40.,140.,50.,150.};
+ arr->alloc(5,2);
+ std::copy(arr1,arr1+10,arr->getPointer());
+ f1->setArray(arr);
+ arr->decrRef();
+ //
+ f1->checkCoherency();
+ CPPUNIT_ASSERT(f1->simplexize(0));
+ f1->checkCoherency();
+ const double expected1[14]={10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-10);
+ CPPUNIT_ASSERT(!f1->simplexize(0));
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-10);
+ //
+ f1->decrRef();
+ m->decrRef();
+}
self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10);
pass
pass
+
+ def testSimplexize2(self):
+ m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ m.convertToPolyTypes([3]);
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f1.setMesh(m);
+ arr=DataArrayDouble.New();
+ arr1=[10.,110.,20.,120.,30.,130.,40.,140.,50.,150.]
+ arr.setValues(arr1,5,2);
+ f1.setArray(arr);
+ #
+ f1.checkCoherency();
+ self.assertTrue(f1.simplexize(0));
+ f1.checkCoherency();
+ expected1=[10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.]
+ for i in xrange(14):
+ self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10);
+ pass
+ self.assertTrue(not f1.simplexize(0));
+ for i in xrange(14):
+ self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10);
+ pass
+ #
+ pass
def setUp(self):
pass
bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception);
bool zipCoords() throw(INTERP_KERNEL::Exception);
bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception);
+ bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception);