Skip to content

Commit

Permalink
Post: isoSurf dopee
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanMary69 committed Jul 2, 2024
1 parent e737697 commit 4822947
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 884 deletions.
37 changes: 1 addition & 36 deletions Cassiopee/Post/Post/Post.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'exteriorFaces', 'exteriorFacesStructured', 'extractMesh', 'extractPlane',
'extractPoint', 'frontFaces', 'integ', 'integMoment', 'integMomentNorm',
'integNorm', 'integNormProduct', 'interiorFaces', 'isoLine', 'isoSurf',
'isoSurfMC', 'isoSurfMC_opt', 'perlinNoise', 'projectCloudSolution',
'isoSurfMC', 'perlinNoise', 'projectCloudSolution',
'refine', 'renameVars', 'selectCells', 'selectCells2', 'selectCells3',
'sharpEdges', 'silhouette', 'slice', 'streamLine', 'streamLine2',
'streamRibbon', 'streamRibbon2', 'streamSurf', 'usurp', 'zip', 'zipper',
Expand Down Expand Up @@ -1013,41 +1013,6 @@ def isoSurfMC(array, var, value, split='simple'):
except: return []
else: return isoSurf(array, var, value, split)

#==============================================================================
def isoSurfMC_opt(array, var, value):
"""Compute an isoSurf correponding to value of field 'var' in
volume arrays.
Usage: isoSurfMC_opt(array, 'Density', 1.2)"""
try: import Transform
except: return []

if isinstance(array[0], list):
ret = []; pool = []
for i in array:
if len(i) == 5: i = Converter.convertArray2Hexa(i)
if i[3] == 'HEXA':
try:
i = post.isoSurfMC_opt(i, var, value)
#i = Transform.reorder(i, (1,))
ret.append(i)
except: pass
else: pool.append(i)

if pool != []: ret2 = isoSurf(pool, var, value)
else: ret2 = []
return ret + ret2
else:
if len(array) == 5:
array = Converter.convertArray2Hexa(array)
if array[3] == 'HEXA':
try:
b = post.isoSurfMC_opt(array, var, value)
#for a in b:
#a = Transform.reorder(a, (1,))
return b
except: return []
else: return isoSurf(array, var, value)

#==============================================================================
def enforceIndicatorNearBodies(indicator, octreeHexa, bodies):
"""Enforce the refinement indicator to -1000 near bodies."""
Expand Down
95 changes: 0 additions & 95 deletions Cassiopee/Post/Post/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2173,101 +2173,6 @@ def isoSurf(t, var, value, vars=None, split='simple'):
except: raise
return ret

def isoSurfMC_opt(t, var, value, list=[]):
"""Compute an iso surface in volume zones using marching cubes.
If varlist present, only variables of varlist are interpolated on the isosurface
Usage: isoSurfMC_opt(t, var, value, varlist)"""
import KCore
OMP_NUM_THREADS = KCore.getOmpMaxThreads()
zvars = var.split(':')
if len(zvars) == 2: var = zvars[1]
ret = []; new_list=[]; coord=['CoordinateX','CoordinateY','CoordinateZ']

if list != []:
if var not in coord: list.append(var) # ajout du champ source de l'isosurface

#for v in list: t = C.center2Node(t, 'centers:'+v) # calcul des valeur au node strictement necessaire (list + var)

new_list = coord + list

#else: t = C.center2Node(t, Internal.__FlowSolutionCenters__)

zones = Internal.getZones(t)

for z in zones:
array = []
if list==[]: array = C.getAllFields(z, 'nodes')[0]
else:
# bout de code pompe de Converter.getFields
dim = Internal.getZoneDim(z)
if dim[0] == 'Structured':
np = dim[1]*dim[2]*dim[3]
connects = []
else:
np = dim[1]
connects = Internal.getElementNodes(z)

info = z[2]; out = []; loc = 0
for i in info:
if (i[0] in [Internal.__GridCoordinates__,Internal.__FlowSolutionNodes__]):
locf = Internal.getNodeFromType1(i, 'GridLocation_t')
if (locf is not None and Internal.getValue(locf) == 'CellCenter'): loc = 1
for j in i[2]:
if (j[3] == 'DataArray_t' and j[0] in new_list): out.append(j)

if out != []: array = Internal.convertDataNodes2Array(out, dim, connects, loc)
else: array = []

try:
b = Post.isoSurfMC_opt(array, var, value)
c = 0
for a in b:
if a != []:
c += 1
##si calcul sur un thread on peu recuperer le nom de la zone direct.
# Voir avec christophe la mainiere elegante de recuper l info thread en python
# import os obligatoire??
if OMP_NUM_THREADS == 1: name= z[0]
else: name = z[0]+'_omp'+str(c)
zp = C.convertArrays2ZoneNode(z[0], a)
zp[0] = name # pour identification
ret.append(zp)
except: raise

if var not in coord: ret = C.rmVars(ret, var)
return ret


#def isoSurfMC(t, var, value, vars=None, split='simple'):
# """Compute an iso surface in volume zones using marching cubes.
# Usage: isoSurfMC(t, var, value, vars, split)"""
# if vars is None:
# t = C.center2Node(t, Internal.__FlowSolutionCenters__)
# else:
# for v in vars:
# vs = v.split(':')
# vc = []; vn = ['CoordinateX','CoordinateY','CoordinateY']
# if len(vs) == 2 and vs[0] == 'centers': vc.append(vs[1])
# elif len(vs) == 2 and vs[0] == 'nodes': vn.append(vs[1])
# else: vn.append(v)
# if vc != []: t = C.center2Node(t, vc)
#
# zones = Internal.getZones(t)
# var, loc = Internal.fixVarName(var)
# ret = []
# for z in zones:
# if vars is None: array = C.getAllFields(z, 'nodes')[0]
# else: array = C.getFields([Internal.__GridCoordinates__, Internal.__FlowSolutionNodes__], z, vn+vc)[0]
# try:
# a = Post.isoSurfMC(array, var, value, split)
# if a != []:
# zp = C.convertArrays2ZoneNode(z[0], a)
# zp[0] = z[0] # pour identification
# ret.append(zp)
# except: raise
# return ret


def isoSurfMC(t, var, value, vars=None, split='simple'):
"""Compute an iso surface in volume zones using marching cubes.
Usage: isoSurfMC(t, var, value, vars, split)"""
Expand Down
Loading

0 comments on commit 4822947

Please sign in to comment.