Esempio n. 1
0
def playForward(event=None):
    if CTK.t == []: return
    walls = VARS[3].get()
    t0 = CTK.varsFromWidget(VARS[0].get(), type=1)[0]
    time = CTK.varsFromWidget(VARS[1].get(), type=1)[0]
    tf = CTK.varsFromWidget(VARS[2].get(), type=1)[0]
    step = (tf - t0) / 100.

    if CTK.__MAINTREE__ == 1:
        CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()

    if (walls == '1' and CTK.dt == []):
        zones = Internal.getNodesFromType(CTK.t, 'Zone_t')
        Z = buildWalls(zones)
        CTK.dt = C.newPyTree(['Base'])
        CTK.dt[2][1][2] += Z

    CTK.__BUSY__ = True
    CPlot.setState(cursor=2)
    while (time < tf and CTK.__BUSY__):
        if (walls == '1'): temp = RM.evalPosition(CTK.dt, time)
        else: temp = RM.evalPosition(CTK.t, time)
        CTK.display(temp, mainTree=CTK.TIME)
        time += step
        VARS[1].set(str(time))
        WIDGETS['slider'].set((time - t0) / step)
        WIDGETS['time'].update()
        WIDGETS['slider'].update()
    CTK.__BUSY__ = False
    CPlot.setState(cursor=0)
