Salome HOME
Merge from V6_main_20120808 08Aug12
[tools/medcoupling.git] / src / MEDLoader / Swig / MEDLoaderDataForTest.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 from MEDLoader import *
22 from math import pi,e,sqrt
23
24 class MEDLoaderDataForTest:
25     def build1DMesh_1(cls):
26         coords=[ 0.0, 0.3, 0.75, 1.0, 1.4, 1.3 ]
27         conn=[ 0,1, 1,2, 2,3 , 3,4,5]
28         mesh=MEDCouplingUMesh.New();
29         mesh.setName("1DMesh_1");
30         mesh.setMeshDimension(1);
31         mesh.allocateCells(4);
32         mesh.insertNextCell(NORM_SEG2,2,conn[0:2])
33         mesh.insertNextCell(NORM_SEG2,2,conn[2:4])
34         mesh.insertNextCell(NORM_SEG2,2,conn[4:6])
35         mesh.insertNextCell(NORM_SEG3,3,conn[6:9])
36         mesh.finishInsertingCells();
37         myCoords=DataArrayDouble.New();
38         myCoords.setValues(coords,6,1);
39         myCoords.setInfoOnComponent(0,"tototototototot [m*m*m*m*m*m*m*m]");
40         mesh.setCoords(myCoords);
41         return mesh;
42
43     def build2DCurveMesh_1(cls):
44         coords=[ 0.0,0.0, 0.3,0.3, 0.75,0.75, 1.0,1.0, 1.4,1.4, 1.3,1.3 ]
45         conn=[ 0,1, 1,2, 2,3 , 3,4,5]
46         mesh=MEDCouplingUMesh.New();
47         mesh.setName("2DCurveMesh_1");
48         mesh.setMeshDimension(1);
49         mesh.allocateCells(4);
50         mesh.insertNextCell(NORM_SEG2,2,conn[0:2])
51         mesh.insertNextCell(NORM_SEG2,2,conn[2:4])
52         mesh.insertNextCell(NORM_SEG2,2,conn[4:6])
53         mesh.insertNextCell(NORM_SEG3,3,conn[6:9])
54         mesh.finishInsertingCells();
55         myCoords=DataArrayDouble.New();
56         myCoords.setValues(coords,6,2);
57         mesh.setCoords(myCoords);
58         return mesh;
59
60     def build2DMesh_1(cls):
61         targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7,
62                       -0.05,0.95, 0.2,1.2, 0.45,0.95]
63         targetConn=[1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4]
64         targetMesh=MEDCouplingUMesh.New();
65         targetMesh.setMeshDimension(2);
66         targetMesh.allocateCells(6);
67         targetMesh.setName("2DMesh_1");
68         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
69         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
70         targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
71         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
72         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
73         targetMesh.insertNextCell(NORM_POLYGON,4,targetConn[20:24])
74         targetMesh.finishInsertingCells();
75         myCoords=DataArrayDouble.New();
76         myCoords.setValues(targetCoords,12,2);
77         myCoords.setInfoOnComponent(0,"tototototototot [m]");
78         myCoords.setInfoOnComponent(1,"energie [kW]");
79         targetMesh.setCoords(myCoords)
80         return targetMesh;
81
82     def build2DMesh_2(cls):
83         targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7,
84                       -0.05,0.95, 0.2,1.2, 0.45,0.95]
85         targetConn=[1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4]
86         targetMesh=MEDCouplingUMesh.New();
87         targetMesh.setMeshDimension(2);
88         targetMesh.allocateCells(5);
89         targetMesh.setName("2DMesh_2");
90         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
91         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
92         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
93         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
94         targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
95         targetMesh.finishInsertingCells();
96         myCoords=DataArrayDouble.New();
97         myCoords.setValues(targetCoords,12,2);
98         myCoords.setInfoOnComponent(0,"toto [m]");
99         myCoords.setInfoOnComponent(1,"energie [kW]");
100         targetMesh.setCoords(myCoords);
101         return targetMesh;
102
103     #this mesh has several cells duplicated ! it is not beautiful but efficient to test file WR.
104     def build2DMesh_3(cls):
105         targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7,
106                       -0.05,0.95, 0.2,1.2, 0.45,0.95]
107         targetConn=[1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4]
108         targetMesh=MEDCouplingUMesh.New();
109         targetMesh.setMeshDimension(2);
110         targetMesh.allocateCells(13);
111         targetMesh.setName("2DMesh_3");
112         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
113         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
114         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
115         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
116         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
117         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
118         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
119         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
120         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
121         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
122         targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
123         targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
124         targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
125         targetMesh.finishInsertingCells();
126         myCoords=DataArrayDouble.New();
127         myCoords.setValues(targetCoords,12,2);
128         myCoords.setInfoOnComponent(0,"toto [m]");
129         myCoords.setInfoOnComponent(1,"energie [kW]");
130         targetMesh.setCoords(myCoords);
131         return targetMesh;
132
133     def build3DMesh_1(cls):
134         coords=[0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
135                 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0.,
136                 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1.,
137                 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1.,
138                 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2.,
139         3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2.,
140                 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3.,
141                 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.]
142         conn=[
143             # 0
144             0,11,1,3,15,26,16,18,   1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17,
145             1,6,5,3,16,21,20,18,   13,10,9,6,28,25,24,21,
146             11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23,
147             7,12,14,13,22,27,29,28,
148             # 1
149             15,26,16,18,30,41,31,33,   16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32,
150             16,21,20,18,31,36,35,33,   28,25,24,21,43,40,39,36,
151             26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38,
152             22,27,29,28,37,42,44,43,
153             # 2
154             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,
155             31,36,35,33,46,51,50,48,  43,40,39,36,58,55,54,51,
156             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,
157             37,42,44,43,52,57,59,58]
158         #
159         ret=MEDCouplingUMesh.New();
160         ret.setName("3DMesh_1");
161         ret.setMeshDimension(3);
162         ret.allocateCells(18);
163         #
164         ret.insertNextCell(NORM_HEXA8,8,conn[0:8])
165         ret.insertNextCell(NORM_HEXA8,8,conn[51:59])
166         ret.insertNextCell(NORM_HEXA8,8,conn[59:67])
167         ret.insertNextCell(NORM_HEXA8,8,conn[110:118])
168         #
169         ret.insertNextCell(NORM_HEXA8,8,conn[118:126])
170         ret.insertNextCell(NORM_HEXA8,8,conn[169:177])
171         ret.insertNextCell(NORM_HEXA8,8,conn[177:185])
172         ret.insertNextCell(NORM_HEXA8,8,conn[228:236])
173         #
174         ret.insertNextCell(NORM_HEXA8,8,conn[236:244])
175         ret.insertNextCell(NORM_HEXA8,8,conn[287:295])
176         ret.insertNextCell(NORM_HEXA8,8,conn[295:303])
177         ret.insertNextCell(NORM_HEXA8,8,conn[346:354])
178         #
179         ret.insertNextCell(NORM_POLYHED,43,conn[8:51])
180         ret.insertNextCell(NORM_POLYHED,43,conn[67:110])
181         ret.insertNextCell(NORM_POLYHED,43,conn[126:169])
182         ret.insertNextCell(NORM_POLYHED,43,conn[185:228])
183         ret.insertNextCell(NORM_POLYHED,43,conn[244:287])
184         ret.insertNextCell(NORM_POLYHED,43,conn[303:346])
185         #
186         ret.finishInsertingCells();
187         myCoords=DataArrayDouble.New();
188         myCoords.setValues(coords,60,3);
189         myCoords.setInfoOnComponent(0,"titi [m]");
190         myCoords.setInfoOnComponent(1,"density power [MW/m^3]");
191         myCoords.setInfoOnComponent(2,"t [kW]");
192         ret.setCoords(myCoords);
193         return ret;
194     
195     def build3DSurfMesh_1(cls):
196         targetCoords=[-0.3,-0.3,-0.3, 0.2,-0.3,-0.3, 0.7,-0.3,-0.3, -0.3,0.2,-0.3, 0.2,0.2,-0.3, 0.7,0.2,-0.3, -0.3,0.7,-0.3, 0.2,0.7,-0.3, 0.7,0.7,-0.3
197                       ,-0.05,0.95,-0.3, 0.2,1.2,-0.3, 0.45,0.95,-0.3]
198         targetConn=[1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4]
199         targetMesh=MEDCouplingUMesh.New();
200         targetMesh.setMeshDimension(2);
201         targetMesh.allocateCells(6);
202         targetMesh.setName("3DSurfMesh_1");
203         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
204         targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
205         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
206         targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
207         targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
208         targetMesh.insertNextCell(NORM_POLYGON,4,targetConn[20:24])
209         targetMesh.finishInsertingCells();
210         myCoords=DataArrayDouble.New();
211         myCoords.setValues(targetCoords,12,3);
212         myCoords.setInfoOnComponent(0,"toto [m]");
213         myCoords.setInfoOnComponent(2,"ff [km]");#component 1 is not set for test
214         targetMesh.setCoords(myCoords);
215         return targetMesh;
216     
217     def build3DMesh_2(cls):
218         m3dsurfBase=MEDLoaderDataForTest.build3DSurfMesh_1();
219         numbers=[0,1,2,3,5]
220         m3dsurf=m3dsurfBase.buildPartOfMySelf(numbers,False);
221         m1dBase=MEDLoaderDataForTest.build1DMesh_1();
222         numbers2=[0,1,2,3]
223         m1d=m1dBase.buildPartOfMySelf(numbers2,False);
224         m1d.changeSpaceDimension(3);
225         vec=[0.,1.,0.]
226         pt=[0.,0.,0.]
227         m1d.rotate(pt,vec,-pi/2.);
228         ret=m3dsurf.buildExtrudedMesh(m1d,0);
229         return ret;
230
231     def buildMultiLevelMesh_1(cls):
232         coo=[10.,0.,10.,1.25,10.,2.5,10.,3.75,10.,5.,8.75,0.,8.75,1.25,8.75,2.5,8.75,3.75,8.75,5.,7.5,0.,7.5,1.25,7.5,2.5,7.5,3.75,7.5,5.,6.25,0.,6.25,1.25,6.25,2.5,6.25,3.75,6.25,5.,5.,0.,5.,1.25,5.,2.5,5.,3.75,5.,5.,3.75,0.,3.75,1.25,3.75,2.5,3.75,3.75,3.75,5.,2.5,0.,2.5,1.25,2.5,2.5,2.5,3.75,2.5,5.,1.25,0.,1.25,1.25,1.25,2.5,1.25,3.75,1.25,5.,0.,1.25,0.,2.5,0.,3.75,0.,5.,0.,0.,0.,5.,10.,5.,0.,10.,10.,10.,5.,5.,5.,5.,5.,10.,5.,10.,0.625,5.,1.25,5.,1.875,5.,2.5,5.,3.125,5.,3.75,5.,4.375,5.,5.,6.25,5.,7.5,5.,8.75,4.375,10.,3.75,10.,3.125,10.,2.5,10.,1.875,10.,1.25,10.,0.625,10.,0.,8.75,0.,7.5,0.,6.25,4.375,6.25,4.375,7.5,4.375,8.75,3.75,6.25,3.75,7.5,3.75,8.75,3.125,6.25,3.125,7.5,3.125,8.75,2.5,6.25,2.5,7.5,2.5,8.75,1.875,6.25,1.875,7.5,1.875,8.75,1.25,6.25,1.25,7.5,1.25,8.75,0.625,6.25,0.625,7.5,0.625,8.75,5.625,5.,6.25,5.,6.875,5.,7.5,5.,8.125,5.,8.75,5.,9.375,5.,10.,6.25,10.,7.5,10.,8.75,9.375,10.,8.75,10.,8.125,10.,7.5,10.,6.875,10.,6.25,10.,5.625,10.,5.,8.75,5.,7.5,5.,6.25,9.375,6.25,9.375,7.5,9.375,8.75,8.75,6.25,8.75,7.5,8.75,8.75,8.125,6.25,8.125,7.5,8.125,8.75,7.5,6.25,7.5,7.5,7.5,8.75,6.875,6.25,6.875,7.5,6.875,8.75,6.25,6.25,6.25,7.5,6.25,8.75,5.625,6.25,5.625,7.5,5.625,8.75]
233         coo2=DataArrayDouble.New()
234         coo2.setValues(coo,135,2)
235         coo2=coo2.changeNbOfComponents(3,0.)
236         coo2.setInfoOnComponent(0,"X [INCONNUE]")
237         coo2.setInfoOnComponent(1,"Y [INCONNUE]")
238         coo2.setInfoOnComponent(2,"Z [INCONNUE]")
239         c2tri=[0,1,6,0,6,5,1,2,6,2,7,6,2,3,8,2,8,7,3,4,8,4,9,8,5,6,11,5,11,10,6,7,11,7,12,11,7,8,13,7,13,12,8,9,13,9,14,13,10,11,16,10,16,15,11,12,16,12,17,16,12,13,18,12,18,17,13,14,18,14,19,18,15,16,21,15,21,20,16,17,21,17,22,21,17,18,23,17,23,22,18,19,23,19,24,23,20,21,26,20,26,25,21,22,26,22,27,26,22,23,28,22,28,27,23,24,28,24,29,28,25,26,31,25,31,30,26,27,31,27,32,31,27,28,33,27,33,32,28,29,33,29,34,33,30,31,36,30,36,35,31,32,36,32,37,36,32,33,38,32,38,37,33,34,38,34,39,38,35,36,40,35,40,44,36,37,40,37,41,40,37,38,42,37,42,41,38,39,42,39,43,42]
240         c2quad4=[46,101,114,100,101,102,115,114,102,103,116,115,103,48,104,116,100,114,117,99,114,115,118,117,115,116,119,118,116,104,105,119,99,117,120,98,117,118,121,120,118,119,122,121,119,105,106,122,98,120,123,97,120,121,124,123,121,122,125,124,122,106,107,125,97,123,126,96,123,124,127,126,124,125,128,127,125,107,108,128,96,126,129,95,126,127,130,129,127,128,131,130,128,108,109,131,95,129,132,94,129,130,133,132,130,131,134,133,131,109,110,134,94,132,113,50,132,133,112,113,133,134,111,112,134,110,51,111,49,60,73,59,60,61,74,73,61,62,75,74,62,52,63,75,59,73,76,58,73,74,77,76,74,75,78,77,75,63,64,78,58,76,79,57,76,77,80,79,77,78,81,80,78,64,65,81,57,79,82,56,79,80,83,82,80,81,84,83,81,65,66,84,56,82,85,55,82,83,86,85,83,84,87,86,84,66,67,87,55,85,88,54,85,86,89,88,86,87,90,89,87,67,68,90,54,88,91,53,88,89,92,91,89,90,93,92,90,68,69,93,53,91,72,45,91,92,71,72,92,93,70,71,93,69,47,70]
241         m2=MEDCouplingUMesh.New("ma",2)
242         m2.setCoords(coo2)
243         m2.allocateCells(128)
244         nbTri=len(c2tri)/3
245         for i in xrange(nbTri):
246             m2.insertNextCell(NORM_TRI3,3,c2tri[3*i:3*i+3])
247             pass
248         nbQua=len(c2quad4)/4
249         for i in xrange(nbQua):
250             m2.insertNextCell(NORM_QUAD4,4,c2quad4[4*i:4*i+4])
251             pass
252         m2.finishInsertingCells()
253         m2.setDescription("CREE PAR CODE_ASTER")
254         m1=MEDCouplingUMesh.New("ma",1)
255         m1.setCoords(coo2)
256         c1seg=[0,1,1,2,2,3,3,4,4,9,9,14,14,19,19,24,24,29,29,34,34,39,39,43,43,42,42,41,41,40,40,44,44,35,35,30,30,25,25,20,20,15,15,10,10,5,5,0,43,39,39,34,34,29,29,24,24,19,19,14,14,9,9,4,45,53,53,54,54,55,55,56,56,57,57,58,58,59,59,49,49,60,60,61,61,62,62,52,52,63,63,64,64,65,65,66,66,67,67,68,68,69,69,47,47,70,70,71,71,72,72,45,50,94,94,95,95,96,96,97,97,98,98,99,99,100,100,46,46,101,101,102,102,103,103,48,48,104,104,105,105,106,106,107,107,108,108,109,109,110,110,51,51,111,111,112,112,113,113,50]
257         m1.allocateCells(80)
258         for i in xrange(80):
259             m1.insertNextCell(NORM_SEG2,2,c1seg[2*i:2*i+2])
260             pass
261         m1.finishInsertingCells()
262         m1.setDescription("CREE PAR CODE_ASTER")
263         m0=MEDCouplingUMesh.New("ma",0)
264         m0.setCoords(coo2)
265         c0pt=[44,0,47,48]
266         m0.allocateCells(4)
267         for i in xrange(4):
268             m0.insertNextCell(NORM_POINT1,1,[c0pt[i]])
269             pass
270         m0.finishInsertingCells()
271         f2=DataArrayInt.New()
272         f2.alloc(128,1)
273         f2[:64]=-1
274         f2[64:96]=-2
275         f2[96:]=-3
276         f1=DataArrayInt.New()
277         f1.alloc(80,1)
278         f1[:4]=-8
279         f1[4:12]=-9
280         f1[12:16]=-10
281         f1[16:24]=-11
282         f1[24:28]=-12
283         f1[28:32]=-13
284         f1[32:40]=-14
285         f1[40:44]=-15
286         f1[44:52]=-16
287         f1[52:56]=-17
288         f1[56:64]=-18
289         f1[64:68]=-19
290         f1[68:76]=-20
291         f1[76:]=-21
292         f0=DataArrayInt.New()
293         f0.setValues([-4,-5,-6,-7],4,1)
294         p=DataArrayInt.New()
295         p.alloc(135,1)
296         p.fillWithZero()
297         p1=DataArrayInt.New()
298         p1.alloc(13,1)
299         p1.iota(1)
300         p[[0,4,24,43,44,45,46,47,48,49,50,51,52]]=p1
301         n2=DataArrayInt.New()
302         n2.alloc(128,1)
303         n2.iota(1)
304         n1=DataArrayInt.New()
305         n1.alloc(80,1)
306         n1.iota(133)
307         n0=DataArrayInt.New()
308         n0.alloc(4,1)
309         n0.iota(129)
310         fns=['A1A2____________________________', 'A1______________________________', 'A2A4____________________________', 'A2______________________________', 'A3A1____________________________', 'A3C5____________________________', 'A3______________________________', 'A4A3____________________________', 'A4______________________________', 'B1C1____________________________', 'B1______________________________', 'B2B4____________________________', 'B2______________________________', 'B3B1____________________________', 'B3______________________________', 'B4C3____________________________', 'B4______________________________', 'C1C4____________________________', 'C1______________________________', 'C2B2____________________________', 'C2______________________________', 'C3C2____________________________', 'C3______________________________', 'C4B3____________________________', 'C4______________________________', 'C5A4____________________________', 'C5______PMMA____________________', 'FAMILLE_ZERO', 'MESH____APPS____AP1_____________', 'MESH____APPS____AP2_____________', 'MESH____APPS____AP3_____________', 'MESH____APPS____AP4_____________', 'MESH____DALQ1___DALLE___________', 'MESH____DALQ2___DALLE___________', 'MESH____DALT3___DALLE___________']
311         fids=[-11, 5, -8, 1, -10, -12, 4, -9, 2, -14, 6, -19, 7, -17, 8, -20, 9, -15, 10, -18, 11, -21, 12, -16, 13, -13, 3, 0, -4, -5, -6, -7, -3, -2, -1]
312         grpns=['A1', 'A1A2', 'A2', 'A2A4', 'A3', 'A3A1', 'A3C5', 'A4', 'A4A3', 'AP1', 'AP2', 'AP3', 'AP4', 'APPS', 'B1', 'B1C1', 'B2', 'B2B4', 'B3', 'B3B1', 'B4', 'B4C3', 'C1', 'C1C4', 'C2', 'C2B2', 'C3', 'C3C2', 'C4', 'C4B3', 'C5', 'C5A4', 'DALLE', 'DALQ1', 'DALQ2', 'DALT3', 'MESH', 'PMMA']
313         famIdsPerGrp=[[5],[-11],[1],[-8],[4],[-10],[-12],[2],[-9],[-4],[-5],[-6],[-7],[-4,-5,-6,-7],[6],[-14],[7],[-19],[8],[-17],[9],[-20],[10],[-15],[11],[-18],[12],[-21],[13],[-16],[3],[-13],[-3,-2,-1],[-3],[-2],[-1],[-4,-5,-6,-7,-3,-2,-1],[3]]
314         return m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp
315
316     def buildMLMeshUnPolyze(cls,tester):
317         """Level 0 (meshDim=3) - 2 TETRA4 + 3 PENTA6 + 2 POLYH
318         # POLYH #0 becomes 1 TETRA4
319         # POLYH #1 becomes HEXA8
320         # Level -1 (meshDim=2) - 2 TRI3 + 3 QUAD4 + 4 POLYG
321         # POLYG #2 becomes TRI3"""
322         meshName="NightmareMesh"
323         #
324         coords=DataArrayDouble.New(38,3) ; coords.rearrange(1) ; coords.iota(1000.) ; coords.rearrange(3) ; coords.setInfoOnComponents(["X [m]","Y [m]","Z [m]"])
325         mesh0=MEDCouplingUMesh(meshName,3)
326         type0=[NORM_TETRA4,NORM_TETRA4, NORM_PENTA6,NORM_PENTA6,NORM_PENTA6, NORM_POLYHED,NORM_POLYHED]
327         conn0=[[0,1,2,3],[4,5,6,7], [8,9,10,11,12,13],[14,15,16,17,18,19],[20,21,22,23,24,25], [26,27,28,-1,26,29,27,-1,27,29,28,-1,28,29,26],[30,31,32,33,-1,34,37,36,35,-1,30,34,35,31,-1,31,35,36,32,-1,32,36,37,33,-1,33,37,34,30]]
328         mesh0.allocateCells(len(type0))
329         for typ,nodalConn in zip(type0,conn0):
330             mesh0.insertNextCell(typ,nodalConn);
331             pass
332         mesh0.finishInsertingCells()
333         mesh0.setCoords(coords)
334         
335         meshM1=MEDCouplingUMesh(meshName,2)
336         typeM1=[NORM_TRI3,NORM_TRI3, NORM_QUAD4,NORM_QUAD4,NORM_QUAD4, NORM_POLYGON,NORM_POLYGON,NORM_POLYGON,NORM_POLYGON]
337         connM1=[[0,1,2],[3,4,5], [6,7,8,9],[10,11,12,13],[14,15,16,17], [18,19,20,21,22],[23,24,25,26,27],[28,29,30],[31,32,33,34,35,36,37]]
338         meshM1.allocateCells(len(typeM1))
339         for typ,nodalConn in zip(typeM1,connM1):
340             meshM1.insertNextCell(typ,nodalConn);
341             pass
342         meshM1.finishInsertingCells()
343         meshM1.setCoords(coords)
344         #
345         mm=MEDFileUMesh.New()
346         mm.setMeshAtLevel(0,mesh0)
347         mm.setMeshAtLevel(-1,meshM1)
348         grp0_L0=DataArrayInt.New([0,1,5,7]) ; grp0_L0.setName("grp0_L0")
349         grp1_L0=DataArrayInt.New([1,2,3,4,6]) ; grp1_L0.setName("grp1_L0")
350         tester.assertRaises(InterpKernelException,mm.setGroupsAtLevel,0,[grp0_L0,grp1_L0])# presence of 7 in grp0_L0 (only 7 cells at level 0) -> throw
351         grp0_L0=DataArrayInt.New([0,1,5,6]) ; grp0_L0.setName("grp0_L0")
352         mm.setGroupsAtLevel(0,[grp0_L0,grp1_L0])
353         grp0_LM1=DataArrayInt.New([1,2,3,4,7]) ; grp0_LM1.setName("grp0_LM1")
354         grp1_LM1=DataArrayInt.New([2,3,4,5]) ; grp1_LM1.setName("grp1_LM1")
355         grp2_LM1=DataArrayInt.New([5,6,7,8]) ; grp2_LM1.setName("grp2_LM1")
356         mm.setGroupsAtLevel(-1,[grp0_LM1,grp1_LM1,grp2_LM1])
357         grp0_Node=DataArrayInt.New([0,11,15,16]) ; grp0_Node.setName("grp0_Node")
358         grp1_Node=DataArrayInt.New([1,2,13,14,16]) ; grp1_Node.setName("grp1_Node")
359         mm.setGroupsAtLevel(1,[grp0_Node,grp1_Node])
360         #
361         tester.assertRaises(InterpKernelException,mm.setRenumFieldArr,0,DataArrayInt.New([0,8,9,4,5,6,7,10]))# to big array
362         mm.setRenumFieldArr(0,DataArrayInt.New([0,8,9,4,5,6,7]))
363         da=DataArrayInt.New([0,8,9,4,5,6,7,11,12])
364         mm.setRenumFieldArr(-1,da)
365         mm.setRenumFieldArr(-1,None)
366         mm.setRenumFieldArr(-1,da)
367         da=DataArrayInt.New(mm.getNumberOfNodes()+1) ; da.iota(8) ; tester.assertRaises(InterpKernelException,mm.setRenumFieldArr,1,da) # to big array more than number of nodes
368         da=DataArrayInt.New(mm.getNumberOfNodes()) ; da.iota(8) ; mm.setRenumFieldArr(1,da)
369         return mm
370
371     def buildVecFieldOnCells_1(cls):
372         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
373         nbOfCells=mesh.getNumberOfCells();
374         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
375         f1.setName("VectorFieldOnCells");
376         f1.setMesh(mesh);
377         array=DataArrayDouble.New();
378         arr1=[0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.]
379         array.setValues(arr1,nbOfCells,3);
380         array.setInfoOnComponent(0,"power [MW/m^3]");
381         array.setInfoOnComponent(1,"density [g/cm^3]");
382         array.setInfoOnComponent(2,"temperature [K]");
383         f1.setArray(array);
384         tmp=array.getPointer();
385         f1.setTime(2.,0,1);
386         f1.checkCoherency();
387         return f1;
388
389     def buildVecFieldOnNodes_1(cls):
390         mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
391         nbOfNodes=mesh.getNumberOfNodes();
392         f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
393         f1.setName("VectorFieldOnNodes");
394         f1.setMesh(mesh);
395         array=DataArrayDouble.New();
396         f1.setArray(array);
397         arr1=[70.,80.,90.,71.,81.,91.,72.,82.,92.,73.,83.,93.,74.,84.,94.,75.,85.,95.,
398         1000.,10010.,10020.,1001.,10011.,10021.,1002.,10012.,10022.,1003.,10013.,10023.,1004.,10014.,10024.,1005.,10015.,10025.]
399         array.setValues(arr1,nbOfNodes,3);
400         array.setInfoOnComponent(0,"power [MW/m^3]");
401         array.setInfoOnComponent(1,"density [g/cm^3]");
402         array.setInfoOnComponent(2,"temperature [K]");
403         f1.setTime(2.12,2,3);
404         f1.checkCoherency();
405         return f1;
406
407     def buildVecFieldOnGauss_1(cls):
408         _a=0.446948490915965;
409         _b=0.091576213509771;
410         _p1=0.11169079483905;
411         _p2=0.0549758718227661;
412         refCoo1=[ 0.,0., 1.,0., 0.,1. ]
413         gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
414                  2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ];
415         wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ]
416         _refCoo1=refCoo1;
417         _gsCoo1=gsCoo1;
418         _wg1=wg1;
419         m=MEDLoaderDataForTest.build2DMesh_2();
420         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
421         f.setTime(3.14,1,5);
422         f.setMesh(m);
423         f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
424         refCoo2=[-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 ]
425         _refCoo2=refCoo2;
426         _gsCoo1=_gsCoo1[0:6];
427         _gsCoo2=_gsCoo1
428         _wg1=_wg1[0:3];
429         _wg2=_wg1
430         refCoo3=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
431         _refCoo3=refCoo3;
432         _gsCoo1=_gsCoo1[0:4];
433         _wg1=_wg1[0:2];
434         f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo3,_gsCoo1,_wg1);
435         f.setGaussLocalizationOnType(NORM_TRI6,_refCoo2,_gsCoo2,_wg2);
436         array=DataArrayDouble.New();
437         array.alloc(19,2);
438         ptr=array.getPointer();
439         for i in xrange(19*2):
440             array.setIJ(0,i,float(i+7));
441             pass
442         f.setArray(array);
443         f.setName("MyFirstFieldOnGaussPoint");
444         array.setInfoOnComponent(0,"power [MW/m^3]");
445         array.setInfoOnComponent(1,"density");
446         f.checkCoherency();
447         return f;
448
449     def buildVecFieldOnGauss_2(cls):
450         _a=0.446948490915965;
451         _b=0.091576213509771;
452         _p1=0.11169079483905;
453         _p2=0.0549758718227661;
454         refCoo1=[ 0.,0., 1.,0., 0.,1. ]
455         gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
456                  2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ];
457         wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ]
458         _refCoo1=refCoo1;
459         _gsCoo1=gsCoo1;
460         _wg1=wg1;
461         m=MEDLoaderDataForTest.build2DMesh_3();
462         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
463         f.setTime(3.14,1,5);
464         f.setMesh(m);
465         di=DataArrayInt.New(); di.setValues([0,2,3],3,1)
466         f.setGaussLocalizationOnCells(di,_refCoo1,_gsCoo1,_wg1)
467         _wg1[-1]*=2
468         f.setGaussLocalizationOnCells([1,5],_refCoo1,_gsCoo1,_wg1);
469         _wg1[-1]*=2
470         f.setGaussLocalizationOnCells([4],_refCoo1,_gsCoo1,_wg1);
471         refCoo2=[-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 ]
472         _refCoo2=refCoo2;
473         _gsCoo1=_gsCoo1[0:6];
474         _gsCoo2=_gsCoo1
475         _wg1=_wg1[0:3];
476         _wg2=_wg1
477         refCoo3=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
478         _refCoo3=refCoo3;
479         _gsCoo1=_gsCoo1[0:4];
480         _wg1=_wg1[0:2];
481         f.setGaussLocalizationOnCells([6,7,8],_refCoo3,_gsCoo1,_wg1);
482         _wg1[-1]*=2
483         f.setGaussLocalizationOnCells([9],_refCoo3,_gsCoo1,_wg1);
484         f.setGaussLocalizationOnType(NORM_TRI6,_refCoo2,_gsCoo2,_wg2);
485         array=DataArrayDouble.New();
486         array.alloc(53,2);
487         ptr=array.getPointer();
488         for i in xrange(53*2):
489             array.setIJ(0,i,float(i+7));
490             pass
491         f.setArray(array);
492         f.setName("MyFirstFieldOnGaussPoint");
493         array.setInfoOnComponent(0,"power [MW/m^3]");
494         array.setInfoOnComponent(1,"density");
495         f.checkCoherency();
496         return f;
497
498     # idem buildVecFieldOnGauss_2 except that different discretizations are sorted inside one type
499     def buildVecFieldOnGauss_2_Simpler(cls):
500         _a=0.446948490915965;
501         _b=0.091576213509771;
502         _p1=0.11169079483905;
503         _p2=0.0549758718227661;
504         refCoo1=[ 0.,0., 1.,0., 0.,1. ]
505         gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
506                  2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ];
507         wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ]
508         _refCoo1=refCoo1;
509         _gsCoo1=gsCoo1;
510         _wg1=wg1;
511         m=MEDLoaderDataForTest.build2DMesh_3();
512         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
513         f.setTime(3.14,1,5);
514         f.setMesh(m);
515         di=DataArrayInt.New(); di.setValues([0,1,2],3,1)
516         f.setGaussLocalizationOnCells(di,_refCoo1,_gsCoo1,_wg1)
517         _wg1[-1]*=2
518         f.setGaussLocalizationOnCells([3,4],_refCoo1,_gsCoo1,_wg1);
519         _wg1[-1]*=2
520         f.setGaussLocalizationOnCells([5],_refCoo1,_gsCoo1,_wg1);
521         refCoo2=[-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 ]
522         _refCoo2=refCoo2;
523         _gsCoo1=_gsCoo1[0:6];
524         _gsCoo2=_gsCoo1
525         _wg1=_wg1[0:3];
526         _wg2=_wg1
527         refCoo3=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
528         _refCoo3=refCoo3;
529         _gsCoo1=_gsCoo1[0:4];
530         _wg1=_wg1[0:2];
531         f.setGaussLocalizationOnCells([6,7,8],_refCoo3,_gsCoo1,_wg1);
532         _wg1[-1]*=2
533         f.setGaussLocalizationOnCells([9],_refCoo3,_gsCoo1,_wg1);
534         f.setGaussLocalizationOnType(NORM_TRI6,_refCoo2,_gsCoo2,_wg2);
535         array=DataArrayDouble.New();
536         array.alloc(53,2);
537         ptr=array.getPointer();
538         for i in xrange(53*2):
539             array.setIJ(0,i,float(i+7));
540             pass
541         f.setArray(array);
542         f.setName("MyFirstFieldOnGaussPoint");
543         array.setInfoOnComponent(0,"power [MW/m^3]");
544         array.setInfoOnComponent(1,"density");
545         f.checkCoherency();
546         return f;
547
548     def buildVecFieldOnGaussNE_1(cls):
549         m=MEDLoaderDataForTest.build2DMesh_2();
550         f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME);
551         f.setTime(3.14,1,5);
552         f.setMesh(m);
553         array=DataArrayDouble.New();
554         array.alloc(20,2);
555         for i in xrange(2*20):
556             array.setIJ(0,i,float(i+8));
557         f.setArray(array);
558         array.setInfoOnComponent(0,"power [W]");
559         array.setInfoOnComponent(1,"temperature");
560         f.setName("MyFieldOnGaussNE");
561         f.checkCoherency();
562         return f;
563     
564     build1DMesh_1=classmethod(build1DMesh_1)
565     build2DCurveMesh_1=classmethod(build2DCurveMesh_1)
566     build2DMesh_1=classmethod(build2DMesh_1)
567     build2DMesh_2=classmethod(build2DMesh_2)
568     build2DMesh_3=classmethod(build2DMesh_3)
569     build3DMesh_1=classmethod(build3DMesh_1)
570     build3DSurfMesh_1=classmethod(build3DSurfMesh_1)
571     build3DMesh_2=classmethod(build3DMesh_2)
572     buildMLMeshUnPolyze=classmethod(buildMLMeshUnPolyze)
573     buildMultiLevelMesh_1=classmethod(buildMultiLevelMesh_1)
574     buildVecFieldOnCells_1=classmethod(buildVecFieldOnCells_1)
575     buildVecFieldOnNodes_1=classmethod(buildVecFieldOnNodes_1)
576     buildVecFieldOnGauss_1=classmethod(buildVecFieldOnGauss_1)
577     buildVecFieldOnGauss_2=classmethod(buildVecFieldOnGauss_2)
578     buildVecFieldOnGauss_2_Simpler=classmethod(buildVecFieldOnGauss_2_Simpler)
579     buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1)
580     pass