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