Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / MEDReader / plugin / Test / testMEDReader1.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2022  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 medcoupling import *
23 from MEDReaderHelper import WriteInTmpDir,RetriveBaseLine
24
25 @WriteInTmpDir
26 def GenerateCase():
27     """
28     This test focused on ELNO. Here a 2 QUAD4 cells and a single ELNO field
29     is defined.
30     """
31     fname="testMEDReader1.med"
32     coords=DataArrayDouble([(0,0,0),(2,1,0),(1,0,0),(1,1,0),(2,0,0),(0,1,0)])
33     m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coords)
34     m.allocateCells()
35     m.insertNextCell(NORM_QUAD4,[0,5,3,2])
36     m.insertNextCell(NORM_QUAD4,[4,2,3,1])
37     m.finishInsertingCells()
38     WriteMesh(fname,m,True)
39     #
40     f0=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f0.setMesh(m) ; f0.setTimeUnit("ms")
41     f0.setTime(1.1,1,1)
42     f0.setName("myELNOField")
43     arr=DataArrayDouble([7,5,3,1,5,3,1,7]) ; arr.setInfoOnComponent(0,"Comp0")
44     f0.setArray(arr)
45     WriteFieldUsingAlreadyWrittenMesh(fname,f0)
46     #
47     f0.setTime(2.2,2,1)
48     arr=DataArrayDouble([1,7,5,3,7,5,3,1]) ; arr.setInfoOnComponent(0,"Comp0")
49     f0.setArray(arr)
50     WriteFieldUsingAlreadyWrittenMesh(fname,f0)
51     #
52     f0.setTime(3.3,3,1)
53     arr=DataArrayDouble([3,1,7,5,1,7,5,3]) ; arr.setInfoOnComponent(0,"Comp0")
54     f0.setArray(arr)
55     WriteFieldUsingAlreadyWrittenMesh(fname,f0)
56     #
57     f0.setTime(4.4,4,1)
58     arr=DataArrayDouble([5,3,1,7,3,1,7,5]) ; arr.setInfoOnComponent(0,"Comp0")
59     f0.setArray(arr)
60     WriteFieldUsingAlreadyWrittenMesh(fname,f0)
61
62
63 if __name__ == "__main__":
64     GenerateCase()
65     pass