Esempio n. 2
0
def setTime(event=None):
    if CTK.t == []: return
    walls = VARS[3].get()
    time = CTK.varsFromWidget(VARS[1].get(), type=1)
    if len(time) != 1:
        CTK.TXT.insert('START', 'Invalid time.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return
    time = time[0]
    t0 = CTK.varsFromWidget(VARS[0].get(), type=1)[0]
    tf = CTK.varsFromWidget(VARS[2].get(), type=1)[0]
    step = (tf - t0) / 100.

    if CTK.__MAINTREE__ == 1:
        CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()
    if walls == '1' and CTK.dt == []:
        zones = Internal.getZones(CTK.t)
        Z = buildWalls(zones)
        CTK.dt = C.newPyTree(['Base'])
        CTK.dt[2][1][2] += Z

    if walls == '1': temp = RM.evalPosition(CTK.dt, time)
    else: temp = RM.evalPosition(CTK.t, time)

    WIDGETS['slider'].set((time - t0) / step)
    WIDGETS['slider'].update()
    CTK.display(temp, mainTree=CTK.TIME)
def F(a):
    R._setPrescribedMotion3(a,
                            'constant',
                            transl_speed=(0.1, 0, 0),
                            axis_pnt=(0., 0., 0.),
                            axis_vct=(0, 0, 1),
                            omega=1.)
    b = R.evalPosition(a, time=0.1)
    return b
Esempio n. 4
0
def setVars3(event=None):
    nzs = CPlot.getSelectedZones()
    if (nzs == []):
        CTK.TXT.insert('START', 'Selection is empty.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return

    name = VARS[0].get()
    CTK.saveTree()

    transl_speed = CTK.varsFromWidget(VARS[43].get(), 1)
    axis_pnt = CTK.varsFromWidget(VARS[44].get(), 1)
    axis_vct = CTK.varsFromWidget(VARS[45].get(), 1)
    omega = VARS[46].get()

    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        z = CTK.t[2][nob][2][noz]
        CTK.t[2][nob][2][noz] = RM.setPrescribedMotion3(
            z,
            name,
            transl_speed=transl_speed,
            axis_pnt=axis_pnt,
            axis_vct=axis_vct,
            omega=omega)
    CTK.TKTREE.updateApp()
    CTK.TXT.insert('START', 'Motion set in selected zones.\n')
Esempio n. 5
0
def setVars1(event=None):
    nzs = CPlot.getSelectedZones()
    if (nzs == []):
        CTK.TXT.insert('START', 'Selection is empty.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return

    name = VARS[0].get()
    CTK.saveTree()

    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        z = CTK.t[2][nob][2][noz]
        CTK.t[2][nob][2][noz] = RM.setPrescribedMotion1(
            z, name, VARS[1].get(), VARS[2].get(), VARS[3].get(),
            VARS[4].get(), VARS[5].get(), VARS[6].get(), VARS[7].get(),
            VARS[8].get(), VARS[9].get(), VARS[10].get())
    CTK.TKTREE.updateApp()
    CTK.TXT.insert('START', 'Motion set in selected zones.\n')
Esempio n. 6
0
# - setPrescribedMotion3 (pyTree) -
# Motion defined by a constant speed and rotation speed
import RigidMotion.PyTree as R
import Converter.PyTree as C
import Geom.PyTree as D

a = D.sphere((1.2, 0., 0.), 0.2, 30)
a = R.setPrescribedMotion3(a, 'mot', transl_speed=(1, 0, 0))

C.convertPyTree2File(a, 'out.cgns')
def F(a):
    a = R.setPrescribedMotion2(a, 'rotor', transl_speed=(0.1, 0, 0))
    b = R.evalPosition(a, time=0.1)
    return b
Esempio n. 8
0
def setVars2(event=None):
    nzs = CPlot.getSelectedZones()
    if (nzs == []):
        CTK.TXT.insert('START', 'Selection is empty.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return

    name = VARS[0].get()
    CTK.saveTree()

    transl_speed = CTK.varsFromWidget(VARS[17].get(), 1)
    psi0 = VARS[12].get()
    psi0_b = VARS[13].get()
    alp_pnt = CTK.varsFromWidget(VARS[14].get(), 1)
    alp_vct = CTK.varsFromWidget(VARS[15].get(), 1)
    alp0 = VARS[16].get()
    rot_pnt = CTK.varsFromWidget(VARS[18].get(), 1)
    rot_vct = CTK.varsFromWidget(VARS[19].get(), 1)
    rot_omg = VARS[20].get()

    del_pnt = CTK.varsFromWidget(VARS[21].get(), 1)
    del_vct = CTK.varsFromWidget(VARS[22].get(), 1)
    del0 = VARS[23].get()
    delc = CTK.varsFromWidget(VARS[24].get(), 1)
    dels = CTK.varsFromWidget(VARS[25].get(), 1)

    bet_pnt = CTK.varsFromWidget(VARS[26].get(), 1)
    bet_vct = CTK.varsFromWidget(VARS[27].get(), 1)
    bet0 = VARS[28].get()
    betc = CTK.varsFromWidget(VARS[29].get(), 1)
    bets = CTK.varsFromWidget(VARS[30].get(), 1)

    tet_pnt = CTK.varsFromWidget(VARS[31].get(), 1)
    tet_vct = CTK.varsFromWidget(VARS[32].get(), 1)
    tet0 = VARS[33].get()
    tetc = CTK.varsFromWidget(VARS[34].get(), 1)
    tets = CTK.varsFromWidget(VARS[35].get(), 1)

    span_vct = CTK.varsFromWidget(VARS[36].get(), 1)

    pre_lag_pnt = CTK.varsFromWidget(VARS[37].get(), 1)
    pre_lag_vct = CTK.varsFromWidget(VARS[38].get(), 1)
    pre_lag_ang = VARS[39].get()

    pre_con_pnt = CTK.varsFromWidget(VARS[40].get(), 1)
    pre_con_vct = CTK.varsFromWidget(VARS[41].get(), 1)
    pre_con_ang = VARS[42].get()

    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        z = CTK.t[2][nob][2][noz]
        CTK.t[2][nob][2][noz] = RM.setPrescribedMotion2(
            z,
            name,
            transl_speed=transl_speed,
            psi0=psi0,
            psi0_b=psi0_b,
            alp_pnt=alp_pnt,
            alp_vct=alp_vct,
            alp0=alp0,
            rot_pnt=rot_pnt,
            rot_vct=rot_vct,
            rot_omg=rot_omg,
            del_pnt=del_pnt,
            del_vct=del_vct,
            del0=del0,
            delc=delc,
            dels=dels,
            bet_pnt=bet_pnt,
            bet_vct=bet_vct,
            bet0=bet0,
            betc=betc,
            bets=bets,
            tet_pnt=tet_pnt,
            tet_vct=tet_vct,
            tet0=tet0,
            tetc=tetc,
            tets=tets,
            span_vct=span_vct,
            pre_lag_pnt=pre_lag_pnt,
            pre_lag_vct=pre_lag_vct,
            pre_lag_ang=pre_lag_ang,
            pre_con_pnt=pre_con_pnt,
            pre_con_vct=pre_con_vct,
            pre_con_ang=pre_con_ang)
    CTK.TKTREE.updateApp()
    CTK.TXT.insert('START', 'Motion set in selected zones.\n')
Esempio n. 9
0
def F(a):
    a = R.setPrescribedMotion1(a, 'trans', tx="{t}")
    b = R.evalPosition(a, time=0.1)
    return b
Esempio n. 10
0
# - setPrescribedMotion1 (pyTree) - 
# Motion defined by time string
import RigidMotion.PyTree as R
import Converter.PyTree as C
import Geom.PyTree as D

a = D.sphere((1.2,0.,0.), 0.2, 30)
a = R.setPrescribedMotion1(a, 'trans', tx="{t}")

C.convertPyTree2File(a, 'out.cgns')
# Coordonnees du centre de rotation dans le repere absolu
def centerAbs(t):
    return [t, 0, 0]


# Coordonnees du centre de la rotation dans le repere entraine
def centerRel(t):
    return [5, 5, 0]


# Matrice de rotation
def rot(t):
    omega = 0.1
    m = [[cos(omega * t), -sin(omega * t), 0],
         [sin(omega * t), cos(omega * t), 0], [0, 0, 1]]
    return m


# Mouvement complet
def F(t):
    return (centerAbs(t), centerRel(t), rot(t))


a = G.cart((0, 0, 0), (1, 1, 1), (11, 11, 2))

# Move the mesh
time = 3.
b = R.evalPosition(a, time, F)
b[0] = 'move'
C.convertPyTree2File([a, b], "out.cgns")
Esempio n. 12
0
def _transfer(t,
              tc,
              variables,
              graph,
              intersectionDict,
              dictOfADT,
              dictOfNobOfRcvZones,
              dictOfNozOfRcvZones,
              dictOfNobOfDnrZones,
              dictOfNozOfDnrZones,
              dictOfNobOfRcvZonesC,
              dictOfNozOfRcvZonesC,
              time=0.,
              absFrame=True,
              procDict=None,
              cellNName='cellN'):
    if procDict is None: procDict = Cmpi.getProcDict(tc)

    # dictionnaire des matrices de mouvement pour passer du repere relatif d une zone au repere absolu
    dictOfMotionMatR2A = {}
    dictOfMotionMatA2R = {}
    coordsD = [0., 0., 0.]
    coordsC = [0., 0., 0.]  # XAbs = coordsD + Mat*(XRel-coordsC)
    dictOfFields = {}
    dictOfIndices = {}

    datas = {}
    for z in Internal.getZones(t):
        zname = Internal.getName(z)
        if zname not in dictOfNobOfRcvZones: continue

        # coordonnees dans le repere absolu de la zone receptrice
        # on les recupere de zc pour eviter un node2center des coordonnees de z
        nobc = dictOfNobOfRcvZonesC[zname]
        nozc = dictOfNozOfRcvZonesC[zname]
        zc = tc[2][nobc][2][nozc]
        if zc[0] != zname:  # check
            raise ValueError(
                "_transfer: t and tc skeletons must be identical.")

        C._cpVars(z, 'centers:' + cellNName, zc, cellNName)
        res = X.getInterpolatedPoints(zc, loc='nodes', cellNName=cellNName)
        # print 'Zone %s du proc %d a interpoler'%(zname, Cmpi.rank)

        if res is not None:
            # print 'Res not None : zone %s du proc %d a interpoler'%(zname, Cmpi.rank)

            indicesI, XI, YI, ZI = res
            # passage des coordonnees du recepteur dans le repere absolu
            # si mouvement gere par FastS -> les coordonnees dans z sont deja les coordonnees en absolu
            if not absFrame:
                if zname in dictOfMotionMatR2A:
                    MatRel2AbsR = RM.getMotionMatrixForZone(z,
                                                            time=time,
                                                            F=None)
                    dictOfMotionMatR2A[zname] = MatRel2AbsR
                else:
                    MatRel2AbsR = dictOfMotionMatR2A[zname]
                RM._moveN([XI, YI, ZI], coordsD, coordsC, MatRel2AbsR)

            procR = procDict[zname]
            for znamed in intersectionDict[zname]:
                procD = procDict[znamed]
                if procD == Cmpi.rank:
                    nobc = dictOfNobOfDnrZones[znamed]
                    nozc = dictOfNozOfDnrZones[znamed]
                    zdnr = tc[2][nobc][2][nozc]
                    adt = dictOfADT[znamed]
                    if znamed in dictOfMotionMatA2R:
                        MatAbs2RelD = dictOfMotionMatA2R[znamed]
                    else:
                        if znamed in dictOfMotionMatR2A:
                            MatRel2AbsD = dictOfMotionMatR2A[znamed]
                            MatAbs2RelD = numpy.transpose(MatRel2AbsD)
                            dictOfMotionMatA2R[znamed] = MatAbs2RelD
                        else:
                            MatRel2AbsD = RM.getMotionMatrixForZone(zdnr,
                                                                    time=time,
                                                                    F=None)
                            dictOfMotionMatR2A[znamed] = MatRel2AbsD
                            MatAbs2RelD = numpy.transpose(MatRel2AbsD)
                            dictOfMotionMatA2R[znamed] = MatAbs2RelD
                    [XIRel, YIRel, ZIRel] = RM.moveN([XI, YI, ZI], coordsC,
                                                     coordsD, MatAbs2RelD)

                    # transfers avec coordonnees dans le repere relatif
                    fields = X.transferFields(zdnr,
                                              XIRel,
                                              YIRel,
                                              ZIRel,
                                              hook=adt,
                                              variables=variables)
                    if zname not in dictOfFields:
                        dictOfFields[zname] = [fields]
                        dictOfIndices[zname] = indicesI
                    else:
                        dictOfFields[zname].append(fields)

                else:
                    # print ' ECHANGE GLOBAL entre recepteur %s du proc %d et donneur %s du proc %d '%(zname, Cmpi.rank, znamed, procD)
                    if procD not in datas:
                        datas[procD] = [[zname, znamed, indicesI, XI, YI, ZI]]
                    else:
                        datas[procD].append(
                            [zname, znamed, indicesI, XI, YI, ZI])

    # print 'Proc  : ', Cmpi.rank, ' envoie les donnees : ' ,datas.keys()
    # print ' a partir du graphe ', graph
    # 1er envoi : envoi des numpys des donnees a interpoler suivant le graphe
    interpDatas = Cmpi.sendRecv(datas, graph)

    # recuperation par le proc donneur des donnees pour faire les transferts
    transferedDatas = {}
    for i in interpDatas:
        #print Cmpi.rank, 'recoit de',i, '->', len(interpDatas[i])
        for n in interpDatas[i]:
            zdnrname = n[1]
            zrcvname = n[0]
            indicesR = n[2]
            XI = n[3]
            YI = n[4]
            ZI = n[5]
            nobc = dictOfNobOfDnrZones[zdnrname]
            nozc = dictOfNozOfDnrZones[zdnrname]
            zdnr = tc[2][nobc][2][nozc]
            adt = dictOfADT[zdnrname]
            if zdnrname in dictOfMotionMatA2R:
                MatAbs2RelD = dictOfMotionMatA2R[zdnrname]
            else:
                if zdnrname in dictOfMotionMatR2A:
                    MatRel2AbsD = dictOfMotionMatR2A[zdnrname]
                    MatAbs2RelD = numpy.transpose(MatRel2AbsD)
                    dictOfMotionMatA2R[zdnrname] = MatAbs2RelD
                else:
                    MatRel2AbsD = RM.getMotionMatrixForZone(zdnr,
                                                            time=time,
                                                            F=None)
                    dictOfMotionMatR2A[zdnrname] = MatRel2AbsD
                    MatAbs2RelD = numpy.transpose(MatRel2AbsD)
                    dictOfMotionMatA2R[zdnrname] = MatAbs2RelD

            [XIRel, YIRel, ZIRel] = RM.moveN([XI, YI, ZI], coordsC, coordsD,
                                             MatAbs2RelD)
            # transferts avec coordonnees dans le repere relatif
            fields = X.transferFields(zdnr,
                                      XIRel,
                                      YIRel,
                                      ZIRel,
                                      hook=adt,
                                      variables=variables)
            procR = procDict[zrcvname]

            if procR not in transferedDatas:
                transferedDatas[procR] = [[zrcvname, indicesR, fields]]
            else:
                transferedDatas[procR].append([zrcvname, indicesR, fields])

    if transferedDatas != {}:
        # 2nd envoi : envoi des numpys des donnees  interpolees suivant le graphe
        rcvDatas = Cmpi.sendRecv(transferedDatas, graph)

        # remise des donnees interpolees chez les zones receveuses
        # une fois que tous les donneurs potentiels ont calcule et envoye leurs donnees
        for i in rcvDatas:
            #print Cmpi.rank, 'recoit des donnees interpolees de',i, '->', len(rcvDatas[i])
            for n in rcvDatas[i]:
                zrcvname = n[0]
                indicesI = n[1]
                fields = n[2]
                if zrcvname not in dictOfFields:
                    dictOfFields[zrcvname] = [fields]
                    dictOfIndices[zrcvname] = indicesI
                else:
                    dictOfFields[zrcvname].append(fields)

    for zrcvname in dictOfIndices:
        nob = dictOfNobOfRcvZones[zrcvname]
        noz = dictOfNozOfRcvZones[zrcvname]
        z = t[2][nob][2][noz]
        allInterpFields = dictOfFields[zrcvname]
        indicesI = dictOfIndices[zrcvname]
        C._filterPartialFields(z,
                               allInterpFields,
                               indicesI,
                               loc='centers',
                               startFrom=0,
                               filterName='donorVol')

    # SORTIE
    return None
# - setPrescribedMotion2 (pyTree) -
# Motion defined by a Cassiopee Solver rotor motion
import RigidMotion.PyTree as R
import Converter.PyTree as C
import Geom.PyTree as D

a = D.sphere((1.2, 0., 0.), 0.2, 30)
a = R.setPrescribedMotion2(a, 'rotor', transl_speed=(0.1, 0, 0), rot_omg=1.)

C.convertPyTree2File(a, 'out.cgns')