X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=test%2FVisuPrs%2Fimps%2FB2.py;h=f715c973ad5e5afc0d6df433b05c691183724e96;hb=937b15c6a43ec7efea52bd90272e2e35d89ab37b;hp=da7074ea19f00900a162f07fcf37d577b46a6291;hpb=f284847a1f9ec2519639285396adf10a84903eea;p=modules%2Fparavis.git diff --git a/test/VisuPrs/imps/B2.py b/test/VisuPrs/imps/B2.py index da7074ea..f715c973 100644 --- a/test/VisuPrs/imps/B2.py +++ b/test/VisuPrs/imps/B2.py @@ -1,9 +1,9 @@ -# Copyright (C) 2010-2013 CEA/DEN, EDF R&D +# Copyright (C) 2010-2016 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,16 +21,13 @@ from paravistest import datadir from presentations import * -import paravis import pvsimple -my_paravis = paravis.myParavis - # 1. Import MED file print 'Import "ResOK_0000.med"...............', file_path = datadir + "ResOK_0000.med" -my_paravis.ImportFile(file_path) +pvsimple.OpenDataFile(file_path) med_reader = pvsimple.GetActiveSource() if med_reader is None: @@ -38,23 +35,45 @@ if med_reader is None: else: print "OK" + +def _extract_all_arrays_of_type(array_type, source): + import re + #sep = source.GetProperty("Separator").GetData() # "@@][@@" + arrays = source.AllArrays + result = [] + for arr in arrays: + match = re.search("ComSup[^/]*/(.*)@@\]\[@@(.*)", arr) + field_name = match.group(1) + arr_typ = match.group(2) + if arr_typ == array_type: + result += [field_name] + pass + return result +# + +def _extract_cell_arrays(source): + return _extract_all_arrays_of_type("P0", source) +# +def _extract_point_arrays(source): + return _extract_all_arrays_of_type("P1", source) +# + # 2. Get some information on the MED file -fields_on_nodes = med_reader.PointArrays +#fields_on_nodes = med_reader.PointArrays +fields_on_nodes = _extract_point_arrays(med_reader) print "Field names on NODE: ", fields_on_nodes is_ok = len(fields_on_nodes) == 2 and ("temperature" in fields_on_nodes) and ("vitesse" in fields_on_nodes) if not is_ok: raise RuntimeError, "=> Error in PointArrays property" -fields_on_cells = med_reader.CellArrays +#fields_on_cells = med_reader.CellArrays +fields_on_cells = _extract_cell_arrays(med_reader) print "Field names on CELL: ", fields_on_cells is_ok = len(fields_on_cells) == 1 and ("pression" in fields_on_cells) if not is_ok: raise RuntimeError, "=> Error in CellArrays property" -timestamps = med_reader.TimestepValues.GetData() +timestamps = med_reader.TimestepValues.GetData()[1:] print "timestamps: ", timestamps if timestamps != [17.030882013694594]: raise RuntimeError, "=> Wrong TimestepValues property value" - - -