1 # Copyright (C) 2010-2016 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, or (at your option) any later version.
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 *
24 from pvsimple import *
25 from paravistest import save_trace
26 from paraview import smtrace
28 GetActiveViewOrCreate('RenderView')
30 config = smtrace.start_trace()
31 config.SetFullyTraceSupplementalProxies(True)
32 config.SetPropertiesToTraceOnCreate(config.RECORD_ALL_PROPERTIES)
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,
45 'MaximumStreamlineLength': 1.185,
46 'SeedType.Center': [0.1088, 0.03254, 0.431],
47 'SeedType.NumberOfPoints': 33,
48 'SeedType.Radius': 0.0035}
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...")
60 # 2. StreamLines creation
61 field_name = "vitesse"
63 source = MergeBlocks(med_reader)
64 calc = get_add_component_calc(source, EntityType.NODE, field_name)
65 vector_array = calc.ResultArrayName
68 stream = pvs.StreamTracer(source)
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']
86 text = smtrace.stop_trace()
87 path_to_save = os.path.join(os.getenv("HOME"), "StreamLines.py")
88 save_trace( path_to_save, text )
90 # 4. Delete the created objects
91 delete_with_inputs(stream)
93 # 5. Execution of the created script
94 exec(compile(open(path_to_save).read(), path_to_save, 'exec'))
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)!!!")
101 print(settings['name'] + " was found!!!")
105 # IntegrationDirection
106 param = stream.IntegrationDirection
107 if param != settings['IntegrationDirection']:
108 print("ERROR!!! IntegrationDirection of presentation is incorrect: ", param, " instead of ", settings["IntegrationDirection"])
112 param = stream.InitialStepLength
113 if param != settings['InitialStepLength']:
114 print("ERROR!!! InitialStepLength of presentation is incorrect: ", param, " instead of ", settings["InitialStepLength"])
117 # IntegrationStepUnit
118 param = stream.IntegrationStepUnit
119 if param != settings['IntegrationStepUnit']:
120 print("ERROR!!! IntegrationStepUnit of presentation is incorrect: ", param, " instead of ", settings["IntegrationStepUnit"])
124 param = stream.IntegratorType
125 if param != settings['IntegratorType']:
126 print("ERROR!!! IntegratorType of presentation is incorrect: ", param, " instead of ", settings["IntegratorType"])
130 param = stream.MaximumError
131 if param != settings['MaximumError']:
132 print("ERROR!!! MaximumError of presentation is incorrect: ", param, " instead of ", settings["MaximumError"])
136 param = stream.MinimumStepLength
137 if param != settings['MinimumStepLength']:
138 print("ERROR!!! MinimumStepLength of presentation is incorrect: ", param, " instead of ", settings["MinimumStepLength"])
142 param = stream.MaximumStepLength
143 if param != settings['MaximumStepLength']:
144 print("ERROR!!! MaximumStepLength of presentation is incorrect: ", param, " instead of ", settings["MaximumStepLength"])
148 param = stream.MaximumSteps
149 if param != settings['MaximumSteps']:
150 print("ERROR!!! MaximumSteps of presentation is incorrect: ", param, " instead of ", settings["MaximumSteps"])
153 # MaximumStreamlineLength
154 param = stream.MaximumStreamlineLength
155 if param != settings['MaximumStreamlineLength']:
156 print("ERROR!!! MaximumStreamlineLength of presentation is incorrect: ", param, " instead of ", settings["MaximumStreamlineLength"])
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"])
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"])
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"])
178 raise RuntimeError("There is(are) some error(s) was(were) found... For more info see ERRORs above...")