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