| 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 paraview.simple import * |
| 34 |
from phactori import * |
| 35 |
|
| 36 |
#phactori_combine_to_single_python_file_subpiece_begin_1 |
| 37 |
class PhactoriParaviewMultiBlockRecursionControl: |
| 38 |
"""see PhactoriDoParaviewMultiblockRecursion(); |
| 39 |
mOperationPerBlock should be set to a method |
| 40 |
which takes 1 parameter, mParameters should be set to the parameter |
| 41 |
instance which will be passed to the mOperationPerBlock call""" |
| 42 |
def __init__(self): |
| 43 |
self.mOperationToDoPerBlock = None |
| 44 |
self.mParameters = None |
| 45 |
|
| 46 |
def PhactroiParaviewDoMethodPerBlockRecurse1(inInputCsData, inRecursionControlItem): |
| 47 |
"""PhactroiParaviewDoMethodPerBlockRecurse1 is a generic method for doing recursion through |
| 48 |
the multiblock dataset and doing something (a callback) on a per leaf block |
| 49 |
basis. Called by PhactoriRecusivelyDoMethodPerBlockFromParaViewFilter which got clientside data and calls |
| 50 |
itself on internal nodes and calls |
| 51 |
inRecursionControlItem.mOperationToDoPerBlock on leaf block nodes""" |
| 52 |
if PhactoriDbg(100): |
| 53 |
myDebugPrint3('PhactroiParaviewDoMethodPerBlockRecurse1 entered\n', 100) |
| 54 |
|
| 55 |
icsdClassname = inInputCsData.GetClassName() |
| 56 |
if icsdClassname == "vtkMultiBlockDataSet" or \ |
| 57 |
icsdClassname == "vtkExodusIIMultiBlockDataSet": |
| 58 |
myDebugPrint3('recursing: ' + icsdClassname + '\n') |
| 59 |
numBlocks = inInputCsData.GetNumberOfBlocks() |
| 60 |
for ii in range(0, numBlocks): |
| 61 |
oneBlock = inInputCsData.GetBlock(ii) |
| 62 |
if PhactoriDbg(100): |
| 63 |
DebugPrintBlockName(inInputCsData, ii) |
| 64 |
if(oneBlock != None): |
| 65 |
PhactroiParaviewDoMethodPerBlockRecurse1(oneBlock, inRecursionControlItem) |
| 66 |
else: |
| 67 |
inRecursionControlItem.mOperationToDoPerBlock(inRecursionControlItem, inInputCsData, |
| 68 |
inRecursionControlItem.mParameters) |
| 69 |
|
| 70 |
if PhactoriDbg(100): |
| 71 |
myDebugPrint3('PhactroiParaviewDoMethodPerBlockRecurse1 returning\n', 100) |
| 72 |
|
| 73 |
def DebugPrintBlockName(csData, blockIndex): |
| 74 |
if PhactoriDbg(100): |
| 75 |
oneBlock = csData.GetBlock(blockIndex) |
| 76 |
if oneBlock != None: |
| 77 |
oneBlockMetaData = csData.GetMetaData(blockIndex) |
| 78 |
if oneBlockMetaData != None: |
| 79 |
#myDebugPrint3("oneBlockMetaData: " + str(oneBlockMetaData) + "\n") |
| 80 |
theBlockName = oneBlockMetaData.Get(vtk.vtkCompositeDataSet.NAME()) |
| 81 |
myDebugPrint3("block index, name: " + str(blockIndex) + ", " + str(theBlockName) + "\n") |
| 82 |
else: |
| 83 |
myDebugPrint3("oneBlockMetaData is None (1)\n") |
| 84 |
else: |
| 85 |
myDebugPrint3("this block is None, now check meta data\n") |
| 86 |
oneBlockMetaData = csData.GetMetaData(blockIndex) |
| 87 |
if oneBlockMetaData != None: |
| 88 |
#myDebugPrint3("oneBlockMetaData: " + str(oneBlockMetaData) + "\n") |
| 89 |
theBlockName = oneBlockMetaData.Get(vtk.vtkCompositeDataSet.NAME()) |
| 90 |
myDebugPrint3("block index, name (2): " + str(blockIndex) + ", " + str(theBlockName) + "\n") |
| 91 |
else: |
| 92 |
myDebugPrint3("oneBlockMetaData is None (2)\n") |
| 93 |
|
| 94 |
def PhactoriRecusivelyDoMethodPerBlockFromParaViewFilter(inRecursionControlItem, inPvFilter): |
| 95 |
"""grab client side data object, and use that to do recursion""" |
| 96 |
pvClientSideData = inPvFilter.GetClientSideObject().GetOutputDataObject(0) |
| 97 |
if pvClientSideData == None: |
| 98 |
if PhactoriDbg(100): |
| 99 |
myDebugPrint3( |
| 100 |
'DoMethodPerBlock: pvClientSideData is None, returning',100) |
| 101 |
return |
| 102 |
|
| 103 |
PhactroiParaviewDoMethodPerBlockRecurse1(pvClientSideData, inRecursionControlItem) |
| 104 |
|
| 105 |
class PrintPointAndCellArrayInformationRecursionParams: |
| 106 |
def __init__(self): |
| 107 |
self.leafVisitCount = 0 |
| 108 |
|
| 109 |
def PrintPointAndCellArrayInformationInBlock(recursionObject, inInputCsData, inParameters): |
| 110 |
inParameters.leafVisitCount += 1 |
| 111 |
myDebugPrint3("inParameters.leafVisitCount " + str(inParameters.leafVisitCount) + "\n") |
| 112 |
|
| 113 |
celldata = inInputCsData.GetCellData() |
| 114 |
numcellarrays = celldata.GetNumberOfArrays() |
| 115 |
myDebugPrint3("number of cell data arrays: " + str(numcellarrays) + "\n") |
| 116 |
numcelltuples = celldata.GetNumberOfTuples() |
| 117 |
myDebugPrint3("number of cell data tuples: " + str(numcelltuples) + "\n") |
| 118 |
for ii in range(0, numcellarrays): |
| 119 |
myDebugPrint3(str(ii) + ": " + str(celldata.GetArray(ii).GetNumberOfComponents()) + ": " + str(celldata.GetArrayName(ii)) + "\n") |
| 120 |
|
| 121 |
pointdata = inInputCsData.GetPointData() |
| 122 |
numpointarrays = pointdata.GetNumberOfArrays() |
| 123 |
myDebugPrint3("number of point data arrays: " + str(numpointarrays) + "\n") |
| 124 |
numpointtuples = pointdata.GetNumberOfTuples() |
| 125 |
myDebugPrint3("number of point data tuples: " + str(numpointtuples) + "\n") |
| 126 |
for ii in range(0, numpointarrays): |
| 127 |
myDebugPrint3(str(ii) + ": " + str(pointdata.GetArray(ii).GetNumberOfComponents()) + ": " + str(pointdata.GetArrayName(ii)) + "\n") |
| 128 |
|
| 129 |
def RecursivelyPrintPointAndCellArrayInformation(pvFilter): |
| 130 |
if PhactoriDbg(100): |
| 131 |
myDebugPrint3("RecursivelyPrintPointAndCellArrayInformation entered\n") |
| 132 |
|
| 133 |
recursionParams = PrintPointAndCellArrayInformationRecursionParams() |
| 134 |
recursionObj = PhactoriParaviewMultiBlockRecursionControl() |
| 135 |
recursionObj.mParameters = recursionParams |
| 136 |
recursionObj.mOperationToDoPerBlock = PrintPointAndCellArrayInformationInBlock |
| 137 |
|
| 138 |
PhactoriRecusivelyDoMethodPerBlockFromParaViewFilter(recursionObj, pvFilter) |
| 139 |
if PhactoriDbg(100): |
| 140 |
myDebugPrint3("RecursivelyPrintPointAndCellArrayInformation returning\n") |
| 141 |
|
| 142 |
#phactori_combine_to_single_python_file_subpiece_end_1 |