Implementation of buildSubPart for Gauss and GaussNE.
return _type->buildSubMeshData(_mesh,start,end,di);
}
+/*!
+ * This method returns tuples ids implied by the mesh selection of the cell ids contained in array defined as an interval [start;end).
+ * \return a newly allocated DataArrayInt instance containing tuples ids.
+ */
+DataArrayInt *MEDCouplingField::computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const
+{
+ return _type->computeTupleIdsToSelectFromCellIds(_mesh,startCellIds,endCellIds);
+}
+
/*!
* This method returns number of tuples expected regarding its discretization and its _mesh attribute.
* This method expected a not null _mesh instance. If null, an exception will be thrown.
DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const;
+ DataArrayInt *computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const;
MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception);
}
/*!
- * This method returns a submesh of 'mesh' instance constituting cell ids contained in array defined as an interval [start;end].
+ * This method returns a tuple ids selection from cell ids selection [start;end).
+ * This method is called by MEDCouplingFieldDiscretizationP0::buildSubMeshData to return parameter \b di.
+ * Here for P0 it's very simple !
+ *
+ * \return a newly allocated array containing ids to select into the DataArrayDouble of the field.
+ *
+ */
+DataArrayInt *MEDCouplingFieldDiscretizationP0::computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc((int)std::distance(startCellIds,endCellIds),1);
+ std::copy(startCellIds,endCellIds,ret->getPointer());
+ ret->incrRef(); return ret;
+}
+
+/*!
+ * 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.
* Example : The first cell id of returned mesh has the (*di)[0] id in 'mesh'
*/
return ret;
}
+/*!
+ * This method returns a tuple ids selection from cell ids selection [start;end).
+ * This method is called by MEDCouplingFieldDiscretizationP0::buildSubMeshData to return parameter \b di.
+ * Here for P1 only nodes fetched by submesh of mesh[startCellIds:endCellIds) is returned !
+ *
+ * \return a newly allocated array containing ids to select into the DataArrayDouble of the field.
+ *
+ */
+DataArrayInt *MEDCouplingFieldDiscretizationP1::computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP1::computeTupleIdsToSelectFromCellIds : null mesh !");
+ const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> umesh=mesh->buildUnstructured();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> umesh2=static_cast<MEDCouplingUMesh *>(umesh->buildPartOfMySelf(startCellIds,endCellIds,true));
+ return umesh2->computeFetchedNodeIds();
+}
+
MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell():_discr_per_cell(0)
{
}
MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
{
- throw INTERP_KERNEL::Exception("Not implemented yet !");
+ di=computeTupleIdsToSelectFromCellIds(mesh,start,end);
+ return mesh->buildPart(start,end);
+}
+
+/*!
+ * This method returns a tuple ids selection from cell ids selection [start;end).
+ * This method is called by MEDCouplingFieldDiscretizationGauss::buildSubMeshData to return parameter \b di.
+ *
+ * \return a newly allocated array containing ids to select into the DataArrayDouble of the field.
+ *
+ */
+DataArrayInt *MEDCouplingFieldDiscretizationGauss::computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::computeTupleIdsToSelectFromCellIds : null mesh !");
+ if(!_discr_per_cell)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::computeTupleIdsToSelectFromCellIds : null discretization ids !");
+ int nbOfCells=mesh->getNumberOfCells();
+ if(_discr_per_cell->getNumberOfTuples()!=nbOfCells)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::computeTupleIdsToSelectFromCellIds : mismatch of nb of tuples of cell ids array and number of cells !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfNodesPerCell=DataArrayInt::New(); nbOfNodesPerCell->alloc(nbOfCells,1);
+ int *retPtr=nbOfNodesPerCell->getPointer();
+ const int *pt=_discr_per_cell->getConstPointer();
+ int nbMaxOfLocId=(int)_loc.size();
+ for(int i=0;i<nbOfCells;i++,retPtr++)
+ {
+ if(*pt>=0 && *pt<nbMaxOfLocId)
+ *retPtr=_loc[*pt].getNumberOfGaussPt();
+ }
+ nbOfNodesPerCell->computeOffsets2();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> sel=DataArrayInt::New(); sel->useArray(startCellIds,false,CPP_DEALLOC,(int)std::distance(startCellIds,endCellIds),1);
+ return sel->buildExplicitArrByRanges(nbOfNodesPerCell);
}
/*!
MEDCouplingMesh *MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
{
- throw INTERP_KERNEL::Exception("Not implemented yet !");
+ di=computeTupleIdsToSelectFromCellIds(mesh,start,end);
+ return mesh->buildPart(start,end);
+}
+
+/*!
+ * This method returns a tuple ids selection from cell ids selection [start;end).
+ * This method is called by MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData to return parameter \b di.
+ *
+ * \return a newly allocated array containing ids to select into the DataArrayDouble of the field.
+ *
+ */
+DataArrayInt *MEDCouplingFieldDiscretizationGaussNE::computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::computeTupleIdsToSelectFromCellIds : null mesh !");
+ const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> umesh=mesh->buildUnstructured();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfNodesPerCell=umesh->computeNbOfNodesPerCell();
+ nbOfNodesPerCell->computeOffsets2();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> sel=DataArrayInt::New(); sel->useArray(startCellIds,false,CPP_DEALLOC,(int)std::distance(startCellIds,endCellIds),1);
+ return sel->buildExplicitArrByRanges(nbOfNodesPerCell);
}
/*!
virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0;
+ virtual DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const = 0;
virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const = 0;
virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0;
void renumberValuesOnCells(double epsOnVals, 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;
+ DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
public:
static const char REPR[];
static const TypeOfField TYPE;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
+ DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
+ DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
+ DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
std::vector<DataArrayDouble *> arrays;
_time_discr->getArrays(arrays);
std::vector<DataArrayDouble *> arrs;
- const int *arrSelBg=arrSelect->getConstPointer();
- const int *arrSelEnd=arrSelBg+arrSelect->getNbOfElems();
+ const int *arrSelBg=arrSelect->begin();
+ const int *arrSelEnd=arrSelect->end();
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
{
DataArrayDouble *arr=0;
return false;
}
+/*!
+ * This method calls MEDCouplingUMesh::buildSlice3D method. So this method makes the assumption that underlying mesh exists.
+ * For the moment, this method is implemented for fields on cells.
+ *
+ * \return a newly allocated field double containing the result that the user should deallocate.
+ */
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::extractSlice3D(const double *origin, const double *vec, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDCouplingMesh *mesh=getMesh();
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::extractSlice3D : underlying mesh is null !");
+ if(getTypeOfField()!=ON_CELLS)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::extractSlice3D : only implemented for fields on cells !");
+ const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=clone(false);
+ ret->setMesh(umesh);
+ DataArrayInt *cellIds=0;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh2=umesh->buildSlice3D(origin,vec,eps,cellIds);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds2=cellIds;
+ ret->setMesh(mesh2);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tupleIds=computeTupleIdsToSelectFromCellIds(cellIds->begin(),cellIds->end());
+ std::vector<DataArrayDouble *> arrays;
+ _time_discr->getArrays(arrays);
+ int i=0;
+ std::vector<DataArrayDouble *> newArr(arrays.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > newArr2(arrays.size());
+ for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++,i++)
+ {
+ if(*iter)
+ {
+ newArr2[i]=(*iter)->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
+ newArr[i]=newArr2[i];
+ }
+ }
+ ret->setArrays(newArr);
+ ret->incrRef(); return ret;
+}
+
/*!
* This method applyies ParaMEDMEM::MEDCouplingUMesh::simplexize on 'this->_mesh'.
* The semantic of 'policy' is given in ParaMEDMEM::MEDCouplingUMesh::simplexize method.
bool mergeNodes2(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
bool zipCoords(double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
bool zipConnectivity(int compType, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *extractSlice3D(const double *origin, const double *vec, double eps) const 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);
return ret;
}
+/*!
+ * This method returns a newly allocated array containing this->getNumberOfCells() tuples and 1 component.
+ * For each cell in \b this the number of nodes constituting cell is computed.
+ * Excepted for poyhedrons, the result can be deduced by performing a deltaShiftIndex on the nodal connectivity index in \b this minus 1.
+ * For polyhedrons, the face separation (-1) are excluded from the couting.
+ *
+ * \return a newly allocated array
+ */
+DataArrayInt *MEDCouplingUMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+ checkConnectivityFullyDefined();
+ int nbOfCells=getNumberOfCells();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbOfCells,1);
+ int *retPtr=ret->getPointer();
+ const int *conn=getNodalConnectivity()->getConstPointer();
+ const int *connI=getNodalConnectivityIndex()->getConstPointer();
+ for(int i=0;i<nbOfCells;i++,retPtr++)
+ {
+ if(conn[connI[i]]!=(int)INTERP_KERNEL::NORM_POLYHED)
+ *retPtr=connI[i+1]-connI[i]-1;
+ else
+ *retPtr=connI[i+1]-connI[i]-1-std::count(conn+connI[i]+1,conn+connI[i+1],-1);
+ }
+ ret->incrRef(); return ret;
+}
+
/*!
* Array returned is the correspondance in \b old \b to \b new format. The returned array is newly created and should be dealt by the caller.
* The maximum value stored in returned array is the number of nodes of 'this' minus 1 after call of this method.
MEDCOUPLING_EXPORT std::vector<DataArrayInt *> partitionBySpreadZone() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *computeFetchedNodeIds() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception);
//
m->decrRef();
}
+
+void MEDCouplingBasicsTest5::testBuildSlice3D2()
+{
+ MEDCouplingUMesh *mesh2D=0;
+ MEDCouplingUMesh *mesh3D=build3DExtrudedUMesh_1(mesh2D);
+ mesh2D->decrRef();
+ // First slice in the middle of 3D cells
+ const double vec1[3]={-0.07,1.,0.07};
+ const double origin1[3]={1.524,1.4552,1.74768};
+ DataArrayInt *ids=0;
+ MEDCouplingUMesh *slice1=mesh3D->buildSlice3D(origin1,vec1,1e-10,ids);
+ //
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f->setTime(4.5,6,7) ; f->setMesh(mesh3D);
+ DataArrayDouble *arr=DataArrayDouble::New(); arr->alloc(mesh3D->getNumberOfCells(),2);
+ arr->rearrange(1); arr->iota(2.); arr->rearrange(2);
+ f->setArray(arr);
+ f->checkCoherency();
+ const int exp1[9]={1,3,4,7,9,10,13,15,16};
+ DataArrayInt *expected1=DataArrayInt::New(); expected1->alloc(9,1); std::copy(exp1,exp1+9,expected1->getPointer());
+ CPPUNIT_ASSERT(expected1->isEqual(*ids));
+ DataArrayDouble *arr2=arr->selectByTupleIdSafe(expected1->begin(),expected1->end());
+ //
+ MEDCouplingFieldDouble *f2=f->extractSlice3D(origin1,vec1,1e-10);
+ CPPUNIT_ASSERT(f2->getArray()->isEqual(*arr2,1e-12));
+ CPPUNIT_ASSERT(slice1->isEqual(f2->getMesh(),1e-12));
+ int a,b;
+ double c=f2->getTime(a,b);
+ CPPUNIT_ASSERT_EQUAL(6,a);
+ CPPUNIT_ASSERT_EQUAL(7,b);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5,c,1e-12);
+ //
+ ids->decrRef();
+ slice1->decrRef();
+ arr2->decrRef();
+ arr->decrRef();
+ f2->decrRef();
+ f->decrRef();
+ mesh3D->decrRef();
+ expected1->decrRef();
+}
+
+void MEDCouplingBasicsTest5::testComputeTupleIdsToSelectFromCellIds1()
+{
+ MEDCouplingUMesh *m=build2DTargetMesh_3();
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_NE,NO_TIME);
+ f->setMesh(m);
+ DataArrayDouble *arr=DataArrayDouble::New(); arr->alloc(52,2) ; arr->rearrange(1) ; arr->iota(7.); arr->rearrange(2);
+ f->setArray(arr);
+ //
+ const int subPart1[3]={1,5,9};
+ MEDCouplingFieldDouble *f2=f->buildSubPart(subPart1,subPart1+3);
+ f2->checkCoherency();
+ DataArrayInt *cI=m->computeNbOfNodesPerCell();
+ cI->computeOffsets2();
+ const int sel1[3]={1,5,9};
+ DataArrayInt *sel=DataArrayInt::New(); sel->useArray(sel1,false,CPP_DEALLOC,3,1);
+ DataArrayInt *res=sel->buildExplicitArrByRanges(cI);
+ DataArrayDouble *arr2=arr->selectByTupleIdSafe(res->begin(),res->end());
+ const double expected1[30]={13.,14.,15.,16.,17.,18.,19.,20.,59.,60.,61.,62.,63.,64.,95.,96.,97.,98.,99.,100.,101.,102.,103.,104.,105.,106.,107.,108.,109.,110.};
+ DataArrayDouble *arr3=DataArrayDouble::New(); arr3->useArray(expected1,false,CPP_DEALLOC,15,2);
+ CPPUNIT_ASSERT(arr2->isEqual(*arr3,1e-12));
+ CPPUNIT_ASSERT(arr2->isEqual(*f2->getArray(),1e-12));
+ //
+ cI->decrRef();
+ arr3->decrRef();
+ arr2->decrRef();
+ arr->decrRef();
+ m->decrRef();
+ f->decrRef();
+ f2->decrRef();
+ sel->decrRef();
+ res->decrRef();
+}
CPPUNIT_TEST( testDataArraySort1 );
CPPUNIT_TEST( testPartitionBySpreadZone1 );
CPPUNIT_TEST( testGiveCellsWithType1 );
+ CPPUNIT_TEST( testBuildSlice3D2 );
+ CPPUNIT_TEST( testComputeTupleIdsToSelectFromCellIds1 );
CPPUNIT_TEST_SUITE_END();
public:
void testUMeshTessellate2D1();
void testDataArraySort1();
void testPartitionBySpreadZone1();
void testGiveCellsWithType1();
+ void testBuildSlice3D2();
+ void testComputeTupleIdsToSelectFromCellIds1();
};
}
pass
pass
+ def testBuildSlice3D2(self):
+ mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
+ vec1=[-0.07,1.,0.07]
+ origin1=[1.524,1.4552,1.74768]
+ slice1,ids=mesh3D.buildSlice3D(origin1,vec1,1e-10);
+ f=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME)
+ f.setTime(4.5,6,7) ; f.setMesh(mesh3D)
+ arr=DataArrayDouble(mesh3D.getNumberOfCells(),2)
+ arr.rearrange(1) ; arr.iota(2.) ; arr.rearrange(2)
+ f.setArray(arr)
+ f.checkCoherency()
+ expected1=DataArrayInt([1,3,4,7,9,10,13,15,16])
+ self.assertTrue(expected1.isEqual(ids))
+ arr2=arr[expected1]
+ #
+ f2=f.extractSlice3D(origin1,vec1,1e-10)
+ self.assertTrue(f2.getArray().isEqual(arr2,1e-12));
+ self.assertTrue(slice1.isEqual(f2.getMesh(),1e-12))
+ self.assertEqual(6,f2.getTime()[1]) ; self.assertEqual(7,f2.getTime()[2])
+ self.assertAlmostEqual(4.5,f2.getTime()[0],12);
+ pass
+
+ def testComputeTupleIdsToSelectFromCellIds1(self):
+ m=MEDCouplingDataForTest.build2DTargetMesh_3()
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,NO_TIME);
+ f.setMesh(m);
+ arr=DataArrayDouble(52,2) ; arr.rearrange(1) ; arr.iota(7.) ; arr.rearrange(2)
+ f.setArray(arr)
+ #
+ f2=f.buildSubPart([1,5,9])
+ f2.checkCoherency()
+ cI=m.computeNbOfNodesPerCell()
+ cI.computeOffsets2()
+ sel=DataArrayInt([1,5,9])
+ res=sel.buildExplicitArrByRanges(cI)
+ arr2=arr[res]
+ self.assertTrue(arr2.isEqual(DataArrayDouble([13,14,15,16,17,18,19,20,59,60,61,62,63,64,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110],15,2),1e-12))
+ self.assertTrue(arr2.isEqual(f2.getArray(),1e-12))
+ pass
+
def setUp(self):
pass
pass
%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr;
%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr;
+%newobject ParaMEDMEM::MEDCouplingField::computeTupleIdsToSelectFromCellIds;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::getArray;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::getEndArray;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::magnitude;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxPerTuple;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::keepSelectedComponents;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::extractSlice3D;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::DotFields;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::dot;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::CrossProductFields;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity2;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMesh;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildSpreadZonesWithPoly;
+%newobject ParaMEDMEM::MEDCouplingUMesh::computeNbOfNodesPerCell;
%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes;
%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshesOnSameCoords;
%newobject ParaMEDMEM::MEDCouplingUMesh::ComputeSpreadZoneGradually;
DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
DataArrayInt *computeFetchedNodeIds() const throw(INTERP_KERNEL::Exception);
DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception);
+ DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
return res;
}
+ DataArrayInt *computeTupleIdsToSelectFromCellIds(PyObject *li) const
+ {
+ int sw;
+ int pos1;
+ std::vector<int> pos2;
+ DataArrayInt *pos3=0;
+ DataArrayIntTuple *pos4=0;
+ convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4);
+ switch(sw)
+ {
+ case 1:
+ {
+ return self->computeTupleIdsToSelectFromCellIds(&pos1,&pos1+1);
+ }
+ case 2:
+ {
+ return self->computeTupleIdsToSelectFromCellIds(&pos2[0],&pos2[0]+pos2.size());
+ }
+ case 3:
+ {
+ return self->computeTupleIdsToSelectFromCellIds(pos3->begin(),pos3->end());
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingField::computeTupleIdsToSelectFromCellIds : unexpected input array type recognized !");
+ }
+ }
+
void setGaussLocalizationOnCells(PyObject *li, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
{
self->setSelectedComponents(f,tmp);
}
+ MEDCouplingFieldDouble *extractSlice3D(PyObject *origin, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ double val,val2;
+ DataArrayDouble *a,*a2;
+ DataArrayDoubleTuple *aa,*aa2;
+ std::vector<double> bb,bb2;
+ int sw;
+ int spaceDim=3;
+ const char msg[]="Python wrap of MEDCouplingFieldDouble::extractSlice3D : 1st paramater for origin.";
+ const char msg2[]="Python wrap of MEDCouplingFieldDouble::extractSlice3D : 2nd paramater for vector.";
+ const double *orig=convertObjToPossibleCpp5_Safe(origin,sw,val,a,aa,bb,msg,1,spaceDim,true);
+ const double *vect=convertObjToPossibleCpp5_Safe(vec,sw,val2,a2,aa2,bb2,msg2,1,spaceDim,true);
+ //
+ return self->extractSlice3D(orig,vect,eps);
+ }
+
PyObject *___iadd___(PyObject *trueSelf, const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
{
*self+=other;