Re: [Yade-users] [Question #696648]: Image and erase

2021-05-04 Thread Bruno Chareyre
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Bruno Chareyre proposed the following answer:
Is #6 not enough to avoid the issue? I understand what you want is to produce 
an image without the wall, isn't it?
Bruno

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-05-03 Thread Jan Stránský
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Status: Open => Answered

Jan Stránský proposed the following answer:
> what do I need to do to fix it?
> And how can I report it to gitlab?

- fix in source code: add checking if b[i] is nullptr and if yes, implement 
different behavior
- gitlab issue (and wait until some developer fix it and publish the fix): [5] 
(or [6] -> Issues -> New issue)

> For my code I did not use ViscoeleasticPM, I used LudingPM.
> O.engines = [ ..., DeformControl(label="DefControl")]

As explained, the problem is in DeformControl.
Placement of that class source code in "ViscoelasticPM.*pp" is not important.

>  when I am running the command in the terminal is erase my walls. It
only crashes when I add it in my script.

More information is needed to solve this problem.
This behavior should be independent of terminal/script. Of course assuming you 
do the same thing in terminal and script.
Since in your provided script, the erase is "deep" inside PyRunner and 
checkers, I suspect that "running the command in the terminal" might simply do 
something different than "added it in the script".

Cheers
Jan

[5] https://gitlab.com/yade-dev/trunk/-/issues/new
[6] https://gitlab.com/yade-dev/trunk/

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-05-03 Thread Mithushan Soundaranathan
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Mithushan Soundaranathan posted a new comment:
Just one thing, when I am running the command in the terminal is erase
my walls. It only crashes when I add it in my script.

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-05-03 Thread Mithushan Soundaranathan
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Status: Answered => Open

Mithushan Soundaranathan is still having a problem:
Hi Jan,

Thank you, what do I need to do to fix it? And how can I report it to
gitlab?

For my code I did not use ViscoeleasticPM, I used LudingPM.

Thanks,
Mithu

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-05-03 Thread Jan Stránský
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Status: Open => Answered

Jan Stránský proposed the following answer:
> Backtrace:
> /home/mithu/myYade/trunk/install/lib/x86_64-linux-gnu/yade-Unknown/libdem.so(_ZN4yade13DeformControl6actionEv+0x93)[0x7feb6444a173]

This is the problem, inside DeformControl::action [3], specifically here [4] 
(and below following the same logic with b[i]->...).
b ... body container (like O.bodies in Python)
i ... some index
b[i] ... i-th body. But after O.bodies.erase b[i] it is possibly nullptr (None 
in Python). The null-ity is not checked (but it should be to work with 
O.bodies.erase)
b[i]-> ... some operation with the body. But if the body is erased, b[i] is 
nullptr and it ends with segmentation fault.

If you want it to be fixed, you can:
- fix it yourself
- report an issue on gitlab (referencing this question)

Similar questions (O.bodies.erase and then segmentation fault) arises
from time to time, with always the same reason - some piece of Yade C++
code not considering the possibility of erased bodies, maybe the topic
deserves a FAQ.

Cheers
Jan

[3] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/ViscoelasticPM.cpp#L408
[4] 
https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/ViscoelasticPM.cpp#L415

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-04-20 Thread Bruno Chareyre
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Bruno Chareyre posted a new comment:
Note: if you want to just "not show"  (instead of "delete") you can also
use this:

In [2]: rr=yade.qt.Renderer()

In [3]: rr.hideBody?

Docstring:
hideBody( (OpenGLRenderer)arg1, (int)id) -> None :
Hide body from id (see :yref:`OpenGLRenderer::showBody`)


Regards
Bruno

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-04-20 Thread Jan Stránský
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Status: Open => Needs information

Jan Stránský requested more information:
SnapshotEngine should work, don't know why. also qt.SnapshotEngine
cannot be found.. I think it is a topic for separate question :-)

concerning segmentation fault, it is probably somewhere, where the code expects 
a body, but it is deleted at the time.
Please run
catchsegv yade script.py
(where "yade" and "script.py" are the executable and the file you are using)
and provide the output

cheers
Jan

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-04-20 Thread Mithushan Soundaranathan
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Status: Answered => Open

Mithushan Soundaranathan is still having a problem:
Hi Jan,

The snapshotengine does not work, getting erro message saying
'SnapshotEngine' is not defined.

Here is my code:
#!/usr/bin/env python
#encoding: ascii

# Modefied Oedometric Test for particle deformation under const. volume
# The reference paper [Haustein2017]


from __future__ import print_function
from yade import utils, plot, timing
from yade import pack


o = Omega()

# Physical parameters
fr = 0.3
rho = 2000
tc = 0.002
en = 0.7
et = 0.7
Diameter = 16.5e-3   # R

#*

o.dt = 1.0e-5   # Timestep

#*

# Add material
mat1 = O.materials.append(ViscElMat(frictionAngle=fr, tc=tc, en=en, et=et))


# Spheres for compression

sp=pack.SpherePack()
sp.makeCloud((-4.0*Diameter,-4.0*Diameter,-2.5*Diameter),(3.0*Diameter,3.0*Diameter,15.0*Diameter),
 rMean=Diameter/2.0, num=300)
sp.toSimulation()


##
cylinder=O.bodies.append(
geom.facetBox((0,0,0), (4.0*Diameter,4.0*Diameter,4.0*Diameter), 
wallMask=63-32, material=mat1)
)

