ymport.stl function scale and shift

Asked by Hans Henning on 2021-02-02

Dear all,

I have a question, if I look into the documentation of Yade DEM the stl import function: ymport.stl should work fine with the following commands:

ymport(file, scale = 1.0, shift=Vector3(0,0,0))

I have tried this with the rod penetration example https://gitlab.com/yade-dev/trunk/-/tree/master/examples/rod-penetration but it was not working.

I have only added the the scale to the code as attached. Can it be that it is connect to the stl file or these commands (scale / shift) does not work for the ymport.stl ?

#!/usr/bin/python
# -*- coding: utf-8 -*-

from __future__ import print_function
from builtins import range
import random
from yade import ymport

## PhysicalParameters

## Variant of mesh
mesh = 'coarse'
#mesh = 'fine'
#mesh = 'tiny'

## Import geometry
rod = O.bodies.append(ymport.stl('rod-'+mesh+'.stl',wire=True,scale=1.0,))

# Spheres
sphereRadius = 0.01
nbSpheres = (32,11,32)
print("Creating %d spheres..."%(nbSpheres[0]*nbSpheres[1]*nbSpheres[2]), end=' ')
for i in range(nbSpheres[0]):
 for j in range(nbSpheres[1]):
  for k in range(nbSpheres[2]):
   x = (i*2 - nbSpheres[0])*sphereRadius*1.1+sphereRadius*random.uniform(-0.1,0.1)
   y = -j*sphereRadius*2.2-0.01
   z = (k*2 - nbSpheres[2])*sphereRadius*1.1+sphereRadius*random.uniform(-0.1,0.1)
   r = random.uniform(sphereRadius,sphereRadius*0.9)
   fixed = False
   color=[0.51,0.52,0.4]
   if (i==0 or i==nbSpheres[0]-1 or j==nbSpheres[1]-1 or k==0 or k==nbSpheres[2]-1):
    fixed = True
    color=[0.21,0.22,0.1]
   O.bodies.append(sphere([x,y,z],r,color=color,fixed=fixed))
print("done\n")

## Estimate time step
#O.dt=PWaveTimeStep()
O.dt=0.0001

## Engines
O.engines=[
 ## Resets forces and momenta the act on bodies
 ForceResetter(),

 ## Using bounding boxes find possible body collisions.
 InsertionSortCollider([
  Bo1_Sphere_Aabb(),
  Bo1_Facet_Aabb(),
 ]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_FrictPhys()],
  [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
 ## Apply gravity
 ## Motion equation
 NewtonIntegrator(damping=0.3,gravity=[0,-9.81,0]),
 ## Apply kinematics to rod
 TranslationEngine(ids=rod,translationAxis=[0,-1,0],velocity=0.075),
 ## Save force on rod
 #ForceRecorder(ids=rod,file='force-'+mesh+'.dat',iterPeriod=50),
]

import sys,time

print("Start simulation: " + mesh)
nbIter=10000

from yade import qt
qt.View()

O.stopAtIter=nbIter
O.run()

#for t in xrange(2):
# start=time.time();O.run(nbIter);O.wait();finish=time.time()
# speed=nbIter/(finish-start); print '%g iter/sec\n'%speed
#print "FINISH"
#quit()

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Hans Henning
Solved:
2021-02-02
Last query:
2021-02-02
Last reply:
2021-02-02

Hi Hans,

Which yade/yadedaily version are you using? I ask, as the scale and shift parameters were added recently to the ymport.stl function (just last month).

Surprisingly, the latest version of yadedaily I get in Ubuntu 18.04 (using "sudo apt update"+"sudo apt upgrade") is '20201129-4411~e07e530~bionic1', which does not include these functionalities. I think it is important to ask why hasn't yadedaily updated since then? One of the senior devs could help us understand why this happened.

To solve your issue, you could either wait for yadedaily to be updated or else compile the source code yourself [1]. I just checked and scale/shift work fine on '2021-01-28.git-3c2874e' compiled three days ago.

I logged an issue on this [2].

Hope this helps,
Vasileios

[1] https://yade-dem.org/doc/installation.html#source-code
[2] https://gitlab.com/yade-dev/trunk/-/issues/195

Hi again,

Just had another look with the help of Janek and the issue I mentioned above was related to my local installation of yadedaily, i.e. there is no bug in the code.

This being said, using the latest version of yadedaily should solve your issue.

All the best,
Vasileios

Hans Henning (hansstutz) said : #3

Dear Vasileios,

Thanks a lot, I used the Yade 2020.1 version with yadedaily (after I installed it), it works fine.