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 ?

# -*- 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
   if (i==0 or i==nbSpheres[0]-1 or j==nbSpheres[1]-1 or k==0 or k==nbSpheres[2]-1):
    fixed = True

## Estimate time step

## Engines
 ## Resets forces and momenta the act on bodies

 ## Using bounding boxes find possible body collisions.
 ## Apply gravity
 ## Motion equation
 ## Apply kinematics to rod
 ## Save force on rod

import sys,time

print("Start simulation: " + mesh)

from yade import qt


#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"

Question information

English Edit question
Yade Edit question
No assignee Edit question
Solved by:
Hans Henning
Last query:
Last reply:

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,

[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,

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.