From 89a73adf4215897b01c1b191d9d5076dc9ac495c Mon Sep 17 00:00:00 2001 From: DUC ANH HOANG Date: Wed, 20 Apr 2022 10:13:12 +0200 Subject: [PATCH] [EDF25207] integrate the commit ee33c67ce54b04a in V9_6_BR --- src/INTERP_KERNEL/MeshElement.hxx | 6 ++-- src/INTERP_KERNEL/MeshElement.txx | 4 +-- .../MEDCouplingBasicsTest7.py | 32 +++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/INTERP_KERNEL/MeshElement.hxx b/src/INTERP_KERNEL/MeshElement.hxx index 9c2ca842a..990f9b9ef 100644 --- a/src/INTERP_KERNEL/MeshElement.hxx +++ b/src/INTERP_KERNEL/MeshElement.hxx @@ -22,6 +22,8 @@ #include "BoundingBox.hxx" +#include + namespace INTERP_KERNEL { @@ -42,7 +44,7 @@ namespace INTERP_KERNEL ConnType getIndex() const { return _index; } - unsigned char getNumberOfNodes() const { return _number; } + std::uint16_t getNumberOfNodes() const { return _number; } const BoundingBox* getBoundingBox() const { return _box; } @@ -56,7 +58,7 @@ namespace INTERP_KERNEL /// global number of the element const ConnType _index; - const unsigned char _number; + const std::uint16_t _number; /// bounding box of the element - does not change after having been initialised BoundingBox* _box; diff --git a/src/INTERP_KERNEL/MeshElement.txx b/src/INTERP_KERNEL/MeshElement.txx index d6ed35ac4..0a350c11d 100755 --- a/src/INTERP_KERNEL/MeshElement.txx +++ b/src/INTERP_KERNEL/MeshElement.txx @@ -39,11 +39,11 @@ namespace INTERP_KERNEL template template MeshElement::MeshElement(const ConnType index, const MyMeshType& mesh) - : _index(index), _number((unsigned char)mesh.getNumberOfNodesOfElement(OTT::indFC(index))), _box(0) + : _index(index), _number( static_cast(mesh.getNumberOfNodesOfElement(OTT::indFC(index))) ), _box(nullptr) { const double**vertices = new const double*[_number]; - for(unsigned char i = 0 ; i < _number ; ++i) + for(std::uint16_t i = 0 ; i < _number ; ++i) vertices[i] = getCoordsOfNode(i , OTT::indFC(index), mesh); // create bounding box diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py index 3e480e24b..bd15a8645 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py @@ -897,6 +897,38 @@ class MEDCouplingBasicsTest7(unittest.TestCase): f.setArray(DataArrayDouble(18*[0.])) self.assertTrue(f.getLocalizationOfDiscr().isEqual(coo[conn],1e-10)) + def testBugWithPolyhedInterpWithMoreThan255Nodes(self): + """ + [EDF25207] : Check interpolation containing polyhedron with more than 255 nodes is OK at bbox computation stage + """ + n = 8 + arr = DataArrayDouble(n) ; arr.iota() + m = MEDCouplingCMesh() + m.setCoords(arr,arr,arr) + m = m.buildUnstructured() + skin = m.computeSkin() + skin.zipCoords() + # check that skin contains more than 2**8-1 node to reveal bug + self.assertTrue(skin.getNumberOfNodes()>255) + # Build a single polyhedron cell from skin + skin1 = MEDCoupling1SGTUMesh(skin) + conn = skin1.getNodalConnectivity() + conn.rearrange( MEDCouplingUMesh.GetNumberOfNodesOfGeometricType(skin1.getCellModelEnum()) ) + connPolyhed = conn.changeNbOfComponents(MEDCouplingUMesh.GetNumberOfNodesOfGeometricType(skin1.getCellModelEnum())+1,-1) + connPolyhed.rearrange(1) + connPolyhed.popBackSilent() + meshSinglePolyhed = MEDCouplingUMesh("",3) + meshSinglePolyhed.allocateCells() + meshSinglePolyhed.insertNextCell(NORM_POLYHED,connPolyhed.getValues()) + meshSinglePolyhed.setCoords( skin1.getCoords() ) + + rem = MEDCouplingRemapper() + rem.prepare(meshSinglePolyhed,m,"P0P0") + res = rem.getCrudeMatrix() + self.assertTrue( all([len(elt)==1 for elt in res]) ) + self.assertTrue( all([elt[0]>0.99 and elt[0]<1.01 for elt in res]) ) + + pass if __name__ == '__main__': -- 2.39.2