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