Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriStreamTracerOperation.py

raw
1 # Copyright(C) 1999-2020, 2024 National Technology & Engineering Solutions
2 # of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 # NTESS, the U.S. Government retains certain rights in this software.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 #
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials provided
15 # with the distribution.
16 #
17 # * Neither the name of NTESS nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 from phactori import *
34 from paraview.simple import *
35
36 #phactori_combine_to_single_python_file_subpiece_begin_1
37 class PhactoriStreamTracerOperation(PhactoriOperationSpecifics):
38 def __init__(self):
39 PhactoriOperationSpecifics.__init__(self)
40 self.LineSourcePoint1 = [-0.5, -0.5, -0.5]
41 self.LineSourcePoint2 = [0.5, 0.5, 0.5]
42 self.Resolution = 500
43 return
44
45 def ParseParametersFromJson(self, inJson):
46 key1 = "line source point 1"
47 self.LineSourcePoint1 = getParameterFromBlock(inJson, key1, self.LineSourcePoint1)
48 if len(self.LineSourcePoint1) != 3:
49 myDebugPrint3AndException(
50 "'" + key1 + "' must be list with three floats for x, y, z\n")
51
52 key2 = "line source point 2"
53 self.LineSourcePoint2 = getParameterFromBlock(inJson, key2, self.LineSourcePoint2)
54 if len(self.LineSourcePoint2) != 3:
55 myDebugPrint3AndException(
56 "'" + key2 + "' must be list with three floats for x, y, z\n")
57
58 key3 = "resolution"
59 self.Resolution = getParameterFromBlock(inJson, key3, self.Resolution)
60 if isinstance(self.Resolution, int) == False:
61 myDebugPrint3AndException(
62 "'" + key3 + "' must be an integer\n")
63
64
65 def CreateParaViewFilter(self, inInputFilter):
66 """create the clip plane filter for ParaView"""
67 if PhactoriDbg(100):
68 myDebugPrint3('PhactoriStreamTracerOperation:CreateParaViewFilter entered\n', 100)
69 #info in block class should already be parsed and checked
70
71 UpdatePipelineWithCurrentTimeArgument(inInputFilter)
72
73 savedActiveSource = GetActiveSource()
74
75 newParaViewFilter = StreamTracer(Input = inInputFilter, SeedType="High Resolution Line Source")
76 newParaViewFilter.Vectors = ["CELLS", "velocity_xyz"]
77 newParaViewFilter.MaximumStreamlineLength = 100.0
78 newParaViewFilter.SeedType.Point1 = self.LineSourcePoint1
79 newParaViewFilter.SeedType.Point2 = self.LineSourcePoint2
80 newParaViewFilter.SeedType.Resolution = self.Resolution
81 newParaViewFilter.IntegrationDirection = 'FORWARD'
82 newParaViewFilter.MaximumSteps = 5000
83 #newParaViewFilter.InitialStepLength = 0.01
84
85 if PhactoriDbg(100):
86 stcso = newParaViewFilter.GetClientSideObject()
87 stodo = stcso.GetOutputDataObject(0)
88 myDebugPrint3("stodo st: " + str(stodo.GetClassName()) + " numcells " + str(stodo.GetNumberOfCells()) + " numpoints " + str(stodo.GetNumberOfPoints()) + "\n")
89 stido0 = stcso.GetInputDataObject(0,0)
90 myDebugPrint3("stido0 st: " + str(stido0.GetClassName()) + "\n")
91 stido1 = stcso.GetInputDataObject(1,0)
92 myDebugPrint3("stido1 st: " + str(stido1.GetClassName()) + " numcells " + str(stido1.GetNumberOfCells()) + " numpoints " + str(stido1.GetNumberOfPoints()) + "\n")
93
94 SetActiveSource(newParaViewFilter)
95 SetActiveSource(savedActiveSource)
96
97 UpdatePipelineWithCurrentTimeArgument(newParaViewFilter)
98
99 if PhactoriDbg(100):
100 stcso = newParaViewFilter.GetClientSideObject()
101 stodo = stcso.GetOutputDataObject(0)
102 myDebugPrint3("B stodo st: " + str(stodo.GetClassName()) + " numcells " + str(stodo.GetNumberOfCells()) + " numpoints " + str(stodo.GetNumberOfPoints()) + "\n")
103 stido0 = stcso.GetInputDataObject(0,0)
104 myDebugPrint3("B stido0 st: " + str(stido0.GetClassName()) + "\n")
105 stido1 = stcso.GetInputDataObject(1,0)
106 myDebugPrint3("B stido1 st: " + str(stido1.GetClassName()) + " numcells " + str(stido1.GetNumberOfCells()) + " numpoints " + str(stido1.GetNumberOfPoints()) + "\n")
107
108 if PhactoriDbg(100):
109 myDebugPrint3('PhactoriStreamTracerOperation.CreateParaViewFilter returning\n', 100)
110
111 return newParaViewFilter
112
113 #phactori_combine_to_single_python_file_subpiece_end_1