s = C.convertArray2Tetra(s); s = T.join(s); s = P.exteriorFaces(s) t = C.newPyTree(['Base']); t[2][1][2] = [a] # Blanking bodies = [[s]] BM = N.array([[1]],N.int32) t = X.blankCells(t,bodies,BM,blankingType='center_in') t = X.setHoleInterpolatedPoints(t,depth=-2) # Dist2Walls t = DTW.distance2Walls(t,[s],type='ortho',loc='centers',signed=1) t = C.center2Node(t,'centers:TurbulentDistance') # Gradient de distance localise en centres => normales t = P.computeGrad(t, 'TurbulentDistance') t = I.initConst(t,MInf=0.2,loc='centers') tc = C.node2Center(t) t = X.setIBCData(t, tc, loc='centers', storage='direct') no = 1 for bcType in xrange(4): for varType in xrange(1,4): t2 = X.setInterpTransfers(t,tc,bcType=bcType,varType=varType) test.testT(t2,no) no+=1 # Stockage inverse Internal._rmNodesByName(t,"IBCD_*") tc = X.setIBCData(t, tc, loc='centers', storage='inverse') for bcType in xrange(4): for varType in xrange(1,4): X._setInterpTransfers(t,tc,bcType=bcType,varType=varType) test.testT(tc,no) no += 1
def _eikonal(t, tc=None, loc='nodes', nitmax=10, err=0.01): MB = 1 try: import Connector.PyTree as X except: MB = 0 if tc is None or MB == 0: for z in Internal.getNodesFromType2(t, 'Zone_t'): _eikonalForZone(z, loc) return None # Eikonal nzones = len(Internal.getNodesFromType2(t, "Zone_t")) isConverged = [0] * nzones it = 0 nocv = 0 # nb de zones convergees # calcul de la taille de maille sur le niveau le plus fin dhmin = PHIMAX for z in Internal.getNodesFromType2(t, "Zone_t"): dhmin = min( dhmin, C.getValue(z, 'CoordinateX', 1) - C.getValue(z, 'CoordinateX', 0)) while nocv < nzones and it < nitmax + 1: print 'Iteration %d' % it # Eikonal sur les zones non convergees et sources if loc == 'nodes': C._initVars(t, 'PhiM={Phi}') else: C._initVars(t, 'centers:PhiM={centers:Phi}') no = 0 for z in Internal.getNodesFromType2(t, "Zone_t"): if isConverged[no] < 1 and C.getMaxValue(z, loc + ':flag') > 0.: if loc == 'nodes': C._initVars( z, 'Phi=({flag}<0.1)*%f+({flag}>0.)*{Phi}' % PHIMAX) else: C._initVars( z, 'centers:Phi=({centers:flag}<0.1)*%f+({centers:flag}>0.)*{Phi}' % PHIMAX) _eikonalForZone(z, loc=loc) isConverged[no] = -1 no += 1 # Synchro print 'Synchronization/transfers' if tc is not None: no = 0 for z in Internal.getNodesFromType2(t, "Zone_t"): if isConverged[no] == -1: # a ete eikonalise: transferts z2 = Internal.getNodeFromName(tc, z[0]) C._cpVars(z, loc + ':Phi', z2, 'Phi') C._initVars(z2, 'flag', 1.) # PAS THREADE ????? X._setInterpTransfers(t, z2, variables=['Phi', 'flag'], variablesIBC=None) no += 1 # Convergence if it > 0: no = 0 nocv = 0 for z in Internal.getNodesFromType2(t, "Zone_t"): if loc == 'nodes': C._initVars( z, 'DPhi=abs({Phi}-{PhiM})/(maximum(1.e-12,{Phi}))') else: C._initVars( z, 'centers:DPhi=abs({centers:Phi}-{centers:PhiM})/(maximum(1.e-12,{centers:Phi}))' ) valmax = C.getMaxValue(z, loc + ':DPhi') dhloc = C.getValue(z, 'CoordinateX', 1) - C.getValue( z, 'CoordinateX', 0) errloc = err * dhloc / dhmin # on augmente la tolerance au fur et a mesure qu on diminue la resolution if valmax < errloc and isConverged[no] == -1: isConverged[no] = 1 nocv += 1 elif isConverged[no] == 1: nocv += 1 no += 1 # Iteration it += 1 #----------------------------------------------------------------------------- if it < nitmax + 1: print 'Distance by Eikonal converged after %d subiterations.' % it else: print 'Warning: distance by Eikonal did not converged after %d subiterations.' % nitmax noi = 0 for i in isConverged: if i != 1: print i, noi noi += 1 return None
t = C.newPyTree(['Corps1', 'Corps2']) t[2][1][2].append(a) t[2][2][2].append(b) t = X.connectMatch(t, dim=3) C._fillEmptyBCWith(t, 'nref', 'BCFarfield', dim=3) C._addState(t, 'EquationDimension', 3) C._addVars(t, 'F') C._initVars(t, 'centers:G', 1.) t = X.applyBCOverlaps(t, depth=1) tDnr = C.node2ExtCenter(t) t1 = X.setInterpData(t, tDnr, sameName=1, loc='centers', storage='direct') C._initVars(tDnr, '{F}={CoordinateX}*{CoordinateY}') C._initVars(t1, '{centers:F}={centers:CoordinateX}*{centers:CoordinateY}') X._setInterpTransfers(t1, tDnr, cellNVariable='', variables=['F']) test.testT(t1, 0) t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='interpolated') t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='extrapolated') t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='orphan') t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='cellRatio') t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='donorAspect') test.testT(t1, 1) import sys sys.exit() tDnr = X.setInterpData(t, tDnr, sameName=1, loc='centers', storage='inverse') t1 = X.getOversetInfo(t, tDnr, loc='centers', type='interpolated') t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='extrapolated') t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='orphan') t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='cellRatio')
def transferCellN__(t, tc, DEPTH, loc): if tc is None: return t try: import Connector.PyTree as X except: raise ImportError( "Dist2Walls: Eikonal version requires Connector module.") # POINTS EXTERIEURS # Marquage des pts de front entre du 0 et du 1 t = X.setHoleInterpolatedPoints(t, depth=DEPTH, loc=loc) # transfert du cellN aux raccords if tc is not None: C._cpVars(t, loc + ':cellN', tc, 'cellN') for zc in Internal.getNodesFromType2(tc, "Zone_t"): if C.getMaxValue(zc, 'cellN') == 2.: X._setInterpTransfers(t, zc, variables=["cellN"]) if loc == 'nodes': C._initVars(t, "cellN=({cellN}>1.5)*2.+({cellN}>0.)*({cellN}<1.5)") C._initVars(t, 'cellN = 1-{cellN}+({cellN}>1.5)*3') else: C._initVars( t, "centers:cellN=({centers:cellN}>1.5)*2.+({centers:cellN}>0.)*({centers:cellN}<1.5)" ) C._initVars( t, 'centers:cellN = 1-{centers:cellN}+({centers:cellN}>1.5)*3') t = X.setHoleInterpolatedPoints(t, depth=DEPTH, loc=loc) if loc == 'nodes': C._initVars(t, 'cellN = 1-{cellN}+({cellN}>1.5)*3') C._initVars(t, 'cellN2={cellN}') else: C._initVars( t, 'centers:cellN = 1-{centers:cellN}+({centers:cellN}>1.5)*3') C._initVars(t, 'centers:cellN2={centers:cellN}') # POINTS INTERIEURS if loc == 'nodes': C._initVars(t, 'cellN=minimum(1.,{cellN})') else: C._initVars(t, 'centers:cellN=minimum(1.,{centers:cellN})') t = X.setHoleInterpolatedPoints(t, depth=-DEPTH, loc=loc) # transfert du cellN aux raccords if tc is not None: C._cpVars(t, loc + ':cellN', tc, 'cellN') for zc in Internal.getNodesFromType2(tc, "Zone_t"): if C.getMaxValue(zc, 'cellN') == 2.: X._setInterpTransfers(t, zc, variables=["cellN"]) if loc == 'nodes': C._initVars(t, "cellN=({cellN}>1.5)*2.+({cellN}>0.)*({cellN}<1.5)") C._initVars(t, 'cellN = 1-{cellN}+({cellN}>1.5)*3') else: C._initVars( t, "centers:cellN=({centers:cellN}>1.5)*2.+({centers:cellN}>0.)*({centers:cellN}<1.5)" ) C._initVars( t, 'centers:cellN = 1-{centers:cellN}+({centers:cellN}>1.5)*3') t = X.setHoleInterpolatedPoints(t, depth=-DEPTH, loc=loc) if loc == 'nodes': C._initVars(t, 'cellN = 1-{cellN}+({cellN}>1.5)*3') C._initVars(t, 'cellN=maximum({cellN},{cellN2})') C._rmVars(t, ['cellN2']) else: C._initVars( t, 'centers:cellN = 1-{centers:cellN}+({centers:cellN}>1.5)*3') C._initVars(t, 'centers:cellN=maximum({centers:cellN},{centers:cellN2})') C._rmVars(t, ['centers:cellN2']) return t