예제 #1
0
# - connectMatch (pyTree) -
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.PyTree as C
import Converter.elsAProfile as elsAProfile

a = G.cylinder((0., 0., 0.), 0.1, 1., 0., 90., 5., (11, 11, 11))
t = C.newPyTree(['Base', a])
t = X.connectMatchPeriodic(t,
                           rotationCenter=[0., 0., 0.],
                           translation=[0., 0., 5.])
t = X.connectMatchPeriodic(t,
                           rotationCenter=[0., 0., 0.],
                           rotationAngle=[0., 0., 90.])
tp = elsAProfile.adaptPeriodicMatch(t)
C.convertPyTree2File(tp, 'out.cgns')
DIM = 3
if NK == 2: DIM = 2
a = G.cylinder((0, 0, 0), 1, 2, 10, 130, 1, (60, 20, NK))
a[0] = 'cyl1'
b = G.cylinder((0, 0, 0), 1, 1.5, 0, 30, 1, (30, 20, NK))
b[0] = 'cyl2'
C._addBC2Zone(a, 'wall', 'BCWall', 'jmin')
C._addBC2Zone(b, 'wall', 'BCWall', 'jmin')
C._fillEmptyBCWith(b, 'overlap', 'BCOverlap', dim=DIM)
t = C.newPyTree(['Base', 'Base2'])
t[2][1][2] = [a]
t[2][2][2] = [b]
C._initVars(t, 'Density', 1.)
C._initVars(t, 'centers:cellN', 1)
t = X.connectMatchPeriodic(t,
                           rotationCenter=[0., 0., 0.],
                           rotationAngle=[0., 0., 120.],
                           dim=DIM)
C._fillEmptyBCWith(t, 'nref', 'BCFarfield', dim=DIM)
C._addState(t[2][1], 'EquationDimension', DIM)
t = X.applyBCOverlaps(t, depth=1)
t = X.setInterpolations(t,
                        double_wall=1,
                        storage='direct',
                        prefixFile=LOCAL + '/chm')
C.convertPyTree2File(t, "out.cgns")
test.testT(t, 1)
# test avec Chimere periodique
NK = 51
a = G.cylinder((0, 0, 0), 1, 2, 10, 130, 4., (60, 20, NK))
a[0] = 'cyl1'
b = G.cart((0.4, 1.2, -0.3), (0.04, 0.04, 0.1), (11, 11, 21))
# - connectMatchPeriodic (pyTree) -
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.PyTree as C
import KCore.test as test

# Un seul bloc
a = G.cylinder((0., 0., 0.), 0.1, 1., 0., 90., 5., (11, 11, 11))
a = C.convertArray2NGon(a)
a = G.close(a)
C._initVars(a, 'F', 1.)
C._initVars(a, 'centers:G', 2.)
t = C.newPyTree(['Base', a])
C._addState(t[2][1], 'EquationDimension', 3)
t = X.connectMatchPeriodic(t,
                           rotationCenter=[0., 0., 0.],
                           rotationAngle=[0., 0., 90.],
                           unitAngle=None)
test.testT(t, 1)

# sur une base
a = G.cylinder((0., 0., 0.), 0.1, 1., 0., 45., 5., (11, 11, 11))
b = G.cylinder((0., 0., 0.), 0.1, 1., 45., 90., 5., (11, 11, 11))
b[0] = 'cyl2'
a = C.convertArray2NGon(a)
a = G.close(a)
b = C.convertArray2NGon(b)
b = G.close(b)
t = C.newPyTree(['Base'])
t[2][1][2] += [a, b]
C._initVars(t, 'F', 1.)
C._initVars(t, 'centers:G', 2.)
예제 #4
0
def connectMatch():
    if CTK.t == []: return
    eps = VARS[2].get()
    eps = float(eps)
    node = Internal.getNodeFromName(CTK.t, 'EquationDimension')
    if node is not None: ndim = Internal.getValue(node)
    else:
        CTK.TXT.insert('START',
                       'EquationDimension not found (tkState). Using 3D.\n')
        CTK.TXT.insert('START', 'Warning: ', 'Warning')
        ndim = 3

    mode = VARS[9].get()
    translation = [0., 0., 0.]
    rotationCenter = [0., 0., 0.]
    rotationAngle = [0., 0., 0.]
    if mode == 'Translation':
        mode = 1
        translation = CTK.varsFromWidget(VARS[10].get(), type=1)
    elif mode == 'Rotation (Degree)':
        mode = 1
        f = CTK.varsFromWidget(VARS[10].get(), type=1)
        rotationCenter = f[0:3]
        rotationAngle = f[3:6]
    else:
        mode = 0

    nzs = CPlot.getSelectedZones()
    CTK.saveTree()
    if CTK.__MAINTREE__ <= 0 or nzs == []:
        try:
            if mode == 0: CTK.t = X.connectMatch(CTK.t, tol=eps, dim=ndim)
            else:
                CTK.t = X.connectMatchPeriodic(CTK.t,
                                               rotationCenter=rotationCenter,
                                               rotationAngle=rotationAngle,
                                               translation=translation,
                                               tol=eps,
                                               dim=ndim,
                                               unitAngle=None)
            CTK.TKTREE.updateApp()
            CTK.TXT.insert('START', 'Matching BCs successfully set.\n')
        except Exception as e:
            Panels.displayErrors([0, str(e)], header='Error: connectMatch')
            CTK.TXT.insert('START', 'Matching BCs failed.\n')
            CTK.TXT.insert('START', 'Error: ', 'Error')
    else:
        sel = []
        for nz in nzs:
            nob = CTK.Nb[nz] + 1
            noz = CTK.Nz[nz]
            z = CTK.t[2][nob][2][noz]
            sel.append(z)
        try:
            if mode == 0: sel = X.connectMatch(sel, tol=eps, dim=ndim)
            else:
                sel = X.connectMatchPeriodic(sel,
                                             rotationCenter=rotationCenter,
                                             rotationAngle=rotationAngle,
                                             translation=translation,
                                             tol=eps,
                                             dim=ndim,
                                             unitAngle=None)
            c = 0
            for nz in nzs:
                nob = CTK.Nb[nz] + 1
                noz = CTK.Nz[nz]
                CTK.t[2][nob][2][noz] = sel[c]
                c += 1
            CTK.TKTREE.updateApp()
            CTK.TXT.insert('START', 'Matching BCs successfully set.\n')
        except Exception as e:
            Panels.displayErrors([0, str(e)], header='Error: connectMatch')
            CTK.TXT.insert('START', 'Matching BCs failed.\n')
            CTK.TXT.insert('START', 'Error: ', 'Error')
    check()
예제 #5
0
# - connectMatch (pyTree) -
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.PyTree as C
import KCore.test as test
import math

# Un seul bloc
a = G.cylinder((0.,0.,0.), 0.1, 1., 0., 90., 5., (11,11,11)) 
a = C.initVars(a,'F',1.); a = C.initVars(a,'centers:G',2.)
a = C.addBC2Zone(a,'wall','BCWall','jmin')
a = C.addBC2Zone(a,'overlap','BCOverlap','jmax')
t = C.newPyTree(['Base']); t[2][1][2] += [a]
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t = X.connectMatchPeriodic(t,rotationCenter=[0.,0.,0.],rotationAngle=[0.,0.,90.])
test.testT(t,1)
# 2 blocs coincidents
a = G.cylinder((0.,0.,0.), 0.1, 1., 0., 30., 5., (11,11,11)) 
a = C.initVars(a,'F',1.); a = C.initVars(a,'centers:G',2.)
a = C.addBC2Zone(a,'wall','BCWall','jmin')
a = C.addBC2Zone(a,'overlap','BCOverlap','jmax')
t = C.newPyTree(['Base']) ; t[2][1][2] += [a]
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t = X.connectMatchPeriodic(t,rotationCenter=[0.,0.,0.],rotationAngle=[0.,0.,90.])
test.testT(t,11)

a = G.cylinder((0.,0.,0.), 0.1, 1., 0., 45., 5., (11,11,11)) 
a = C.initVars(a,'F',1.); a = C.initVars(a,'centers:G',2.)
a = C.addBC2Zone(a,'wall','BCWall','jmin')
a = C.addBC2Zone(a,'overlap','BCOverlap','jmax')
b = G.cylinder((0.,0.,0.), 0.1, 1., 45., 90., 5., (11,11,11)); b[0] = 'cyl2'