can we do tesselation at another code

Asked by nobody on 2019-10-06

hi all,

Because of the Cluster I am using right now can not use the TesselationWrapper, so I am thinking maybe I can use the cluster to save the simulation and export some files to a virtual machine in a workstation to get the micro-strain and micro-stress by using tesselationWrapper.

So I did a very simple try in the virtual machine.

First I use the following code to save the simulation.

##################################
from yade import pack, plot
from yade import export
from yade import utils
compFricDegree=45.0
finalFricDegree=19.5
rate=-15
damp=0.7
target_strain = 0.15
stabilityThreshold=0.001
young=4e8
mn,mx=Vector3(0,0,0),Vector3(4e-3,8e-3,4e-3)
O.materials.append(CohFrictMat(young=young,poisson=0.3,frictionAngle=radians(compFricDegree),isCohesive=False,alphaKr=0.2,alphaKtw=0,etaRoll=0.5,momentRotationLaw=True,density=2648,label='spheres'))
O.materials.append(FrictMat(young=young,poisson=0.3,frictionAngle=0,density=0,label='walls'))
walls=aabbWalls([mn,mx],thickness=0,material='walls')
wallIds=O.bodies.append(walls)
sp=pack.SpherePack()
psdSizes=[0.12e-3,0.14e-3,0.16e-3,0.18e-3,0.19e-3,0.20e-3,0.22e-3,0.24e-3,0.29e-3,0.38e-3]
psdCumm=[0,11.1,22.2,33.3,44.4,55.5,66.6,77.7,88.8,100]
sp.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,num=2000,distributeMass=1,seed=1)
sp.toSimulation(material='spheres')
O.dt=.5*PWaveTimeStep()
triax=TriaxialStressController(
 maxMultiplier=1.0+2e5/young,
 finalMaxMultiplier=1.0+2e4/young,
 thickness=0,
 stressMask=7,
 internalCompaction=False
)
newton=NewtonIntegrator(damping=damp)
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
   [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom()],
   [Ip2_FrictMat_FrictMat_FrictPhys(),Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
   [Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(useIncrementalForm=True,always_use_moment_law=True,label='cohesiveLaw')]
 ),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.8),
 triax,
 newton,
]
triax.goal1=triax.goal2=triax.goal3=-100000
while 1:
 O.run(3000,True)
 unb=unbalancedForce()
 print 'unbalanced force: ',unb,'mean stress: ',triax.meanStress
 if unb<stabilityThreshold and abs(-100000-triax.meanStress)/-100000<0.001:
  break
triax.wall_bottom_activated=True
triax.wall_top_activated=True
triax.wall_left_activated=True
triax.wall_right_activated=True
triax.wall_back_activated=True
triax.wall_front_activated=True
setContactFriction(radians(finalFricDegree))
re11=-triax.strain[0]
re22=-triax.strain[1]
re33=-triax.strain[2]
triax.stressMask = 5
newton=NewtonIntegrator(damping=0.0)
triax.goal2=rate
triax.strainRate2=15
triax.strainRate1=triax.strainRate3=1000.0
def stop_loading():
 if -triax.strain[1]-re22> target_strain:
  O.pause()
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
   [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom()],
   [Ip2_FrictMat_FrictMat_FrictPhys(),Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
   [Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(useIncrementalForm=True,always_use_moment_law=True,label='cohesiveLaw')]
 ),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.8),
 triax,
 newton,
 PyRunner(command='stop_loading()',iterPeriod=10000),
 VTKRecorder(fileName='3d-vtk-',recorders=['all','bstresses'],iterPeriod=1000),

]
O.run(500000,True)
O.save("test.yade") ####### Here I saved the simulation.
O.saveTmp()

#######################

then I use another code to do the tesselationWrapper.

#########################
O.load("test.yade") ###### this is line 1.
O.run(100,True)
TW=TesselationWrapper()
TW.triangulate() ########### this is line 4.
TW.computeVolumes()
TW.volume(10)
TW.setState(0)
O.run(100,True)
TW.setState(1)
TW.defToVtk("strain.vtk")

