Question #691026 on Yade changed:
https://answers.launchpad.net/yade/+question/691026

yang yi posted a new comment:
To Jan Stránský :
Thank you very much. I am sorry that the script can not meet  MWE.  My script 
is similar with yours.  The facet rotate and restore the location , then 
display the rotation process by reload the location. How ever my facet is a 
quadrangle, and consist with two  triangles.   
      I used the " pack.sweptPolylines2gtsSurface([positionWind[0]], 
capStart=True, capEnd=True)" to create the plank, but I do not know why the 
quadrangle consists with two triangles.  That is source of my problem.  In the 
rotation process, the quadrangle moving with the two triangles sticks together 
in the 3D show.  However, If I read the location from the storage, in the 3D 
show,  the two triangles separated.

    I desire your help. so I modified the script as follow, I hope it
can meet the MWE

(1) Rotation process:

positionWind = []
temp = [Vector3(0, 0, 0),
        Vector3(0, 10, 0),
        Vector3(10, 10, 0),
        Vector3(10, 0, 0)]
positionWind.append(temp)
Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, 
capEnd=True)
IDWind = O.bodies.append(pack.gtsSurface2Facets(Wind1))
saveCounter = 0
##---------------------------------------##
def WindowsAction_SaveLoaction(IDWind):
    global WinAction, windPosition, saveCounter, RotationW1
    RotationW1.angularVelocity = -0.000001
    outputDir = "Output/location/"
    if not os.path.exists(outputDir):
        os.makedirs(outputDir)
    Position = []
    for i in IDWind:
        temp = [i, o.bodies[i].state.pos]
        Position.append(temp)
    location_name = outputDir + 'wind' + '_' + str(saveCounter)
    np.save(location_name, Position)
    saveCounter += 1

O.engines = [
    ForceResetter(),
    GlobalStiffnessTimeStepper(),
    NewtonIntegrator(gravity=(0, 0, 9.8), damping=0.5, label='down'),
    RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, ids=IDWind, 
zeroPoint=positionWind[0][0],
                   label='RotationW1'),
    PyRunner(command="WindowsAction_SaveLoaction(IDWind)", iterPeriod=200000),
]

==========================================
(2) Read the location

positionWind = []
temp = [Vector3(0, 0, 0),
        Vector3(0, 10, 0),
        Vector3(10, 10, 0),
        Vector3(10, 0, 0)]
positionWind.append(temp)
Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, 
capEnd=True)
IDWind = O.bodies.append(pack.gtsSurface2Facets(Wind1))

saveCounter = 0
import os.path
rootdir = "Output/location/"
wind_locations = []
for parent, dirnames, filenames in os.walk(rootdir):
    for filename in filenames:
        if filename[0:4] == 'wind':
            wind_locations.append(filename)
fileNum = len(filenames)
saveCounter=0

def Display():
    global fileNum,saveCounter
    path = 'Output/location/'
    wind_name = path + 'wind_' + str(saveCounter) + '.npy'
    locationWind = np.load(wind_name, allow_pickle=True)
    print(locationWind)
    print('--------------')
    for i in range(0, len(locationWind)):
        n = locationWind[i][0]
        o.bodies[n].state.pos = locationWind[i][1]
    saveCounter +=1

O.engines = [
    ForceResetter(),
    GlobalStiffnessTimeStepper(),
    NewtonIntegrator(gravity=(0, 0, 9.8), damping=0.5, label='down'),
    PyRunner(command="Display()", iterPeriod=200000),
]

Thank you very much

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to