| 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 PhactoriStreamTracerSeedSourceOperation(PhactoriOperationSpecifics): |
| 38 |
def __init__(self): |
| 39 |
PhactoriOperationSpecifics.__init__(self) |
| 40 |
self.SeedSourceName = None |
| 41 |
self.InternalParaViewFilterPtr = None |
| 42 |
return |
| 43 |
|
| 44 |
def ParseParametersFromJson(self, inJson): |
| 45 |
key1 = "seed source" |
| 46 |
if key1 not in inJson: |
| 47 |
myDebugPrint3AndException("PhactoriStreamTracerSeedSourceOperation:ParseParametersFromJson\n" |
| 48 |
"'" + key1 + "' must be in block to specify source for seed points\n") |
| 49 |
self.SeedSourceName = inJson[key1] |
| 50 |
|
| 51 |
def GetListOfInputOperationNamesForThisOperationType(self): |
| 52 |
"""PhactoriStreamTracerSeedSourceOperation depends on the seed sources as |
| 53 |
well as the input source""" |
| 54 |
retList = [] |
| 55 |
retList.append(self.SeedSourceName) |
| 56 |
return retList |
| 57 |
|
| 58 |
def DebugPrintInputPortAndOutputPortInfo(self, infoTag): |
| 59 |
if PhactoriDbg(100): |
| 60 |
myDebugPrint3(infoTag) |
| 61 |
stcso = self.InternalParaViewFilterPtr.GetClientSideObject() |
| 62 |
stodo = stcso.GetOutputDataObject(0) |
| 63 |
myDebugPrint3("stodo: " + str(stodo.GetClassName()) + " numcells " + str(stodo.GetNumberOfCells()) + " numpoints " + str(stodo.GetNumberOfPoints()) + "\n") |
| 64 |
stido0 = stcso.GetInputDataObject(0,0) |
| 65 |
myDebugPrint3("stido0: " + str(stido0.GetClassName()) + "\n") |
| 66 |
stido1 = stcso.GetInputDataObject(1,0) |
| 67 |
myDebugPrint3("stido1: " + str(stido1.GetClassName()) + " numcells " + str(stido1.GetNumberOfCells()) + " numpoints " + str(stido1.GetNumberOfPoints()) + "\n") |
| 68 |
|
| 69 |
def CreateParaViewFilter2(self, inInputFilter, inPipeAndViewsState): |
| 70 |
"""create the clip plane filter for ParaView""" |
| 71 |
if PhactoriDbg(100): |
| 72 |
myDebugPrint3('PhactoriStreamTracerSeedSourceOperation:CreateParaViewFilter entered\n', 100) |
| 73 |
#info in block class should already be parsed and checked |
| 74 |
|
| 75 |
UpdatePipelineWithCurrentTimeArgument(inInputFilter) |
| 76 |
|
| 77 |
#get seed source operation |
| 78 |
paraviewSeedSource = inPipeAndViewsState.GetParaViewSourceByOperationName(self.SeedSourceName) |
| 79 |
if PhactoriDbg(100): |
| 80 |
myDebugPrint3("self.SeedSourceName: " + str(self.SeedSourceName) + \ |
| 81 |
"\nparaviewSeedSource: " + str(paraviewSeedSource) + "\n", 100) |
| 82 |
|
| 83 |
UpdatePipelineWithCurrentTimeArgument(paraviewSeedSource) |
| 84 |
|
| 85 |
if PhactoriDbg(100): |
| 86 |
psscso = paraviewSeedSource.GetClientSideObject() |
| 87 |
pssodo = psscso.GetOutputDataObject(0) |
| 88 |
myDebugPrint3("pssodo: " + str(pssodo.GetClassName()) + " numcells " + str(pssodo.GetNumberOfCells()) + " numpoints " + str(pssodo.GetNumberOfPoints()) + "\n") |
| 89 |
|
| 90 |
savedActiveSource = GetActiveSource() |
| 91 |
|
| 92 |
self.InternalParaViewFilterPtr = StreamTracerWithCustomSource(Input = inInputFilter, SeedSource=paraviewSeedSource) |
| 93 |
|
| 94 |
#psscso = paraviewSeedSource.GetClientSideObject() |
| 95 |
#pssodo = psscso.GetOutputDataObject(0) |
| 96 |
#stcso = self.InternalParaViewFilterPtr.GetClientSideObject() |
| 97 |
#stcso.SetInputDataObject(1,pssodo) |
| 98 |
|
| 99 |
self.InternalParaViewFilterPtr.Vectors = ["CELLS", "velocity_xyz"] |
| 100 |
#self.InternalParaViewFilterPtr.Vectors = ["POINTS", "velocity_xyz"] |
| 101 |
self.InternalParaViewFilterPtr.MaximumStreamlineLength = 100.0 |
| 102 |
self.InternalParaViewFilterPtr.IntegrationDirection = 'FORWARD' |
| 103 |
self.InternalParaViewFilterPtr.MaximumSteps = 5000 |
| 104 |
#self.InternalParaViewFilterPtr.InitialStepLength = 0.01 |
| 105 |
|
| 106 |
self.DebugPrintInputPortAndOutputPortInfo("pre filter update 1\n") |
| 107 |
|
| 108 |
SetActiveSource(self.InternalParaViewFilterPtr) |
| 109 |
SetActiveSource(savedActiveSource) |
| 110 |
|
| 111 |
UpdatePipelineWithCurrentTimeArgument(self.InternalParaViewFilterPtr) |
| 112 |
|
| 113 |
self.DebugPrintInputPortAndOutputPortInfo("post filter update 1\n") |
| 114 |
|
| 115 |
if PhactoriDbg(100): |
| 116 |
myDebugPrint3("self.InternalParaViewFilterPtr: " + str(self.InternalParaViewFilterPtr) + "\n", 100) |
| 117 |
|
| 118 |
if PhactoriDbg(100): |
| 119 |
myDebugPrint3('PhactoriStreamTracerSeedSourceOperation.CreateParaViewFilter returning\n', 100) |
| 120 |
|
| 121 |
return self.InternalParaViewFilterPtr |
| 122 |
|
| 123 |
#phactori_combine_to_single_python_file_subpiece_end_1 |