Salome HOME
cbee37b9fafa94056ba261106995f32e226dcd2a
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader1.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016  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, or (at your option) any later version.
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
21
22 from MEDLoader import *
23
24 """
25 This test focused on ELNO. Here a 2 QUAD4 cells and a single ELNO field
26 is defined.
27 """
28 fname="testMEDReader1.med"
29
30 coords=DataArrayDouble([(0,0,0),(2,1,0),(1,0,0),(1,1,0),(2,0,0),(0,1,0)])
31 m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coords)
32 m.allocateCells()
33 m.insertNextCell(NORM_QUAD4,[0,5,3,2])
34 m.insertNextCell(NORM_QUAD4,[4,2,3,1])
35 m.finishInsertingCells()
36 WriteMesh(fname,m,True)
37 #
38 f0=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f0.setMesh(m) ; f0.setTimeUnit("ms")
39 f0.setTime(1.1,1,1)
40 f0.setName("myELNOField")
41 arr=DataArrayDouble([7,5,3,1,5,3,1,7]) ; arr.setInfoOnComponent(0,"Comp0")
42 f0.setArray(arr)
43 WriteFieldUsingAlreadyWrittenMesh(fname,f0)
44 #
45 f0.setTime(2.2,2,1)
46 arr=DataArrayDouble([1,7,5,3,7,5,3,1]) ; arr.setInfoOnComponent(0,"Comp0")
47 f0.setArray(arr)
48 WriteFieldUsingAlreadyWrittenMesh(fname,f0)
49 #
50 f0.setTime(3.3,3,1)
51 arr=DataArrayDouble([3,1,7,5,1,7,5,3]) ; arr.setInfoOnComponent(0,"Comp0")
52 f0.setArray(arr)
53 WriteFieldUsingAlreadyWrittenMesh(fname,f0)
54 #
55 f0.setTime(4.4,4,1)
56 arr=DataArrayDouble([5,3,1,7,3,1,7,5]) ; arr.setInfoOnComponent(0,"Comp0")
57 f0.setArray(arr)
58 WriteFieldUsingAlreadyWrittenMesh(fname,f0)