Re: [Yade-users] [Question #665569]: export the sphere in specific position with VTK format
Question #665569 on Yade changed: https://answers.launchpad.net/yade/+question/665569 Status: Open => Answered Jan Stránský proposed the following answer: Hello, > export the sphere in specific position with VTK format > I plan to export the txt format please be consistent in your requirements :-) > but it's failed please always be as specific as possible (e.g. it gives this and that error, it does not save what it should...). In this case, I got variable 'i' referenced before assignment which is understandable, because in your function exportSelectedSpheres, "i" is used: > xCor = O.bodies[i].state.pos[0] but python don't know what it is.. > I think it's difficult to make it true through this method this should do what you want (although in the given setting, no sphere satisfy your condition and therefore no vtk file is saved) ### vtk = export.VTKExporter("zdj") def exportSelectedSpheres(): def check(b): x,y,z = b.state.pos return isinstance(b.shape,Sphere) and 0<=x and x<=0.000150 and 0<=y and y<=0.00050 and -0.3<=z and z<=0.7 ids = [b.id for b in O.bodies if check(b)] vtk.exportSpheres(ids=ids) ### cheers Jan -- 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 : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
Re: [Yade-users] [Question #665569]: export the sphere in specific position with VTK format
Question #665569 on Yade changed: https://answers.launchpad.net/yade/+question/665569 Status: Answered => Open zhao dejin is still having a problem: Hi ,Jérôme I think it's difficult to make it true through this method , I plan to export the txt format ,here is my code , but it's failed, can you guide me ? thanks a lot . ###code ## # !/usr/bin/python # -*- coding: utf-8 -*- ### # IMPORT MODULES ### from yade import export from yade import pack from yade import qt ### # DEFINE MATERIALS ### steel=FrictMat(young=2.2e11,poisson=0.3,density=7800,frictionAngle=0.3,label='steel') O.materials.append(steel) ### ### plank1=O.bodies.append(geom.facetBox(center=(0.00075,0.00025,-0.5),extents=(0.00075,0.00025,0.5),wire=True)) plank2=O.bodies.append(geom.facetBox(center=(0.00075,0.0006,0.5),extents=(0.00075,0.0001,0.5),wire=False)) plank2=O.bodies.append(geom.facetBox(center=(0.00075,-0.0001,0.5),extents=(0.00075,0.0001,0.5),wire=False)) sp=pack.SpherePack() sp.makeCloud((-0.0005,-0.0002,0.0001),(0,0.0007,0.0006),psdSizes=[0.17, 0.25, 0.32,0.38, 0.44, 0.53],psdCumm=[0, 0.4, 0.56,0.65, 0.85, 1]) ids=sp.toSimulation(color=(0.8,0.8,0.8),material='steel') ..(omit) ### # ENGINES ### O.engines=[ ForceResetter(), InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Box_Aabb()]), InteractionLoop( [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_ScGeom_FrictPhys_CundallStrack()] ), GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=5,timestepSafetyCoefficient=0.8,defaultDt=PWaveTimeStep()), NewtonIntegrator(gravity=(0,0,-9.81),damping=0.5), PyRunner(command="exportSelectedSpheres()",iterPeriod=5000), ] ### # DEFINE FUNCATIONS ### def exportSelectedSpheres(): xCor = O.bodies[i].state.pos[0] yCor = O.bodies[i].state.pos[1] zCor = O.bodies[i].state.pos[2] for i in sp: if (0 <= xCor <= 0.000150) & (0 <= yCor <= 0.00050) & (-0.3 <= zCor <= 0.7): export.text('zdj.txt') ### #set an optimal timestep O.dt=utils.PWaveTimeStep() O.usesTimeStepper=True qt.View() qt.Controller() -- 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 : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
Re: [Yade-users] [Question #665569]: export the sphere in specific position with VTK format
Question #665569 on Yade changed: https://answers.launchpad.net/yade/+question/665569 Status: Open => Answered Jérôme Duriez proposed the following answer: Sorry, I misunderstood this part of your question. Then VTKExporter.exportSpheres function from export module (and its ids attribute, picking a list of ids that satisfy your position criteria) would help : https://yade- dem.org/doc/yade.export.html?highlight=vtkexport#yade.export.VTKExporter.exportSpheres -- 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 : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
Re: [Yade-users] [Question #665569]: export the sphere in specific position with VTK format
Question #665569 on Yade changed: https://answers.launchpad.net/yade/+question/665569 Status: Answered => Open zhao dejin is still having a problem: Hello, Thanks ,Jérôme , I have tried the VTKRecorder,like this : O.engines=[ ForceResetter(), .. . ( omit) VTKRecorder (fileName='test',recorders=['sphere',iterPeriod=200]) ] but all sphere are exported through this method ,not in specific position ,like sphere in a box [ 0 ≦ x ≦ 1,0 ≦ y ≦ 1, 0 ≦ z ≦ 1] . -- 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 : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
Re: [Yade-users] [Question #665569]: export the sphere in specific position with VTK format
Question #665569 on Yade changed: https://answers.launchpad.net/yade/+question/665569 Status: Open => Answered Jérôme Duriez proposed the following answer: Hello, Did you try using (e.g. including it in your O.engines) VTKRecorder [*] ? It seems to me this is exactly what you want [*] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.VTKRecorder, including 'spheres' in recorders attributes -- 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 : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
[Yade-users] [Question #665569]: export the sphere in specific position with VTK format
New question #665569 on Yade: https://answers.launchpad.net/yade/+question/665569 Hi, everyone I am doing a powder bed simulation ,and I need to export the sphere in specific position with VTK format,.Can this be realized in yade? Best wishes ZDJ -- 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 : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp