1 # Copyright (C) 2010-2013 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.
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/dump_study/A7 case
22 from paravistest import datadir, delete_with_inputs
23 from presentations import *
25 from pvsimple import *
27 my_paravis = paravis.myParavis
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,
39 'MaximumStreamlineLength': 1.185,
40 'SeedType.Center': [0.1088, 0.03254, 0.431],
41 'SeedType.NumberOfPoints': 33,
42 'SeedType.Radius': 0.0035}
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..."
54 # 2. StreamLines creation
55 field_name = "vitesse"
57 source = MergeBlocks(med_reader)
58 calc = get_add_component_calc(source, EntityType.NODE, field_name)
59 vector_array = calc.ResultArrayName
62 stream = pv.StreamTracer(source)
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']
80 path_to_save = os.path.join(os.getenv("HOME"), "StreamLines.py")
81 SaveTrace( path_to_save )
83 # 4. Delete the created objects
84 delete_with_inputs(stream)
86 # 5. Execution of the created script
87 execfile(path_to_save)
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)!!!"
94 print settings['name'] + " was found!!!"
98 # IntegrationDirection
99 param = stream.IntegrationDirection
100 if param != settings['IntegrationDirection']:
101 print "ERROR!!! IntegrationDirection of presentation is incorrect: ", param, " instead of ", settings["IntegrationDirection"]
105 param = stream.InitialStepLength
106 if param != settings['InitialStepLength']:
107 print "ERROR!!! InitialStepLength of presentation is incorrect: ", param, " instead of ", settings["InitialStepLength"]
110 # IntegrationStepUnit
111 param = stream.IntegrationStepUnit
112 if param != settings['IntegrationStepUnit']:
113 print "ERROR!!! IntegrationStepUnit of presentation is incorrect: ", param, " instead of ", settings["IntegrationStepUnit"]
117 param = stream.IntegratorType
118 if param != settings['IntegratorType']:
119 print "ERROR!!! IntegratorType of presentation is incorrect: ", param, " instead of ", settings["IntegratorType"]
123 param = stream.MaximumError
124 if param != settings['MaximumError']:
125 print "ERROR!!! MaximumError of presentation is incorrect: ", param, " instead of ", settings["MaximumError"]
129 param = stream.MinimumStepLength
130 if param != settings['MinimumStepLength']:
131 print "ERROR!!! MinimumStepLength of presentation is incorrect: ", param, " instead of ", settings["MinimumStepLength"]
135 param = stream.MaximumStepLength
136 if param != settings['MaximumStepLength']:
137 print "ERROR!!! MaximumStepLength of presentation is incorrect: ", param, " instead of ", settings["MaximumStepLength"]
141 param = stream.MaximumSteps
142 if param != settings['MaximumSteps']:
143 print "ERROR!!! MaximumSteps of presentation is incorrect: ", param, " instead of ", settings["MaximumSteps"]
146 # MaximumStreamlineLength
147 param = stream.MaximumStreamlineLength
148 if param != settings['MaximumStreamlineLength']:
149 print "ERROR!!! MaximumStreamlineLength of presentation is incorrect: ", param, " instead of ", settings["MaximumStreamlineLength"]
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"]
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"]
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"]
171 raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."