Salome HOME
Update ParaVis non-regression test base in the following ways:
[modules/paravis.git] / test / VisuPrs / dump_study / A7.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/dump_study/A7 case
21
22 from paravistest import datadir, delete_with_inputs
23 from presentations import *
24 from pvsimple import *
25
26 # StreamLines settings
27 settings = {'name': 'myStreamLines',
28             'IntegrationDirection': 'FORWARD',
29             'InitialStepLength': 0.009,
30             'IntegrationStepUnit': 'Length',
31             'IntegratorType': 'Runge-Kutta 4-5',
32             'MaximumError': 1.45e-06,
33             'MinimumStepLength': 0.0079917,
34             'MaximumStepLength': 0.008,
35             'MaximumSteps': 475,
36             'MaximumStreamlineLength': 1.185,
37             'SeedType.Center': [0.1088, 0.03254, 0.431],
38             'SeedType.NumberOfPoints': 33,
39             'SeedType.Radius': 0.0035}
40
41 # errors counter
42 errors = 0
43
44 # 1. TimeStamps.med import
45 file_path = datadir + "TimeStamps.med"
46 OpenDataFile(file_path)
47 med_reader = GetActiveSource()
48 if med_reader is None :
49     raise RuntimeError, "TimeStamps.med wasn't imported..."
50
51 # 2. StreamLines creation
52 field_name = "vitesse"
53
54 source = MergeBlocks(med_reader)
55 calc = get_add_component_calc(source, EntityType.NODE, field_name)
56 vector_array = calc.ResultArrayName
57 calc.UpdatePipeline()
58 source = calc
59 stream = pvs.StreamTracer(source)
60
61 # 3. Apply settings
62 RenameSource(settings['name'], stream)
63 stream.IntegrationDirection = settings['IntegrationDirection']
64 stream.InitialStepLength = settings['InitialStepLength']
65 stream.IntegrationStepUnit = settings['IntegrationStepUnit']
66 stream.IntegratorType = settings['IntegratorType']
67 stream.MaximumError = settings['MaximumError']
68 stream.MinimumStepLength = settings['MinimumStepLength']
69 stream.MaximumStepLength = settings['MaximumStepLength']
70 stream.MaximumSteps = settings['MaximumSteps']
71 stream.MaximumStreamlineLength = settings['MaximumStreamlineLength']
72 stream.SeedType.Center = settings['SeedType.Center']
73 stream.SeedType.NumberOfPoints = settings['SeedType.NumberOfPoints']
74 stream.SeedType.Radius = settings['SeedType.Radius']
75
76 # 4. Dump Study
77 path_to_save = os.path.join(os.getenv("HOME"), "StreamLines.py")
78 SaveTrace( path_to_save )
79
80 # 4. Delete the created objects
81 delete_with_inputs(stream)
82
83 # 5. Execution of the created script
84 execfile(path_to_save)
85
86 # 6. Find the recreated StreamTracer object
87 recreated_stream = FindSource(settings['name'])
88 if recreated_stream is None:
89     raise RuntimeError, "There is no StreamLines in the study (must be created by executed python script)!!!"
90
91 print settings['name'] + " was found!!!"
92
93 # 7. Check settings
94
95 # IntegrationDirection
96 param = stream.IntegrationDirection
97 if param != settings['IntegrationDirection']:
98     print "ERROR!!! IntegrationDirection of presentation is incorrect: ",  param, " instead of ", settings["IntegrationDirection"]
99     errors += 1
100
101 # InitialStepLength
102 param = stream.InitialStepLength
103 if param != settings['InitialStepLength']:
104     print "ERROR!!! InitialStepLength of presentation is incorrect: ",  param, " instead of ", settings["InitialStepLength"]
105     errors += 1
106
107 # IntegrationStepUnit
108 param = stream.IntegrationStepUnit
109 if param != settings['IntegrationStepUnit']:
110     print "ERROR!!! IntegrationStepUnit of presentation is incorrect: ",  param, " instead of ", settings["IntegrationStepUnit"]
111     errors += 1
112
113 # IntegratorType
114 param = stream.IntegratorType
115 if param != settings['IntegratorType']:
116     print "ERROR!!! IntegratorType of presentation is incorrect: ",  param, " instead of ", settings["IntegratorType"]
117     errors += 1
118
119 # MaximumError
120 param = stream.MaximumError
121 if param != settings['MaximumError']:
122     print "ERROR!!! MaximumError of presentation is incorrect: ",  param, " instead of ", settings["MaximumError"]
123     errors += 1
124
125 # MinimumStepLength
126 param = stream.MinimumStepLength
127 if param != settings['MinimumStepLength']:
128     print "ERROR!!! MinimumStepLength of presentation is incorrect: ",  param, " instead of ", settings["MinimumStepLength"]
129     errors += 1
130
131 # MaximumStepLength
132 param = stream.MaximumStepLength
133 if param != settings['MaximumStepLength']:
134     print "ERROR!!! MaximumStepLength of presentation is incorrect: ",  param, " instead of ", settings["MaximumStepLength"]
135     errors += 1
136
137 # MaximumSteps
138 param = stream.MaximumSteps
139 if param != settings['MaximumSteps']:
140     print "ERROR!!! MaximumSteps of presentation is incorrect: ",  param, " instead of ", settings["MaximumSteps"]
141     errors += 1
142
143 # MaximumStreamlineLength
144 param = stream.MaximumStreamlineLength
145 if param != settings['MaximumStreamlineLength']:
146     print "ERROR!!! MaximumStreamlineLength of presentation is incorrect: ",  param, " instead of ", settings["MaximumStreamlineLength"]
147     errors += 1
148
149 # SeedType.Center
150 param = list(stream.SeedType.Center)
151 if param != settings['SeedType.Center']:
152     print "ERROR!!! SeedType.Center of presentation is incorrect: ",  param, " instead of ", settings["SeedType.Center"]
153     errors += 1
154
155 # SeedType.NumberOfPoints
156 param = stream.SeedType.NumberOfPoints
157 if param != settings['SeedType.NumberOfPoints']:
158     print "ERROR!!! SeedType.NumberOfPoints of presentation is incorrect: ",  param, " instead of ", settings["SeedType.NumberOfPoints"]
159     errors += 1
160
161 # SeedType.Radius
162 param = stream.SeedType.Radius
163 if param != settings['SeedType.Radius']:
164     print "ERROR!!! SeedType.Radius of presentation is incorrect: ",  param, " instead of ", settings["SeedType.Radius"]
165     errors += 1
166
167 if errors > 0:
168     raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."