From: ageay Date: Tue, 15 Jul 2008 13:08:29 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5e63ad9a5fd1e7beaa8b3142ad71b90d93ad7339;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/INTERP_KERNEL/CellModel.cxx b/src/INTERP_KERNEL/CellModel.cxx new file mode 100644 index 000000000..8e2894574 --- /dev/null +++ b/src/INTERP_KERNEL/CellModel.cxx @@ -0,0 +1,182 @@ +#include "CellModel.hxx" + +#include "InterpolationUtils.hxx" + +#include + +using namespace std; + +namespace INTERP_KERNEL +{ + std::map CellModel::_mapOfUniqueInstance; + + const CellModel& CellModel::getCellModel(NormalizedCellType type) + { + if(_mapOfUniqueInstance.empty()) + buildUniqueInstance(); + const map::iterator iter=_mapOfUniqueInstance.find(type); + if(iter==_mapOfUniqueInstance.end()) + { + ostringstream stream; stream << "no cellmodel for normalized type " << type; + throw Exception(stream.str().c_str()); + } + return (*iter).second; + } + + void CellModel::buildUniqueInstance() + { + _mapOfUniqueInstance.insert(make_pair(NORM_TRI3,CellModel(NORM_TRI3))); + _mapOfUniqueInstance.insert(make_pair(NORM_QUAD4,CellModel(NORM_QUAD4))); + _mapOfUniqueInstance.insert(make_pair(NORM_TRI6,CellModel(NORM_TRI6))); + _mapOfUniqueInstance.insert(make_pair(NORM_QUAD8,CellModel(NORM_QUAD8))); + _mapOfUniqueInstance.insert(make_pair(NORM_TETRA4,CellModel(NORM_TETRA4))); + _mapOfUniqueInstance.insert(make_pair(NORM_HEXA8,CellModel(NORM_HEXA8))); + _mapOfUniqueInstance.insert(make_pair(NORM_PYRA5,CellModel(NORM_PYRA5))); + _mapOfUniqueInstance.insert(make_pair(NORM_PENTA6,CellModel(NORM_PENTA6))); + _mapOfUniqueInstance.insert(make_pair(NORM_TETRA10,CellModel(NORM_TETRA10))); + _mapOfUniqueInstance.insert(make_pair(NORM_PYRA13,CellModel(NORM_PYRA13))); + _mapOfUniqueInstance.insert(make_pair(NORM_PENTA15,CellModel(NORM_PENTA15))); + _mapOfUniqueInstance.insert(make_pair(NORM_HEXA20,CellModel(NORM_HEXA20))); + } + + CellModel::CellModel(NormalizedCellType type) + { + switch(type) + { + case NORM_TETRA4: + { + _nbOfPts=4; _nbOfSons=4; _dim=3; + _sonsType[0]=NORM_TRI3; _sonsType[1]=NORM_TRI3; _sonsType[2]=NORM_TRI3; _sonsType[3]=NORM_TRI3; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=2; _nbOfSonsCon[0]=3; + _sonsCon[1][0]=0; _sonsCon[1][1]=3; _sonsCon[1][2]=1; _nbOfSonsCon[1]=3; + _sonsCon[2][0]=1; _sonsCon[2][1]=3; _sonsCon[2][2]=2; _nbOfSonsCon[2]=3; + _sonsCon[3][0]=2; _sonsCon[3][1]=3; _sonsCon[3][2]=0; _nbOfSonsCon[3]=3; + } + break; + case NORM_HEXA8: + { + _nbOfPts=8; _nbOfSons=6; _dim=3; + _sonsType[0]=NORM_QUAD4; _sonsType[1]=NORM_QUAD4; _sonsType[2]=NORM_QUAD4; _sonsType[3]=NORM_QUAD4; _sonsType[4]=NORM_QUAD4; _sonsType[5]=NORM_QUAD4; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=2; _sonsCon[0][3]=3; _nbOfSonsCon[0]=4; + _sonsCon[1][0]=4; _sonsCon[1][1]=7; _sonsCon[1][2]=6; _sonsCon[1][3]=5; _nbOfSonsCon[1]=4; + _sonsCon[2][0]=0; _sonsCon[2][1]=4; _sonsCon[2][2]=5; _sonsCon[2][3]=1; _nbOfSonsCon[2]=4; + _sonsCon[3][0]=1; _sonsCon[3][1]=5; _sonsCon[3][2]=6; _sonsCon[3][3]=2; _nbOfSonsCon[3]=4; + _sonsCon[4][0]=2; _sonsCon[4][1]=6; _sonsCon[4][2]=7; _sonsCon[4][3]=3; _nbOfSonsCon[4]=4; + _sonsCon[5][0]=3; _sonsCon[5][1]=7; _sonsCon[5][2]=4; _sonsCon[5][3]=0; _nbOfSonsCon[5]=4; + } + break; + case NORM_QUAD4: + { + _nbOfPts=4; _nbOfSons=4; _dim=2; + _sonsType[0]=NORM_SEG2; _sonsType[1]=NORM_SEG2; _sonsType[2]=NORM_SEG2; _sonsType[3]=NORM_SEG2; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _nbOfSonsCon[0]=2; + _sonsCon[1][0]=1; _sonsCon[1][1]=2; _nbOfSonsCon[1]=2; + _sonsCon[2][0]=2; _sonsCon[2][1]=3; _nbOfSonsCon[2]=2; + _sonsCon[3][0]=3; _sonsCon[3][1]=0; _nbOfSonsCon[3]=2; + } + break; + case NORM_TRI3: + { + _nbOfPts=3; _nbOfSons=3; _dim=2; + _sonsType[0]=NORM_SEG2; _sonsType[1]=NORM_SEG2; _sonsType[2]=NORM_SEG2; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _nbOfSonsCon[0]=2; + _sonsCon[1][0]=1; _sonsCon[1][1]=2; _nbOfSonsCon[1]=2; + _sonsCon[2][0]=2; _sonsCon[2][1]=0; _nbOfSonsCon[2]=2; + } + break; + case NORM_TRI6: + { + _nbOfPts=6; _nbOfSons=3; _dim=2; + _sonsType[0]=NORM_SEG3; _sonsType[1]=NORM_SEG3; _sonsType[2]=NORM_SEG3; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=3; _nbOfSonsCon[0]=3; + _sonsCon[1][0]=1; _sonsCon[1][1]=2; _sonsCon[1][2]=4; _nbOfSonsCon[1]=3; + _sonsCon[2][0]=2; _sonsCon[2][1]=0; _sonsCon[2][2]=5; _nbOfSonsCon[2]=3; + } + break; + case NORM_QUAD8: + { + _nbOfPts=8; _nbOfSons=4; _dim=2; + _sonsType[0]=NORM_SEG3; _sonsType[1]=NORM_SEG3; _sonsType[2]=NORM_SEG3; _sonsType[3]=NORM_SEG3; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=4; _nbOfSonsCon[0]=3; + _sonsCon[1][0]=1; _sonsCon[1][1]=2; _sonsCon[1][2]=5; _nbOfSonsCon[1]=3; + _sonsCon[2][0]=2; _sonsCon[2][1]=3; _sonsCon[2][2]=6; _nbOfSonsCon[2]=3; + _sonsCon[3][0]=3; _sonsCon[3][1]=0; _sonsCon[3][2]=7; _nbOfSonsCon[3]=3; + } + break; + case NORM_PYRA5: + { + _nbOfPts=5; _nbOfSons=5; _dim=3; + _sonsType[0]=NORM_QUAD4; _sonsType[1]=NORM_TRI3; _sonsType[2]=NORM_TRI3; _sonsType[3]=NORM_TRI3; _sonsType[4]=NORM_TRI3; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=2; _sonsCon[0][3]=3; _nbOfSonsCon[0]=4; + _sonsCon[1][0]=0; _sonsCon[1][1]=4; _sonsCon[1][2]=1; _nbOfSonsCon[1]=3; + _sonsCon[2][0]=1; _sonsCon[2][1]=4; _sonsCon[2][2]=2; _nbOfSonsCon[2]=3; + _sonsCon[3][0]=2; _sonsCon[3][1]=4; _sonsCon[3][2]=3; _nbOfSonsCon[3]=3; + _sonsCon[4][0]=3; _sonsCon[4][1]=4; _sonsCon[4][2]=0; _nbOfSonsCon[4]=3; + } + break; + case NORM_PENTA6: + { + _nbOfPts=6; _nbOfSons=5; _dim=3; + _sonsType[0]=NORM_TRI3; _sonsType[1]=NORM_TRI3; _sonsType[2]=NORM_QUAD4; _sonsType[3]=NORM_QUAD4; _sonsType[4]=NORM_QUAD4; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=2; _nbOfSonsCon[0]=3; + _sonsCon[1][0]=3; _sonsCon[1][1]=5; _sonsCon[1][2]=4; _nbOfSonsCon[1]=3; + _sonsCon[2][0]=0; _sonsCon[2][1]=3; _sonsCon[2][2]=4; _sonsCon[2][3]=1; _nbOfSonsCon[2]=4; + _sonsCon[3][0]=1; _sonsCon[3][1]=4; _sonsCon[3][2]=5; _sonsCon[3][3]=2; _nbOfSonsCon[3]=4; + _sonsCon[4][0]=2; _sonsCon[4][1]=4; _sonsCon[4][2]=5; _sonsCon[4][3]=0; _nbOfSonsCon[4]=4; + } + break; + case NORM_TETRA10: + { + _nbOfPts=10; _nbOfSons=4; _dim=3; + _sonsType[0]=NORM_TRI6; _sonsType[1]=NORM_TRI6; _sonsType[2]=NORM_TRI6; _sonsType[3]=NORM_TRI6; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=2; _sonsCon[0][3]=4; _sonsCon[0][4]=5; _sonsCon[0][5]=6; _nbOfSonsCon[0]=6; + _sonsCon[1][0]=0; _sonsCon[1][1]=3; _sonsCon[1][2]=1; _sonsCon[1][3]=7; _sonsCon[1][4]=8; _sonsCon[1][5]=4; _nbOfSonsCon[1]=6; + _sonsCon[2][0]=1; _sonsCon[2][1]=3; _sonsCon[2][2]=2; _sonsCon[2][3]=8; _sonsCon[2][4]=9; _sonsCon[2][5]=5; _nbOfSonsCon[2]=6; + _sonsCon[3][0]=2; _sonsCon[3][1]=3; _sonsCon[3][2]=0; _sonsCon[3][3]=9; _sonsCon[3][4]=7; _sonsCon[3][5]=6; _nbOfSonsCon[3]=6; + } + break; + case NORM_PYRA13: + { + _nbOfPts=13; _nbOfSons=5; _dim=3; + _sonsType[0]=NORM_QUAD8; _sonsType[1]=NORM_TRI6; _sonsType[2]=NORM_TRI6; _sonsType[3]=NORM_TRI6; _sonsType[4]=NORM_TRI6; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=2; _sonsCon[0][3]=3; _sonsCon[0][4]=5; _sonsCon[0][5]=6; _sonsCon[0][6]=7; _sonsCon[0][7]=8; _nbOfSonsCon[0]=8; + _sonsCon[1][0]=0; _sonsCon[1][1]=4; _sonsCon[1][2]=1; _sonsCon[1][3]=9; _sonsCon[1][4]=10; _sonsCon[1][5]=5; _nbOfSonsCon[1]=6; + _sonsCon[2][0]=1; _sonsCon[2][1]=4; _sonsCon[2][2]=2; _sonsCon[2][3]=10; _sonsCon[2][4]=11; _sonsCon[2][5]=6; _nbOfSonsCon[2]=6; + _sonsCon[3][0]=2; _sonsCon[3][1]=4; _sonsCon[3][2]=3; _sonsCon[3][3]=11; _sonsCon[3][4]=12; _sonsCon[3][5]=7; _nbOfSonsCon[3]=6; + _sonsCon[4][0]=3; _sonsCon[4][1]=4; _sonsCon[4][2]=0; _sonsCon[4][3]=12; _sonsCon[4][4]=9; _sonsCon[4][5]=8; _nbOfSonsCon[4]=6; + } + break; + case NORM_PENTA15: + { + _nbOfPts=15; _nbOfSons=5; _dim=3; + _sonsType[0]=NORM_TRI6; _sonsType[1]=NORM_TRI6; _sonsType[2]=NORM_QUAD8; _sonsType[3]=NORM_QUAD8; _sonsType[4]=NORM_QUAD8; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=2; _sonsCon[0][3]=6; _sonsCon[0][4]=7; _sonsCon[0][5]=8; _nbOfSonsCon[0]=6; + _sonsCon[1][0]=3; _sonsCon[1][1]=5; _sonsCon[1][2]=4; _sonsCon[1][3]=11; _sonsCon[1][4]=10; _sonsCon[1][5]=9; _nbOfSonsCon[1]=6; + _sonsCon[2][0]=0; _sonsCon[2][1]=3; _sonsCon[2][2]=4; _sonsCon[2][3]=1; _sonsCon[2][4]=12; _sonsCon[2][5]=9; _sonsCon[2][6]=13; _sonsCon[2][7]=6; _nbOfSonsCon[2]=8; + _sonsCon[3][0]=1; _sonsCon[3][1]=4; _sonsCon[3][2]=5; _sonsCon[3][3]=2; _sonsCon[3][4]=13; _sonsCon[3][5]=10; _sonsCon[3][6]=14; _sonsCon[3][7]=7; _nbOfSonsCon[3]=8; + _sonsCon[4][0]=2; _sonsCon[4][1]=4; _sonsCon[4][2]=5; _sonsCon[4][3]=0; _sonsCon[4][4]=14; _sonsCon[4][5]=11; _sonsCon[4][6]=12; _sonsCon[4][7]=8; _nbOfSonsCon[4]=8; + } + break; + case NORM_HEXA20: + { + _nbOfPts=20; _nbOfSons=6; _dim=3; + _sonsType[0]=NORM_QUAD8; _sonsType[1]=NORM_QUAD8; _sonsType[2]=NORM_QUAD8; _sonsType[3]=NORM_QUAD8; _sonsType[4]=NORM_QUAD8; _sonsType[5]=NORM_QUAD8; + _sonsCon[0][0]=0; _sonsCon[0][1]=1; _sonsCon[0][2]=2; _sonsCon[0][3]=3; _sonsCon[0][4]=8; _sonsCon[0][5]=9; _sonsCon[0][6]=10; _sonsCon[0][7]=11; _nbOfSonsCon[0]=8; + _sonsCon[1][0]=4; _sonsCon[1][1]=7; _sonsCon[1][2]=6; _sonsCon[1][3]=5; _sonsCon[1][4]=15; _sonsCon[1][5]=14; _sonsCon[1][6]=13; _sonsCon[1][7]=12; _nbOfSonsCon[1]=8; + _sonsCon[2][0]=0; _sonsCon[2][1]=4; _sonsCon[2][2]=5; _sonsCon[2][3]=1; _sonsCon[2][4]=16; _sonsCon[2][5]=12; _sonsCon[2][6]=17; _sonsCon[2][7]=8; _nbOfSonsCon[2]=8; + _sonsCon[3][0]=1; _sonsCon[3][1]=5; _sonsCon[3][3]=6; _sonsCon[3][3]=2; _sonsCon[3][4]=17; _sonsCon[3][5]=13; _sonsCon[3][6]=18; _sonsCon[3][7]=9;_nbOfSonsCon[3]=8; + _sonsCon[4][0]=2; _sonsCon[4][1]=6; _sonsCon[4][3]=7; _sonsCon[4][3]=3; _sonsCon[4][4]=18; _sonsCon[4][5]=14; _sonsCon[4][6]=19; _sonsCon[4][7]=10; _nbOfSonsCon[4]=8; + _sonsCon[5][0]=3; _sonsCon[5][1]=7; _sonsCon[5][3]=4; _sonsCon[5][3]=0; _sonsCon[5][4]=19; _sonsCon[5][5]=15; _sonsCon[5][6]=16; _sonsCon[5][7]=11; _nbOfSonsCon[5]=8; + } + break; + } + } + + void CellModel::fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const + { + unsigned nbOfTurnLoop=_nbOfSonsCon[sonId]; + const unsigned *sonConn=_sonsCon[sonId]; + for(unsigned i=0;i + +namespace INTERP_KERNEL +{ + /*! + * This class descibes all static elements (different from polygons and polyhedron) 3D, 2D and 1D. + */ + class CellModel + { + public: + static const unsigned MAX_NB_OF_SONS=6; + static const unsigned MAX_NB_OF_NODES_PER_ELEM=30; + private: + CellModel(NormalizedCellType type); + static void buildUniqueInstance(); + public: + static const CellModel& getCellModel(NormalizedCellType type); + //! sonId is in C format. + unsigned getDimension() const { return _dim; } + const unsigned *getNodesConstituentTheSon(unsigned sonId) const { return _sonsCon[sonId]; } + unsigned getNumberOfNodes() const { return _nbOfPts; } + unsigned getNumberOfSons() const { return _nbOfSons; } + unsigned getNumberOfNodesConstituentTheSon(unsigned sonId) const { return _nbOfSonsCon[sonId]; } + NormalizedCellType getSonType(unsigned sonId) const { return _sonsType[sonId]; } + void fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const; + private: + unsigned _dim; + unsigned _nbOfPts; + unsigned _nbOfSons; + unsigned _sonsCon[MAX_NB_OF_SONS][MAX_NB_OF_NODES_PER_ELEM]; + unsigned _nbOfSonsCon[MAX_NB_OF_SONS]; + NormalizedCellType _sonsType[MAX_NB_OF_SONS]; + static std::map _mapOfUniqueInstance; + }; +} + +#endif diff --git a/src/INTERP_KERNEL/Interpolation3D.txx b/src/INTERP_KERNEL/Interpolation3D.txx index 96cdd36b6..135bd9d75 100644 --- a/src/INTERP_KERNEL/Interpolation3D.txx +++ b/src/INTERP_KERNEL/Interpolation3D.txx @@ -131,7 +131,7 @@ namespace INTERP_KERNEL // Continue until the source region contains only one element, at which point the intersection volumes are // calculated with all the remaining target mesh elements and stored in the matrix if they are non-zero. - stack< RegionNode* > nodes; + std::stack< RegionNode* > nodes; nodes.push(firstNode); while(!nodes.empty()) @@ -171,7 +171,7 @@ namespace INTERP_KERNEL - for(typename vector< MeshElement* >::const_iterator iter = currNode->getSrcRegion().getBeginElements() ; + for(typename std::vector< MeshElement* >::const_iterator iter = currNode->getSrcRegion().getBeginElements() ; iter != currNode->getSrcRegion().getEndElements() ; ++iter) { @@ -215,7 +215,7 @@ namespace INTERP_KERNEL LOG(5, " -- Adding source elements"); int numLeftElements = 0; int numRightElements = 0; - for(typename vector*>::const_iterator iter = currNode->getSrcRegion().getBeginElements() ; + for(typename std::vector*>::const_iterator iter = currNode->getSrcRegion().getBeginElements() ; iter != currNode->getSrcRegion().getEndElements() ; ++iter) { LOG(6, " --- New target node"); diff --git a/src/INTERP_KERNEL/IntersectorHexa.hxx b/src/INTERP_KERNEL/IntersectorHexa.hxx index 5f65c6d78..9105dafbc 100644 --- a/src/INTERP_KERNEL/IntersectorHexa.hxx +++ b/src/INTERP_KERNEL/IntersectorHexa.hxx @@ -50,11 +50,11 @@ namespace INTERP_KERNEL /// pointers to the IntersectorTetra objects representing the tetrahedra /// that result from the splitting of the hexahedron - vector< IntersectorTetra* > _tetra; + std::vector< IntersectorTetra* > _tetra; /// vector of pointers to double[3] containing the coordinates of the /// (sub) - nodes - vector _nodes; + std::vector _nodes; }; diff --git a/src/INTERP_KERNEL/IntersectorHexa.txx b/src/INTERP_KERNEL/IntersectorHexa.txx index b984b480c..e671b1318 100644 --- a/src/INTERP_KERNEL/IntersectorHexa.txx +++ b/src/INTERP_KERNEL/IntersectorHexa.txx @@ -7,9 +7,6 @@ #include "IntersectorTetra.hxx" -using namespace MED_EN; -using namespace MEDMEM; - namespace INTERP_KERNEL { @@ -76,11 +73,11 @@ namespace INTERP_KERNEL template IntersectorHexa::~IntersectorHexa() { - for(typename vector< IntersectorTetra* >::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) + for(typename std::vector< IntersectorTetra* >::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) delete *iter; // free potential sub-mesh nodes that have been allocated - vector::iterator iter = _nodes.begin() + 8; + std::vector::iterator iter = _nodes.begin() + 8; while(iter != _nodes.end()) { delete[] *iter; @@ -392,7 +389,7 @@ namespace INTERP_KERNEL double IntersectorHexa::intersectSourceCell(typename MyMeshType::MyConnType srcCell) { double volume = 0.0; - for(typename vector*>::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) + for(typename std::vector*>::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) volume += (*iter)->intersectSourceCell(srcCell); return volume; } diff --git a/src/INTERP_KERNEL/IntersectorTetra.hxx b/src/INTERP_KERNEL/IntersectorTetra.hxx index 2f8753a51..c0ddd6656 100644 --- a/src/INTERP_KERNEL/IntersectorTetra.hxx +++ b/src/INTERP_KERNEL/IntersectorTetra.hxx @@ -11,9 +11,6 @@ #include #include -#include "MEDMEM_define.hxx" -#include "MEDMEM_CellModel.hxx" - using __gnu_cxx::hash_map; namespace INTERP_KERNEL diff --git a/src/INTERP_KERNEL/IntersectorTetra.txx b/src/INTERP_KERNEL/IntersectorTetra.txx index e402f5b03..b501cec45 100644 --- a/src/INTERP_KERNEL/IntersectorTetra.txx +++ b/src/INTERP_KERNEL/IntersectorTetra.txx @@ -7,6 +7,7 @@ #include "TransformedTriangle.hxx" #include "MeshUtils.hxx" #include "VectorUtils.hxx" +#include "CellModel.hxx" #include "Log.hxx" #include @@ -14,9 +15,6 @@ #include #include -using namespace MEDMEM; -using namespace MED_EN; - /// Smallest volume of the intersecting elements in the transformed space that will be returned as non-zero. /// Since the scale is always the same in the transformed space (the target tetrahedron is unitary), this number is independent of the scale of the meshes. #define SPARSE_TRUNCATION_LIMIT 1.0e-14 @@ -100,30 +98,20 @@ namespace INTERP_KERNEL } // get type of cell - unsigned char nbOfNodes4Type = _srcMesh.getNumberOfNodesOfElement(element); - // hack tony for the moment - - medGeometryElement type; - if(nbOfNodes4Type==4) - type=MED_EN::MED_TETRA4; - else if(nbOfNodes4Type==8) - type=MED_EN::MED_HEXA8; - else - std::cerr << "ca merde sec" << std::endl; - ////const medGeometryElement type = _srcMesh.getNumberOfNodesOfElement(element); - - // get cell model for the element - const CELLMODEL& cellModel= CELLMODEL_Map::retrieveCellModel(type); - + NormalizedCellType normCellType=_srcMesh.getTypeOfElement(element); + const CellModel& cellModelCell=CellModel::getCellModel(normCellType); + unsigned nbOfNodes4Type=cellModelCell.getNumberOfNodes(); // halfspace filtering bool isOutside[8] = {true, true, true, true, true, true, true, true}; bool isTargetOutside = false; // calculate the coordinates of the nodes + int *cellNodes=new int[nbOfNodes4Type]; for(int i = 0;i global numbers too, but not sure it is worth it const int globalNodeNum = getGlobalNumberOfNode(i, element, _srcMesh); + cellNodes[i]=globalNodeNum; if(_nodes.find(globalNodeNum) == _nodes.end()) { calculateNode(globalNodeNum); @@ -146,28 +134,16 @@ namespace INTERP_KERNEL if(!isTargetOutside) { - for(int i = 1 ; i <= cellModel.getNumberOfConstituents(1) ; ++i) + for(unsigned ii = 0 ; ii < cellModelCell.getNumberOfSons() ; ++ii) { - const medGeometryElement faceType = cellModel.getConstituentType(1, i); - const CELLMODEL& faceModel= CELLMODEL_Map::retrieveCellModel(faceType); - + NormalizedCellType faceType = cellModelCell.getSonType(ii); + const CellModel& faceModel=CellModel::getCellModel(faceType); assert(faceModel.getDimension() == 2); - - int faceNodes[faceModel.getNumberOfNodes()]; - - // get the nodes of the face - for(int j = 1; j <= faceModel.getNumberOfNodes(); ++j) - { - const int locNodeNum = cellModel.getNodeConstituent(1, i, j); - assert(locNodeNum >= 1); - assert(locNodeNum <= cellModel.getNumberOfNodes()); - - faceNodes[j-1] = getGlobalNumberOfNode(locNodeNum-1, element, _srcMesh); - } - + int *faceNodes=new int[faceModel.getNumberOfNodes()]; + cellModelCell.fillSonCellNodalConnectivity(ii,cellNodes,faceNodes); switch(faceType) { - case MED_EN::MED_TRIA3: + case NORM_TRI3: { // create the face key TriangleFaceKey key = TriangleFaceKey(faceNodes[0], faceNodes[1], faceNodes[2]); @@ -185,7 +161,7 @@ namespace INTERP_KERNEL } break; - case MED_EN::MED_QUAD4: + case NORM_QUAD4: // simple triangulation of faces along a diagonal : // @@ -234,9 +210,10 @@ namespace INTERP_KERNEL std::cout << "+++ Error : Only elements with triangular and quadratilateral faces are supported at the moment." << std::endl; assert(false); } + delete [] faceNodes; } } - + delete [] cellNodes; // reset if it is very small to keep the matrix sparse // is this a good idea? if(epsilonEqual(totalVolume, 0.0, SPARSE_TRUNCATION_LIMIT)) diff --git a/src/INTERP_KERNEL/Makefile.am b/src/INTERP_KERNEL/Makefile.am index 9b7306807..a2c9f5684 100644 --- a/src/INTERP_KERNEL/Makefile.am +++ b/src/INTERP_KERNEL/Makefile.am @@ -55,6 +55,7 @@ TransformedTriangle_intersect.cxx\ TransformedTriangle_math.cxx\ BoundingBox.cxx\ TetraAffineTransform.cxx\ +CellModel.cxx \ Remapper.cxx \ PointLocator.cxx diff --git a/src/INTERP_KERNEL/MeshUtils.hxx b/src/INTERP_KERNEL/MeshUtils.hxx index 596dd33f2..d3a151b79 100644 --- a/src/INTERP_KERNEL/MeshUtils.hxx +++ b/src/INTERP_KERNEL/MeshUtils.hxx @@ -9,7 +9,7 @@ namespace INTERP_KERNEL * Returns the global number of the node of an element. * (1 <= node <= no. nodes of element) * - * @param node the node for which the global number is sought (in numPol policy) + * @param node the node for which the global number is sought (ALWAYS in C mode) * @param element an element of the mesh (in numPol policy) * @param mesh a mesh * @return the node's global number so that (its coordinates in the coordinates array are at [SPACEDIM*globalNumber, SPACEDIM*globalNumber + 2] diff --git a/src/INTERP_KERNEL/NormalizedUnstructuredMesh.hxx b/src/INTERP_KERNEL/NormalizedUnstructuredMesh.hxx index ab2673f77..5d758a844 100644 --- a/src/INTERP_KERNEL/NormalizedUnstructuredMesh.hxx +++ b/src/INTERP_KERNEL/NormalizedUnstructuredMesh.hxx @@ -12,6 +12,8 @@ namespace INTERP_KERNEL typedef enum { + NORM_SEG2 = 1, + NORM_SEG3 = 2, NORM_TRI3 = 3, NORM_QUAD4 = 4, NORM_POLYGON = 5, @@ -21,7 +23,12 @@ namespace INTERP_KERNEL NORM_TETRA4 = 14, NORM_PYRA5 = 15, NORM_PENTA6 = 16, - NORM_HEXA8 = 18 + NORM_HEXA8 = 18, + NORM_TETRA10 = 20, + NORM_PYRA13 = 23, + NORM_PENTA15 = 25, + NORM_HEXA20 = 30, + NORM_POLYHED = 31 } NormalizedCellType; class GenericMesh diff --git a/src/INTERP_KERNEL/PointLocatorAlgos.txx b/src/INTERP_KERNEL/PointLocatorAlgos.txx index 32eceac26..ffe41b600 100644 --- a/src/INTERP_KERNEL/PointLocatorAlgos.txx +++ b/src/INTERP_KERNEL/PointLocatorAlgos.txx @@ -1,9 +1,8 @@ #ifndef _POINT_LOCATOR_ALGOS_TXX_ #define _POINT_LOCATOR_ALGOS_TXX_ -#include "MEDMEM_Exception.hxx" #include "InterpolationUtils.hxx" -#include "MEDMEM_CellModel.hxx" +#include "CellModel.hxx" #include "BBTree.txx" #include @@ -71,10 +70,10 @@ namespace INTERP_KERNEL{ { typedef typename MyMeshType::MyConnType ConnType; const NumberingPolicy numPol=MyMeshType::My_numPol; - vector candidates; + std::vector candidates; _tree->getElementsAroundPoint(x,candidates); - list retlist; - for (int i=0; i< candidates.size(); i++) + std::list retlist; + for(int i=0; i< candidates.size(); i++) { int ielem=candidates[i]; if (elementContainsPoint(ielem,x)) @@ -95,9 +94,10 @@ namespace INTERP_KERNEL{ const ConnType* conn=_mesh.getConnectivityPtr(); const ConnType* conn_index= _mesh.getConnectivityIndexPtr(); const ConnType* conn_elem=conn+OTT::ind2C(conn_index[i]); + NormalizedCellType type=_mesh.getTypeOfElement(OTT::indFC(i)); + const CellModel& cmType=CellModel::getCellModel(type); - - int nbnodes = conn_index[i+1]-conn_index[i]; + int nbnodes = cmType.getNumberOfNodes();//conn_index[i+1]-conn_index[i]; // with dimension 2, it suffices to check all the edges // and see if the sign of double products from the point @@ -137,32 +137,14 @@ namespace INTERP_KERNEL{ if (SPACEDIM==3) { - MED_EN::medGeometryElement elem_type; - switch (nbnodes) { - case 4 : - elem_type=MED_EN::MED_TETRA4; - break; - case 5: - elem_type=MED_EN::MED_PYRA5; - break; - case 6 : - elem_type=MED_EN::MED_PENTA6; - break; - case 8: - elem_type=MED_EN::MED_HEXA8; - break; - default: - throw MEDMEM::MEDEXCEPTION("PointLocatorAlgos : bad number of nodes in 3D locator"); - } - const MEDMEM::CELLMODEL& model=MEDMEM::CELLMODEL_Map::retrieveCellModel(elem_type); - int nbfaces = model.getNumberOfConstituents(1); + int nbfaces = cmType.getNumberOfSons(); int sign[nbfaces]; for (int iface=0; iface::ind2C(conn_elem[connface[0]-1])); - const double* BB=coords+SPACEDIM*(OTT::ind2C(conn_elem[connface[1]-1])); - const double* CC=coords+SPACEDIM*(OTT::ind2C(conn_elem[connface[2]-1])); + const unsigned* connface=cmType.getNodesConstituentTheSon(iface); + const double* AA=coords+SPACEDIM*(OTT::ind2C(conn_elem[connface[0]])); + const double* BB=coords+SPACEDIM*(OTT::ind2C(conn_elem[connface[1]])); + const double* CC=coords+SPACEDIM*(OTT::ind2C(conn_elem[connface[2]])); double Vol=triple_product(AA,BB,CC,x); if (Vol<-1e-12) @@ -172,7 +154,7 @@ namespace INTERP_KERNEL{ else sign[iface]=0; } - return decide_from_sign(sign, nbfaces); + return decide_from_sign(sign, nbfaces); } } @@ -186,10 +168,7 @@ namespace INTERP_KERNEL{ min_sign=(sign[i]max_sign)?sign[i]:max_sign; } - if (min_sign==-1 && max_sign==1) - return false; - else - return true; + return (min_sign!=-1 || max_sign!=1); } }; } diff --git a/src/INTERP_KERNEL/PolygonAlgorithms.txx b/src/INTERP_KERNEL/PolygonAlgorithms.txx index 1942b0997..fbdd36cef 100644 --- a/src/INTERP_KERNEL/PolygonAlgorithms.txx +++ b/src/INTERP_KERNEL/PolygonAlgorithms.txx @@ -7,8 +7,6 @@ #include #include -using namespace std; - namespace INTERP_KERNEL { template