# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2014 CEA/DEN, EDF R&D
+# Copyright (C) 2007-2023 CEA, EDF
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from MEDCoupling import *
+
+import sys
+from medcoupling import *
class MEDCouplingDataForTest:
def build2DTargetMesh_1(cls):
myCoords.setValues(targetCoords,9,2);
targetMesh.setCoords(myCoords);
return targetMesh;
-
+
def build2DSourceMesh_1(cls):
sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
sourceConn=[0,3,1,0,2,3]
myCoords.setValues(sourceCoords,4,2);
sourceMesh.setCoords(myCoords);
return sourceMesh;
-
+
def build3DTargetMesh_1(cls):
targetCoords=[ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
targetMesh=MEDCouplingUMesh.New();
targetMesh.setMeshDimension(3);
targetMesh.allocateCells(12);
- for i in xrange(8):
+ for i in range(8):
targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*i+8]);
pass
targetMesh.finishInsertingCells();
myCoords.setValues(sourceCoords,9,3);
sourceMesh.setCoords(myCoords);
return sourceMesh;
-
+
def build3DSurfTargetMesh_1(self):
targetCoords=[-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5]
30,41,31,33,45,56,46,48, 31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47,
31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51,
41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53,
- 37,42,44,43,52,57,59,58]
+ 37,42,44,43,52,57,59,58]
conn2=[7,12,14,13, 11,8,7,4,2,1, 13,10,9,6, 1,6,5,3, 1,2,4,7,13,6, 0,11,1,3]
#
ret=MEDCouplingUMesh.New();
mesh2D.finishInsertingCells();
mesh2D.setCoords(myCoords);
return ret,mesh2D
-
+
def buildCU1DMesh_U(self):
coords=[ 0.0, 0.3, 0.75, 1.0 ]
conn=[ 0,1, 1,2, 2,3 ]
targetMesh=MEDCouplingUMesh.New();
targetMesh.setMeshDimension(3);
targetMesh.allocateCells(12);
- for i in xrange(8):
+ for i in range(8):
targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*(i+1)]);
pass
targetMesh.finishInsertingCells();
myCoords.setValues(targetCoords,9,2);
targetMesh.setCoords(myCoords);
return targetMesh;
-
+
def build1DSourceMesh_2(cls):
ret=MEDCouplingUMesh.New("1DSourceMesh",1);
ret.allocateCells(4);
conn=[0,1,2,3,1,2,3,4]
- for i in xrange(4):
+ for i in range(4):
ret.insertNextCell(NORM_SEG2,2,conn[2*i:2*i+2]);
pass
ret.finishInsertingCells();
myCoords=DataArrayDouble.New();
myCoords.setValues(coords,11,2);
ret.setCoords(myCoords);
- ret.checkCoherency();
+ ret.checkConsistencyLight();
return ret;
def build2DTargetMesh_4(cls):
15,24,25,16,12,21,22,13,
16,25,26,17,13,22,23,14];
mesh.allocateCells(8);
- for i in xrange(8):
+ for i in range(8):
mesh.insertNextCell(NORM_HEXA8,8,conn[8*i:8*(i+1)])
pass
mesh.finishInsertingCells();
mesh.setCoords(coo);
mesh2.setCoords(coo);
mesh.allocateCells(16);
- for i in xrange(12):
+ for i in range(12):
mesh.insertNextCell(NORM_TETRA4,4,conn[4*i:4*i+4])
pass
mesh.insertNextCell(NORM_PYRA5,5,conn[48:53])
#[1,34,29,23,41,32]
conn2=[0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9]
mesh2.allocateCells(6);
- for i in xrange(4):
+ for i in range(4):
mesh2.insertNextCell(NORM_TRI3,3,conn2[3*i:3*i+3])
pass
mesh2.insertNextCell(NORM_QUAD4,4,conn2[12:16])
mesh2.insertNextCell(NORM_QUAD4,4,conn2[16:20])
mesh2.finishInsertingCells();
return [mesh,mesh2]
-
+
# 2D usecase1 for interpolation Gauss Pt-> Gauss Pt. Coming from ASTER : Please, do not touch
def buildFieldOnGauss_1(self):
coo=DataArrayDouble([1.0,0.0,1.33333333333333,0.0,1.66666666666667,0.0,0.923879532511287,0.38268343236509006,1.23183937668172,0.510244576486786,1.53979922085214,0.6378057206084831,2.0,0.0,1.8477590650225701,0.7653668647301801,0.9428090415820631,0.9428090415820631,1.1785113019775801,1.1785113019775801,1.4142135623731,1.41421356237309,0.707106781186548,0.707106781186547,0.38268343236509006,0.923879532511287,0.510244576486786,1.23183937668172,0.6378057206084831,1.53979922085214,0.7653668647301801,1.8477590650225701,3.1550283219328204e-17,1.33333333333333,1.16009632455949e-17,1.66666666666667,-2.7620050344068196e-16,2.0,-1.3810025172034098e-16,1.0,-2.0,0.0,-1.53979922085214,0.6378057206084831,-1.66666666666667,0.0,-1.33333333333333,0.0,-0.923879532511287,0.38268343236509006,-1.8477590650225701,0.7653668647301801,-0.9428090415820631,0.9428090415820631,-1.23183937668172,0.510244576486786,-1.83333333333333,0.0,-1.6937791429373599,0.701586292669331,-1.5,0.0,-1.30771370720431,0.26012042935483803,-1.16666666666667,0.0,-1.0778594545965,0.44646400442593803,-1.38578268717091,0.9259503883660041,-1.38581929876693,0.574025148547635,-1.06066017177982,1.06066017177982,-0.8314696123025451,0.5555702330196021,-1.0,0.0,-1.1785113019775801,1.1785113019775801,-0.707106781186548,0.707106781186547,-1.63464213400538,0.325150536693547,-1.9615705608064598,0.390180644032256,-1.47117792060485,0.292635483024192,-0.9807852804032301,0.19509032201612803,-1.524360955888,1.0185454272026,-1.2963624321753402,1.2963624321753402,-1.10862614973673,0.740760310692803,-0.970047881019636,0.6481652718562021,-0.824957911384305,0.824957911384305,-1.4142135623731,1.41421356237309,-1.7981063474059198,0.357665590362902,-1.1442494938037702,0.227605375685483,-1.66293922460509,1.1111404660392,-1.24720441845382,0.833355349529403,-0.7653668647301801,1.8477590650225701,-0.6378057206084831,1.53979922085214,-0.510244576486786,1.23183937668172,-0.701586292669331,1.6937791429373599,-0.574025148547635,1.38581929876693,-0.44646400442593803,1.0778594545965,-0.38268343236509006,0.923879532511287,-0.9259503883660041,1.38578268717091,-0.740760310692803,1.10862614973673,-0.5555702330196021,0.8314696123025451,-0.325150536693547,1.63464213400538,-0.26012042935483803,1.30771370720431,-0.19509032201612803,0.9807852804032301,1.6805133673525298e-18,1.83333333333333,-2.4643915380595496e-16,1.5,-1.4799359654427099e-16,1.16666666666667,-1.1111404660392,1.66293922460509,-0.39018064403225705,1.9615705608064598],73,2)
m.setCoords(coo)
m.allocateCells()
conn=[[11,8,13],[11,13,12],[8,9,13],[9,14,13],[9,10,15],[9,15,14],[12,13,19],[13,16,19],[13,14,17],[13,17,16],[14,15,17],[15,18,17],[0,1,4,3],[1,2,5,4],[2,6,7,5],[3,4,8,11],[4,5,9,8],[5,7,10,9],[20,22,21,28,41,51],[21,25,20,29,42,51],[22,23,21,30,43,41],[23,27,21,31,35,43],[23,38,24,32,44,52],[24,27,23,33,31,52],[25,21,50,29,45,53],[21,39,50,34,46,45],[21,27,26,35,47,54],[26,39,21,36,34,54],[27,24,26,33,48,47],[24,40,26,37,49,48],[50,39,56,55,46,62,58,71],[39,26,57,56,36,63,59,62],[26,40,61,57,49,64,60,63],[55,56,17,18,58,65,68,72],[56,57,16,17,59,66,69,65],[57,61,19,16,60,67,70,66]]
- for i in xrange(0,12):
+ for i in range(0, 12):
m.insertNextCell(NORM_TRI3,conn[i])
pass
- for i in xrange(12,18):
+ for i in range(12, 18):
m.insertNextCell(NORM_QUAD4,conn[i])
pass
- for i in xrange(18,30):
+ for i in range(18, 30):
m.insertNextCell(NORM_TRI6,conn[i])
pass
- for i in xrange(30,36):
+ for i in range(30, 36):
m.insertNextCell(NORM_QUAD8,conn[i])
pass
- fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH1RB") ; fff.setNature(ConservativeVolumic)
+ fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH1RB") ; fff.setNature(IntensiveMaximum)
fff.setMesh(m)
- fff.setGaussLocalizationOnCells(range(0,12),[0.,0.,1.,0.,0.,1.],[0.3333333333333333,0.3333333333333333],[0.5])
- fff.setGaussLocalizationOnCells(range(12,18),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.])
- fff.setGaussLocalizationOnCells(range(18,30),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666])
- fff.setGaussLocalizationOnCells(range(30,36),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234])
+ fff.setGaussLocalizationOnCells(list(range(0, 12)), [0., 0., 1., 0., 0., 1.], [0.3333333333333333, 0.3333333333333333], [0.5])
+ fff.setGaussLocalizationOnCells(list(range(12, 18)), [-1., -1., 1., -1., 1., 1., -1., 1.], [-0.577350269189626, -0.577350269189626, 0.577350269189626, -0.577350269189626, 0.577350269189626, 0.577350269189626, -0.577350269189626, 0.577350269189626], [1., 1., 1., 1.])
+ fff.setGaussLocalizationOnCells(list(range(18, 30)), [0., 0., 1., 0., 0., 1., 0.5, 0., 0.5, 0.5, 0., 0.5], [0.16666666666666666, 0.16666666666666666, 0.6666666666666666, 0.16666666666666666, 0.16666666666666666, 0.6666666666666666], [0.16666666666666666, 0.16666666666666666, 0.16666666666666666])
+ fff.setGaussLocalizationOnCells(list(range(30, 36)), [-1., -1., 1., -1., 1., 1., -1., 1., 0., -1., 1., 0., 0., 1., -1., 0.], [-0.774596669241483, -0.774596669241483, 0.774596669241483, -0.774596669241483, 0.774596669241483, 0.774596669241483, -0.774596669241483, 0.774596669241483, 0.0, -0.774596669241483, 0.774596669241483, 0.0, 0.0, 0.774596669241483, -0.774596669241483, 0.0, 0.0, 0.0], [0.30864197530864196, 0.30864197530864196, 0.30864197530864196, 0.30864197530864196, 0.49382716049382713, 0.49382716049382713, 0.49382716049382713, 0.49382716049382713, 0.7901234567901234])
return MEDCouplingFieldTemplate(fff)
# 2D usecase2 for interpolation Gauss Pt-> Gauss Pt. Coming from ASTER : Please, do not touch
m.setCoords(coo)
m.allocateCells(0)
conn=[[198,194,200],[198,200,199],[194,195,200],[195,201,200],[195,196,202],[195,202,201],[196,197,202],[197,203,202],[199,200,205],[199,205,204],[200,201,205],[201,206,205],[201,202,207],[201,207,206],[202,203,207],[203,208,207],[204,205,210],[204,210,209],[205,206,210],[206,211,210],[206,207,212],[206,212,211],[207,208,212],[208,213,212],[209,210,215],[209,215,214],[210,211,215],[211,216,215],[211,212,217],[211,217,216],[212,213,217],[213,218,217],[214,215,157],[214,157,158],[215,216,157],[216,156,157],[216,217,155],[216,155,156],[217,218,155],[218,163,155],[169,170,174,173],[170,171,175,174],[171,172,176,175],[172,189,190,176],[173,174,178,177],[174,175,179,178],[175,176,180,179],[176,190,191,180],[177,178,182,181],[178,179,183,182],[179,180,184,183],[180,191,192,184],[181,182,186,185],[182,183,187,186],[183,184,188,187],[184,192,193,188],[185,186,194,198],[186,187,195,194],[187,188,196,195],[188,193,197,196],[0,2,1,27,62,89],[1,7,0,28,63,89],[2,3,1,29,64,62],[3,9,1,30,36,64],[3,5,4,31,65,90],[4,9,3,32,30,90],[5,6,4,33,66,65],[6,11,4,34,39,66],[7,1,8,28,67,91],[8,12,7,35,68,91],[1,9,8,36,69,67],[9,14,8,37,42,69],[9,4,10,32,70,92],[10,14,9,38,37,92],[4,11,10,39,71,70],[11,16,10,40,45,71],[12,8,13,35,72,93],[13,17,12,41,73,93],[8,14,13,42,74,72],[14,19,13,43,48,74],[14,10,15,38,75,94],[15,19,14,44,43,94],[10,16,15,45,76,75],[16,21,15,46,51,76],[17,13,18,41,77,95],[18,22,17,47,78,95],[13,19,18,48,79,77],[19,24,18,49,54,79],[19,15,20,44,80,96],[20,24,19,50,49,96],[15,21,20,51,81,80],[21,26,20,52,57,81],[22,18,23,47,82,97],[23,59,22,53,83,97],[18,24,23,54,84,82],[24,60,23,55,85,84],[24,20,25,50,86,98],[25,60,24,56,55,98],[20,26,25,57,87,86],[26,61,25,58,88,87],[59,23,100,99,53,135,115,164],[23,60,101,100,85,136,116,135],[60,25,102,101,56,137,117,136],[25,61,131,102,88,138,118,137],[99,100,104,103,115,139,119,165],[100,101,105,104,116,140,120,139],[101,102,106,105,117,141,121,140],[102,131,132,106,118,142,122,141],[103,104,108,107,119,143,123,166],[104,105,109,108,120,144,124,143],[105,106,110,109,121,145,125,144],[106,132,133,110,122,146,126,145],[107,108,112,111,123,147,127,167],[108,109,113,112,124,148,128,147],[109,110,114,113,125,149,129,148],[110,133,134,114,126,150,130,149],[111,112,155,163,127,151,159,168],[112,113,156,155,128,152,160,151],[113,114,157,156,129,153,161,152],[114,134,158,157,130,154,162,153]]
- for i in xrange(0,40):
+ for i in range(0, 40):
m.insertNextCell(NORM_TRI3,conn[i])
pass
- for i in xrange(40,60):
+ for i in range(40, 60):
m.insertNextCell(NORM_QUAD4,conn[i])
pass
- for i in xrange(60,100):
+ for i in range(60, 100):
m.insertNextCell(NORM_TRI6,conn[i])
pass
- for i in xrange(100,120):
+ for i in range(100, 120):
m.insertNextCell(NORM_QUAD8,conn[i])
pass
- fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH2RB") ; fff.setNature(ConservativeVolumic)
+ fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH2RB") ; fff.setNature(IntensiveMaximum)
fff.setMesh(m)
- fff.setGaussLocalizationOnCells(range(0,40),[0.,0.,1.,0.,0.,1.],[0.3333333333333333,0.3333333333333333],[0.5])
- fff.setGaussLocalizationOnCells(range(40,60),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.])
- fff.setGaussLocalizationOnCells(range(60,100),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666])
- fff.setGaussLocalizationOnCells(range(100,120),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234])
+ fff.setGaussLocalizationOnCells(list(range(0, 40)), [0., 0., 1., 0., 0., 1.], [0.3333333333333333, 0.3333333333333333], [0.5])
+ fff.setGaussLocalizationOnCells(list(range(40, 60)), [-1., -1., 1., -1., 1., 1., -1., 1.], [-0.577350269189626, -0.577350269189626, 0.577350269189626, -0.577350269189626, 0.577350269189626, 0.577350269189626, -0.577350269189626, 0.577350269189626], [1., 1., 1., 1.])
+ fff.setGaussLocalizationOnCells(list(range(60, 100)), [0., 0., 1., 0., 0., 1., 0.5, 0., 0.5, 0.5, 0., 0.5], [0.16666666666666666, 0.16666666666666666, 0.6666666666666666, 0.16666666666666666, 0.16666666666666666, 0.6666666666666666], [0.16666666666666666, 0.16666666666666666, 0.16666666666666666])
+ fff.setGaussLocalizationOnCells(list(range(100, 120)), [-1., -1., 1., -1., 1., 1., -1., 1., 0., -1., 1., 0., 0., 1., -1., 0.], [-0.774596669241483, -0.774596669241483, 0.774596669241483, -0.774596669241483, 0.774596669241483, 0.774596669241483, -0.774596669241483, 0.774596669241483, 0.0, -0.774596669241483, 0.774596669241483, 0.0, 0.0, 0.774596669241483, -0.774596669241483, 0.0, 0.0, 0.0], [0.30864197530864196, 0.30864197530864196, 0.30864197530864196, 0.30864197530864196, 0.49382716049382713, 0.49382716049382713, 0.49382716049382713, 0.49382716049382713, 0.7901234567901234])
return MEDCouplingFieldTemplate(fff)
# 3D usecase1 for interpolation Gauss Pt-> Gauss Pt. Coming from ASTER : Please, do not touch
conn=[[3,10,8,4],[19,22,23,20,14],[0,6,1,3,8,4],[4,8,10,5,9,11],[12,16,17,14,19,20],[14,20,23,15,21,24],[1,2,5,4,6,7,9,8],[12,13,15,14,17,18,21,20]]
m.insertNextCell(NORM_TETRA4,conn[0])
m.insertNextCell(NORM_PYRA5,conn[1])
- for i in xrange(2,6):
+ for i in range(2, 6):
m.insertNextCell(NORM_PENTA6,conn[i])
pass
m.insertNextCell(NORM_HEXA8,conn[6])
m.insertNextCell(NORM_HEXA8,conn[7])
- fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH13") ; fff.setNature(ConservativeVolumic)
+ fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH13") ; fff.setNature(IntensiveMaximum)
fff.setMesh(m)
fff.setGaussLocalizationOnCells([0],[0.,1.,0.,0.,0.,0.,0.,0.,1.,1.,0.,0.],[0.25,0.25,0.25],[0.16666666666666666])
fff.setGaussLocalizationOnCells([1],[1.,0.,0.,0.,-1.,0.,-1.,0.,0.,0.,1.,0.,0.,0.,1.],[0.5,0.,0.1531754163448146,0.,0.5,0.1531754163448146,-0.5,0.,0.1531754163448146,0.,-0.5,0.1531754163448146,0.,0.,0.6372983346207416],[0.1333333333333333,0.1333333333333333,0.1333333333333333,0.1333333333333333,0.1333333333333333])
conn=[[3,10,8,4],[19,22,23,20,14],[0,6,1,3,8,4],[4,8,10,5,9,11],[12,16,17,14,19,20],[14,20,23,15,21,24],[1,2,5,4,6,7,9,8],[12,13,15,14,17,18,21,20]]
m.insertNextCell(NORM_TETRA4,conn[0])
m.insertNextCell(NORM_PYRA5,conn[1])
- for i in xrange(2,6):
+ for i in range(2, 6):
m.insertNextCell(NORM_PENTA6,conn[i])
pass
m.insertNextCell(NORM_HEXA8,conn[6])
m.insertNextCell(NORM_HEXA8,conn[7])
- fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH23") ; fff.setNature(ConservativeVolumic)
+ fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH23") ; fff.setNature(IntensiveMaximum)
fff.setMesh(m)
fff.setGaussLocalizationOnCells([0],[0.,1.,0.,0.,0.,0.,0.,0.,1.,1.,0.,0.],[0.25,0.25,0.25],[0.16666666666666666])
fff.setGaussLocalizationOnCells([1],[1.,0.,0.,0.,-1.,0.,-1.,0.,0.,0.,1.,0.,0.,0.,1.],[0.5,0.,0.1531754163448146,0.,0.5,0.1531754163448146,-0.5,0.,0.1531754163448146,0.,-0.5,0.1531754163448146,0.,0.,0.6372983346207416],[0.1333333333333333,0.1333333333333333,0.1333333333333333,0.1333333333333333,0.1333333333333333])
fff.setGaussLocalizationOnCells([6,7],[-1.,-1.,-1.,-1.,1.,-1.,1.,1.,-1.,1.,-1.,-1.,-1.,-1.,1.,-1.,1.,1.,1.,1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,-0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626],[1.,1.,1.,1.,1.,1.,1.,1.])
return MEDCouplingFieldTemplate(fff)
- def buildCircle(self, center_X, center_Y, radius):
+ def buildCircle(self, center_X, center_Y, radius):
from cmath import rect
- from math import pi
-
- c = [rect(radius, i*pi/4.0) for i in range(8)]
+ from math import pi
+
+ c = [rect(radius, i * pi / 4.0) for i in range(8)]
coords = [c[-1].real,c[-1].imag, c[3].real,c[3].imag,
c[5].real,c[5].imag, c[1].real,c[1].imag]
- connec = range(4)
- baseMesh = MEDCouplingUMesh.New("circle", 2)
+ connec = list(range(4))
+ baseMesh = MEDCouplingUMesh.New("circle", 2)
baseMesh.allocateCells(1)
- meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ meshCoords = DataArrayDouble.New(coords, len(coords) // 2, 2)
meshCoords += (center_X, center_Y)
baseMesh.setCoords(meshCoords)
-
- baseMesh.insertNextCell(NORM_QPOLYG, connec)
- baseMesh.finishInsertingCells()
+
+ baseMesh.insertNextCell(NORM_QPOLYG, connec)
+ baseMesh.finishInsertingCells()
+ return baseMesh
+
+ def buildCircle2(self, center_X, center_Y, radius):
+ from cmath import rect
+ from math import pi
+
+ c = [rect(radius, i * pi / 4.0) for i in range(8)]
+ coords = []
+ for i in range(8):
+ coords.extend([c[i].real,c[i].imag])
+ connec = [7,5,3,1, 6,4,2,0]
+ baseMesh = MEDCouplingUMesh.New("circle", 2)
+ baseMesh.allocateCells(1)
+ meshCoords = DataArrayDouble.New(coords, len(coords) // 2, 2)
+ meshCoords += (center_X, center_Y)
+ baseMesh.setCoords(meshCoords)
+
+ baseMesh.insertNextCell(NORM_QPOLYG, connec)
+ baseMesh.finishInsertingCells()
return baseMesh
build2DTargetMesh_1=classmethod(build2DTargetMesh_1)
buildFieldOnGauss_3=classmethod(buildFieldOnGauss_3)
buildFieldOnGauss_4=classmethod(buildFieldOnGauss_4)
buildCircle=classmethod(buildCircle)
+ buildCircle2=classmethod(buildCircle2)
pass