# Add engines
o.engines = [
  ForceResetter(),
  InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.05),
 Bo1_Wall_Aabb(),
 Bo1_Facet_Aabb()
 ]),
  InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=1.05),
 Ig2_Facet_Sphere_ScGeom(),
 Ig2_Wall_Sphere_ScGeom()],
[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
[Law2_ScGeom_ViscElPhys_Basic()]
  ),
  NewtonIntegrator(damping=0.1, gravity=[0, 0, -9.81]),
  #VTKRecorder(fileName='vtk-',recorders=['all'],iterPeriod=2),
  PyRunner(command='checkForce()', realPeriod=1, label="fCheck"),
  DeformControl(label="DefControl")
]


def checkForce():
# at the very start, unbalanced force can be low as there is only few
# contacts, but it does not mean the packing is stable
if O.iter < 2:
return
# the rest will be run only if unbalanced is < 1.0 (stabilized packing)
timing.reset()
if unbalancedForce() > 0.2:
return

highSphere=0.0
for b in O.bodies:
if highSphere < b.state.pos[2] and isinstance(b.shape, Sphere):
highSphere = b.state.pos[2]
else:
pass


# add plate at upper box side
O.bodies.append(wall(highSphere+0.5*Diameter, axis=2, sense=-1, 
material=mat1))
# without this line, the plate variable would only exist inside this
# function
global plate
plate = O.bodies[-1]  # the last particles is the plate
# Wall objects are "fixed" by default, i.e. not subject to forces
# prescribing a velocity will therefore make it move at constant velocity
# (downwards)
plate.state.vel = (0, 0, -0.1)
# start plotting the data now, it was not interesting before
O.engines = O.engines + [PyRunner(command='addPlotData()', iterPeriod=1000)]
# next time, do not call this function anymore, but the next one
# (unloadPlate) instead
fCheck.command = 'unloadPlate()'


def unloadPlate():
# if the force on plate exceeds maximum load, start unloading
# if abs(O.forces.f(plate.id)[2]) > 5e-2:
# if plate.state.pos[2] < (-4*Diameter+40.0e-3):
if abs(O.forces.f(plate.id)[2]) > 5e2:
plate.state.vel *= -1
# next time, do not call this function anymore, but the next one
# (stopUnloading) instead
fCheck.command = 'stopUnloading()'


def stopUnloading():
if abs(O.forces.f(plate.id)[2]) == 0:
# O.tags can be used to retrieve unique identifiers of the simulation
# if running in batch, subsequent simulation would overwrite each 
other's output files otherwise
# d (or description) is simulation description (composed of parameter 
values)
# while the id is composed of time and process number
# plot.saveDataTxt(O.tags['d.id'] + '.txt')
plot.saveDataTxt('data'+ O.tags['id'] +'.txt')
print(timing.stats())
O.pause()
for b in O.bodies: 
if isinstance(b.shape,Wall): O.bodies.erase(b.id) # erase all walls 
for j in cylinder: O.bodies.erase(j)







def addPlotData():
if not isinstance(O.bodies[-1].shape, Wall):
plot.addData()
return
Fz = O.forces.f(plate.id)[2]
plot.addData(
Fz=Fz,
w=plate.state.pos[2] - (-4*Diameter),# hight of the box (Bottom to 
upper Wall)
unbalanced=unbalancedForce(),
i=O.iter
)


O.timingEnabled=True
O.run(1, True)
plot.plots={'w':('Fz', None)}
plot.plot()

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

___
Mailing list: 

Re: [Yade-users] [Question #696648]: Image and erase

2021-04-20 Thread Jan Stránský
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Status: Open => Answered

Jan Stránský proposed the following answer:
> When I add the o.bodies.erase, I am getting error message
"Segmentation fault (core dumped)".

please provide the code causing this.

> Snapshot engine works only during the iteration, and does not take
image after o.pause.

not necessarily, something like
###
e = SnapshotEngine(...) # create a SnapshotEngine instance
e() # call the instance
###
could/should work

cheers
Jan

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-04-20 Thread Mithushan Soundaranathan
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Status: Answered => Open

Mithushan Soundaranathan is still having a problem:
Hi Jan,

Thank you for reply, sorry for asking two questions. I thought both of them 
were on the same code. 
When I add the o.bodies.erase, I am getting error message "Segmentation fault 
(core dumped)".

Snapshot engine works only during the iteration,  and does not take
image after o.pause.

Best,
Mithu

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #696648]: Image and erase

2021-04-20 Thread Jan Stránský
Question #696648 on Yade changed:
https://answers.launchpad.net/yade/+question/696648

Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

you have 2 problems in one question. Next time, please create separate
question for separate problem [1]

> How can I erase "walls" and the "plate" once my simulation is done
(after o.pause).

Depends on what "walls" and "plate" are and how to indentify them w.r.t. other 
bodies. In general O.bodies.erase [2] is probably what you want. You can use it 
in different ways:
O.bodies.erase(id) # if you know the ID
O.bodies.erase(body.id) # if you have the body instance
for b in O.bodies:
   if isinstance(b.shape,Wall): O.bodies.erase(b.id) # erase all walls

> I also would like take a image of my simulation after o.pause.

Several options, too, depending on actual needs 
- create screenshot manually
- use SnapshotEngine to create the screenshot
- export data and create image externally (e.g. using Paraview)

Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask
[2] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.BodyContainer.erase

-- 
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@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp