From 2ee3e2b1bb704f0399172ee41d112b0383a107b2 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 13 Feb 2023 08:47:32 +0100 Subject: [PATCH] V5 : Last version of Emmanuelle --- .../GaussPoints/InterpKernelGaussCoords.cxx | 44 +++++++++---------- .../MEDCouplingBasicsTest7.py | 28 ++++-------- 2 files changed, 31 insertions(+), 41 deletions(-) diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx index be9b70a4b..3d5bc5caa 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx @@ -1326,8 +1326,8 @@ void GaussInfo::quad4cInit() devFunValue[2] = -0.25*(1.0 + gc[1]); devFunValue[3] = 0.25*(1.0 - gc[0]); - devFunValue[4] = 0.25*(1.0 + gc[0]); - devFunValue[5] = 0.25*(1.0 + gc[1]); + devFunValue[4] = 0.25*(1.0 + gc[1]); + devFunValue[5] = 0.25*(1.0 + gc[0]); devFunValue[6] = 0.25*(1.0 - gc[1]); devFunValue[7] = -0.25*(1.0 + gc[0]); @@ -3335,30 +3335,30 @@ void GaussInfo::penta18bInit() break; LOCAL_COORD_MACRO_END; - SHAPE_FUN_MACRO_BEGIN; - funValue[0] = 0.5*gc[1]*(1.0 - gc[0])*(2.0*gc[1] - 2.0 - gc[0]); - funValue[2] = 0.5*gc[2]*(1.0 - gc[0])*(2.0*gc[2] - 2.0 - gc[0]); - funValue[1] = 0.5*(gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(gc[0] + 2.0*gc[1] + 2.0*gc[2]); + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = gc[0]*gc[1]*(gc[0]-1.0)*(2.0*gc[1]-1.0)/2.0; + funValue[2] = gc[0]*gc[2]*(gc[0]-1.0)*(2.0*gc[2]-1.0)/2.0; + funValue[1] = gc[0]*(gc[0]-1.0)*(gc[2]+gc[1]-1.0)*(2.0*gc[2]+2.0*gc[1]-1.0)/2.0; - funValue[3] = 0.5*gc[1]*(1.0 + gc[0])*(2.0*gc[1] - 2.0 + gc[0]); - funValue[5] = 0.5*gc[2]*(1.0 + gc[0])*(2.0*gc[2] - 2.0 + gc[0]); - funValue[4] = 0.5*(-gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(-gc[0] + 2.0*gc[1] + 2.0*gc[2]); + funValue[3] = gc[0]*gc[1]*(gc[0]+1.0)*(2.0*gc[1]-1.0)/2.0; + funValue[5] = gc[0]*gc[2]*(gc[0]+1.0)*(2.0*gc[2]-1.0)/2.0; + funValue[4] = gc[0]*(gc[0]+1.0)*(gc[2]+gc[1]-1.0)*(2.0*gc[2]+2.0*gc[1]-1.0)/2.0; - funValue[8] = 2.0*gc[1]*gc[2]*(1.0 - gc[0]); - funValue[7] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]); - funValue[6] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]); + funValue[8] = 2.0*gc[0]*gc[1]*gc[2]*(gc[0]-1.0); + funValue[7] = -2.0*gc[0]*gc[2]*(gc[0]-1.0)*(gc[2]+gc[1]-1.0); + funValue[6] = -2.0*gc[0]*gc[1]*(gc[0]-1.0)*(gc[2]+gc[1]-1.0); - funValue[12] = gc[1]*(1.0 - gc[0]*gc[0]); - funValue[14] = gc[2]*(1.0 - gc[0]*gc[0]); - funValue[13] = (1.0 - gc[1] - gc[2])*(1.0 - gc[0]*gc[0]); + funValue[12] = -gc[1]*(gc[0]-1.0)*(gc[0]+1.0)*(2.0*gc[1]-1.0); + funValue[14] = -gc[2]*(gc[0]-1.0)*(gc[0]+1.0)*(2.0*gc[2]-1.0); + funValue[13] = -(gc[0]-1.0)*(gc[0]+1.0)*(gc[2]+gc[1]-1.0)*(2.0*gc[2]+2.0*gc[1]-1.0); - funValue[11] = 2.0*gc[1]*gc[2]*(1.0 + gc[0]); - funValue[10] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]); - funValue[9] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]); + funValue[11] = 2.0*gc[0]*gc[1]*gc[2]*(gc[0]+1.0); + funValue[10] = -2.0*gc[0]*gc[2]*(gc[0]+1.0)*(gc[2]+gc[1]-1.0); + funValue[9] = -2.0*gc[0]*gc[1]*(gc[0]+1.0)*(gc[2]+gc[1]-1.0); - funValue[17] = 4.0*gc[1]*gc[2]*(1.0 - gc[0] * gc[0]); - funValue[16] = 4.0*gc[2]*(gc[0] * gc[0] - 1) * ( gc[2] + gc[1] - 1); - funValue[15] = 4.0*gc[1]*(gc[0] * gc[0] - 1) * ( gc[2] + gc[1] - 1); + funValue[17] = -4.0*gc[1]*gc[2]*(gc[0]-1.0)*(gc[0]+1.0); + funValue[16] = 4.0*gc[2]*(gc[0]-1.0)*(gc[0]+1.0)*(gc[2]+gc[1]-1.0); + funValue[15] = 4.0*gc[1]*(gc[0]-1.0)*(gc[0]+1.0)*(gc[2]+gc[1]-1.0); SHAPE_FUN_MACRO_END; DEV_SHAPE_FUN_MACRO_BEGIN; @@ -3691,7 +3691,7 @@ void GaussInfo::hexa8DegQuad4aInit() DEV_SHAPE_FUN_MACRO_BEGIN; devFunValue[0] = -0.25*(1.0+gc[1]); - devFunValue[1] = 0.25*(1.0+gc[0]); + devFunValue[1] = 0.25*(1.0-gc[0]); devFunValue[2] = 0.0; devFunValue[3] = -0.25*(1-gc[1]); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py index c4fc83ab5..3a5cacd9f 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py @@ -1081,8 +1081,6 @@ class MEDCouplingBasicsTest7(unittest.TestCase): ref2_mc = DataArrayDouble(ref2) ; ref2_mc.rearrange(1) self.assertTrue( mvDevOfShapeFunc.isEqual( ref2_mc, 1e-12) ) -class MEDCouplingBasicsTest7(unittest.TestCase): - def testShapeFuncAndDerivative1(self): """ This test focus @@ -1120,30 +1118,26 @@ class MEDCouplingBasicsTest7(unittest.TestCase): delta_Z = der_computed[:,2]-der_deduced delta_Z.abs() self.assertTrue(delta_Z.findIdsNotInRange(-1e-5,+1e-5).empty()) - #for gt,ref_coord in [(NORM_HEXA8,[[-1.0, 1.0, 0.0], [-1.0, -1.0, 0.0], [1.0, -1.0, 0.0], [1.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])]: - #for gt,ref_coord in [(NORM_PENTA18,[[-1.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [-1.0, -0.0, 1.0], [1.0, 1.0, 0.0], [1.0, 0.0, 0.0], [1.0, 0.0, 1.0], [-1.0, 0.5, 0.0], [-1.0, 0.0, 0.5], [-1.0, 0.5, 0.5], [1.0, 0.5, 0.0], [1.0, 0.0, 0.5], [1.0, 0.5, 0.5], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.5], [0.0, 0.5, 0.5]])]: - for gt,ref_coord in [(NORM_TETRA4,[[0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0]]),(NORM_TETRA10,[[0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.5], [0.0, 0.5, 0.5], [0.5, 0.5, 0.0], [0.5, 0.0, 0.0], [0.5, 0.0, 0.5]]),(NORM_HEXA8,[[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0], [-1.0, -1.0, 1.0], [-1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, -1.0, 1.0]]),(NORM_PENTA6,[[-1.0, 1.0, 0.0], [-1.0, -1.0, 0.0], [1.0, -1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),(NORM_PENTA6,[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),(NORM_PYRA5,[[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]),(NORM_PYRA13, [[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [0.5, -0.5, 0.0], [-0.5, -0.5, 0.0], [-0.5, 0.5, 0.0], [0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, -0.5, 0.5], [-0.5, 0.0, 0.5], [0.0, 0.5, 0.5]]),(NORM_PENTA15,[[-1.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [-1.0, -0.0, 1.0], [1.0, 1.0, 0.0], [1.0, 0.0, 0.0], [1.0, 0.0, 1.0], [-1.0, 0.5, 0.0], [-1.0, 0.0, 0.5], [-1.0, 0.5, 0.5], [1.0, 0.5, 0.0], [1.0, 0.0, 0.5], [1.0, 0.5, 0.5], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]),(NORM_HEXA20,[[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0], [-1.0, -1.0, 1.0], [-1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, -1.0, 1.0], [-1.0, 0.0, -1.0], [0.0, 1.0, -1.0], [1.0, 0.0, -1.0], [0.0, -1.0, -1.0], [-1.0, 0.0, 1.0], [0.0, 1.0, 1.0], [1.0, 0.0, 1.0], [0.0, -1.0, 1.0], [-1.0, -1.0, 0.0], [-1.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, -1.0, 0.0]])]: # type of cell for which derivatives are implemented - print(".... {} ".format(MEDCouplingUMesh.GetReprOfGeometricType(gt))) + + for gt,ref_coord in [(NORM_TETRA4,[[0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0]]),(NORM_TETRA10,[[0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.5], [0.0, 0.5, 0.5], [0.5, 0.5, 0.0], [0.5, 0.0, 0.0], [0.5, 0.0, 0.5]]),(NORM_HEXA8,[[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0], [-1.0, -1.0, 1.0], [-1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, -1.0, 1.0]]),(NORM_HEXA8,[[-1.0, 1.0, 0.0], [-1.0, -1.0, 0.0], [1.0, -1.0, 0.0], [1.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),(NORM_HEXA8,[[-1.0, -1.0, 0.0], [-1.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, -1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),(NORM_PENTA6,[[-1.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [-1.0, -0.0, 1.0], [1.0, 1.0, 0.0], [1.0, 0.0, 0.0], [1.0, 0.0, 1.0]]),(NORM_PENTA6,[[-1.0, 1.0, 0.0], [-1.0, -1.0, 0.0], [1.0, -1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),(NORM_PENTA6,[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]),(NORM_PYRA5,[[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]),(NORM_PYRA13, [[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [0.5, -0.5, 0.0], [-0.5, -0.5, 0.0], [-0.5, 0.5, 0.0], [0.5, 0.5, 0.0], [0.5, 0.0, 0.5], [0.0, -0.5, 0.5], [-0.5, 0.0, 0.5], [0.0, 0.5, 0.5]]),(NORM_PENTA15,[[-1.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [-1.0, -0.0, 1.0], [1.0, 1.0, 0.0], [1.0, 0.0, 0.0], [1.0, 0.0, 1.0], [-1.0, 0.5, 0.0], [-1.0, 0.0, 0.5], [-1.0, 0.5, 0.5], [1.0, 0.5, 0.0], [1.0, 0.0, 0.5], [1.0, 0.5, 0.5], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]),(NORM_PENTA18,[[-1.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [-1.0, -0.0, 1.0], [1.0, 1.0, 0.0], [1.0, 0.0, 0.0], [1.0, 0.0, 1.0], [-1.0, 0.5, 0.0], [-1.0, 0.0, 0.5], [-1.0, 0.5, 0.5], [1.0, 0.5, 0.0], [1.0, 0.0, 0.5], [1.0, 0.5, 0.5], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.5], [0.0, 0.5, 0.5]]),(NORM_HEXA20,[[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0], [-1.0, -1.0, 1.0], [-1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, -1.0, 1.0], [-1.0, 0.0, -1.0], [0.0, 1.0, -1.0], [1.0, 0.0, -1.0], [0.0, -1.0, -1.0], [-1.0, 0.0, 1.0], [0.0, 1.0, 1.0], [1.0, 0.0, 1.0], [0.0, -1.0, 1.0], [-1.0, -1.0, 0.0], [-1.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, -1.0, 0.0]])]: # type of cell for which derivatives are implemented + der_computed = GetDerivative(ref_coord,vec) der_computed.rearrange(3) der_deduced = ( GetShapeFunc(ref_coord,[vec[0]+eps,vec[1],vec[2]])-GetShapeFunc(ref_coord,vec) ) / eps delta_X = der_computed[:,0]-der_deduced delta_X.abs() - print(delta_X.getValues()) - #self.assertTrue(delta_X.findIdsNotInRange(-1e-5,+1e-5).empty()) + self.assertTrue(delta_X.findIdsNotInRange(-1e-4,+1e-4).empty()) der_deduced = ( GetShapeFunc(ref_coord,[vec[0],vec[1]+eps,vec[2]])-GetShapeFunc(ref_coord,vec) ) / eps delta_Y = der_computed[:,1]-der_deduced delta_Y.abs() - print(delta_Y.getValues()) - #self.assertTrue(delta_Y.findIdsNotInRange(-1e-5,+1e-5).empty()) + self.assertTrue(delta_Y.findIdsNotInRange(-1e-5,+1e-5).empty()) der_deduced = ( GetShapeFunc(ref_coord,[vec[0],vec[1],vec[2]+eps])-GetShapeFunc(ref_coord,vec) ) / eps delta_Z = der_computed[:,2]-der_deduced delta_Z.abs() - print(delta_Z.getValues()) - #self.assertTrue(delta_Z.findIdsNotInRange(-1e-5,+1e-5).empty()) + self.assertTrue(delta_Z.findIdsNotInRange(-1e-5,+1e-5).empty()) # 2D cells vec = [0.64,0.2] @@ -1165,24 +1159,20 @@ class MEDCouplingBasicsTest7(unittest.TestCase): self.assertTrue(delta_Y.findIdsNotInRange(-1e-4,+1e-4).empty()) # B version of TRI6, QUAD4 and QUAD8 - #for gt,ref_coord in [(NORM_QUAD4,[[-1., -1.], [-1., 1.], [1., 1.], [1., -1.]])]: for gt,ref_coord in [(NORM_TRI3,[[0.0, 0.0], [1.0, 0.0], [0.0, 1.0]]),(NORM_TRI6,[[0., 0.], [1., 0.], [0., 1.], [0.5, 0.], [0.5, 0.5], [0., 0.5]]), - (NORM_QUAD4,[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]]),(NORM_QUAD4,[[-1., 0.], [1., 0.], [0., 0.], [0., 0.]]),(NORM_QUAD8,[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.], [0., -1.], [1., 0.], [0., 1.], [-1., 0.]])]: - print(".... {} ".format(MEDCouplingUMesh.GetReprOfGeometricType(gt))) + (NORM_QUAD4,[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]]),(NORM_QUAD4,[[-1., -1.], [-1., 1.], [1., 1.], [1., -1.]]),(NORM_QUAD4,[[-1., 0.], [1., 0.], [0., 0.], [0., 0.]]),(NORM_QUAD8,[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.], [0., -1.], [1., 0.], [0., 1.], [-1., 0.]])]: der_computed = GetDerivative(ref_coord,vec) der_computed.rearrange(2) der_deduced = ( GetShapeFunc(ref_coord,[vec[0]+eps,vec[1]])-GetShapeFunc(ref_coord,vec) ) / eps delta_X = der_computed[:,0]-der_deduced delta_X.abs() - print(delta_X.getValues()) - #self.assertTrue(delta_X.findIdsNotInRange(-1e-5,+1e-5).empty()) + self.assertTrue(delta_X.findIdsNotInRange(-1e-5,+1e-5).empty()) der_deduced = ( GetShapeFunc(ref_coord,[vec[0],vec[1]+eps])-GetShapeFunc(ref_coord,vec) ) / eps delta_Y = der_computed[:,1]-der_deduced delta_Y.abs() - print(delta_Y.getValues()) - #self.assertTrue(delta_Y.findIdsNotInRange(-1e-5,+1e-5).empty()) + self.assertTrue(delta_Y.findIdsNotInRange(-1e-5,+1e-5).empty()) # 1D cells vec = [0.64] -- 2.39.2