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 *
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,
36 'MaximumStreamlineLength': 1.185,
37 'SeedType.Center': [0.1088, 0.03254, 0.431],
38 'SeedType.NumberOfPoints': 33,
39 'SeedType.Radius': 0.0035}
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..."
51 # 2. StreamLines creation
52 field_name = "vitesse"
54 source = MergeBlocks(med_reader)
55 calc = get_add_component_calc(source, EntityType.NODE, field_name)
56 vector_array = calc.ResultArrayName
59 stream = pvs.StreamTracer(source)
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']
77 path_to_save = os.path.join(os.getenv("HOME"), "StreamLines.py")
78 SaveTrace( path_to_save )
80 # 4. Delete the created objects
81 delete_with_inputs(stream)
83 # 5. Execution of the created script
84 execfile(path_to_save)
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)!!!"
91 print settings['name'] + " was found!!!"
95 # IntegrationDirection
96 param = stream.IntegrationDirection
97 if param != settings['IntegrationDirection']:
98 print "ERROR!!! IntegrationDirection of presentation is incorrect: ", param, " instead of ", settings["IntegrationDirection"]
102 param = stream.InitialStepLength
103 if param != settings['InitialStepLength']:
104 print "ERROR!!! InitialStepLength of presentation is incorrect: ", param, " instead of ", settings["InitialStepLength"]
107 # IntegrationStepUnit
108 param = stream.IntegrationStepUnit
109 if param != settings['IntegrationStepUnit']:
110 print "ERROR!!! IntegrationStepUnit of presentation is incorrect: ", param, " instead of ", settings["IntegrationStepUnit"]
114 param = stream.IntegratorType
115 if param != settings['IntegratorType']:
116 print "ERROR!!! IntegratorType of presentation is incorrect: ", param, " instead of ", settings["IntegratorType"]
120 param = stream.MaximumError
121 if param != settings['MaximumError']:
122 print "ERROR!!! MaximumError of presentation is incorrect: ", param, " instead of ", settings["MaximumError"]
126 param = stream.MinimumStepLength
127 if param != settings['MinimumStepLength']:
128 print "ERROR!!! MinimumStepLength of presentation is incorrect: ", param, " instead of ", settings["MinimumStepLength"]
132 param = stream.MaximumStepLength
133 if param != settings['MaximumStepLength']:
134 print "ERROR!!! MaximumStepLength of presentation is incorrect: ", param, " instead of ", settings["MaximumStepLength"]
138 param = stream.MaximumSteps
139 if param != settings['MaximumSteps']:
140 print "ERROR!!! MaximumSteps of presentation is incorrect: ", param, " instead of ", settings["MaximumSteps"]
143 # MaximumStreamlineLength
144 param = stream.MaximumStreamlineLength
145 if param != settings['MaximumStreamlineLength']:
146 print "ERROR!!! MaximumStreamlineLength of presentation is incorrect: ", param, " instead of ", settings["MaximumStreamlineLength"]
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"]
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"]
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"]
168 raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."