← Back to team overview

yade-users team mailing list archive

Re: [Question #277328]: Generating triangular wedge predicate for randomDensePack

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Matt,

I'm a new user of YADE


welcome :-)

Please let me know what the easiest way to generate this triangular wedge
> predicate is


one solution is to use gts surface (first building vertices, than edges,
then triangle faces and finally closed surface). It can be put in a
function. Apart from wedge, you can create pretty complex surfaces with
this approach (you can also load gts surface from file) [1]

##########################
from yade import pack
import gts
from math import tan

length = 10.
width  = 5.
angle  = .3*pi/6.
height = length*tan(angle)

v0 = gts.Vertex(0    ,0     ,0)
v1 = gts.Vertex(width,0     ,0)
v2 = gts.Vertex(0    ,length,0)
v3 = gts.Vertex(width,length,0)
v4 = gts.Vertex(0    ,0     ,height)
v5 = gts.Vertex(width,0     ,height)

e0  = gts.Edge(v0,v1)
e1  = gts.Edge(v2,v3)
e2  = gts.Edge(v4,v5)
e3  = gts.Edge(v0,v2)
e4  = gts.Edge(v1,v3)
e5  = gts.Edge(v0,v4)
e6  = gts.Edge(v1,v5)
e7  = gts.Edge(v2,v4)
e8  = gts.Edge(v3,v5)
e9  = gts.Edge(v0,v5)
e10 = gts.Edge(v0,v3)
e11 = gts.Edge(v3,v4)

f0 = gts.Face(e0,e4,e10)
f1 = gts.Face(e1,e3,e10)
f2 = gts.Face(e5,e2,e9)
f3 = gts.Face(e0,e6,e9)
f4 = gts.Face(e1,e7,e11)
f5 = gts.Face(e2,e8,e11)
f6 = gts.Face(e3,e5,e7)
f7 = gts.Face(e4,e6,e8)

surf = gts.Surface()
for f in (f0,f1,f2,f3,f4,f5,f6,f7):
surf.add(f)

pred = pack.inGtsSurface(surf)
sp =
pack.randomDensePack(pred,spheresInCell=400,radius=.1,returnSpherePack=True)
sp.toSimulation()
##########################

I hope the creating of the surface is self-explanatory, if not, do not
hesitate to ask for more details.

cheers
Jan

[1] https://yade-dem.org/doc/user.html#boundary-representation-brep (e.g.
the horse predicate)


2015-12-09 17:51 GMT+01:00 Matt Kesseler <
question277328@xxxxxxxxxxxxxxxxxxxxx>:

> Question #277328 on Yade changed:
> https://answers.launchpad.net/yade/+question/277328
>
> Description changed to:
> Hi all. I'm a new user of YADE and I'm currently trying to model an
> avalanche down a slope of variable angle (pi/6 - pi/3). I'm currently
> using yade.pack.randomDensePack to generate a box of particles to slide
> down the slope. However, I want to generate a wedge that matches the
> angle of the slope, essentially a triangular prism with the triangle
> being a vertical edge, a horizontal edge, and the diagonal edge,
> extended uniformly across the width of the ramp. I can't figure out how
> to do this using the existing tools.
>
> Here is the existing code that I'm using to generate the box.
>
> pred=pack.inAlignedBox((-.1,-.05,-.1),(.1,.05,0))
>
> SpherePack=pack.randomDensePack(pred,spheresInCell=2000,radius=.005,rRelFuzz=0,color=(0,0,1),material="sand",returnSpherePack=True)
> SpherePack.toSimulation()
>
> I thought I could achieve the desired result by subtracting another
> inAlignedBox from the predicate like this...
>
>
> pred=pack.inAlignedBox((-.1,-.05,-.1),(.1,.05,0))-pack.inAlignedBox((-.1,-.05,-.1),(.1,.05,0),orientation=Quaternion((1,0,0),pi/4))
>
> ...or something similar, but it doesn't work.
>
> Please let me know what the easiest way to generate this triangular
> wedge predicate is. I'm probably missing something very obvious... :p
>
> --
> 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@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

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