← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3755: Add stl-gts example.

 

------------------------------------------------------------
revno: 3755
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Tue 2013-12-03 08:47:09 +0100
message:
  Add stl-gts example.
added:
  examples/stl-gts/
  examples/stl-gts/README
  examples/stl-gts/cone.geo
  examples/stl-gts/convert2stl.sh
  examples/stl-gts/gts-stl.py


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== added directory 'examples/stl-gts'
=== added file 'examples/stl-gts/README'
--- examples/stl-gts/README	1970-01-01 00:00:00 +0000
+++ examples/stl-gts/README	2013-12-03 07:47:09 +0000
@@ -0,0 +1,7 @@
+This example shows, how to perform the following conversion:
+GEO->STL->GTS->Yade(clumps)
+
+Then GTS-file (mesh) is importing into Yade-Script and new spheres
+are adding as a clump within the volume of this mesh.
+
+The script requires gmsh and libgts-bin installed.

=== added file 'examples/stl-gts/cone.geo'
--- examples/stl-gts/cone.geo	1970-01-01 00:00:00 +0000
+++ examples/stl-gts/cone.geo	2013-12-03 07:47:09 +0000
@@ -0,0 +1,38 @@
+acc = 20.0/1000.0;
+D = 280.0/2.0/1000.0;
+d = 180.0/2.0/1000.0;
+h = 180.0/1000.0;
+Point(1) = {0.0, 0.0, 0.0, acc};
+Point(2) = {0.0, D, 0.0, acc};
+Point(3) = {0.0, -D, 0.0, acc};
+Point(4) = {D, 0.0, 0.0, acc};
+Point(5) = {-D, 0.0, 0.0, acc};
+Point(6) = {0.0, 0.0, h, acc};
+Circle(1) = {2, 1, 4};
+Circle(2) = {4, 1, 3};
+Circle(3) = {3, 1, 5};
+Circle(4) = {5, 1, 2};
+Line(5) = {2, 1};
+Line(6) = {2, 6};
+Line(7) = {4, 1};
+Line(8) = {4, 6};
+Line(9) = {3, 1};
+Line(10) = {3, 6};
+Line(11) = {5, 1};
+Line(12) = {5, 6};
+Line Loop(13) = {1, 7, -5};
+Plane Surface(14) = {13};
+Line Loop(15) = {2, 9, -7};
+Plane Surface(16) = {15};
+Line Loop(17) = {3, 11, -9};
+Plane Surface(18) = {17};
+Line Loop(19) = {4, 5, -11};
+Plane Surface(20) = {19};
+Line Loop(21) = {3, 12, -10};
+Ruled Surface(22) = {21};
+Line Loop(23) = {4, 6, -12};
+Ruled Surface(24) = {23};
+Line Loop(25) = {1, 8, -6};
+Ruled Surface(26) = {25};
+Line Loop(27) = {2, 10, -8};
+Ruled Surface(28) = {27};

=== added file 'examples/stl-gts/convert2stl.sh'
--- examples/stl-gts/convert2stl.sh	1970-01-01 00:00:00 +0000
+++ examples/stl-gts/convert2stl.sh	2013-12-03 07:47:09 +0000
@@ -0,0 +1,3 @@
+#!/bin/bash
+gmsh -2 cone.geo -o cone.stl
+stl2gts -r < cone.stl > cone.gts

=== added file 'examples/stl-gts/gts-stl.py'
--- examples/stl-gts/gts-stl.py	1970-01-01 00:00:00 +0000
+++ examples/stl-gts/gts-stl.py	2013-12-03 07:47:09 +0000
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# © 2009 Václav Šmilauer <eudoxos@xxxxxxxx>
+# © 2013 Anton Gladky <gladk@xxxxxxxxxx>
+
+from yade import pack
+import gts, os.path, locale
+
+surf=gts.read(open('cone.gts'))
+
+if surf.is_closed():
+	pred=pack.inGtsSurface(surf)
+	aabb=pred.aabb()
+	dim0=aabb[1][0]-aabb[0][0]; radius=dim0/70. # get some characteristic dimension, use it for radius
+	O.bodies.appendClumped(pack.regularHexa(pred,radius=radius,gap=radius/4.))
+	surf.translate(0,-(aabb[1][1]-aabb[0][1])/2.0,-(aabb[1][2]-aabb[0][2])) # move surface down so that facets are underneath the falling spheres
+O.bodies.append(pack.gtsSurface2Facets(surf,wire=True))
+
+O.engines=[
+	ForceResetter(),
+	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()],label='collider'),
+	InteractionLoop(
+		[Ig2_Sphere_Sphere_L3Geom(),Ig2_Facet_Sphere_L3Geom()],
+		[Ip2_FrictMat_FrictMat_FrictPhys()],
+		[Law2_L3Geom_FrictPhys_ElPerfPl()],
+	),
+	NewtonIntegrator(damping=.1,gravity=[0,0,-500.0]),
+	PyRunner(iterPeriod=1000,command='timing.stats(); O.pause();'),
+	PyRunner(iterPeriod=10,command='addPlotData()')
+]
+O.dt=.7*PWaveTimeStep()
+O.saveTmp()
+O.timingEnabled=True
+O.trackEnergy=True
+from yade import plot
+plot.plots={'i':('total',O.energy.keys,)}
+def addPlotData(): plot.addData(i=O.iter,total=O.energy.total(),**O.energy)
+plot.plot(subPlots=False)
+
+from yade import timing
+from yade import qt
+qt.View()