#############################
I got the error as follows:

Running script try.py
Traceback (most recent call last):
  File "/usr/bin/yade", line 182, in runScript
    execfile(script,globals())
  File "try.py", line 4
SyntaxError: Non-ASCII character '\xe2' in file try.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

############################

In my opinion, we can use the first code to save the scene and then use the second code to do the tesselation by using O.load("test.yade") to reload the simulation and do the tesselation. But I got the error above.

Is there someone can give me some advice.

best,
Yong

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
2019-10-06
Last reply:
2019-10-08
Jan Stránský (honzik) said : #1

Hello,

O.save / O.load is very dependent on Yade version. It is not recommended not to use it between different versions and probably also between builds.
(search yade questions, it was discussed several times)

Maybe you can just export particle data (position, orientation) at different times and do the tessalation from these data? (Does the result depend on enything else?)

cheers
Jan

nobody (nobody01) said : #2

Hi Jan,

Actually, right now I'm doing all this on my virtual machine, so which means the Yade version is the same. I just run code one and then save it and then reload it to the second code to try the tesselationWrapper.

By the way, if I can not use the tesselationWrapper on the Cluster, are there any other ways to get the microstrain and micro stress field? do I need to use some other post-processing software or something to get this? do you have any suggestions?

best,
yong

Jan Stránský (honzik) said : #3

> SyntaxError: Non-ASCII character '\xe2' in file try.py on line 4, but no encoding declared;

sorry, I have missed this error. It seems you

> By the way, if I can not use the tesselationWrapper on the Cluster, are there any other ways to get the microstrain and micro stress field? do I need to use some other post processing software or something to get this? do you have any suggestions?

see #1, "Maybe you can just export particle data (position, orientation) at different times and do the tessalation from these data?"
i.e., save the data to a simple text files, load these files files into Yade and do tesselation there.

cheers
Jan

Jan Stránský (honzik) said : #4

(clicked "propose answer" accidentally)
.. It seems there are some strange characters in your code on line 4, try to completely delete it and rewrite it

Jan

Jan Stránský (honzik) said : #5

> try to completely delete it and rewrite it

it = the line 4, not complete code

nobody (nobody01) said : #6

Hi Jan,

Actually, I copy and paste line 4 from the official website. So I can not figure out what wrong with this line.

Last night, I just commented out the line 4 ( TW.triangulate() ), it seems the code works. But I didn't fully understand what is the function of this line.

As you can see from the official website when we calculate the micro-strain, this line is needed, while when calculating the micro-stress, we don't need this line.

from my understanding, both the micro-strain and micro-stress need the following three lines to calculate it.

TW=TesselationWrapper()
TW.triangulate()
TW.computeVolumes()

can you tell me whether my understanding is right or not?

best,
yong

Jan Stránský (honzik) said : #7

Hello,

concerning the error, just delete the line (the wrong character, possibly some invisible symbol, should be deleted) and manually write TW.triangulate()

concerning saving data without tesselation and do the tesselation externally, here is a MWE for yade:

### code running on cluster without TesselationWrapper
from yade import export
O.bodies.append(sphere((1,1,1),.5))
O.bodies.append([sphere((x,y,z),.5) for x in (0,2) for y in (0,2) for z in (0,2)])
export.text("state0.txt")
O.bodies[0].state.vel = (1,0,0)
O.run(100,True)
export.text("state1.txt")
###

### code running as post-processing with TesselationWrapper
from yade import ymport
O.bodies.append(ymport.text("state0.txt"))
TW=TesselationWrapper()
TW.triangulate()
TW.computeVolumes()
TW.setState(0)
#
O.reset()
O.bodies.append(ymport.text("state1.txt"))
TW.setState(1)
#
TW.defToVtk("strain.vtk")
###

I expect there are other softwares to do this (e.g., I would be surprised if it was not possible in Paraview).

cheers
Jan

nobody (nobody01) said : #8

Hi Jan,

I will try your method.

thanks,
yong

Can you help with this problem?

Provide an answer of your own, or ask nobody for more information if necessary.

To post a message you must log in.