| 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 .PhactoriVectorLibrary import * |
| 35 |
from paraview.simple import * |
| 36 |
from .PhactoriSampledCellInfo import * |
| 37 |
import vtk |
| 38 |
import json |
| 39 |
from .PhactoriParaviewMultiBlockRecursion import * |
| 40 |
|
| 41 |
#phactori_combine_to_single_python_file_subpiece_begin_1 |
| 42 |
|
| 43 |
def GetCellTestPoint(theCell): |
| 44 |
theCellBounds = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 45 |
theCell.GetBounds(theCellBounds) |
| 46 |
retXyz = [0.5 * (theCellBounds[0] + theCellBounds[1]), |
| 47 |
0.5 * (theCellBounds[2] + theCellBounds[3]), |
| 48 |
0.5 * (theCellBounds[4] + theCellBounds[5])] |
| 49 |
return retXyz |
| 50 |
|
| 51 |
def localGetCellijk(ii, jj, kk, inInputCsData, myExtent): |
| 52 |
#returnCell = inInputCsData.GetCell(ii, jj, kk) |
| 53 |
computedIndex = vtk.vtkStructuredData.ComputeCellIdForExtent(myExtent, [ii,jj,kk]) |
| 54 |
returnCell = inInputCsData.GetCell(computedIndex) |
| 55 |
return returnCell |
| 56 |
|
| 57 |
class PhactoriSampledCellInfo: |
| 58 |
def __init__(self): |
| 59 |
self.cellTestPoint = [0.0,0.0,0.0] |
| 60 |
self.pid = -1 |
| 61 |
self.leafVisitCount = -1 |
| 62 |
self.ijk = [-1,-1,-1] |
| 63 |
self.dataTuple = [] |
| 64 |
self.index = -1 |
| 65 |
self.segmentIndex = -1 |
| 66 |
self.collectionAxis = 2 |
| 67 |
|
| 68 |
def ToStr(self): |
| 69 |
outStr = "PhactoriSampledCellInfo:\n" +\ |
| 70 |
"cellTestPoint: " + str(self.cellTestPoint) + "\n" +\ |
| 71 |
"pid: " + str(self.pid) + "\n" +\ |
| 72 |
"leafVisitCount: " + str(self.leafVisitCount) + "\n" +\ |
| 73 |
"ijk: " + str(self.ijk) + "\n" +\ |
| 74 |
"index: " + str(self.index) + "\n" +\ |
| 75 |
"segmentIndex: " + str(self.segmentIndex) + "\n" +\ |
| 76 |
"collectionAxis: " + str(self.collectionAxis) + "\n" +\ |
| 77 |
"dataTuple: " + str(self.dataTuple) + "\n" |
| 78 |
return outStr |
| 79 |
|
| 80 |
def SetFromList(self, newValues): |
| 81 |
tripletVal = newValues[0] |
| 82 |
self.cellTestPoint[0] = tripletVal[0] |
| 83 |
self.cellTestPoint[1] = tripletVal[1] |
| 84 |
self.cellTestPoint[2] = tripletVal[2] |
| 85 |
tripletVal = newValues[1] |
| 86 |
self.ijk[0] = tripletVal[0] |
| 87 |
self.ijk[1] = tripletVal[1] |
| 88 |
self.ijk[2] = tripletVal[2] |
| 89 |
if newValues[2] == None: |
| 90 |
self.dataTuple = None |
| 91 |
else: |
| 92 |
self.dataTuple = list(newValues[2]) |
| 93 |
self.pid = newValues[3] |
| 94 |
self.leafVisitCount = newValues[4] |
| 95 |
self.index = newValues[5] |
| 96 |
self.segmentIndex = newValues[6] |
| 97 |
self.collectionAxis = newValues[7] |
| 98 |
|
| 99 |
def GetAsList(self): |
| 100 |
return [self.cellTestPoint, self.ijk, self.dataTuple, self.pid, self.leafVisitCount, self.index, self.segmentIndex, self.collectionAxis] |
| 101 |
|
| 102 |
def ToStrTerseOneLineList(self): |
| 103 |
return str(self.GetAsList()) |
| 104 |
#outStr = "[" + \ |
| 105 |
# str(self.cellTestPoint) + "," + \ |
| 106 |
# str(self.ijk) + "," + \ |
| 107 |
# str(self.dataTuple) + "," + \ |
| 108 |
# str(self.pid) + "," + \ |
| 109 |
# str(self.index) + "," + \ |
| 110 |
# str(self.segmentIndex) + "," + \ |
| 111 |
# str(self.collectionAxis) + \ |
| 112 |
# "]" |
| 113 |
#return outStr |
| 114 |
|
| 115 |
@staticmethod |
| 116 |
def TerseOneLineJsonFormatComment(): |
| 117 |
outStr = '{"PhactoriSampledCellInfo output format 1 info":[\n' + \ |
| 118 |
'" [cellTestPoint, ijk, dataTuple, pid, index, segmentIndex, collectionAxis]",\n' + \ |
| 119 |
'" cellTestPoint is [X, Y, Z], ijk is [i, j, k], dataTuple is [c1, c2, ... cN]"]}' |
| 120 |
return outStr |
| 121 |
|
| 122 |
def SetIndex(self, newIndex): |
| 123 |
self.index = newIndex |
| 124 |
|
| 125 |
def SetCollectionAxis(self, newCollectionAxis): |
| 126 |
self.collectionAxis = newCollectionAxis |
| 127 |
|
| 128 |
def AxisCrossesExtent(self, myExtent, whichAxis): |
| 129 |
# i -> 0 |
| 130 |
# j -> 1 |
| 131 |
# k -> 2 |
| 132 |
# ij -> 3 |
| 133 |
# ik -> 4 |
| 134 |
# jk -> 5 |
| 135 |
if whichAxis < 3: |
| 136 |
if whichAxis != 0: |
| 137 |
if self.ijk[0] < myExtent[0]: |
| 138 |
return False |
| 139 |
if self.ijk[0] >= myExtent[1]: |
| 140 |
return False |
| 141 |
if whichAxis != 1: |
| 142 |
if self.ijk[1] < myExtent[2]: |
| 143 |
return False |
| 144 |
if self.ijk[1] >= myExtent[3]: |
| 145 |
return False |
| 146 |
if whichAxis != 2: |
| 147 |
if self.ijk[2] < myExtent[4]: |
| 148 |
return False |
| 149 |
if self.ijk[2] >= myExtent[5]: |
| 150 |
return False |
| 151 |
else: |
| 152 |
if whichAxis == 3: |
| 153 |
if self.ijk[2] < myExtent[4]: |
| 154 |
return False |
| 155 |
if self.ijk[2] >= myExtent[5]: |
| 156 |
return False |
| 157 |
if whichAxis == 4: |
| 158 |
if self.ijk[1] < myExtent[2]: |
| 159 |
return False |
| 160 |
if self.ijk[1] >= myExtent[3]: |
| 161 |
return False |
| 162 |
if whichAxis == 5: |
| 163 |
if self.ijk[0] < myExtent[0]: |
| 164 |
return False |
| 165 |
if self.ijk[0] >= myExtent[1]: |
| 166 |
return False |
| 167 |
return True |
| 168 |
|
| 169 |
def GetIntersectingCollectionExtent(self, whichExtent, whichAxis): |
| 170 |
# i -> 0 |
| 171 |
# j -> 1 |
| 172 |
# k -> 2 |
| 173 |
# ij -> 3 |
| 174 |
# ik -> 4 |
| 175 |
# jk -> 5 |
| 176 |
retext = list(whichExtent) |
| 177 |
if self.AxisCrossesExtent(whichExtent, whichAxis) == False: |
| 178 |
retExt[1] = retExt[0] |
| 179 |
retExt[3] = retExt[2] |
| 180 |
retExt[5] = retExt[4] |
| 181 |
return retExt |
| 182 |
if (whichAxis != 0) and (whichAxis != 3) and (whichAxis != 4): |
| 183 |
retext[0] = self.ijk[0] |
| 184 |
retext[1] = self.ijk[0] + 1 |
| 185 |
if (whichAxis != 1) and (whichAxis != 3) and (whichAxis != 5): |
| 186 |
retext[2] = self.ijk[1] |
| 187 |
retext[3] = self.ijk[1] + 1 |
| 188 |
if (whichAxis != 2) and (whichAxis != 4) and (whichAxis != 5): |
| 189 |
retext[4] = self.ijk[2] |
| 190 |
retext[5] = self.ijk[2] + 1 |
| 191 |
return retext |
| 192 |
|
| 193 |
def SetCellTestPoint(self, inPt): |
| 194 |
self.cellTestPoint[0] = inPt[0] |
| 195 |
self.cellTestPoint[1] = inPt[1] |
| 196 |
self.cellTestPoint[2] = inPt[2] |
| 197 |
|
| 198 |
def SetIjk(self, ii, jj, kk): |
| 199 |
self.ijk[0] = ii |
| 200 |
self.ijk[1] = jj |
| 201 |
self.ijk[2] = kk |
| 202 |
|
| 203 |
def SetDataTuple(self, inDataTuple): |
| 204 |
self.dataTuple = list(inDataTuple) |
| 205 |
|
| 206 |
def SerializeAppendToFloatAndIntArray(self, outSerialFloatArray, outSerialIntArray, inTupleSize = 0): |
| 207 |
outSerialFloatArray.append(self.cellTestPoint[0]) |
| 208 |
outSerialFloatArray.append(self.cellTestPoint[1]) |
| 209 |
outSerialFloatArray.append(self.cellTestPoint[2]) |
| 210 |
if self.dataTuple != None: |
| 211 |
localTupleLen = len(self.dataTuple) |
| 212 |
for ii in range(0,inTupleSize): |
| 213 |
if ii >= localTupleLen: |
| 214 |
outSerialFloatArray.append(0.0) |
| 215 |
else: |
| 216 |
outSerialFloatArray.append(self.dataTuple[ii]) |
| 217 |
else: |
| 218 |
for ii in range(0,inTupleSize): |
| 219 |
outSerialFloatArray.append(0.0) |
| 220 |
outSerialIntArray.append(self.pid) |
| 221 |
outSerialIntArray.append(self.leafVisitCount) |
| 222 |
outSerialIntArray.append(self.ijk[0]) |
| 223 |
outSerialIntArray.append(self.ijk[1]) |
| 224 |
outSerialIntArray.append(self.ijk[2]) |
| 225 |
outSerialIntArray.append(self.segmentIndex) |
| 226 |
|
| 227 |
def SerializeAppendToFloatAndIntArrayZeroVersion(self, outSerialFloatArray, outSerialIntArray, inTupleSize = -1): |
| 228 |
outSerialFloatArray.append(0.0) |
| 229 |
outSerialFloatArray.append(0.0) |
| 230 |
outSerialFloatArray.append(0.0) |
| 231 |
if inTupleSize < 0: |
| 232 |
for ffval in self.dataTuple: |
| 233 |
outSerialFloatArray.append(0.0) |
| 234 |
else: |
| 235 |
for ffval in range(0, inTupleSize): |
| 236 |
outSerialFloatArray.append(0.0) |
| 237 |
outSerialIntArray.append(0) |
| 238 |
outSerialIntArray.append(0) |
| 239 |
outSerialIntArray.append(0) |
| 240 |
outSerialIntArray.append(0) |
| 241 |
outSerialIntArray.append(0) |
| 242 |
outSerialIntArray.append(0) |
| 243 |
|
| 244 |
@staticmethod |
| 245 |
def GetSerializeFloatAndIntSize(tupleSize = 0): |
| 246 |
floatsize = 3 + tupleSize |
| 247 |
intsize = 6 |
| 248 |
return floatsize, intsize |
| 249 |
|
| 250 |
def SerializeSetFromFloatAndIntArray(self, inSerialFloatArray, inSerialIntArray, inIndex, inTupleSize = 0): |
| 251 |
#floatsize, intsize = GetSerializeFloatAndIntSize() |
| 252 |
floatsize = 3 + inTupleSize |
| 253 |
intsize = 6 |
| 254 |
floatIndex = floatsize * inIndex |
| 255 |
intIndex = intsize * inIndex |
| 256 |
self.cellTestPoint[0] = inSerialFloatArray[floatIndex+0] |
| 257 |
self.cellTestPoint[1] = inSerialFloatArray[floatIndex+1] |
| 258 |
self.cellTestPoint[2] = inSerialFloatArray[floatIndex+2] |
| 259 |
self.dataTuple = [] |
| 260 |
if inTupleSize > 0: |
| 261 |
for ii in range(0, inTupleSize): |
| 262 |
self.dataTuple.append(inSerialFloatArray[floatIndex+3+ii]) |
| 263 |
self.pid = inSerialIntArray[intIndex + 0] |
| 264 |
self.leafVisitCount = inSerialIntArray[intIndex + 1] |
| 265 |
self.ijk[0] = inSerialIntArray[intIndex + 2] |
| 266 |
self.ijk[1] = inSerialIntArray[intIndex + 3] |
| 267 |
self.ijk[2] = inSerialIntArray[intIndex + 4] |
| 268 |
self.segmentIndex = inSerialIntArray[intIndex + 5] |
| 269 |
|
| 270 |
def Populate1(self, ii, jj, kk, myPid, leafVisitCount, seedCellIndex, |
| 271 |
inInputCsData, myExtent, numCells, outputCellArray, dataArrayNumCmpnts, defaultTuple): |
| 272 |
#used during recursion to set up the cell based on the ii, jj, kk indices |
| 273 |
self.SetIjk(ii,jj,kk) |
| 274 |
self.pid = myPid |
| 275 |
self.leafVisitCount = leafVisitCount |
| 276 |
self.segmentIndex = seedCellIndex |
| 277 |
#dataCell = inInputCsData.GetCell(ii, jj, kk) |
| 278 |
dataCell = localGetCellijk(ii, jj, kk, inInputCsData, myExtent) |
| 279 |
cellTestPoint = GetCellTestPoint(dataCell) |
| 280 |
self.SetCellTestPoint(cellTestPoint) |
| 281 |
cellId = vtk.vtkStructuredData.ComputeCellIdForExtent(myExtent, [ii,jj,kk]) |
| 282 |
self.SetIndex(cellId) |
| 283 |
if dataArrayNumCmpnts > 0: |
| 284 |
if (cellId < numCells) and (cellId >= 0): |
| 285 |
dataTuple = outputCellArray.GetTuple(cellId) |
| 286 |
self.SetDataTuple(dataTuple) |
| 287 |
else: |
| 288 |
self.SetDataTuple(defaultTuple) |
| 289 |
|
| 290 |
class PhactoriFindCellWithMinMaxDataOnThisProcessRecursionParams: |
| 291 |
def __init__(self): |
| 292 |
self.leafVisitCount = 0 |
| 293 |
self.dataArrayName = "noname" |
| 294 |
self.minCell = sys.float_info.max |
| 295 |
self.maxCell = None |
| 296 |
self.dataTotal = 0.0 |
| 297 |
self.dataCount = 0 |
| 298 |
self.currentMinVal = sys.float_info.max |
| 299 |
self.currentMaxVal = -sys.float_info.max |
| 300 |
|
| 301 |
def SetUpForRecursion(self, cellDataArrayName): |
| 302 |
self.dataTotal = 0.0 |
| 303 |
self.dataCount = 0 |
| 304 |
self.currentMinVal = sys.float_info.max |
| 305 |
self.currentMaxVal = -sys.float_info.max |
| 306 |
self.dataArrayName = cellDataArrayName |
| 307 |
self.minCell = PhactoriSampledCellInfo() |
| 308 |
self.minCell.SetFromList([[0.0,0.0,0.0], [-1,-1,-1], [self.currentMinVal], -1, -1, -1, -1, -1]) |
| 309 |
self.maxCell = PhactoriSampledCellInfo() |
| 310 |
self.maxCell.SetFromList([[0.0,0.0,0.0], [-1,-1,-1], [self.currentMaxVal], -1, -1, -1, -1, -1]) |
| 311 |
|
| 312 |
def PhactoriFindCellWithMinMaxDataOnThisProcessInBlock(recursionObject, inInputCsData, inParameters): |
| 313 |
if PhactoriDbg(100): |
| 314 |
myDebugPrint3("PhactoriFindCellWithMinMaxDataOnThisProcessInBlock entered\n") |
| 315 |
|
| 316 |
inParameters.leafVisitCount += 1 |
| 317 |
|
| 318 |
numCells = inInputCsData.GetNumberOfCells() |
| 319 |
numPoints = inInputCsData.GetNumberOfPoints() |
| 320 |
if (numCells == 0) or (numPoints == 0): |
| 321 |
if PhactoriDbg(100): |
| 322 |
myDebugPrint3("PhactoriFindCellWithMinMaxDataOnThisProcessInBlock returning 1\n") |
| 323 |
#no cells here |
| 324 |
return |
| 325 |
|
| 326 |
cellData = inInputCsData.GetCellData() |
| 327 |
if cellData == None: |
| 328 |
if PhactoriDbg(100): |
| 329 |
myDebugPrint3("PhactoriFindCellWithMinMaxDataOnThisProcessInBlock returning 2\n") |
| 330 |
|
| 331 |
outputCellArray = None |
| 332 |
outputCellArray = cellData.GetArray(inParameters.dataArrayName) |
| 333 |
|
| 334 |
if outputCellArray == None: |
| 335 |
if PhactoriDbg(100): |
| 336 |
myDebugPrint3("PhactoriFindCellWithMinMaxDataOnThisProcessInBlock returning 3\n") |
| 337 |
|
| 338 |
myPid = SmartGetLocalProcessId() |
| 339 |
for cellIndex in range(0,numCells): |
| 340 |
thisCellDataTuple = outputCellArray.GetTuple(cellIndex) |
| 341 |
cellDataVal = thisCellDataTuple[0] |
| 342 |
inParameters.dataTotal += cellDataVal |
| 343 |
inParameters.dataCount += 1 |
| 344 |
if cellDataVal < inParameters.currentMinVal: |
| 345 |
inParameters.currentMinVal = cellDataVal |
| 346 |
oneCell = inInputCsData.GetCell(cellIndex) |
| 347 |
cellTestPoint = GetCellTestPoint(oneCell) |
| 348 |
inParameters.minCell.index = cellIndex |
| 349 |
inParameters.minCell.dataTuple[0] = cellDataVal |
| 350 |
inParameters.minCell.cellTestPoint[0] = cellTestPoint[0] |
| 351 |
inParameters.minCell.cellTestPoint[1] = cellTestPoint[1] |
| 352 |
inParameters.minCell.cellTestPoint[2] = cellTestPoint[2] |
| 353 |
inParameters.minCell.pid = myPid |
| 354 |
inParameters.leafVisitCount = inParameters.leafVisitCount |
| 355 |
if cellDataVal > inParameters.currentMaxVal: |
| 356 |
inParameters.currentMaxVal = cellDataVal |
| 357 |
oneCell = inInputCsData.GetCell(cellIndex) |
| 358 |
cellTestPoint = GetCellTestPoint(oneCell) |
| 359 |
inParameters.currentMinVal = cellDataVal |
| 360 |
cellTestPoint = GetCellTestPoint(oneCell) |
| 361 |
inParameters.maxCell.index = cellIndex |
| 362 |
inParameters.maxCell.dataTuple[0] = cellDataVal |
| 363 |
inParameters.maxCell.cellTestPoint[0] = cellTestPoint[0] |
| 364 |
inParameters.maxCell.cellTestPoint[1] = cellTestPoint[1] |
| 365 |
inParameters.maxCell.cellTestPoint[2] = cellTestPoint[2] |
| 366 |
inParameters.maxCell.pid = myPid |
| 367 |
inParameters.leafVisitCount = inParameters.leafVisitCount |
| 368 |
|
| 369 |
if PhactoriDbg(100): |
| 370 |
myDebugPrint3("PhactoriFindCellWithMinMaxDataOnThisProcessInBlock returning\n") |
| 371 |
|
| 372 |
def PhactoriFindCellWithMinMaxDataOnThisProcess(paraviewFilter, cellDataArrayName): |
| 373 |
if PhactoriDbg(100): |
| 374 |
myDebugPrint3("PhactoriFindCellWithMinMaxDataOnThisProcess entered\n" + \ |
| 375 |
"paraviewFilter: " + str(paraviewFilter) + "\n") |
| 376 |
|
| 377 |
recursionParams = PhactoriFindCellWithMinMaxDataOnThisProcessRecursionParams() |
| 378 |
recursionParams.SetUpForRecursion(cellDataArrayName) |
| 379 |
recursionObj = PhactoriParaviewMultiBlockRecursionControl() |
| 380 |
recursionObj.mParameters = recursionParams |
| 381 |
recursionObj.mOperationToDoPerBlock = PhactoriFindCellWithMinMaxDataOnThisProcessInBlock |
| 382 |
|
| 383 |
PhactoriRecusivelyDoMethodPerBlockFromParaViewFilter(recursionObj, paraviewFilter) |
| 384 |
if PhactoriDbg(100): |
| 385 |
myDebugPrint3("PhactoriFindCellWithMinMaxDataOnThisProcess returning\n") |
| 386 |
|
| 387 |
return [recursionParams.minCell, recursionParams.maxCell] |
| 388 |
|
| 389 |
def PhactoriFindCellWtihMinMaxDataUsingMPI(paraviewFilter, cellDataArrayName): |
| 390 |
if PhactoriDbg(100): |
| 391 |
myDebugPrint3("PhactoriFindCellWtihMinMaxDataUsingMPI entered\n" + \ |
| 392 |
"paraviewFilter: " + str(paraviewFilter) + "\n") |
| 393 |
|
| 394 |
thisPidMinMaxCells = PhactoriFindCellWithMinMaxDataOnThisProcess(paraviewFilter, cellDataArrayName) |
| 395 |
globalMinMaxCells = PhactoriLocalToGlobalCellsWithMinMaxDataUsingMPI(thisPidMinMaxCells, 1) |
| 396 |
|
| 397 |
if PhactoriDbg(100): |
| 398 |
myDebugPrint3("PhactoriFindCellWtihMinMaxDataUsingMPI returning\n") |
| 399 |
return globalMinMaxCells |
| 400 |
|
| 401 |
def PhactoriLocalToGlobalCellsWithMinMaxDataUsingMPI(localPidMinMaxCellPair, tupleSize): |
| 402 |
|
| 403 |
if PhactoriDbg(100): |
| 404 |
myDebugPrint3("PhactoriLocalToGlobalCellsWithMinMaxDataUsingMPI entered\n") |
| 405 |
#find overall min/max |
| 406 |
minVal = localPidMinMaxCellPair[0].dataTuple[0] |
| 407 |
maxVal = localPidMinMaxCellPair[1].dataTuple[0] |
| 408 |
if PhactoriDbg(100): |
| 409 |
myDebugPrint3("local min/max, tupleSize: " + str([minVal, maxVal, tupleSize]) + "\n") |
| 410 |
localMinMax = [-minVal, maxVal] |
| 411 |
globalMinMax = UseReduceOnFloatList(localMinMax, 0) |
| 412 |
globalMinVal = -globalMinMax[0] |
| 413 |
globalMaxVal = globalMinMax[1] |
| 414 |
if PhactoriDbg(100): |
| 415 |
myDebugPrint3("global min/max, tupleSize: " + str([globalMinVal, globalMaxVal, tupleSize]) + "\n") |
| 416 |
|
| 417 |
localPidMinMax = [-1,-1] |
| 418 |
myPid = SmartGetLocalProcessId() |
| 419 |
if globalMinVal == minVal: |
| 420 |
localPidMinMax[0] = myPid |
| 421 |
if globalMaxVal == maxVal: |
| 422 |
localPidMinMax[1] = myPid |
| 423 |
|
| 424 |
if PhactoriDbg(100): |
| 425 |
myDebugPrint3("localPidMinMax: " + str(localPidMinMax) + "\n") |
| 426 |
globalPidMinMax = UseReduceOnIntegerList(localPidMinMax, 0) |
| 427 |
if PhactoriDbg(100): |
| 428 |
myDebugPrint3("globalPidMinMax: " + str(globalPidMinMax) + "\n") |
| 429 |
|
| 430 |
localSerializedFloatArray = [] |
| 431 |
localSerializedIntArray = [] |
| 432 |
if globalPidMinMax[0] == myPid: |
| 433 |
localPidMinMaxCellPair[0].SerializeAppendToFloatAndIntArray(localSerializedFloatArray, localSerializedIntArray, tupleSize) |
| 434 |
else: |
| 435 |
localPidMinMaxCellPair[0].SerializeAppendToFloatAndIntArrayZeroVersion(localSerializedFloatArray, localSerializedIntArray, tupleSize) |
| 436 |
if globalPidMinMax[1] == myPid: |
| 437 |
localPidMinMaxCellPair[1].SerializeAppendToFloatAndIntArray(localSerializedFloatArray, localSerializedIntArray, tupleSize) |
| 438 |
else: |
| 439 |
localPidMinMaxCellPair[1].SerializeAppendToFloatAndIntArrayZeroVersion(localSerializedFloatArray, localSerializedIntArray, tupleSize) |
| 440 |
|
| 441 |
globalSerializedFloatArray = UseReduceOnFloatList(localSerializedFloatArray, 2) |
| 442 |
globalSerializedIntArray = UseReduceOnIntegerList(localSerializedIntArray, 2) |
| 443 |
|
| 444 |
globalMinCell = PhactoriSampledCellInfo() |
| 445 |
globalMaxCell = PhactoriSampledCellInfo() |
| 446 |
globalMinCell.SerializeSetFromFloatAndIntArray(globalSerializedFloatArray, globalSerializedIntArray, 0, tupleSize) |
| 447 |
globalMaxCell.SerializeSetFromFloatAndIntArray(globalSerializedFloatArray, globalSerializedIntArray, 1, tupleSize) |
| 448 |
|
| 449 |
if PhactoriDbg(100): |
| 450 |
myDebugPrint3("PhactoriLocalToGlobalCellsWithMinMaxDataUsingMPI returning\n") |
| 451 |
return [globalMinCell, globalMaxCell] |
| 452 |
|
| 453 |
#phactori_combine_to_single_python_file_subpiece_end_1 |