Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriMergeBlocksOperation.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
36 #phactori_combine_to_single_python_file_subpiece_begin_1
37 class PhactoriMergeBlocksOperation(PhactoriOperationSpecifics):
38 """merge blocks (MergeBlocks) operation, adapter to the catalyst filter
39
40 PhactoriMergeBlocksOperation is the phactori manager for working with the
41 ParaView/Catalyst MergeBlocks() filter and its parameters, providing
42 access and pipeline/input/output managment via the json, lexx/yacc, or soon
43 yaml interface. The user may specify a named input to the filter, with the
44 unnamed default being the incoming data mesh.
45
46 The MergeBlocks filter combines all the elements from all blocks of a
47 multiblock dataset into a single block with one set of elemeeents and one set
48 of points. The input is, e.g., a vtkMultiBlockDataset, and the output is
49 usually an vtkUnstructuredGrid or vtkPoly. Sometimes other filters which are
50 failing will succeed when placed after a MergeBlocks filter.
51
52 For moree information on the MergeBlocks() filter from ParaView, see the
53 ParaView Documentation.
54
55 To control the MergeBlocks you have a section in the
56 "operation blocks" section of the phactori control script which looks like:
57
58 ::
59
60 "operation blocks":{
61 "mymergeblocks1":{
62 "type":"mergeblocks"
63 }
64 }
65
66 As with other pipeline operations, you can add an
67 "input":"other_op_name" line to place this after another operation in the
68 pipeline such as a clip or a slice or a contour.
69 """
70
71 def __init__(self):
72 PhactoriOperationSpecifics.__init__(self)
73 self.mergePoints = True
74 self.mergePartitionsOnly = False
75
76 def ParseParametersFromJson(self, inJson):
77 key1 = "merge points"
78 if key1 in inJson:
79 self.mergePoints = inJson[key1]
80 key1 = "merge partitions only"
81 if key1 in inJson:
82 self.mergePartitionsOnly = inJson[key1]
83 dummy = 0
84
85 def CreateParaViewFilter(self, inInputFilter):
86 """create the MergeBlocks filter for ParaView"""
87 if PhactoriDbg(100):
88 myDebugPrint3("PhactoriMergeBlocksOperation.CreateParaViewFilter "
89 "entered\n", 100)
90
91 savedActiveSource = GetActiveSource()
92
93 UpdatePipelineWithCurrentTimeArgument(inInputFilter)
94 newParaViewFilter = MergeBlocks(inInputFilter)
95 if self.mergePoints:
96 newParaViewFilter.MergePoints = 1
97 else:
98 newParaViewFilter.MergePoints = 0
99 if self.mergePartitionsOnly:
100 newParaViewFilter.MergePartitionsOnly = 1
101 else:
102 newParaViewFilter.MergePartitionsOnly = 0
103
104 SetActiveSource(newParaViewFilter)
105 UpdatePipelineWithCurrentTimeArgument(newParaViewFilter)
106 SetActiveSource(savedActiveSource)
107
108 if PhactoriDbg(100):
109 myDebugPrint3("PhactoriMergeBlocksOperation.CreateParaViewFilter "
110 "returning\n", 100)
111
112 return newParaViewFilter
113
114 #phactori_combine_to_single_python_file_subpiece_end_1