Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriExtractComponentOperation.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 PhactoriExtractComponentOperation(PhactoriOperationSpecifics):
38 def __init__(self):
39 PhactoriOperationSpecifics.__init__(self)
40 self.Component = 0
41 self.InputArrayName = "None"
42 self.InputArrayCellsOrPoints = "POINTS"
43 self.OutputArrayName = "Result"
44 return
45
46 def ParseParametersFromJson(self, inJson):
47 keyval1 = "component"
48 if keyval1 in inJson:
49 self.Component = inJson[keyval1]
50
51 keyval2 = "output array name"
52 if keyval2 in inJson:
53 self.OutputArrayName = inJson[keyval2]
54
55 keyval3 = "input array name"
56 if keyval3 in inJson:
57 self.InputArrayName = inJson[keyval3]
58 else:
59 myDebugPrint3AndException(
60 "PhactoriExtractComponentOperation:ParseParametersFromJson\n"
61 "must have keys 'input array name' and 'input array type'\n")
62
63 keyval4 = "input array type"
64 if keyval4 in inJson:
65 typeval = inJson[keyval4]
66 if typeval == "points":
67 self.InputArrayCellsOrPoints = "POINTS"
68 elif typeval == "cells":
69 self.InputArrayCellsOrPoints = "CELLS"
70 elif typeval == "nodes":
71 self.InputArrayCellsOrPoints = "POINTS"
72 elif typeval == "elements":
73 self.InputArrayCellsOrPoints = "CELLS"
74 else:
75 myDebugPrint3AndException(
76 "PhactoriExtractComponentOperation:ParseParametersFromJson\n"
77 "'input array type' must be 'points' 'cells' 'nodes' or 'elements'\n")
78 else:
79 myDebugPrint3AndException(
80 "PhactoriExtractComponentOperation:ParseParametersFromJson\n"
81 "must have keys 'input array name' and 'input array type'\n")
82
83 def CreateParaViewFilter(self, inInputFilter):
84 if PhactoriDbg(100):
85 myDebugPrint3("PhactoriExtractComponentOperation:CreateParaViewFilter entered\n", 100)
86 #info in block class should already be parsed and checked
87
88 if PhactoriDbg(100):
89 myDebugPrint3("about to call UpdatePipelineWithCurrentTimeArgument\n", 100)
90 UpdatePipelineWithCurrentTimeArgument(inInputFilter)
91
92 savedActiveSource = GetActiveSource()
93 newParaViewFilter = ExtractComponent(Input = inInputFilter)
94 newParaViewFilter.Component = self.Component
95 newParaViewFilter.OutputArrayName = self.OutputArrayName
96 newParaViewFilter.InputArray = [self.InputArrayCellsOrPoints, self.InputArrayName]
97 if PhactoriDbg(100):
98 myDebugPrint3(
99 "newParaViewFilter.Component" + str(newParaViewFilter.Component) + "\n"
100 "newParaViewFilter.OutputArrayName" + str(newParaViewFilter.OutputArrayName) + "\n"
101 "newParaViewFilter.InputArray" + str(newParaViewFilter.InputArray) + "\n", 100)
102
103 SetActiveSource(newParaViewFilter)
104 if PhactoriDbg(100):
105 myDebugPrint3("about to call UpdatePipelineWithCurrentTimeArgument\n", 100)
106 UpdatePipelineWithCurrentTimeArgument(newParaViewFilter)
107 SetActiveSource(savedActiveSource)
108
109 if PhactoriDbg(100):
110 myDebugPrint3("PhactoriExtractComponentOperation.CreateParaViewFilter returning\n", 100)
111
112 return newParaViewFilter
113
114 #phactori_combine_to_single_python_file_subpiece_end_1