_z_array->getPointer(),std::bind2nd(std::plus<double>(),vector[2]));
}
+void MEDCouplingCMesh::scale(const double *point, double factor)
+{
+ //not implemented yet !
+ throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
MEDCouplingMesh *MEDCouplingCMesh::mergeMyselfWith(const MEDCouplingMesh *other) const
{
//not implemented yet !
int getCellContainingPoint(const double *pos, double eps) const;
void rotate(const double *center, const double *vector, double angle);
void translate(const double *vector);
+ void scale(const double *point, double factor);
MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
DataArrayDouble *getCoordinatesAndOwner() const;
DataArrayDouble *getBarycenterAndOwner() const;
_mesh1D->translate(vector);
}
+void MEDCouplingExtrudedMesh::scale(const double *point, double factor)
+{
+ _mesh2D->scale(point,factor);
+ _mesh1D->scale(point,factor);
+}
+
MEDCouplingMesh *MEDCouplingExtrudedMesh::buildPart(const int *start, const int *end) const
{
// not implemented yet !
MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception);
void rotate(const double *center, const double *vector, double angle);
void translate(const double *vector);
+ void scale(const double *point, double factor);
MEDCouplingMesh *buildPart(const int *start, const int *end) const;
MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
}
/*!
- * This method retrieves the weighting field of 'this'. If no '_mesh' is defined an exception will be thrown.
+ * This method retrieves the measure field of 'this'. If no '_mesh' is defined an exception will be thrown.
* Warning the retrieved field life cycle is the responsability of caller.
*/
-MEDCouplingFieldDouble *MEDCouplingField::buildWeightingField(bool isAbs) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingField::buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception)
{
if(_mesh==0)
- throw INTERP_KERNEL::Exception("MEDCouplingField::getWeightingField : no mesh defined !!!");
- return _type->getWeightingField(_mesh,isAbs);
+ throw INTERP_KERNEL::Exception("MEDCouplingField::getMeasureField : no mesh defined !!!");
+ return _type->getMeasureField(_mesh,isAbs);
}
void MEDCouplingField::setMesh(const MEDCouplingMesh *mesh)
/*!
* 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 (nodes, cells ids...) in mesh 'mesh' of entity in returned submesh.
+ * @param di is an array returned that specifies entity ids (nodes, cells ids...) in mesh 'mesh' of entity in returned submesh.
*/
MEDCouplingMesh *MEDCouplingField::buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const
{
void setDescription(const char *desc) { _desc=desc; }
const char *getName() const { return _name.c_str(); }
TypeOfField getTypeOfField() const;
- MEDCouplingFieldDouble *buildWeightingField(bool isAbs) 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;
MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
// Gauss point specific methods
/*!
* Computes normL1 of DataArrayDouble instance arr.
* @param res output parameter expected to be of size arr->getNumberOfComponents();
- * @throw when the field discretization fails on getWeighting fields (gauss points for example)
+ * @throw when the field discretization fails on getMeasure fields (gauss points for example)
*/
void MEDCouplingFieldDiscretization::normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingFieldDouble *vol=getWeightingField(mesh,true);
+ MEDCouplingFieldDouble *vol=getMeasureField(mesh,true);
int nbOfCompo=arr->getNumberOfComponents();
int nbOfElems=getNumberOfTuples(mesh);
std::fill(res,res+nbOfCompo,0.);
/*!
* Computes normL2 of DataArrayDouble instance arr.
* @param res output parameter expected to be of size arr->getNumberOfComponents();
- * @throw when the field discretization fails on getWeighting fields (gauss points for example)
+ * @throw when the field discretization fails on getMeasure fields (gauss points for example)
*/
void MEDCouplingFieldDiscretization::normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingFieldDouble *vol=getWeightingField(mesh,true);
+ MEDCouplingFieldDouble *vol=getMeasureField(mesh,true);
int nbOfCompo=arr->getNumberOfComponents();
int nbOfElems=getNumberOfTuples(mesh);
std::fill(res,res+nbOfCompo,0.);
/*!
* Computes integral of DataArrayDouble instance arr.
* @param res output parameter expected to be of size arr->getNumberOfComponents();
- * @throw when the field discretization fails on getWeighting fields (gauss points for example)
+ * @throw when the field discretization fails on getMeasure fields (gauss points for example)
*/
void MEDCouplingFieldDiscretization::integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingFieldDouble *vol=getWeightingField(mesh,isWAbs);
+ MEDCouplingFieldDouble *vol=getMeasureField(mesh,isWAbs);
int nbOfCompo=arr->getNumberOfComponents();
int nbOfElems=getNumberOfTuples(mesh);
std::fill(res,res+nbOfCompo,0.);
}
}
-MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP0::getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const
+MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP0::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const
{
return mesh->getMeasureField(isAbs);
}
/*!
* 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.
+ * @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'
*/
MEDCouplingMesh *MEDCouplingFieldDiscretizationP0::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
}
}
-MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP1::getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const
+MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP1::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const
{
return mesh->getMeasureFieldOnNode(isAbs);
}
/*!
* 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.
+* @param di is an array returned that specifies entity ids (here nodes ids) in mesh 'mesh' of entity in returned submesh.
* Example : The first node id of returned mesh has the (*di)[0] id in 'mesh'
*/
MEDCouplingMesh *MEDCouplingFieldDiscretizationP1::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
}
}
-MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const
+MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
}
}
-MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGaussNE::getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const
+MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGaussNE::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0;
virtual double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0;
- virtual MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
+ virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
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 MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
DataArrayInt *&cellRest);
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const;
+ MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
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;
DataArrayInt *&cellRest);
void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const;
+ MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const;
+ MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const;
+ MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
}
/*!
- * This method returns the average value in 'this' weighted by ParaMEDMEM::MEDCouplingField::buildWeightingField.
+ * This method returns the average value in 'this' weighted by ParaMEDMEM::MEDCouplingField::buildMeasureField.
* 'This' is expected to be a field with exactly \b one component. If not an exception will be thrown.
* To getAverageValue on vector field applyFunc is needed before. This method looks only \b default array \b and \b only \b default.
* If default array does not exist, an exception will be thrown.
{
if(getArray()==0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !");
- MEDCouplingFieldDouble *w=buildWeightingField(true);
+ MEDCouplingFieldDouble *w=buildMeasureField(true);
double deno=w->getArray()->accumulate(0);
w->getArray()->multiplyEqual(getArray());
double res=w->getArray()->accumulate(0);
}
/*!
- * Given a nodeIds range ['partBg','partEnd'), this method returns the set of cell ids in ascendant order that are \b fully whose connectivity of
- * these cells are fully included in the range. As a consequence the returned set of cell ids does not \b always fit the nodes in ['partBg','partEnd')
+ * Given a nodeIds range ['partBg','partEnd'), this method returns the set of cell ids in ascendant order whose connectivity of
+ * these cells are fully included in the range. As a consequence the returned set of cell ids does \b not \b always fit the nodes in ['partBg','partEnd')
* This method returns the corresponding cells in a newly created array that the caller has the responsability.
*/
DataArrayInt *MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const
virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0;
virtual void rotate(const double *center, const double *vector, double angle) = 0;
virtual void translate(const double *vector) = 0;
+ virtual void scale(const double *point, double factor) = 0;
virtual void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0;
virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const = 0;
virtual MEDCouplingMesh *buildPart(const int *start, const int *end) const = 0;
DataArrayInt *comm,*commI;
findCommonNodes(limitNodeId,precision,comm,commI);
int oldNbOfNodes=getNumberOfNodes();
- DataArrayInt *ret=buildNewNumberingFromCommNodesFrmt(comm,commI,newNbOfNodes);
+ DataArrayInt *ret=buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes);
areNodesMerged=(oldNbOfNodes!=newNbOfNodes);
comm->decrRef();
commI->decrRef();
* @param commI in param in the same format than one returned by findCommonNodes method.
* @return the old to new correspondance array.
*/
-DataArrayInt *MEDCouplingPointSet::buildNewNumberingFromCommNodesFrmt(const DataArrayInt *comm, const DataArrayInt *commIndex,
- int& newNbOfNodes) const
+DataArrayInt *MEDCouplingPointSet::buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex,
+ int& newNbOfNodes) const
{
DataArrayInt *ret=DataArrayInt::New();
int nbNodesOld=getNumberOfNodes();
/*!
* This method implements pure virtual method MEDCouplingMesh::buildPartAndReduceNodes.
* This method build a part of 'this' by simply keeping cells whose ids are in ['start','end') \b and potentially reduces the nodes set
- * behind returned mesh. This cause an overhead but it is more little in memory.
+ * behind returned mesh. This cause an overhead but it is lesser in memory.
* This method returns an array too. This array allows to the caller to know the mapping between nodeids in 'this' and nodeids in
* returned mesh. This is quite usefull for MEDCouplingFieldDouble on nodes for example...
* The returned mesh has to be managed by the caller.
virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
DataArrayInt *buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const;
void findCommonNodes(int limitNodeId, double prec, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
- DataArrayInt *buildNewNumberingFromCommNodesFrmt(const DataArrayInt *comm, const DataArrayInt *commIndex,
- int& newNbOfNodes) const;
+ DataArrayInt *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex,
+ int& newNbOfNodes) const;
void getBoundingBox(double *bbox) const;
void zipCoords();
double getCaracteristicDimension() const;
}
case Integral:
{
- MEDCouplingFieldDouble *deno=srcField->getDiscretization()->getWeightingField(srcField->getMesh(),true);
- MEDCouplingFieldDouble *denoR=trgField->getDiscretization()->getWeightingField(trgField->getMesh(),true);
+ MEDCouplingFieldDouble *deno=srcField->getDiscretization()->getMeasureField(srcField->getMesh(),true);
+ MEDCouplingFieldDouble *denoR=trgField->getDiscretization()->getMeasureField(trgField->getMesh(),true);
const double *denoPtr=deno->getArray()->getConstPointer();
const double *denoRPtr=denoR->getArray()->getConstPointer();
if(trgField->getMesh()->getMeshDimension()==-1)
}
case RevIntegral:
{
- MEDCouplingFieldDouble *deno=trgField->getDiscretization()->getWeightingField(trgField->getMesh(),true);
- MEDCouplingFieldDouble *denoR=srcField->getDiscretization()->getWeightingField(srcField->getMesh(),true);
+ MEDCouplingFieldDouble *deno=trgField->getDiscretization()->getMeasureField(trgField->getMesh(),true);
+ MEDCouplingFieldDouble *denoR=srcField->getDiscretization()->getMeasureField(srcField->getMesh(),true);
const double *denoPtr=deno->getArray()->getConstPointer();
const double *denoRPtr=denoR->getArray()->getConstPointer();
if(trgField->getMesh()->getMeshDimension()==-1)
#include "PointLocatorAlgos.txx"
#include "BBTree.txx"
#include "DirectedBoundingBox.hxx"
+#include "InterpKernelMeshQuality.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
#include <sstream>
{
}
+/*!
+ * This method checks that this is correctly designed. For example le coordinates are set, nodal connectivity.
+ * When this method returns without throwing any exception, 'this' is expected to be writable, exchangeable and to be
+ * available for most of algorithm. When a mesh has been constructed from scratch it is a good habits to call this method to check
+ * that all is in order in 'this'.
+ */
void MEDCouplingUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
{
if(_mesh_dim<-1)
}
/*!
- * build a sub part of 'this'. This sub part is defined by the cell ids contained in the array in [start,end).
- * @param start start of array containing the cell ids to keep.
+ * build a sub part of 'this'. This sub part is defined by the cell ids contained in the array in [begin,end).
+ * @param begin begin of array containing the cell ids to keep.
* @param end end of array of cell ids to keep. \b WARNING end param is \b not included ! Idem STL standard definitions.
* @param keepCoords that specifies if you want or not to keep coords as this or zip it (see zipCoords)
*/
-MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const
+MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const
{
if(getMeshDimension()!=-1)
{
- MEDCouplingUMesh *ret=buildPartOfMySelfKeepCoords(start,end);
+ MEDCouplingUMesh *ret=buildPartOfMySelfKeepCoords(begin,end);
if(!keepCoords)
ret->zipCoords();
return ret;
}
else
{
- if(end-start!=1)
+ if(end-begin!=1)
throw INTERP_KERNEL::Exception("-1D mesh has only one cell !");
- if(start[0]!=0)
+ if(begin[0]!=0)
throw INTERP_KERNEL::Exception("-1D mesh has only one cell : 0 !");
incrRef();
return (MEDCouplingUMesh *)this;
}
}
+DataArrayInt *MEDCouplingUMesh::getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const
+{
+ std::vector<int> cellIdsKept;
+ fillCellIdsToKeepFromNodeIds(partBg,partEnd,true,cellIdsKept);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(cellIdsKept.size(),1);
+ std::copy(cellIdsKept.begin(),cellIdsKept.end(),ret->getPointer());
+ return ret;
+}
+
/*!
- * Keeps from 'this' only cells which constituing point id are in the ids specified by ['start','end').
- * The return newly allocated mesh will share the same coordinates as 'this'.
+ * Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end').
+ * The resulting cell ids are stored at the end of the 'cellIdsKept' parameter.
* Parameter 'fullyIn' specifies if a cell that has part of its nodes in ids array is kept or not.
- * If 'fullyIn' is true only cells whose ids are \b fully contained in ['start','end') tab will be kept.
+ * If 'fullyIn' is true only cells whose ids are \b fully contained in ['begin','end') tab will be kept.
+ *
+ * @param begin input start of array of node ids.
+ * @param end input end of array of node ids.
+ * @param fullyIn input that specifies if all node ids must be in ['begin','end') array to consider cell to be in.
+ * @param cellIdsKept in/out array where all candidate cell ids are put at the end.
*/
-MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const
+void MEDCouplingUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, std::vector<int>& cellIdsKept) const
{
- std::set<int> fastFinder(start,end);
+ std::set<int> fastFinder(begin,end);
+ int nbOfCells=getNumberOfCells();
const int *conn=getNodalConnectivity()->getConstPointer();
const int *connIndex=getNodalConnectivityIndex()->getConstPointer();
- int nbOfCells=getNumberOfCells();
- std::vector<int> cellIdsKept;
for(int i=0;i<nbOfCells;i++)
{
std::set<int> connOfCell(conn+connIndex[i]+1,conn+connIndex[i+1]);
if(((int)locMerge.size()==refLgth && fullyIn) || (locMerge.size()!=0 && !fullyIn))
cellIdsKept.push_back(i);
}
+}
+
+/*!
+ * 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'.
+ * Parameter 'fullyIn' specifies if a cell that has part of its nodes in ids array is kept or not.
+ * If 'fullyIn' is true only cells whose ids are \b fully contained in ['begin','end') tab will be kept.
+ */
+MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const
+{
+ std::vector<int> cellIdsKept;
+ fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept);
return buildPartOfMySelf(&cellIdsKept[0],&cellIdsKept[0]+cellIdsKept.size(),true);
}
/*!
- * Contrary to MEDCouplingUMesh::buildPartOfMySelfNode method this method a mesh with a meshDimension equal to
+ * Contrary to MEDCouplingUMesh::buildPartOfMySelfNode method this method builds a mesh with a meshDimension equal to
* this->getMeshDimension()-1. The return newly allocated mesh will share the same coordinates as 'this'.
* Parameter 'fullyIn' specifies if a face that has part of its nodes in ids array is kept or not.
- * If 'fullyIn' is true only faces whose ids are \b fully contained in ['start','end') tab will be kept.
+ * If 'fullyIn' is true only faces whose ids are \b fully contained in ['begin','end') tab will be kept.
*/
-MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const
+MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const
{
DataArrayInt *desc,*descIndx,*revDesc,*revDescIndx;
desc=DataArrayInt::New(); descIndx=DataArrayInt::New(); revDesc=DataArrayInt::New(); revDescIndx=DataArrayInt::New();
MEDCouplingUMesh *subMesh=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
desc->decrRef(); descIndx->decrRef(); revDesc->decrRef(); revDescIndx->decrRef();
- MEDCouplingUMesh *ret=(MEDCouplingUMesh *)subMesh->buildPartOfMySelfNode(start,end,fullyIn);
+ MEDCouplingUMesh *ret=(MEDCouplingUMesh *)subMesh->buildPartOfMySelfNode(begin,end,fullyIn);
subMesh->decrRef();
return ret;
}
/*!
* This is the low algorithm of buildPartOfMySelf.
- * Keeps from 'this' only cells which constituing point id are in the ids specified by ['start','end').
+ * 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'.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *start, const int *end) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const
{
checkFullyDefined();
MEDCouplingUMesh *ret=MEDCouplingUMesh::New();
ret->setName(getName());
ret->_mesh_dim=_mesh_dim;
ret->setCoords(_coords);
- int nbOfElemsRet=end-start;
+ int nbOfElemsRet=end-begin;
int *connIndexRet=new int[nbOfElemsRet+1];
connIndexRet[0]=0;
const int *conn=_nodal_connec->getConstPointer();
const int *connIndex=_nodal_connec_index->getConstPointer();
int newNbring=0;
- for(const int *work=start;work!=end;work++,newNbring++)
+ for(const int *work=begin;work!=end;work++,newNbring++)
connIndexRet[newNbring+1]=connIndexRet[newNbring]+connIndex[*work+1]-connIndex[*work];
int *connRet=new int[connIndexRet[nbOfElemsRet]];
int *connRetWork=connRet;
std::set<INTERP_KERNEL::NormalizedCellType> types;
- for(const int *work=start;work!=end;work++)
+ for(const int *work=begin;work!=end;work++)
{
types.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*work]]);
connRetWork=std::copy(conn+connIndex[*work],conn+connIndex[*work+1],connRetWork);
}
/*!
- * This methods returns a vector newly created field on cells that represents the director vector of each 1D cell of this.
+ * This methods returns a vector newly created field on cells that represents the direction vector of each 1D cell of this.
* This method is only callable on mesh with meshdim == 1 containing only SEG2.
*/
-MEDCouplingFieldDouble *MEDCouplingUMesh::buildLinearField() const
+MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const
{
if(getMeshDimension()!=1)
- throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 1 for buildLinearField !");
+ throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 1 for buildDirectionVectorField !");
if(_types.size()!=1 || *(_types.begin())!=INTERP_KERNEL::NORM_SEG2)
- throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for buildLinearField !");
+ throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for buildDirectionVectorField !");
MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
DataArrayDouble *array=DataArrayDouble::New();
int nbOfCells=getNumberOfCells();
throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for project1D !");
if(getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("Expected a umesh with spaceDim==3 for project1D !");
- MEDCouplingFieldDouble *f=buildLinearField();
+ MEDCouplingFieldDouble *f=buildDirectionVectorField();
const double *fPtr=f->getArray()->getConstPointer();
double tmp[3];
for(int i=0;i<getNumberOfCells();i++)
/*!
* This method is only available for a mesh with meshDim==2 and spaceDim==2||spaceDim==3.
* This method returns a vector 'cells' where all detected butterfly cells have been added to cells.
+ * A 2D cell is considered to be butterfly if it exists at least one pair of distinct edges of it that intersect each other
+ * anywhere excepted their extremities. An INTERP_KERNEL::NORM_NORI3 could \b not be butterfly.
*/
void MEDCouplingUMesh::checkButterflyCells(std::vector<int>& cells) const
{
* @param vec output of size at least 3 used to store the normal vector (with norm equal to Area ) of searched plane.
* @param pos output of size at least 3 used to store a point owned of searched plane.
*/
-void MEDCouplingUMesh::getFastMiddlePlaneOfThis(double *vec, double *pos) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::getFastAveragePlaneOfThis(double *vec, double *pos) const throw(INTERP_KERNEL::Exception)
{
if(getMeshDimension()!=2 || getSpaceDimension()!=3)
- throw INTERP_KERNEL::Exception("Invalid mesh to apply getFastMiddlePlaneOfThis on it : must be meshDim==2 and spaceDim==3 !");
+ throw INTERP_KERNEL::Exception("Invalid mesh to apply getFastAveragePlaneOfThis on it : must be meshDim==2 and spaceDim==3 !");
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
const double *coordsPtr=_coords->getConstPointer();
std::copy(coordsPtr+3*conn[1],coordsPtr+3*conn[1]+3,pos);
}
+/*!
+ * The returned newly created field has to be managed by the caller.
+ * This method returns a field on cell with no time lying on 'this'. The meshdimension and spacedimension of this are expected to be both in [2,3]. If not an exception will be thrown.
+ * This method for the moment only deals with NORM_TRI3, NORM_QUAD4 and NORM_TETRA4 geometric types.
+ * If a cell has an another type an exception will be thrown.
+ */
+MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ int spaceDim=getSpaceDimension();
+ int meshDim=getMeshDimension();
+ if(spaceDim!=2 && spaceDim!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getEdgeRatioField : SpaceDimension must be equal to 2 or 3 !");
+ if(meshDim!=2 && meshDim!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getEdgeRatioField : MeshDimension must be equal to 2 or 3 !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ ret->setMesh(this);
+ int nbOfCells=getNumberOfCells();
+ DataArrayDouble *arr=DataArrayDouble::New();
+ arr->alloc(nbOfCells,1);
+ double *pt=arr->getPointer();
+ ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
+ arr->decrRef();
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ const double *coo=_coords->getConstPointer();
+ double tmp[12];
+ for(int i=0;i<nbOfCells;i++,pt++)
+ {
+ INTERP_KERNEL::NormalizedCellType t=(INTERP_KERNEL::NormalizedCellType)*conn;
+ switch(t)
+ {
+ case INTERP_KERNEL::NORM_TRI3:
+ {
+ fillInCompact3DMode(spaceDim,3,conn+1,coo,tmp);
+ *pt=INTERP_KERNEL::triEdgeRatio(tmp);
+ break;
+ }
+ case INTERP_KERNEL::NORM_QUAD4:
+ {
+ fillInCompact3DMode(spaceDim,4,conn+1,coo,tmp);
+ *pt=INTERP_KERNEL::quadEdgeRatio(tmp);
+ break;
+ }
+ case INTERP_KERNEL::NORM_TETRA4:
+ {
+ fillInCompact3DMode(spaceDim,4,conn+1,coo,tmp);
+ *pt=INTERP_KERNEL::tetraEdgeRatio(tmp);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getEdgeRatioField : A cell with not manged type (NORM_TRI3, NORM_QUAD4 and NORM_TETRA4) has been detected !");
+ }
+ conn+=connI[i+1]-connI[i];
+ }
+ ret->setName("EdgeRatio");
+ ret->incrRef();
+ return ret;
+}
+
+/*!
+ * The returned newly created field has to be managed by the caller.
+ * This method returns a field on cell with no time lying on 'this'. The meshdimension and spacedimension of this are expected to be both in [2,3]. If not an exception will be thrown.
+ * This method for the moment only deals with NORM_TRI3, NORM_QUAD4 and NORM_TETRA4 geometric types.
+ * If a cell has an another type an exception will be thrown.
+ */
+MEDCouplingFieldDouble *MEDCouplingUMesh::getAspectRatioField() const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ int spaceDim=getSpaceDimension();
+ int meshDim=getMeshDimension();
+ if(spaceDim!=2 && spaceDim!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAspectRatioField : SpaceDimension must be equal to 2 or 3 !");
+ if(meshDim!=2 && meshDim!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAspectRatioField : MeshDimension must be equal to 2 or 3 !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ ret->setMesh(this);
+ int nbOfCells=getNumberOfCells();
+ DataArrayDouble *arr=DataArrayDouble::New();
+ arr->alloc(nbOfCells,1);
+ double *pt=arr->getPointer();
+ ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
+ arr->decrRef();
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ const double *coo=_coords->getConstPointer();
+ double tmp[12];
+ for(int i=0;i<nbOfCells;i++,pt++)
+ {
+ INTERP_KERNEL::NormalizedCellType t=(INTERP_KERNEL::NormalizedCellType)*conn;
+ switch(t)
+ {
+ case INTERP_KERNEL::NORM_TRI3:
+ {
+ fillInCompact3DMode(spaceDim,3,conn+1,coo,tmp);
+ *pt=INTERP_KERNEL::triAspectRatio(tmp);
+ break;
+ }
+ case INTERP_KERNEL::NORM_QUAD4:
+ {
+ fillInCompact3DMode(spaceDim,4,conn+1,coo,tmp);
+ *pt=INTERP_KERNEL::quadAspectRatio(tmp);
+ break;
+ }
+ case INTERP_KERNEL::NORM_TETRA4:
+ {
+ fillInCompact3DMode(spaceDim,4,conn+1,coo,tmp);
+ *pt=INTERP_KERNEL::tetraAspectRatio(tmp);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAspectRatioField : A cell with not manged type (NORM_TRI3, NORM_QUAD4 and NORM_TETRA4) has been detected !");
+ }
+ conn+=connI[i+1]-connI[i];
+ }
+ ret->setName("AspectRatio");
+ ret->incrRef();
+ return ret;
+}
+
+/*!
+ * The returned newly created field has to be managed by the caller.
+ * This method returns a field on cell with no time lying on 'this'. The meshdimension must be equal to 2 and the spacedimension must be equal to 3. If not an exception will be thrown.
+ * This method for the moment only deals with NORM_QUAD4 geometric type.
+ * If a cell has an another type an exception will be thrown.
+ */
+MEDCouplingFieldDouble *MEDCouplingUMesh::getWarpField() const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ int spaceDim=getSpaceDimension();
+ int meshDim=getMeshDimension();
+ if(spaceDim!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getWarpField : SpaceDimension must be equal to 3 !");
+ if(meshDim!=2)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getWarpField : MeshDimension must be equal to 2 !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ ret->setMesh(this);
+ int nbOfCells=getNumberOfCells();
+ DataArrayDouble *arr=DataArrayDouble::New();
+ arr->alloc(nbOfCells,1);
+ double *pt=arr->getPointer();
+ ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
+ arr->decrRef();
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ const double *coo=_coords->getConstPointer();
+ double tmp[12];
+ for(int i=0;i<nbOfCells;i++,pt++)
+ {
+ INTERP_KERNEL::NormalizedCellType t=(INTERP_KERNEL::NormalizedCellType)*conn;
+ switch(t)
+ {
+ case INTERP_KERNEL::NORM_QUAD4:
+ {
+ fillInCompact3DMode(3,4,conn+1,coo,tmp);
+ *pt=INTERP_KERNEL::quadWarp(tmp);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getWarpField : A cell with not manged type (NORM_QUAD4) has been detected !");
+ }
+ conn+=connI[i+1]-connI[i];
+ }
+ ret->setName("Warp");
+ ret->incrRef();
+ return ret;
+}
+
+/*!
+ * The returned newly created field has to be managed by the caller.
+ * This method returns a field on cell with no time lying on 'this'. The meshdimension must be equal to 2 and the spacedimension must be equal to 3. If not an exception will be thrown.
+ * This method for the moment only deals with NORM_QUAD4 geometric type.
+ * If a cell has an another type an exception will be thrown.
+ */
+MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ int spaceDim=getSpaceDimension();
+ int meshDim=getMeshDimension();
+ if(spaceDim!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getSkewField : SpaceDimension must be equal to 3 !");
+ if(meshDim!=2)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getSkewField : MeshDimension must be equal to 2 !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ ret->setMesh(this);
+ int nbOfCells=getNumberOfCells();
+ DataArrayDouble *arr=DataArrayDouble::New();
+ arr->alloc(nbOfCells,1);
+ double *pt=arr->getPointer();
+ ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef.
+ arr->decrRef();
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ const double *coo=_coords->getConstPointer();
+ double tmp[12];
+ for(int i=0;i<nbOfCells;i++,pt++)
+ {
+ INTERP_KERNEL::NormalizedCellType t=(INTERP_KERNEL::NormalizedCellType)*conn;
+ switch(t)
+ {
+ case INTERP_KERNEL::NORM_QUAD4:
+ {
+ fillInCompact3DMode(3,4,conn+1,coo,tmp);
+ *pt=INTERP_KERNEL::quadSkew(tmp);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getSkewField : A cell with not manged type (NORM_QUAD4) has been detected !");
+ }
+ conn+=connI[i+1]-connI[i];
+ }
+ ret->setName("Skew");
+ ret->incrRef();
+ return ret;
+}
+
/*!
* This method aggregate the bbox of each cell and put it into bbox parameter.
* @param bbox out parameter of size 2*spacedim*nbOfcells.
* The mesh after this call will pass the test of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder with the same inputs.
* The returned array minimizes the permutations that is to say the order of cells inside same geometric type remains the same.
*/
-DataArrayInt *MEDCouplingUMesh::getRenumArrForConsctvCellTypesSpe(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const
+DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const
{
checkFullyDefined();
int nbOfCells=getNumberOfCells();
for(const int *i=connI;i!=connI+nbOfCells;)
{
INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
- int startCellId=std::distance(connI,i);
+ int beginCellId=std::distance(connI,i);
i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType));
int endCellId=std::distance(connI,i);
- int sz=endCellId-startCellId;
+ int sz=endCellId-beginCellId;
int *cells=new int[sz];
for(int j=0;j<sz;j++)
- cells[j]=startCellId+j;
+ cells[j]=beginCellId+j;
MEDCouplingUMesh *m=(MEDCouplingUMesh *)buildPartOfMySelf(cells,cells+sz,true);
delete [] cells;
ret.push_back(m);
}
}
}
+
+/*!
+ * This method put in zip format into parameter 'zipFrmt' in full interlace mode.
+ * This format is often asked by INTERP_KERNEL algorithms to avoid many indirections into coordinates array.
+ */
+void MEDCouplingUMesh::fillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt) throw(INTERP_KERNEL::Exception)
+{
+ double *w=zipFrmt;
+ if(spaceDim==3)
+ for(int i=0;i<nbOfNodesInCell;i++)
+ w=std::copy(coo+3*conn[i],coo+3*conn[i]+3,w);
+ else if(spaceDim==2)
+ {
+ for(int i=0;i<nbOfNodesInCell;i++)
+ {
+ w=std::copy(coo+2*conn[i],coo+2*conn[i]+2,w);
+ *w++=0.;
+ }
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillInCompact3DMode : Invalid spaceDim specified : must be 2 or 3 !");
+}
MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
+ MEDCOUPLING_EXPORT DataArrayInt *getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const;
MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const;
MEDCOUPLING_EXPORT std::string simpleRepr() const;
MEDCOUPLING_EXPORT std::string advancedRepr() const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const;
MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes);
MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
- MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
- MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
+ 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 MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const;
MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector<int>& nodes) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
- MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildLinearField() const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildDirectionVectorField() const;
MEDCOUPLING_EXPORT void project1D(const double *pt, const double *v, double eps, double *res) const;
MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
MEDCOUPLING_EXPORT void orientCorrectly2DCells(const double *vec, bool polyOnly) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void arePolyhedronsNotCorrectlyOriented(std::vector<int>& cells) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void getFastMiddlePlaneOfThis(double *vec, double *pos) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void getFastAveragePlaneOfThis(double *vec, double *pos) const throw(INTERP_KERNEL::Exception);
+ //Mesh quality
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
//utilities for MED File RW
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypes() const;
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
- MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsctvCellTypesSpe(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
+ MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
MEDCOUPLING_EXPORT DataArrayInt *rearrange2ConsecutiveCellTypes();
MEDCOUPLING_EXPORT std::vector<MEDCouplingUMesh *> splitByType() const;
MEDCOUPLING_EXPORT DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
void reprConnectivityOfThisLL(std::ostringstream& stream) const;
//tools
void renumberNodesInConn(const int *newNodeNumbers);
+ void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, std::vector<int>& cellIdsKept) const;
MEDCouplingUMesh *buildExtrudedMeshFromThisLowLev(int nbOfNodesOf1Lev, bool isQuad) const;
DataArrayDouble *fillExtCoordsUsingTranslation(const MEDCouplingUMesh *mesh1D, bool isQuad) const;
template<int SPACEDIM>
void findCommonCellsBase(int compType, std::vector<int>& res, std::vector<int>& resI) const;
bool areCellsEqualInPool(const std::vector<int>& candidates, int compType, std::vector<int>& result) const;
- MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const int *start, const int *end) const;
+ MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const int *begin, const int *end) const;
template<int SPACEDIM>
void getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints,
double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
+ static void fillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt) throw(INTERP_KERNEL::Exception);
static void appendExtrudedCell(const int *connBg, const int *connEnd, int nbOfNodesPerLev, bool isQuad, std::vector<int>& ret);
private:
//! this iterator stores current position in _nodal_connec array.
CPPUNIT_TEST( testSortPerTuple1 );
CPPUNIT_TEST( testIsEqualWithoutConsideringStr1 );
CPPUNIT_TEST( testGetNodeIdsOfCell1 );
+ CPPUNIT_TEST( testGetEdgeRatioField1 );
//MEDCouplingBasicsTestInterp.cxx
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
void testSortPerTuple1();
void testIsEqualWithoutConsideringStr1();
void testGetNodeIdsOfCell1();
+ void testGetEdgeRatioField1();
//MEDCouplingBasicsTestInterp.cxx
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
CPPUNIT_ASSERT_EQUAL(1,commI->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(0,comm->getNumberOfTuples());
int newNbOfNodes;
- DataArrayInt *o2n=targetMesh->buildNewNumberingFromCommNodesFrmt(comm,commI,newNbOfNodes);
+ DataArrayInt *o2n=targetMesh->buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes);
CPPUNIT_ASSERT_EQUAL(27,newNbOfNodes);
CPPUNIT_ASSERT_EQUAL(27,o2n->getNumberOfTuples());
const int o2nExp1[27]=
const int commIExpected[3]={0,4,6};
CPPUNIT_ASSERT(std::equal(commExpected,commExpected+6,comm->getConstPointer()));
CPPUNIT_ASSERT(std::equal(commIExpected,commIExpected+3,commI->getConstPointer()));
- o2n=targetMesh->buildNewNumberingFromCommNodesFrmt(comm,commI,newNbOfNodes);
+ o2n=targetMesh->buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes);
CPPUNIT_ASSERT_EQUAL(31,o2n->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(27,newNbOfNodes);
const int o2nExp2[31]=
CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypes());
CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypesAndOrder(order1,order1+2));
CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypesAndOrder(order2,order2+2));
- DataArrayInt *da=targetMesh->getRenumArrForConsctvCellTypesSpe(order1,order1+2);
+ DataArrayInt *da=targetMesh->getRenumArrForConsecutiveCellTypesSpec(order1,order1+2);
CPPUNIT_ASSERT_EQUAL(5,da->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
const int expected1[5]={2,0,1,3,4};
CPPUNIT_ASSERT(std::equal(expected1,expected1+5,da->getConstPointer()));
da->decrRef();
- da=targetMesh->getRenumArrForConsctvCellTypesSpe(order2,order2+2);
+ da=targetMesh->getRenumArrForConsecutiveCellTypesSpec(order2,order2+2);
CPPUNIT_ASSERT_EQUAL(5,da->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
const int expected2[5]={0,3,4,1,2};
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[0],f1->normL2(0),1e-9);
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[1],f1->normL2(1),1e-9);
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[2],f1->normL2(2),1e-9);
- //buildWeightingField
- MEDCouplingFieldDouble *f4=f1->buildWeightingField(false);
+ //buildMeasureField
+ MEDCouplingFieldDouble *f4=f1->buildMeasureField(false);
CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.2,f4->accumulate(0),1e-12);
f4->decrRef();
- f4=f1->buildWeightingField(true);
+ f4=f1->buildMeasureField(true);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.62,f4->accumulate(0),1e-12);
f4->decrRef();
//
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.2,coords[1],1e-13);
mesh1->decrRef();
}
+
+void MEDCouplingBasicsTest::testGetEdgeRatioField1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ MEDCouplingFieldDouble *f1=m1->getEdgeRatioField();
+ CPPUNIT_ASSERT_EQUAL(m1->getNumberOfCells(),f1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
+ const double expected1[5]={1.,1.4142135623730951, 1.4142135623730951,1.,1.};
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(i,0),1e-14);
+ f1->decrRef();
+ m1->decrRef();
+ //
+ m1=build3DSurfTargetMesh_1();
+ f1=m1->getEdgeRatioField();
+ CPPUNIT_ASSERT_EQUAL(m1->getNumberOfCells(),f1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
+ const double expected2[5]={1.4142135623730951, 1.7320508075688772, 1.7320508075688772, 1.4142135623730951, 1.4142135623730951};
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f1->getIJ(i,0),1e-14);
+ f1->decrRef();
+ m1->decrRef();
+}
comm,commI=targetMesh.findCommonNodes(-1,1e-10);
self.assertEqual(1,commI.getNumberOfTuples());
self.assertEqual(0,comm.getNumberOfTuples());
- o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommNodesFrmt(comm,commI);
+ o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI);
self.assertEqual(27,newNbOfNodes);
self.assertEqual(27,o2n.getNumberOfTuples());
o2nExp1=range(27)
commIExpected=[0,4,6]
self.assertEqual(commExpected,list(comm.getValues()));
self.assertEqual(commIExpected,list(commI.getValues()));
- o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommNodesFrmt(comm,commI);
+ o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI);
self.assertEqual(31,o2n.getNumberOfTuples());
self.assertEqual(27,newNbOfNodes);
o2nExp2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
self.assertTrue(not targetMesh.checkConsecutiveCellTypes());
self.assertTrue(not targetMesh.checkConsecutiveCellTypesAndOrder(order1));
self.assertTrue(not targetMesh.checkConsecutiveCellTypesAndOrder(order2));
- da=targetMesh.getRenumArrForConsctvCellTypesSpe(order1);
+ da=targetMesh.getRenumArrForConsecutiveCellTypesSpec(order1);
self.assertEqual(5,da.getNumberOfTuples());
self.assertEqual(1,da.getNumberOfComponents());
expected1=[2,0,1,3,4]
self.assertTrue(expected1==list(da.getValues()));
- da=targetMesh.getRenumArrForConsctvCellTypesSpe(order2);
+ da=targetMesh.getRenumArrForConsecutiveCellTypesSpec(order2);
self.assertEqual(5,da.getNumberOfTuples());
self.assertEqual(1,da.getNumberOfComponents());
expected2=[0,3,4,1,2]
self.assertTrue(abs(expected7[0]-f1.normL2(0))<1e-9);
self.assertTrue(abs(expected7[1]-f1.normL2(1))<1e-9);
self.assertTrue(abs(expected7[2]-f1.normL2(2))<1e-9);
- #buildWeightingField
- f4=f1.buildWeightingField(False);
+ #buildMeasureField
+ f4=f1.buildMeasureField(False);
self.assertTrue(abs(-0.2-f4.accumulate(0))<1e-12);
- f4=f1.buildWeightingField(True);
+ f4=f1.buildMeasureField(True);
self.assertTrue(abs(1.62-f4.accumulate(0))<1e-12);
# Testing with 2D Curve
m1=MEDCouplingDataForTest.build2DCurveTargetMesh_3();
li2=mesh1.getNodalConnectivityIndex().getValuesAsTuple()
self.assertEqual(6,len(li2))
pass
+
+ def testGetEdgeRatioField1(self):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ f1=m1.getEdgeRatioField();
+ self.assertEqual(m1.getNumberOfCells(),f1.getNumberOfTuples());
+ self.assertEqual(5,f1.getNumberOfTuples());
+ self.assertEqual(1,f1.getNumberOfComponents());
+ expected1=[1.,1.4142135623730951, 1.4142135623730951,1.,1.]
+ for i in xrange(5):
+ self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),14);
+ pass
+ #
+ m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ f1=m1.getEdgeRatioField();
+ self.assertEqual(m1.getNumberOfCells(),f1.getNumberOfTuples());
+ self.assertEqual(5,f1.getNumberOfTuples());
+ self.assertEqual(1,f1.getNumberOfComponents());
+ expected2=[1.4142135623730951, 1.7320508075688772, 1.7320508075688772, 1.4142135623730951, 1.4142135623730951]
+ for i in xrange(5):
+ self.assertAlmostEqual(expected2[i],f1.getIJ(i,0),14);
+ pass
+ pass
def setUp(self):
pass
%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
%newobject ParaMEDMEM::MEDCouplingUMesh::New;
-%newobject ParaMEDMEM::MEDCouplingField::buildWeightingField;
+%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::mergeFields;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::doublyContractedProduct;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsctvCellTypesSpe;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField;
%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New;
%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh;
%newobject ParaMEDMEM::MEDCouplingCMesh::New;
self->getCoordinatesOfNode(nodeId,coo);
return convertDblArrToPyList2(coo);
}
+
+ void scale(PyObject *point, double factor)
+ {
+ int sz;
+ double *p=convertPyToNewDblArr2(point,&sz);
+ self->scale(p,factor);
+ delete [] p;
+ }
}
};
}
void zipCoords();
double getCaracteristicDimension() const;
void translate(const double *vector);
- void scale(const double *point, double factor);
void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception);
void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
return self->simpleRepr();
}
- PyObject *buildNewNumberingFromCommNodesFrmt(const DataArrayInt *comm, const DataArrayInt *commIndex) const
+ PyObject *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex) const
{
int newNbOfNodes;
- DataArrayInt *ret0=self->buildNewNumberingFromCommNodesFrmt(comm,commIndex,newNbOfNodes);
+ DataArrayInt *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes);
PyObject *res = PyList_New(2);
PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes));
self->translate(v);
delete [] v;
}
- void scale(PyObject *point, double factor)
- {
- int sz;
- double *p=convertPyToNewDblArr2(point,&sz);
- self->scale(p,factor);
- delete [] p;
- }
void renumberNodes(PyObject *li, int newNbOfNodes)
{
int size;
MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const;
void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
bool isPresenceOfQuadratic() const;
+ MEDCouplingFieldDouble *buildDirectionVectorField() const;
void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
%extend {
std::string __str__() const
{
return ret;
}
- DataArrayInt *getRenumArrForConsctvCellTypesSpe(PyObject *li) const
+ DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(PyObject *li) const
{
int sz;
INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
- DataArrayInt *ret=self->getRenumArrForConsctvCellTypesSpe(order,order+sz);
+ DataArrayInt *ret=self->getRenumArrForConsecutiveCellTypesSpec(order,order+sz);
delete [] order;
return ret;
}
self->arePolyhedronsNotCorrectlyOriented(cells);
return convertIntArrToPyList2(cells);
}
+
+ PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception)
+ {
+ double vec[3];
+ double pos[3];
+ self->getFastAveragePlaneOfThis(vec,pos);
+ double vals[6];
+ std::copy(vec,vec+3,vals);
+ std::copy(pos,pos+3,vals+3);
+ return convertDblArrToPyListOfTuple(vals,3,2);
+ }
}
void convertToPolyTypes(const std::vector<int>& cellIdsToConvert);
MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
void setDescription(const char *desc);
const char *getName() const;
TypeOfField getTypeOfField() const;
- MEDCouplingFieldDouble *buildWeightingField(bool isAbs) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDiscretization *getDiscretization() const;
void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);