Salome HOME
Copyrights update 2015.
[modules/paravis.git] / test / VisuPrs / imps / B2.py
1 # Copyright (C) 2010-2015  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # This case corresponds to: /visu/imps/B2 case
21
22 from paravistest import datadir
23 from presentations import *
24 import pvserver as paravis
25 import pvsimple
26
27 my_paravis = paravis.myParavis
28
29 # 1. Import MED file
30 print 'Import "ResOK_0000.med"...............',
31
32 file_path = datadir + "ResOK_0000.med"
33 OpenDataFile(file_path)
34 med_reader = pvsimple.GetActiveSource()
35
36 if med_reader is None:
37     raise RuntimeError, "import failed"
38 else:
39     print "OK"
40
41 # 2. Get some information on the MED file
42 fields_on_nodes = med_reader.PointArrays
43 print "Field names on NODE: ", fields_on_nodes
44 is_ok = len(fields_on_nodes) == 2 and ("temperature" in fields_on_nodes) and ("vitesse" in fields_on_nodes)
45 if not is_ok:
46     raise RuntimeError,  "=> Error in PointArrays property"
47
48 fields_on_cells = med_reader.CellArrays
49 print "Field names on CELL: ", fields_on_cells
50 is_ok = len(fields_on_cells) == 1 and ("pression" in fields_on_cells)
51 if not is_ok:
52     raise RuntimeError,  "=> Error in CellArrays property"
53
54 timestamps = med_reader.TimestepValues.GetData()
55 print "timestamps: ", timestamps
56 if timestamps != [17.030882013694594]:
57     raise RuntimeError,  "=> Wrong TimestepValues property value"
58
59
60