| 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 PhactoriGroupOperation(PhactoriOperationSpecifics): |
| 38 |
"""manages group filter: group the results of two or more operations into |
| 39 |
a single multiblock source""" |
| 40 |
def __init__(self): |
| 41 |
PhactoriOperationSpecifics.__init__(self) |
| 42 |
#filled in from parsing |
| 43 |
self.mOperationNameList = None |
| 44 |
#filled in by finding operations id'd by self.mOperationNameList |
| 45 |
self.mOperationList = None |
| 46 |
|
| 47 |
def ParseParametersFromJson(self, inJson): |
| 48 |
|
| 49 |
if 'operation group list' in inJson: |
| 50 |
self.mOperationNameList = inJson['operation group list'] |
| 51 |
else: |
| 52 |
myDebugPrint3AndException( |
| 53 |
"PhactoriGroupOperation::ParseParametersFromJson\n" |
| 54 |
"Error: must have 'operation group list' token\n") |
| 55 |
|
| 56 |
def GetListOfInputOperationNamesForThisOperationType(self): |
| 57 |
"""the group operation depends on all the operations in |
| 58 |
self.mOperationNameList""" |
| 59 |
retList = list(self.mOperationNameList) |
| 60 |
return retList |
| 61 |
|
| 62 |
def CreateParaViewFilter2(self, ioPipeAndViewsState): |
| 63 |
"""create the group filter for ParaView""" |
| 64 |
if PhactoriDbg(100): |
| 65 |
myDebugPrint3("PhactoriGroupOperation.CreateParaViewFilter " |
| 66 |
"entered\n", 100) |
| 67 |
#info in block class should already be parsed and checked |
| 68 |
|
| 69 |
savedActiveSource = GetActiveSource() |
| 70 |
|
| 71 |
#get direct list of operations (not through name list) |
| 72 |
#should be valid here |
| 73 |
self.mOperationList = [] |
| 74 |
for ii in self.mOperationNameList: |
| 75 |
if ii not in ioPipeAndViewsState.mOperationBlocks: |
| 76 |
myDebugPrint3AndException( |
| 77 |
"PhactoriGroupOperation::CreateParaViewFilter\n" |
| 78 |
"Error: operation '" + str(ii) + "' not available\n") |
| 79 |
inputOperationBlock = ioPipeAndViewsState.mOperationBlocks[ii] |
| 80 |
if inputOperationBlock.GetPvFilter() == None: |
| 81 |
myDebugPrint3AndException( |
| 82 |
"PhactoriGroupOperation::CreateParaViewFilter\n" |
| 83 |
"Error: operation '" + str(ii) + "' paraview filter not " |
| 84 |
"constructed\n") |
| 85 |
self.mOperationList.append(inputOperationBlock.GetPvFilter()) |
| 86 |
|
| 87 |
newParaViewFilter = GroupDatasets(Input = self.mOperationList) |
| 88 |
|
| 89 |
SetActiveSource(newParaViewFilter) |
| 90 |
UpdatePipelineWithCurrentTimeArgument(newParaViewFilter) |
| 91 |
SetActiveSource(savedActiveSource) |
| 92 |
|
| 93 |
if PhactoriDbg(100): |
| 94 |
myDebugPrint3("PhactoriGroupOperation.CreateParaViewFilter " |
| 95 |
"returning\n", 100) |
| 96 |
|
| 97 |
return newParaViewFilter |
| 98 |
#phactori_combine_to_single_python_file_subpiece_end_1 |
| 99 |
|