1 # Copyright (C) 2010-2016 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # This case corresponds to: /visu/imps/B2 case
22 from paravistest import datadir
23 from presentations import *
27 print 'Import "ResOK_0000.med"...............',
29 file_path = datadir + "ResOK_0000.med"
30 pvsimple.OpenDataFile(file_path)
31 med_reader = pvsimple.GetActiveSource()
33 if med_reader is None:
34 raise RuntimeError, "import failed"
39 def _extract_all_arrays_of_type(array_type, source):
41 #sep = source.GetProperty("Separator").GetData() # "@@][@@"
42 arrays = source.AllArrays
45 match = re.search("ComSup[^/]*/(.*)@@\]\[@@(.*)", arr)
46 field_name = match.group(1)
47 arr_typ = match.group(2)
48 if arr_typ == array_type:
49 result += [field_name]
54 def _extract_cell_arrays(source):
55 return _extract_all_arrays_of_type("P0", source)
57 def _extract_point_arrays(source):
58 return _extract_all_arrays_of_type("P1", source)
61 # 2. Get some information on the MED file
62 #fields_on_nodes = med_reader.PointArrays
63 fields_on_nodes = _extract_point_arrays(med_reader)
64 print "Field names on NODE: ", fields_on_nodes
65 is_ok = len(fields_on_nodes) == 2 and ("temperature" in fields_on_nodes) and ("vitesse" in fields_on_nodes)
67 raise RuntimeError, "=> Error in PointArrays property"
69 #fields_on_cells = med_reader.CellArrays
70 fields_on_cells = _extract_cell_arrays(med_reader)
71 print "Field names on CELL: ", fields_on_cells
72 is_ok = len(fields_on_cells) == 1 and ("pression" in fields_on_cells)
74 raise RuntimeError, "=> Error in CellArrays property"
76 timestamps = med_reader.TimestepValues.GetData()[1:]
77 print "timestamps: ", timestamps
78 if timestamps != [17.030882013694594]:
79 raise RuntimeError, "=> Wrong TimestepValues property value"