From aaf8863cc6c7eac8a1cb1131e6654796c79ebd6c Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 11 Mar 2010 16:24:19 +0000 Subject: [PATCH] Some docs. --- src/MEDCoupling/MEDCouplingExtrudedMesh.cxx | 15 ++- src/MEDCoupling/MEDCouplingExtrudedMesh.hxx | 8 +- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 51 +++++++- src/MEDCoupling/MEDCouplingMesh.cxx | 25 ++++ src/MEDCoupling/MEDCouplingPointSet.cxx | 97 ++++++++++++++- src/MEDCoupling/MEDCouplingPointSet.hxx | 3 +- .../MEDCouplingTimeDiscretization.cxx | 6 + .../MEDCouplingTimeDiscretization.hxx | 4 +- src/MEDCoupling/MEDCouplingUMesh.cxx | 111 +++++++++++++++++- 9 files changed, 299 insertions(+), 21 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index d0162ffd1..779bd46fe 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -31,7 +31,14 @@ using namespace ParaMEDMEM; -MEDCouplingExtrudedMesh *MEDCouplingExtrudedMesh::New(MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception) +/*! + * Build an extruded mesh instance from 3D and 2D unstructured mesh lying on the \b same \b coords. + * @param mesh3D 3D unstructured mesh. + * @param mesh2D 2D unstructured mesh lying on the same coordinates than mesh3D. \b Warning mesh2D is \b not \b const + * because the mesh is aggregated and potentially modified by rotate or translate method. + * @param cell2DId Id of cell in mesh2D mesh where the computation of 1D mesh will be done. + */ +MEDCouplingExtrudedMesh *MEDCouplingExtrudedMesh::New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception) { return new MEDCouplingExtrudedMesh(mesh3D,mesh2D,cell2DId); } @@ -41,7 +48,7 @@ MEDCouplingMeshType MEDCouplingExtrudedMesh::getType() const return EXTRUDED; } -MEDCouplingExtrudedMesh::MEDCouplingExtrudedMesh(MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception) +MEDCouplingExtrudedMesh::MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception) try:_mesh2D(mesh2D),_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(0),_cell_2D_id(cell2DId) { if(_mesh2D!=0) @@ -188,7 +195,7 @@ MEDCouplingExtrudedMesh::~MEDCouplingExtrudedMesh() _mesh3D_ids->decrRef(); } -void MEDCouplingExtrudedMesh::computeExtrusion(MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception) +void MEDCouplingExtrudedMesh::computeExtrusion(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception) { const char errMsg1[]="2D mesh is empty unable to compute extrusion !"; const char errMsg2[]="Coords between 2D and 3D meshes are not the same ! Try MEDCouplingPointSet::tryToShareSameCoords method"; @@ -365,7 +372,7 @@ DataArrayDouble *MEDCouplingExtrudedMesh::getBarycenterAndOwner() const return 0; } -void MEDCouplingExtrudedMesh::computeExtrusionAlg(MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception) +void MEDCouplingExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception) { _mesh3D_ids->alloc(mesh3D->getNumberOfCells(),1); int nbOf1DLev=mesh3D->getNumberOfCells()/_mesh2D->getNumberOfCells(); diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx index f18207ba0..d0040a827 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx @@ -34,7 +34,7 @@ namespace ParaMEDMEM class MEDCOUPLING_EXPORT MEDCouplingExtrudedMesh : public MEDCouplingMesh { public: - static MEDCouplingExtrudedMesh *New(MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); + static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); MEDCouplingMeshType getType() const; bool isStructured() const; int getNumberOfCells() const; @@ -61,9 +61,9 @@ namespace ParaMEDMEM DataArrayDouble *getCoordinatesAndOwner() const; DataArrayDouble *getBarycenterAndOwner() const; private: - MEDCouplingExtrudedMesh(MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); - void computeExtrusion(MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception); - void computeExtrusionAlg(MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception); + MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); + void computeExtrusion(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception); + void computeExtrusionAlg(const MEDCouplingUMesh *mesh3D) throw(INTERP_KERNEL::Exception); void build1DExtrusion(int idIn3DDesc, int newId, int nbOf1DLev, MEDCouplingUMesh *subMesh, const int *desc3D, const int *descIndx3D, const int *revDesc3D, const int *revDescIndx3D, diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 5bf486d26..41b9514a1 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -108,6 +108,9 @@ void MEDCouplingFieldDouble::checkCoherency() const throw(INTERP_KERNEL::Excepti _type->checkCoherencyBetween(_mesh,getArray()); } +/*! + * Returns the accumulation (the sum) of comId_th component of each tuples of default array. + */ double MEDCouplingFieldDouble::accumulate(int compId) const { const double *ptr=getArray()->getConstPointer(); @@ -119,6 +122,10 @@ double MEDCouplingFieldDouble::accumulate(int compId) const return ret; } +/*! + * Returns the accumulation (the sum) of all tuples of default array. + * The res is expected to be of size getNumberOfComponents(). + */ void MEDCouplingFieldDouble::accumulate(double *res) const { const double *ptr=getArray()->getConstPointer(); @@ -129,6 +136,11 @@ void MEDCouplingFieldDouble::accumulate(double *res) const std::transform(ptr+i*nbComps,ptr+(i+1)*nbComps,res,res,std::plus()); } +/*! + * Returns the accumulation (the sum) of comId_th component of each tuples weigthed by the field + * returns by getWeightingField relative of the _type of field of default array. + * This method is usefull to check the conservativity of interpolation method. + */ double MEDCouplingFieldDouble::measureAccumulate(int compId, bool isWAbs) const { if(!_mesh) @@ -143,6 +155,11 @@ double MEDCouplingFieldDouble::measureAccumulate(int compId, bool isWAbs) const return ret; } +/*! + * Returns the accumulation (the sum) of each tuples weigthed by the field + * returns by getWeightingField relative of the _type of field of default array. + * This method is usefull to check the conservativity of interpolation method. + */ void MEDCouplingFieldDouble::measureAccumulate(bool isWAbs, double *res) const { if(!_mesh) @@ -163,18 +180,32 @@ void MEDCouplingFieldDouble::measureAccumulate(bool isWAbs, double *res) const delete [] tmp; } +/*! + * This method is reserved for field lying on structured mesh spatial support. It returns the value of cell localized by (i,j,k) + * If spatial support is not structured mesh an exception will be thrown. + * @param res out array expected to be equal to size getNumberOfComponents() + */ void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception) { const DataArrayDouble *arr=_time_discr->getArray(); _type->getValueOnPos(arr,_mesh,i,j,k,res); } +/*! + * Returns value of 'this' on default time of point 'spaceLoc' using spatial discretization. + * If 'point' is outside the spatial discretization of this an exception will be thrown. + */ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception) { const DataArrayDouble *arr=_time_discr->getArray(); _type->getValueOn(arr,_mesh,spaceLoc,res); } +/*! + * Returns value of 'this' on time 'time' of point 'spaceLoc' using spatial discretization. + * If 'time' is not covered by this->_time_discr an exception will be thrown. + * If 'point' is outside the spatial discretization of this an exception will be thrown. + */ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception) { std::vector< const DataArrayDouble *> arrs=_time_discr->getArraysForTime(time); @@ -188,21 +219,38 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, dou _time_discr->getValueForTime(time,res2,res); } +/*! + * Applies a*x+b on 'compoId'th component of each cell. + */ void MEDCouplingFieldDouble::applyLin(double a, double b, int compoId) { _time_discr->applyLin(a,b,compoId); } +/*! + * Applyies the function specified by pointer 'func' on each tuples on all arrays contained in _time_discr. + * If '*func' returns false during one evaluation an exception will be thrown. + */ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, FunctionToEvaluate func) { _time_discr->applyFunc(nbOfComp,func); } +/*! + * Applyies the function specified by the string repr 'func' on each tuples on all arrays contained in _time_discr. + * If '*func' fails in evaluation during one evaluation an exception will be thrown. + * The field will contain 'nbOfComp' components after the call. + */ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) { _time_discr->applyFunc(nbOfComp,func); } +/*! + * Applyies the function specified by the string repr 'func' on each tuples on all arrays contained in _time_discr. + * If '*func' fails in evaluation during one evaluation an exception will be thrown. + * The field will contain exactly the same number of components after the call. + */ void MEDCouplingFieldDouble::applyFunc(const char *func) { _time_discr->applyFunc(func); @@ -223,8 +271,7 @@ int MEDCouplingFieldDouble::getNumberOfTuples() const throw(INTERP_KERNEL::Excep void MEDCouplingFieldDouble::updateTime() { MEDCouplingField::updateTime(); - if(getArray()) - updateTimeWith(*getArray()); + updateTimeWith(*_time_discr); } void MEDCouplingFieldDouble::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingMesh.cxx b/src/MEDCoupling/MEDCouplingMesh.cxx index a9f5d37fd..48fd14bb9 100644 --- a/src/MEDCoupling/MEDCouplingMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMesh.cxx @@ -37,6 +37,17 @@ bool MEDCouplingMesh::areCompatible(const MEDCouplingMesh *other) const return true; } +/*! + * This method builds a field lying on 'this' with 'nbOfComp' components. + * 'func' is a pointer that points to a function that takes 2 arrays in parameter and returns a boolean. + * The first array is a in-param of size this->getSpaceDimension and the second an out param of size 'nbOfComp'. + * The return field will have type specified by 't'. 't' is also used to determine where values of field will be + * evaluate. + * @param t type of field returned and specifies where the evaluation of func will be done. + * @param nbOfComp number of components of returned field. + * @param func pointer to a function that should return false if the evaluation failed. (division by 0. for example) + * @return field with counter = 1. + */ MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const { MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(t); @@ -68,6 +79,16 @@ MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbO return ret; } +/*! + * This method builds a field lying on 'this' with 'nbOfComp' components. + * 'func' is a string that is the expression to evaluate. + * The return field will have type specified by 't'. 't' is also used to determine where values of field will be + * evaluate. + * @param t type of field returned and specifies where the evaluation of func will be done. + * @param nbOfComp number of components of returned field. + * @param func expression. + * @return field with counter = 1. + */ MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const { INTERP_KERNEL::ExprParser expr(func); @@ -117,6 +138,10 @@ MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbO return ret; } +/*! + * retruns a newly created mesh with counter=1 + * that is the union of mesh1 and mesh2 if possible. The cells of mesh2 will appear after cells of 'mesh1'. Idem for nodes. + */ MEDCouplingMesh *MEDCouplingMesh::mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) { return mesh1->mergeMyselfWith(mesh2); diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index b48b6df43..aa3be9b9e 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -96,6 +96,18 @@ DataArrayDouble *MEDCouplingPointSet::getCoordinatesAndOwner() const return _coords; } +bool MEDCouplingPointSet::isEqual(const MEDCouplingMesh *other, double prec) const +{ + const MEDCouplingPointSet *otherC=dynamic_cast(other); + if(!otherC) + return false; + if(!MEDCouplingMesh::isEqual(other,prec)) + return false; + if(!areCoordsEqual(*otherC,prec)) + return false; + return true; +} + bool MEDCouplingPointSet::areCoordsEqual(const MEDCouplingPointSet& other, double prec) const { if(_coords==0 && other._coords==0) @@ -108,6 +120,8 @@ bool MEDCouplingPointSet::areCoordsEqual(const MEDCouplingPointSet& other, doubl } /*! + * This methods searches for each node n1 nodes in _coords that are less far than 'prec' from n1. if any these nodes are stored in params + * comm and commIndex. * @param comm out parameter (not inout) * @param commIndex out parameter (not inout) */ @@ -193,6 +207,13 @@ DataArrayInt *MEDCouplingPointSet::buildNewNumberingFromCommNodesFrmt(const Data return ret; } +/* + * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes. + * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes()) + * This value is asked because often known by the caller of this method. + * @param newNodeNumbers array specifying the new numbering. + * @param newNbOfNodes the new number of nodes. + */ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNodes) { DataArrayDouble *newCoords=DataArrayDouble::New(); @@ -208,6 +229,11 @@ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNo newCoords->decrRef(); } +/*! + * This method fills bbox params like that : bbox[0]=XMin, bbox[1]=XMax, bbox[2]=YMin... + * The returned bounding box is arranged along trihedron. + * @param bbox out array of size 2*this->getSpaceDimension(). + */ void MEDCouplingPointSet::getBoundingBox(double *bbox) const { int dim=getSpaceDimension(); @@ -234,6 +260,9 @@ void MEDCouplingPointSet::getBoundingBox(double *bbox) const } } +/*! + * This method removes useless nodes in coords. + */ void MEDCouplingPointSet::zipCoords() { checkFullyDefined(); @@ -241,6 +270,14 @@ void MEDCouplingPointSet::zipCoords() traducer->decrRef(); } +/*! + * Non const method that operates a rotation of 'this'. + * If spaceDim==2 'vector' parameter is ignored (and could be 0) and the rotation is done around 'center' with angle specified by 'angle'. + * If spaceDim==3 the rotation axe is defined by ('center','vector') and the angle is 'angle'. + * @param center an array of size getSpaceDimension(). + * @param vector in array of size getSpaceDimension(). + * @param angle angle of rotation in radian. + */ void MEDCouplingPointSet::rotate(const double *center, const double *vector, double angle) { int spaceDim=getSpaceDimension(); @@ -254,6 +291,10 @@ void MEDCouplingPointSet::rotate(const double *center, const double *vector, dou updateTime(); } +/*! + * Non const method that operates a translation of 'this'. + * @param vector in array of size getSpaceDimension(). + */ void MEDCouplingPointSet::translate(const double *vector) { double *coords=_coords->getPointer(); @@ -266,6 +307,11 @@ void MEDCouplingPointSet::translate(const double *vector) updateTime(); } +/*! + * Non const method that operates a scale on 'this' with 'point' as reference point of scale and with factor 'factor'. + * @param point in array of size getSpaceDimension(). + * @param factor factor of the scaling + */ void MEDCouplingPointSet::scale(const double *point, double factor) { double *coords=_coords->getPointer(); @@ -283,7 +329,11 @@ void MEDCouplingPointSet::scale(const double *point, double factor) updateTime(); } -void MEDCouplingPointSet::tryToShareSameCoords(MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) +/*! + * This method try to substitute this->_coords with other._coords if arrays match. + * This method potentially modifies 'this' if it succeeds, otherway an exception is thrown. + */ +void MEDCouplingPointSet::tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) { if(_coords==other._coords) return ; @@ -293,8 +343,12 @@ void MEDCouplingPointSet::tryToShareSameCoords(MEDCouplingPointSet& other, doubl throw INTERP_KERNEL::Exception("Other instance has no coords whereas current has !"); if(!_coords->isEqual(*other._coords,epsilon)) throw INTERP_KERNEL::Exception("Coords are not the same !"); + setCoords(other._coords); } +/*! + * merge _coords arrays of m1 and m2 and returns the union. The returned instance is newly created with ref count == 1. + */ DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) { int spaceDim=m1->getSpaceDimension(); @@ -303,6 +357,10 @@ DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet return DataArrayDouble::aggregate(m1->getCoords(),m2->getCoords()); } +/*! + * Factory to build new instance of instanciable subclasses of MEDCouplingPointSet. + * This method is used during unserialization process. + */ MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingMeshType type) { switch(type) @@ -316,6 +374,9 @@ MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingM } } +/*! + * First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process. + */ void MEDCouplingPointSet::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const { if(_coords) @@ -341,6 +402,9 @@ void MEDCouplingPointSet::getTinySerializationInformation(std::vector& tiny } } +/*! + * Third and final step of serialization process. + */ void MEDCouplingPointSet::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const { if(_coords) @@ -352,6 +416,10 @@ void MEDCouplingPointSet::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) con a2=0; } +/*! + * Second step of serialization process. + * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. + */ void MEDCouplingPointSet::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) { if(tinyInfo[2]>=0 && tinyInfo[1]>=1) @@ -365,6 +433,10 @@ void MEDCouplingPointSet::resizeForUnserialization(const std::vector& tinyI } } +/*! + * Second and final unserialization process. + * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. + */ void MEDCouplingPointSet::unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) { if(tinyInfo[2]>=0 && tinyInfo[1]>=1) @@ -378,9 +450,9 @@ void MEDCouplingPointSet::unserialization(const std::vector& tinyInfo, Data setName(littleStrings[0].c_str()); } -// ============================================= -// Intersect Bounding Box given 2 Bounding Boxes -// ============================================= +/*! + * Intersect Bounding Box given 2 Bounding Boxes. + */ bool MEDCouplingPointSet::intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps) { double* bbtemp = new double[2*dim]; @@ -424,6 +496,10 @@ void MEDCouplingPointSet::rotate3D(const double *center, const double *vect, dou rotate3DAlg(center,vect,angle,nbNodes,coords); } +/*! + * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' + * around an axe ('center','vect') and with angle 'angle'. + */ void MEDCouplingPointSet::rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords) { double sina=sin(angle); @@ -466,6 +542,10 @@ void MEDCouplingPointSet::rotate2D(const double *center, double angle) rotate2DAlg(center,angle,nbNodes,coords); } +/*! + * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' + * around the center point 'center' and with angle 'angle'. + */ void MEDCouplingPointSet::rotate2DAlg(const double *center, double angle, int nbNodes, double *coords) { double cosa=cos(angle); @@ -490,6 +570,12 @@ public: static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; }; +/*! + * res should be an empty vector before calling this method. + * This method returns all the node coordinates included in _coords which ids are in [startConn;endConn) and put it into 'res' vector. + * If spaceDim==3 a projection will be done for each nodes on the middle plane containing these all nodes in [startConn;endConn). + * And after each projected nodes are moved to Oxy plane in order to consider these nodes as 2D nodes. + */ void MEDCouplingPointSet::project2DCellOnXY(const int *startConn, const int *endConn, std::vector& res) const { const double *coords=_coords->getConstPointer(); @@ -514,6 +600,9 @@ void MEDCouplingPointSet::project2DCellOnXY(const int *startConn, const int *end throw INTERP_KERNEL::Exception("Invalid spacedim for project2DCellOnXY !"); } +/*! + * low level method that checks that the 2D cell is not a butterfly cell. + */ bool MEDCouplingPointSet::isButterfly2DCell(const std::vector& res, bool isQuad) { int nbOfNodes=res.size()/2; diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 804dae5ae..260e65cb6 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -43,6 +43,7 @@ namespace ParaMEDMEM void setCoords(DataArrayDouble *coords); DataArrayDouble *getCoords() const { return _coords; } DataArrayDouble *getCoordinatesAndOwner() const; + bool isEqual(const MEDCouplingMesh *other, double prec) const; bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const; virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged) = 0; void findCommonNodes(DataArrayInt *&comm, DataArrayInt *&commIndex, double prec) const; @@ -53,7 +54,7 @@ namespace ParaMEDMEM void rotate(const double *center, const double *vector, double angle); void translate(const double *vector); void scale(const double *point, double factor); - void tryToShareSameCoords(MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); + void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2); static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type); static void rotate2DAlg(const double *center, double angle, int nbNodes, double *coords); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 0f3337323..e207da83d 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -49,6 +49,12 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDisc } } +void MEDCouplingTimeDiscretization::updateTime() +{ + if(_array) + updateTimeWith(*_array); +} + bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const { if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index 07aea3bfb..f97924786 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -20,6 +20,7 @@ #define __MEDCOUPLINGTIMEDISCRETIZATION_HXX__ #include "MEDCoupling.hxx" +#include "MEDCouplingTimeLabel.hxx" #include "MEDCouplingRefCountObject.hxx" #include "InterpKernelException.hxx" @@ -30,12 +31,13 @@ namespace ParaMEDMEM class DataArrayDouble; class TimeLabel; - class MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization + class MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization : public TimeLabel { protected: MEDCouplingTimeDiscretization(); MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy); public: + void updateTime(); static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type); virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const; virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 35d7414b8..8a776468f 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -113,6 +113,12 @@ void MEDCouplingUMesh::allocateCells(int nbOfCells) declareAsNew(); } +/*! + * Appends a cell in connectivity array. + * @param type type of cell to add. + * @param size number of nodes constituting this cell. + * @param nodalConnOfCell the connectivity of the cell to add. + */ void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) { int *pt=_nodal_connec_index->getPointer(); @@ -123,6 +129,9 @@ void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, in pt[++_iterator]=idx+size+1; } +/*! + * Method to be called to cloture the insertion of cells using this->insertNextCell. + */ void MEDCouplingUMesh::finishInsertingCells() { const int *pt=_nodal_connec_index->getConstPointer(); @@ -131,23 +140,26 @@ void MEDCouplingUMesh::finishInsertingCells() _nodal_connec->reAlloc(idx); _nodal_connec_index->reAlloc(_iterator+1); _iterator=-1; + _nodal_connec->declareAsNew(); + _nodal_connec_index->declareAsNew(); + updateTime(); } +/*! + * This method is a method that compares 'this' and 'other'. + * This method compares \b all attributes, even names and component names. + */ bool MEDCouplingUMesh::isEqual(const MEDCouplingMesh *other, double prec) const { - //checkFullyDefined(); const MEDCouplingUMesh *otherC=dynamic_cast(other); if(!otherC) return false; - //otherC->checkFullyDefined(); - if(!MEDCouplingMesh::isEqual(other,prec)) + if(!MEDCouplingPointSet::isEqual(other,prec)) return false; if(_mesh_dim!=otherC->_mesh_dim) return false; if(_types!=otherC->_types) return false; - if(!areCoordsEqual(*otherC,prec)) - return false; if(_nodal_connec!=0 || otherC->_nodal_connec!=0) if(_nodal_connec==0 || otherC->_nodal_connec==0) return false; @@ -434,6 +446,12 @@ DataArrayInt *MEDCouplingUMesh::mergeNodes(double precision, bool& areNodesMerge return ret; } +/*! + * 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. + * @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 { if(getMeshDimension()!=-1) @@ -481,6 +499,12 @@ MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfNode(const int *start, c return buildPartOfMySelf(&cellIdsKept[0],&cellIdsKept[0]+cellIdsKept.size(),true); } +/*! + * This method returns a mesh with meshDim=this->getMeshDimension()-1. + * This returned mesh contains cells that are linked with one and only one cell of this. + * @param keepCoords specifies if zipCoords is called on returned mesh before being returned. + * @return mesh with ref counter equal to 1. + */ MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const { DataArrayInt *desc=DataArrayInt::New(); @@ -504,6 +528,9 @@ MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const return ret; } +/*! + * This methods returns set of nodes lying on the boundary of this. + */ void MEDCouplingUMesh::findBoundaryNodes(std::vector& nodes) const { DataArrayInt *desc=DataArrayInt::New(); @@ -534,6 +561,13 @@ void MEDCouplingUMesh::findBoundaryNodes(std::vector& nodes) const meshDM1->decrRef(); } +/* + * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes. + * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes()) + * This value is asked because often known by the caller of this method. + * @param newNodeNumbers array specifying the new numbering. + * @param newNbOfNodes the new number of nodes. + */ void MEDCouplingUMesh::renumberNodes(const int *newNodeNumbers, int newNbOfNodes) { MEDCouplingPointSet::renumberNodes(newNodeNumbers,newNbOfNodes); @@ -549,6 +583,8 @@ void MEDCouplingUMesh::renumberNodes(const int *newNodeNumbers, int newNbOfNodes node=newNodeNumbers[node]; } } + _nodal_connec->declareAsNew(); + updateTime(); } /*! @@ -603,6 +639,9 @@ void MEDCouplingUMesh::giveElemsInBoundingBox(const double *bbox, double eps, st delete [] elem_bb; } +/*! + * Returns the cell type of cell with id 'cellId'. + */ INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::getTypeOfCell(int cellId) const { const int *ptI=_nodal_connec_index->getConstPointer(); @@ -610,6 +649,9 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::getTypeOfCell(int cellId) co return (INTERP_KERNEL::NormalizedCellType) pt[ptI[cellId]]; } +/*! + * Appends the nodal connectivity in 'conn' of cell with id 'cellId'. + */ void MEDCouplingUMesh::getNodeIdsOfCell(int cellId, std::vector& conn) const { const int *ptI=_nodal_connec_index->getConstPointer(); @@ -619,6 +661,9 @@ void MEDCouplingUMesh::getNodeIdsOfCell(int cellId, std::vector& conn) cons conn.push_back(*w); } +/*! + * Returns coordinates of node with id 'nodeId' and append it in 'coo'. + */ void MEDCouplingUMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const { const double *cooPtr=_coords->getConstPointer(); @@ -636,6 +681,10 @@ int MEDCouplingUMesh::getNumberOfNodesInCell(int cellId) const return std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind2nd(std::not_equal_to(),-1)); } +/*! + * Method reserved for advanced users having prepared their connectivity before. + * Arrays 'conn' and 'connIndex' will be aggregated without any copy and their counter will be incremented. + */ void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes) { DataArrayInt::setArrayIn(conn,_nodal_connec); @@ -645,6 +694,10 @@ void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connInd declareAsNew(); } +/*! + * Copy constructor. If 'deepCpy' is false 'this' is a shallow copy of other. + * If 'deeCpy' is true all arrays (coordinates and connectivities) are deeply copied. + */ MEDCouplingUMesh::MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy):MEDCouplingPointSet(other,deepCpy),_iterator(-1),_mesh_dim(other._mesh_dim), _nodal_connec(0),_nodal_connec_index(0), _types(other._types) @@ -663,6 +716,9 @@ MEDCouplingUMesh::~MEDCouplingUMesh() _nodal_connec_index->decrRef(); } +/*! + * This method recomputes all cell types of 'this'. + */ void MEDCouplingUMesh::computeTypes() { if(_nodal_connec && _nodal_connec_index) @@ -706,11 +762,17 @@ int MEDCouplingUMesh::getMeshDimension() const return _mesh_dim; } +/*! + * This method is for test reason. Normally the integer returned is not useable by user. + */ int MEDCouplingUMesh::getMeshLength() const { return _nodal_connec->getNbOfElems(); } +/*! + * First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process. + */ void MEDCouplingUMesh::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const { MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings); @@ -722,12 +784,16 @@ void MEDCouplingUMesh::getTinySerializationInformation(std::vector& tinyInf tinyInfo.push_back(-1); } +/*! + * First step of unserialization process. + */ bool MEDCouplingUMesh::isEmptyMesh(const std::vector& tinyInfo) const { return tinyInfo[4]<=0; } /*! + * Second step of serialization process. * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. */ void MEDCouplingUMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) @@ -737,6 +803,9 @@ void MEDCouplingUMesh::resizeForUnserialization(const std::vector& tinyInfo a1->alloc(tinyInfo[5]+tinyInfo[4]+1,1); } +/*! + * Third and final step of serialization process. + */ void MEDCouplingUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const { MEDCouplingPointSet::serialize(a1,a2); @@ -755,6 +824,7 @@ void MEDCouplingUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const } /*! + * Second and final unserialization process. * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. */ void MEDCouplingUMesh::unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) @@ -777,6 +847,11 @@ void MEDCouplingUMesh::unserialization(const std::vector& tinyInfo, DataArr } } +/*! + * This is the low algorithm of buildPartOfMySelf. + * 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'. + */ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *start, const int *end) const { checkFullyDefined(); @@ -859,6 +934,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const return field; } +/*! + * This methods returns a field on nodes and no time. This method is usefull to check "P1*" conservative interpolators. + * This field returns the getMeasureField of the dualMesh in P1 sens of 'this'. + */ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) const { MEDCouplingFieldDouble *tmp=getMeasureField(isAbs); @@ -889,6 +968,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) cons return ret; } +/*! + * This methods returns a vector field on cells that represents the orthogonal vector normalized of each 2D cell of this. + * This method is only callable on mesh with meshdim == 2 and spacedim==2 or 3. + */ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const { if(getMeshDimension()!=2) @@ -925,6 +1008,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const return ret; } +/*! + * Returns a cell if any that contains the point located on 'pos' with precison eps. + * If 'pos' is outside 'this' -1 is returned. If several cells contain this point the cell with the smallest id is returned. + */ int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) const { std::vector elts; @@ -934,6 +1021,9 @@ int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) cons return elts.front(); } +/*! + * Returns all cellIds in 'elts' of point 'pos' with eps accuracy. + */ void MEDCouplingUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const { std::vector eltsIndex; @@ -1128,6 +1218,9 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypes() const return true; } +/*! + * Returns a newly created mesh (with ref count ==1) that contains merge of 'this' and 'other'. + */ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) const { if(other->getType()!=UNSTRUCTURED) @@ -1136,6 +1229,11 @@ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) return mergeUMeshes(this,otherC); } +/*! + * Returns an array with this->getNumberOfCells() tuples and this->getSpaceDimension() dimension. + * The false barycenter is computed that is to say barycenter of a cell is computed using average on each + * components of coordinates of the cell. + */ DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const { DataArrayDouble *ret=DataArrayDouble::New(); @@ -1163,6 +1261,9 @@ DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const return ret; } +/*! + * Returns a newly created mesh (with ref count ==1) that contains merge of 'mesh1' and 'other'. + */ MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) { MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); -- 2.39.2