Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriPointSource.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 .PhactoriMpiUtilities import *
36
37 #phactori_combine_to_single_python_file_subpiece_begin_1
38
39 class PhactoriPointSource(PhactoriOperationSpecifics):
40 """Filter/operation which reads in a .json file which is a list of 3d
41 coordinates and creates a new point source from that list. Resulting
42 point source will have 1 element an N points. This source is intented
43 to work correctly in parallel for Catalyst or pvbatch symmetric mode.
44 The json file which is read in will only be read on one process and
45 mpi broadcast is used to distribute the list, rather than having each
46 process read the json file."""
47 def __init__(self):
48 self.UseDefaultRadius = True
49 self.Radius = 0.0
50 self.UseDefaultNumPoints = True
51 self.NumPoints = 1
52 self.UseDefaultCenter = True
53 self.Center = [0.0,0.0,0.0]
54
55 def ParseParametersFromJson(self, inJson):
56 key1 = "radius"
57 if key1 in inJson:
58 self.UseDefaultRadius = False
59 self.Radius = float(inJson[key1])
60 key1 = "number of points"
61 if key1 in inJson:
62 self.UseDefaultNumPoints = False
63 self.NumPoints = int(inJson[key1])
64 key1 = "center"
65 if key1 in inJson:
66 self.UseDefaultCenter = False
67 self.Center = inJson[key1]
68 if len(self.Center) != 3:
69 myDebugPrint3AndException("PhactoriPointSource:ParseParametersFromJson:\n"
70 "bad center, need like [0.1,2.3,4.5]\n")
71
72 def CreateParaViewFilter(self, inInputFilter):
73 if PhactoriDbg(100):
74 myDebugPrint3("PhactoriPointSource.CreateParaViewFilter entered\n", 100)
75
76 savedActiveSource = GetActiveSource()
77
78 newParaViewFilter = PointSource()
79 if self.UseDefaultRadius == False:
80 newParaViewFilter.Radius = self.Radius
81 if self.UseDefaultNumPoints == False:
82 newParaViewFilter.NumberOfPoints = self.NumPoints
83 if self.UseDefaultCenter == False:
84 newParaViewFilter.Center = self.Center
85
86 UpdatePipelineWithCurrentTimeArgument(newParaViewFilter)
87
88 SetActiveSource(newParaViewFilter)
89 SetActiveSource(savedActiveSource)
90
91 if PhactoriDbg(100):
92 myDebugPrint3("Radius: " + str(newParaViewFilter.Radius) + "\n" + \
93 "NumberOfPoints: " + str(newParaViewFilter.NumberOfPoints) + "\n" + \
94 "Center: " + str(newParaViewFilter.Center) + "\n")
95
96 if PhactoriDbg(100):
97 myDebugPrint3("PhactoriPointSource.CreateParaViewFilter returning\n", 100)
98
99 return newParaViewFilter
100
101 #phactori_combine_to_single_python_file_subpiece_end_1
102