From: Anthony Geay Date: Thu, 10 Aug 2023 06:38:22 +0000 (+0200) Subject: [EDF27859] : all tests OK X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=957b4a98e72e6792b566c431280d2aee7dd22bb6;p=tools%2Fmedcoupling.git [EDF27859] : all tests OK --- diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx index 858b253da..844c3982d 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx @@ -126,17 +126,17 @@ namespace INTERP_KERNEL } } else - { + {// for HEXA and GENERAL_24 no need to use subsplitting into dual mesh for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) { releaseArrays(); ConnType nbOfNodesS=Intersector3D::_src_mesh.getNumberOfNodesOfElement(OTT::indFC(*iterCellS)); - _split.splitTargetCell(*iterCellS,nbOfNodesS,_tetra); + _split.splitTargetCell2(*iterCellS,_tetra); for(typename std::vector*>::const_iterator iter = _tetra.cbegin(); iter != _tetra.cend(); ++iter) { double volume = std::abs( (*iter)->intersectSourceCell(targetCell) ); // node #0 is for internal node node #1 is for the node at the middle of the face - ConnType sourceNode0( (*iter)->getId(2) ), sourceNode1( (*iter)->getId(3) ); + ConnType sourceNode0( (*iter)->getId(0) ), sourceNode1( (*iter)->getId(1) ); AddContributionInRow(resRow,OTT::indFC(sourceNode0),volume/2.); AddContributionInRow(resRow,OTT::indFC(sourceNode1),volume/2.); } diff --git a/src/INTERP_KERNEL/SplitterTetra.hxx b/src/INTERP_KERNEL/SplitterTetra.hxx index b65bb4994..5a5e3a559 100644 --- a/src/INTERP_KERNEL/SplitterTetra.hxx +++ b/src/INTERP_KERNEL/SplitterTetra.hxx @@ -551,6 +551,7 @@ namespace INTERP_KERNEL void fiveSplit(const int* const subZone, typename std::vector< SplitterTetra* >& tetra);//to suppress void sixSplit(const int* const subZone, typename std::vector< SplitterTetra* >& tetra);//to suppress void calculateGeneral24Tetra(typename std::vector< SplitterTetra* >& tetra);//to suppress + void calculateGeneral24TetraOld(typename std::vector< SplitterTetra* >& tetra); void calculateGeneral48Tetra(typename std::vector< SplitterTetra* >& tetra);//to suppress void splitPyram5(typename std::vector< SplitterTetra* >& tetra);//to suppress void splitConvex(typename MyMeshTypeT::MyConnType targetCell,//to suppress @@ -560,6 +561,9 @@ namespace INTERP_KERNEL inline const double* getCoordsOfSubNode2(typename MyMeshTypeT::MyConnType node, typename MyMeshTypeT::MyConnType& nodeId);//to suppress //template inline void calcBarycenter(typename MyMeshTypeT::MyConnType n, double* barycenter, const int* pts);//to suppress + private: + void sixSplitGen(const int* const subZone, typename std::vector< SplitterTetra* >& tetra, std::function func); + void calculateGeneral24TetraGen(typename std::vector< SplitterTetra* >& tetra, std::function func); private: const MyMeshTypeT& _target_mesh; const MyMeshTypeS& _src_mesh; diff --git a/src/INTERP_KERNEL/SplitterTetra.txx b/src/INTERP_KERNEL/SplitterTetra.txx index a0da9c3c0..94b5b1624 100644 --- a/src/INTERP_KERNEL/SplitterTetra.txx +++ b/src/INTERP_KERNEL/SplitterTetra.txx @@ -1021,7 +1021,7 @@ namespace INTERP_KERNEL case GENERAL_24: { - calculateGeneral24Tetra(tetra); + calculateGeneral24TetraOld(tetra); } break; @@ -1074,6 +1074,17 @@ namespace INTERP_KERNEL } } + template + void SplitterTetra2::sixSplit(const int* const subZone, typename std::vector< SplitterTetra* >& tetra) + { + sixSplitGen(subZone,tetra,[](SplitterTetra2& obj, typename MyMeshTypeS::MyConnType& conn, const double *&coords) + { + typename MyMeshTypeS::MyConnType realConn; + coords = obj.getCoordsOfSubNode2(conn,realConn); + conn = realConn; + }); + } + /** * Splits the hexahedron into six tetrahedra. * This method adds six SplitterTetra objects to the vector tetra. @@ -1082,7 +1093,7 @@ namespace INTERP_KERNEL * splitting to be reused on the subzones of the GENERAL_* types of splitting */ template - void SplitterTetra2::sixSplit(const int* const subZone, typename std::vector< SplitterTetra* >& tetra) + void SplitterTetra2::sixSplitGen(const int* const subZone, typename std::vector< SplitterTetra* >& tetra, std::function func) { for(int i = 0; i < 6; ++i) { @@ -1091,24 +1102,46 @@ namespace INTERP_KERNEL for(int j = 0; j < 4; ++j) { conn[j] = subZone[SPLIT_NODES_6[4*i+j]]; - typename MyMeshTypeS::MyConnType realConn; - nodes[j] = getCoordsOfSubNode2(conn[j],realConn); - conn[j] = realConn; + func(*this,conn[j],nodes[j]); } SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); tetra.push_back(t); } } + /** + * Version of calculateGeneral24Tetra connectivity aware for P1P0 and P0P1 + */ + template + void SplitterTetra2::calculateGeneral24Tetra(typename std::vector< SplitterTetra* >& tetra) + { + calculateGeneral24TetraGen(tetra,[](SplitterTetra2& obj, typename MyMeshTypeS::MyConnType conn[4], const double* nodes[4]) { + typename MyMeshTypeS::MyConnType realConn; + nodes[2] = obj.getCoordsOfSubNode2(conn[2],realConn); conn[2] = realConn; + nodes[3] = obj.getCoordsOfSubNode2(conn[3],realConn); conn[3] = realConn; + }); + } + + /*! + * Version for 3D2DP0P0 + */ + template + void SplitterTetra2::calculateGeneral24TetraOld(typename std::vector< SplitterTetra* >& tetra) + { + calculateGeneral24TetraGen(tetra,[](SplitterTetra2& obj, typename MyMeshTypeS::MyConnType conn[4], const double* nodes[4]) { + nodes[2] = obj.getCoordsOfSubNode(conn[2]); + nodes[3] = obj.getCoordsOfSubNode(conn[3]); + }); + } + /** * Splits the hexahedron into 24 tetrahedra. * The splitting is done by combining the barycenter of the tetrahedron, the barycenter of each face * and the nodes of each edge of the face. This creates 6 faces * 4 edges / face = 24 tetrahedra. * The submesh nodes introduced are the barycenters of the faces and the barycenter of the cell. - * */ template - void SplitterTetra2::calculateGeneral24Tetra(typename std::vector< SplitterTetra* >& tetra) + void SplitterTetra2::calculateGeneral24TetraGen(typename std::vector< SplitterTetra* >& tetra, std::function func) { // The two nodes of the original mesh cell used in each tetrahedron. // The tetrahedra all have nodes (cellCenter, faceCenter, edgeNode1, edgeNode2) @@ -1119,7 +1152,6 @@ namespace INTERP_KERNEL typename MyMeshTypeS::MyConnType conn[4]; // get the cell center conn[0] = 14; - typename MyMeshTypeS::MyConnType realConn; nodes[0] = getCoordsOfSubNode(conn[0]); for(int faceCenterNode = 8; faceCenterNode < 14; ++faceCenterNode) @@ -1132,16 +1164,13 @@ namespace INTERP_KERNEL const int row = 4*(faceCenterNode - 8) + j; conn[2] = TETRA_EDGES_GENERAL_24[2*row]; conn[3] = TETRA_EDGES_GENERAL_24[2*row + 1]; - nodes[2] = getCoordsOfSubNode2(conn[2],realConn); conn[2] = realConn; - nodes[3] = getCoordsOfSubNode2(conn[3],realConn); conn[3] = realConn; - + func(*this,conn,nodes); SplitterTetra* t = new SplitterTetra(_src_mesh, nodes, conn); tetra.push_back(t); } } } - /** * Splits the hexahedron into 48 tetrahedra. * The splitting is done by introducing the midpoints of all the edges @@ -1155,7 +1184,9 @@ namespace INTERP_KERNEL { for(int i = 0; i < 8; ++i) { - sixSplit(GENERAL_48_SUBZONES+8*i,tetra); + sixSplitGen(GENERAL_48_SUBZONES+8*i,tetra,[](SplitterTetra2& obj, typename MyMeshTypeS::MyConnType& conn, const double *&coords){ + coords = obj.getCoordsOfSubNode(conn); + }); } } diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index ed9e22971..c5221bbaa 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -1672,7 +1672,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): expectedMatrix0 = [{10: 503624.09065889206, 11: 100868.41855508549, 12: 503863.42469772906, 13: 100629.0845162416, 14: 100629.08451623631, 15: 503863.4246977626, 16: 100868.418555101, 17: 503624.0906588909}] expectedMatrix1 = [{10: 604492.509213978, 11: 201736.8371101737, 12: 201736.83711016813, 13: 201497.50307132734, 14: 201258.16903247262, 15: 201497.50307133005, 16: 604492.5092140044, 17: 201258.16903247265}] - expectedMatrix2 = [{10: 251707.3366874401, 11: 252036.42099087787, 12: 302440.7135135655, 13: 302051.7957004154, 14: 302081.71245527605, 15: 302410.79675872216, 16: 352815.0892814113, 17: 352426.17146825284}] + expectedMatrix2 = [{10: 302066.754077835, 11: 302425.7551361466, 12: 302425.7551361466, 13: 302066.754077835, 14: 302066.7540778395, 15: 302425.7551361595, 16: 302425.7551361595, 17: 302066.75407783955}] for sp,expectedMatrix in [ (PLANAR_FACE_5,expectedMatrix0),(PLANAR_FACE_6,expectedMatrix1),(GENERAL_24,expectedMatrix2)]: remap = MEDCouplingRemapper() remap.setSplittingPolicy( sp )