Debian Codegraph @

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

raw
1 # Copyright(C) 1999-2020 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 from .PhactoriParallelGeometryUtilities import *
36
37 #phactori_combine_to_single_python_file_subpiece_begin_1
38
39 class PhactoriExtractSubsetWithSeed(PhactoriOperationSpecifics):
40 """manages extract block filter, including creating flat block
41 indices list from list of block names"""
42 def __init__(self):
43 PhactoriOperationSpecifics.__init__(self)
44 self.Seed = [0.0, 0.0, 0.0]
45 self.Direction = "I"
46 self.FindSeedNearestTestPoint = False
47 self.TestPointToFindSeed = [0.0, 0.0, 0.0]
48 self.SeedOffset = [0.0, 0.0, 0.0]
49 self.SeedWithOffset = [0.0, 0.0, 0.0]
50
51 def ParseParametersFromJson(self, inJson):
52 key1 = "seed"
53 key2 = "seed from cell nearest point"
54 if "seed" in inJson:
55 if key2 in inJson:
56 myDebugPrint3AndException(
57 "PhactoriExtractSubsetWithSeed.ParseParametersFromJson exception:\n"
58 "block may have one of the following two tokens, but not both:\n"
59 "'" + key1 + "'\n"
60 "'" + key2 + "'\n")
61 self.Seed = inJson["seed"]
62 if len(self.Seed) != 3:
63 myDebugPrint3AndException(
64 "PhactoriExtractSubsetWithSeed.ParseParametersFromJson exception:\n"
65 "'" + key1 + "' token must be [x,y,z] (list of 3 floats)\n")
66
67 if key2 in inJson:
68 self.FindSeedNearestTestPoint = True
69 self.TestPointToFindSeed = inJson[key2]
70 if len(self.TestPointToFindSeed) != 3:
71 myDebugPrint3AndException(
72 "PhactoriExtractSubsetWithSeed.ParseParametersFromJson exception:\n"
73 "'" + key2 + "' token must be [x,y,z] (list of 3 floats)\n")
74
75 key3 = "seed offset"
76 if key3 in inJson:
77 self.SeedOffset = inJson[key3]
78 if len(self.SeedOffset) != 3:
79 myDebugPrint3AndException(
80 "PhactoriExtractSubsetWithSeed.ParseParametersFromJson exception:\n"
81 "'" + key3 + "' token must be [x,y,z] (list of 3 floats)\n")
82
83 if "direction" in inJson:
84 self.Direction = inJson["direction"]
85 validDirectionStrings = ["I", "J", "K", "IJ", "JK", "KI"]
86 if self.Direction not in validDirectionStrings:
87 myDebugPrint3AndException(
88 "PhactoriExtractSubsetWithSeed.ParseParametersFromJson exception:\n"
89 "illegal 'direction' token: " + str(self.Direction) + "\n"
90 "the direction must one of: " + str(validDirectionStrings) + "\n")
91
92 def CreateParaViewFilter(self, inInputFilter):
93 """create the ExtractSubsetWithSeed filter for ParaView"""
94 if PhactoriDbg(100):
95 myDebugPrint3("PhactoriExtractSubsetWithSeed.CreateParaViewFilter "
96 "entered\n", 100)
97
98 savedActiveSource = GetActiveSource()
99
100 UpdatePipelineWithCurrentTimeArgument(inInputFilter)
101
102 newParaViewFilter = ExtractSubsetWithSeed(inInputFilter)
103
104 if self.FindSeedNearestTestPoint:
105 ##nearestCellTestPointList = GetListOfCellTestPointsNearestListOfPointsV5(inInputFilter, [self.TestPointToFindSeed])
106 nearestCellTestPointList = GetListOfGridPointsNearestListOfPointsV5(inInputFilter, [self.TestPointToFindSeed])
107 self.Seed = nearestCellTestPointList[0]
108 if PhactoriDbg(100):
109 myDebugPrint3("find grid point for seed nearest this point:\n" + str(self.TestPointToFindSeed) + "\n"
110 "seed point found:\n" + str(self.Seed) + "\n")
111
112 self.SeedWithOffset[0] = self.Seed[0] + self.SeedOffset[0]
113 self.SeedWithOffset[1] = self.Seed[1] + self.SeedOffset[1]
114 self.SeedWithOffset[2] = self.Seed[2] + self.SeedOffset[2]
115 if PhactoriDbg(100):
116 myDebugPrint3("self.Seed: " + str(self.Seed) + "\n"
117 "self.SeedWithOffset: " + str(self.SeedWithOffset) + "\n")
118 newParaViewFilter.Seed = self.SeedWithOffset
119 newParaViewFilter.Direction = self.Direction
120
121 SetActiveSource(newParaViewFilter)
122
123 UpdatePipelineWithCurrentTimeArgument(newParaViewFilter)
124
125 SetActiveSource(savedActiveSource)
126
127 if PhactoriDbg(100):
128 myDebugPrint3("PhactoriExtractSubsetWithSeed.CreateParaViewFilter "
129 "returning\n", 100)
130
131 return newParaViewFilter
132 #phactori_combine_to_single_python_file_subpiece_end_1