GridConnection and PFacet: Segmentation fault

Asked by Justin

I seem to get a Segmentation fault (core dumped) when using GridConnection, PFacet, and randomDensePack. And I am not sure why. I have attached an image and "working" example.

Thanks in advance,
Justin

Edit: I could not seem to upload an picture or example code. Thus code below:

from yade.gridpfacet import *
import numpy as np
from yade import utils
from yade import ymport
import sys,time,math,random

from yade import qt
qt.View()

#print(os.path.basename(__file__))
#quit()
########### ParallelEngine, -j4

boxCenter = (0,0,.025)
## double check that /2 would create correct length, I.e., import based_70 to see if they match... they should
boxDem = (.2123/2,.212/2,.064/2) ### based_70 is 212.3x212.21x63.65

boxDem = (.07,.07,.025) ###

blen = boxDem[0]*2 ## Length of Ball pit
bhei = .025 ## Height of Ball pit

# Spheres information
sphereRadius = .004 # [m]
nu = .48
#G = 300000 # [Pa]
den_rub = 89724 # [kg/m^3]
yng_rub = 3000000 # [Pa]
fric_rub = radians(38) # [degrees]
O.materials.append(FrictMat(frictionAngle=fric_rub,young=yng_rub,density=den_rub,poisson=nu,label='rubber'))
O.materials.append(FrictMat(young=200e9,density=8050,poisson=.3, label='steel')) # used steel properties to make rigid

## Stud informtion
#studStartZ = (.01+.022+.01905)
studStartZ = (.01+bhei+.01905)
transVel = 0.000222*2
rotVel = 0.00872665*2

### pack auto fills, i.e., I no longer pick the amount of spheres
pred = pack.inAlignedBox((-(boxDem[0]-.001),-(boxDem[0]-.001),bhei+sphereRadius/2+.001),((boxDem[0]-.001),(boxDem[0]-.001),bhei+.045))
sp = pack.randomDensePack(pred, radius=sphereRadius, memoizeDb='tmp/single_grass.sqlite', returnSpherePack=True)
sp.toSimulation(wire=False,material='rubber')

## Time step set to 20% of Rayleigh Wave
O.dt=.2*utils.RayleighWaveTimeStep() # 0.0011302534626965682
print(O.dt)

### Steps needed to run sim
sphereFalls = 1000 ### Steps spheres need to fall and level out and turn on studs
startRot = sphereFalls+math.floor((studStartZ-bhei-.01)/transVel/O.dt) ### Step needed for transVel to get studs level with spheres

## Rotation steps
deg_to_rad_length = (60*pi/180); # [rad]
num_sec_roto = deg_to_rad_length/rotVel; # [s]
num_of_steps_roto = num_sec_roto/O.dt;

endSim = startRot + math.floor(num_of_steps_roto) ### total steps in sim

O.engines=[
  ###Reset all forces stored in Scene::forces (O.forces in python). Typically, this is the first engine to be run at every step. In addition, reset those energies that should be reset, if energy tracing is enabled.
  ## Resets forces and moments that act on bodies
  ForceResetter(),

  ## Using bounding boxes find possible body collisions.
  InsertionSortCollider([
  Bo1_Facet_Aabb(),
  Bo1_PFacet_Aabb(),
  Bo1_Sphere_Aabb(),
  Bo1_GridConnection_Aabb(),
  Bo1_PFacet_Aabb(),
  ]),
  InteractionLoop([
   Ig2_Facet_Sphere_ScGeom(),
   Ig2_Wall_PFacet_ScGeom(),
   Ig2_Wall_Sphere_ScGeom(),
   Ig2_Sphere_Sphere_ScGeom(),
   Ig2_Sphere_GridConnection_ScGridCoGeom(),
   Ig2_Sphere_PFacet_ScGridCoGeom(),
   Ig2_GridNode_GridNode_GridNodeGeom6D(),
   Ig2_GridConnection_GridConnection_GridCoGridCoGeom(),
   Ig2_GridConnection_PFacet_ScGeom(),
   Ig2_PFacet_PFacet_ScGeom(),
   ],
   [
# Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=True), # internal cylinder physics
   Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True), # internal cylinder physics
   ## Currently grass does not interact with facet, probably should not matter, since the spheres will be holding them up.

   Ip2_FrictMat_FrictMat_FrictPhys() # physics for external interactions, i.e., cylinder-cylinder, sphere-sphere, cylinder-sphere
   ],
   [
   Law2_ScGeom_FrictPhys_CundallStrack(), # contact law for sphere-sphere
   Law2_ScGridCoGeom_FrictPhys_CundallStrack(), # contact law for cylinder-sphere
   Law2_ScGeom6D_CohFrictPhys_CohesionMoment(), # contact law for "internal" cylinder forces
   Law2_GridCoGridCoGeom_FrictPhys_CundallStrack(), # contact law for cylinder-cylinder interaction
  ]),
 NewtonIntegrator(damping=.2,gravity=[0,0,-9.81], label='newtonInt'),
]

## Grass Information
#O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=np.radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='grass')) ## Properties Need to be corrected
O.materials.append(CohFrictMat(young=100,poisson=0.3,density=40,frictionAngle=np.radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='grass'))
#rCyl = 0.0006 ## Radius, Grass was about 1.2 [mm] wide
rCyl = 0.0026 ## Grass was about 1.2 [mm] wide
nL = 4 ## No exact Number here, just trial and error
L = bhei ## Height of spheres

### Grass Creation
### Create all nodes first :
nodesIds=[]
idxc = -1
x_gap = 0.009 ## Between lumps is roughly 9 [mm]
y_gap = 0.01905 ## Between lines of backing is .75 inch apart
range_x = int(math.floor(blen/x_gap)) ## finding the range for x
range_y = int(math.floor(blen/y_gap)) ## finding the range for z
cen_y = -(range_y/2)*y_gap ## Allows the "box" of grass to be center in Z

color=[255./255.,102./255.,0./255.]
steel_r = (1/4*0.00635)/2 ### Converting 1/4 steel to m, to a sphere radius
box = []
box.append(O.bodies.append( gridNode([-boxDem[0],-boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([boxDem[0],-boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([boxDem[0],boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([-boxDem[0],boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
O.bodies.append( gridConnection(box[0],box[1],steel_r,color=color,material='steel') )
O.bodies.append( gridConnection(box[1],box[2],steel_r,color=color,material='steel') )
O.bodies.append( gridConnection(box[2],box[0],steel_r,color=color,material='steel') )
O.bodies.append( gridConnection(box[2],box[3],steel_r,color=color,material='steel') )
O.bodies.append( gridConnection(box[3],box[0],steel_r,color=color,material='steel') )
O.bodies.append( pfacet(box[0],box[1],box[2],wire=False,material='steel',color=color) )
O.bodies.append( pfacet(box[0],box[2],box[3],wire=False,material='steel',color=color) )

O.stopAtIter=endSim ### Stop sim at endSim steps
#O.run()

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Justin
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#1

Hi Justin,
You did not specify the yade version you are using.
Is it possible for you to compile with debug symbols? It would tell more on the problem.
Regards
Bruno

Revision history for this message
Justin (justin-l-rittenhouse) said :
#2

Bruno,

Thanks for the reply.
Version:
Welcome to Yade 20191002-2321~8ce2132~bionic1
Using python version: 3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0]

I just used the package manager to install yadedaily. By "compile with debug symbols" do you mean compile Yade from source code?

Thanks,
Justin

Revision history for this message
Justin (justin-l-rittenhouse) said :
#3

Bruno,

Thanks for the reply.
Version:
Welcome to Yade 20191002-2321~8ce2132~bionic1
Using python version: 3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0]

I just used the package manager to install yadedaily. By "compile with debug symbols" do you mean compile Yade from source code?

Thanks,
Justin

Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#4

Hi Justin,

the problem is the material in gridConnection and pfacet. If you use this approach you should only use the material once, with the gridNode, see below. The rest is set up based on that material.

box.append(O.bodies.append( gridNode([-boxDem[0],-boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([boxDem[0],-boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([boxDem[0],boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([-boxDem[0],boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))

O.bodies.append( gridConnection(box[0],box[1],steel_r,color=color) )
O.bodies.append( gridConnection(box[1],box[2],steel_r,color=color) )
O.bodies.append( gridConnection(box[2],box[0],steel_r,color=color) )
O.bodies.append( gridConnection(box[2],box[3],steel_r,color=color) )
O.bodies.append( gridConnection(box[3],box[0],steel_r,color=color,) )

O.bodies.append( pfacet(box[0],box[1],box[2],wire=False,color=color) )
O.bodies.append( pfacet(box[0],box[2],box[3],wire=False,color=color) )

HTH
Klaus

Revision history for this message
Justin (justin-l-rittenhouse) said :
#5

Klaus,

Thanks for the help. Unfortunately I get another "Segmentation fault (core dumped)" when "grass" is added. Minimum error causing code is below.

What I believe is causing the error. The "grass" is just vertical standing gridConnections. The nodes DOFs are fixed until the spheres fall around them, then all nodes except the bottom nodes are release to move freely. I believe the problem is, the spheres do not interact with the "grass" and are actually going straight through the "grass". Then once the nodes are release, the spheres interact and cause Segmentation fault (core dumped).

Thus do you believe this is the problem, if so, is there anyway I can get the spheres to interact with the grass while the grass' DOFs are fixed? I.e., so there are not spheres going through/in the "grass".

Thanks,
Justin

Minimum error causing code:

from yade.gridpfacet import *
import numpy as np
from yade import utils
from yade import ymport
import sys,time,math,random

from yade import qt
qt.View()

boxCenter = (0,0,.025)
## double check that /2 would create correct length, I.e., import based_70 to see if they match... they should
#boxDem = (.2123/2,.212/2,.064/2) ### based_70 is 212.3x212.21x63.65

boxDem = (.07,.07,.025) ###
# probably need to add O.material that would be the boxes material?
#O.bodies.append(geom.facetBox(boxCenter,boxDem,wallMask=31,color=(1,1,1),wire=True,fixed=True))

O.materials.append(FrictMat(young=200e9,density=8050,poisson=.3, label='steel')) # used steel properties to make rigid

blen = boxDem[0]*2 ## Length of Ball pit
bhei = .025 ## Height of Ball pit

# Spheres information
sphereRadius = .004 # [m]
nu = .48
#G = 300000 # [Pa]
den_rub = 89724 # [kg/m^3]
yng_rub = 3000000 # [Pa]
fric_rub = radians(38) # [degrees]
O.materials.append(FrictMat(frictionAngle=fric_rub,young=yng_rub,density=den_rub,poisson=nu,label='rubber'))

## Stud informtion
#studStartZ = (.01+.022+.01905)
studStartZ = (.01+bhei+.01905)
transVel = 0.000222*2
rotVel = 0.00872665*2

### pack auto fills, i.e., I no longer pick the amount of spheres
pred = pack.inAlignedBox((-(boxDem[0]-.001),-(boxDem[0]-.001),.1+bhei+sphereRadius/2+.001),((boxDem[0]-.001),(boxDem[0]-.001),.1+bhei+.045))
sp = pack.randomDensePack(pred, radius=sphereRadius, memoizeDb='tmp/single_grass.sqlite', returnSpherePack=True)
sp.toSimulation(wire=False,material='rubber')

## Time step set to 20% of Rayleigh Wave
O.dt=.2*utils.RayleighWaveTimeStep() # 0.0011302534626965682
#O.dt=0.00011302534626965682/2
print(O.dt)

### Steps needed to run sim
sphereFalls = 4000 ### Steps spheres need to fall and level out and turn on studs
startRot = sphereFalls+math.floor((studStartZ-bhei-.01)/transVel/O.dt) ### Step needed for transVel to get studs level with spheres

## Rotation steps
deg_to_rad_length = (60*pi/180); # [rad]
num_sec_roto = deg_to_rad_length/rotVel; # [s]
num_of_steps_roto = num_sec_roto/O.dt;

endSim = startRot + math.floor(num_of_steps_roto) ### total steps in sim

O.engines=[
  ###Reset all forces stored in Scene::forces (O.forces in python). Typically, this is the first engine to be run at every step. In addition, reset those energies that should be reset, if energy tracing is enabled.
  ## Resets forces and moments that act on bodies
  ForceResetter(),

  ## Using bounding boxes find possible body collisions.
  InsertionSortCollider([
  Bo1_Facet_Aabb(),
  Bo1_Sphere_Aabb(),
  Bo1_GridConnection_Aabb(),
  Bo1_PFacet_Aabb(),
  ]),
  InteractionLoop([
   Ig2_Facet_Sphere_ScGeom(),
   Ig2_Wall_PFacet_ScGeom(),
   Ig2_Wall_Sphere_ScGeom(),
   Ig2_Sphere_Sphere_ScGeom(),
   Ig2_Sphere_GridConnection_ScGridCoGeom(),
   Ig2_Sphere_PFacet_ScGridCoGeom(),
   Ig2_GridNode_GridNode_GridNodeGeom6D(),
   Ig2_GridConnection_GridConnection_GridCoGridCoGeom(),
   Ig2_GridConnection_PFacet_ScGeom(),
   Ig2_PFacet_PFacet_ScGeom(),
   ],
   [
   Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=True), # internal cylinder physics
# Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True), # internal cylinder physics
   ## Currently grass does not interact with facet, probably should not matter, since the spheres will be holding them up.
   Ip2_FrictMat_FrictMat_FrictPhys() # physics for external interactions, i.e., cylinder-cylinder, sphere-sphere, cylinder-sphere
   ],
   [
   Law2_ScGeom_FrictPhys_CundallStrack(), # contact law for sphere-sphere
   Law2_ScGridCoGeom_FrictPhys_CundallStrack(), # contact law for cylinder-sphere
   Law2_ScGeom6D_CohFrictPhys_CohesionMoment(), # contact law for "internal" cylinder forces
   Law2_GridCoGridCoGeom_FrictPhys_CundallStrack(), # contact law for cylinder-cylinder interaction
  ]),
 NewtonIntegrator(damping=.2,gravity=[0,0,-9.81], label='newtonInt'),
 PyRunner(command='turnongrass()',firstIterRun=sphereFalls, nDo=6, dead=False, label='freeGrass'),
]

## Grass Information
O.materials.append(CohFrictMat(young=100,poisson=0.3,density=40,frictionAngle=np.radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='grass'))
#rCyl = 0.0006 ## Radius, Grass was about 1.2 [mm] wide
rCyl = 0.0026 ## Grass was about 1.2 [mm] wide
nL = 4 ## No exact Number here, just trial and error
L = bhei ## Height of spheres

### Grass Creation
### Create all nodes first :
nodesIds=[]
idxc = -1
x_gap = 0.009 ## Between lumps is roughly 9 [mm]
y_gap = 0.01905 ## Between lines of backing is .75 inch apart
range_x = int(math.floor(blen/x_gap))-1 ## finding the range for x
range_y = int(math.floor(blen/y_gap))-1 ## finding the range for z
cen_y = -(range_y/2)*y_gap ## Allows the "box" of grass to be center in Z

for ii in range(0,range_y):
  cen_x = -(range_x/2)*x_gap # Allows the "box" of grass to be center in X
  for jj in range(0,range_x):
    for z in np.linspace(0,L,nL):
      nodesIds.append(O.bodies.append(gridNode([cen_x,cen_y,z+sphereRadius],rCyl,wire=False,fixed=False,material='grass')))
    idxc += 1
    d = idxc*nL ## Start of grass fiber
    cen_x += x_gap
#### Now create connection between the nodes
    for k,j in zip(nodesIds[d:d+nL-1],nodesIds[d+1:nodesIds[-1]+1]):
      O.bodies.append(gridConnection(k,j,rCyl))
  cen_y += y_gap

for kk in range(0,len(nodesIds)): ## First Blocking all DOF's until balls fall around.
  O.bodies[nodesIds[kk]].state.blockedDOFs='xyzXYZ'

def turnongrass():
 print("Turning on Grass")
 for kk in range(0,len(nodesIds)):
   O.bodies[nodesIds[kk]].state.blockedDOFs='' ## Unblocking all DOF's
 for kk in range(0,len(nodesIds),nL):
  O.bodies[nodesIds[kk]].state.blockedDOFs='xyzXYZ' ## Blocking DOF's for Bottom nodes
  O.bodies[nodesIds[kk+nL-1]].state.blockedDOFs='' ## Top of Grass
 freeGrass.dead = True

colorTG=[40./255.,102./255.,50./255.]
color=[255./255.,102./255.,0./255.]
steel_r = (1/4*0.00635)/2 ### Converting 1/4 steel to m, to a sphere radius
box = []
box.append(O.bodies.append( gridNode([-boxDem[0],-boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([boxDem[0],-boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([boxDem[0],boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([-boxDem[0],boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
O.bodies.append( gridConnection(box[0],box[1],steel_r,color=color) )
O.bodies.append( gridConnection(box[1],box[2],steel_r,color=color) )
O.bodies.append( gridConnection(box[2],box[0],steel_r,color=color) )
O.bodies.append( gridConnection(box[2],box[3],steel_r,color=color) )
O.bodies.append( gridConnection(box[3],box[0],steel_r,color=color) )
O.bodies.append( pfacet(box[0],box[1],box[2],wire=False,color=color,material='steel') )
O.bodies.append( pfacet(box[0],box[2],box[3],wire=False,color=color,material='steel') )

O.stopAtIter=endSim ### Stop sim at endSim steps

Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#6

Hi Justin,

I wouldn't consider this a MWE. Try to reproduce the problem with minimum number of bodies. By minimum I mean one sphere, potentially 2 pfacets and one grass element (2 or 3 cylinders).

Also, something I noticed is that your pFacets are rather thin compared to the rest. This might cause some numerical issues.

Klaus

Revision history for this message
Justin (justin-l-rittenhouse) said :
#7

Klaus,

I updated the code to be a MWE.

Items to note:
I increased the thickness for the pFacets
I could not recreate the problem with one or even two grass strands. I used 4, and had the once sphere far in the center-ish of the four. This recreates the problem every time.

My thoughts, since half the sphere is in the grass strand when the grass is release, it is simply causing too much force? Thoughts? Or would that not be an issue.

Thanks,
Justin

from yade.gridpfacet import *
import numpy as np
from yade import utils
from yade import ymport
import sys,time,math,random

from yade import qt
qt.View()

boxCenter = (0,0,.025)
boxDem = (.07,.07,.025) ###
O.materials.append(FrictMat(young=200e9,density=8050,poisson=.3, label='steel')) # used steel properties to make rigid

blen = boxDem[0]*2 ## Length of Ball pit
bhei = .025 ## Height of Ball pit

# Spheres information
sphereRadius = .004 # [m]
nu = .48
den_rub = 89724 # [kg/m^3]
yng_rub = 3000000 # [Pa]
fric_rub = radians(38) # [degrees]
O.materials.append(FrictMat(frictionAngle=fric_rub,young=yng_rub,density=den_rub,poisson=nu,label='rubber'))

#### SPHERES
phi=20.
E=3.*1e8
O.materials.append( FrictMat( young=E,poisson=0.5,density=260050,frictionAngle=radians(phi),label='frictMat' ) )
O.bodies.append( sphere(center=(Vector3(-0.0015,-0.0015-.04,0.05)),radius=sphereRadius,material='frictMat',fixed=False) )

## Time step set to 20% of Rayleigh Wave
O.dt=.2*utils.RayleighWaveTimeStep() # 0.0011302534626965682

### Steps needed to run sim
sphereFalls = 20000 ### Steps spheres need to fall and level out and turn on studs

O.engines=[
  ###Reset all forces stored in Scene::forces (O.forces in python). Typically, this is the first engine to be run at every step. In addition, reset those energies that should be reset, if energy tracing is enabled.
  ## Resets forces and moments that act on bodies
  ForceResetter(),

  ## Using bounding boxes find possible body collisions.
  InsertionSortCollider([
  Bo1_Facet_Aabb(),
  Bo1_Sphere_Aabb(),
  Bo1_GridConnection_Aabb(),
  Bo1_PFacet_Aabb(),
  ]),
  InteractionLoop([
   Ig2_Facet_Sphere_ScGeom(),
   Ig2_Wall_PFacet_ScGeom(),
   Ig2_Wall_Sphere_ScGeom(),
   Ig2_Sphere_Sphere_ScGeom(),
   Ig2_Sphere_GridConnection_ScGridCoGeom(),
   Ig2_Sphere_PFacet_ScGridCoGeom(),
   Ig2_GridNode_GridNode_GridNodeGeom6D(),
   Ig2_GridConnection_GridConnection_GridCoGridCoGeom(),
   Ig2_GridConnection_PFacet_ScGeom(),
   Ig2_PFacet_PFacet_ScGeom(),
   ],
   [
   Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=True), # internal cylinder physic
   Ip2_FrictMat_FrictMat_FrictPhys() # physics for external interactions, i.e., cylinder-cylinder, sphere-sphere, cylinder-sphere
   ],
   [
   Law2_ScGeom_FrictPhys_CundallStrack(), # contact law for sphere-sphere
   Law2_ScGridCoGeom_FrictPhys_CundallStrack(), # contact law for cylinder-sphere
   Law2_ScGeom6D_CohFrictPhys_CohesionMoment(), # contact law for "internal" cylinder forces
   Law2_GridCoGridCoGeom_FrictPhys_CundallStrack(), # contact law for cylinder-cylinder interaction
  ]),
 NewtonIntegrator(damping=.2,gravity=[0,0,-9.81], label='newtonInt'),
 PyRunner(command='turnongrass()',firstIterRun=sphereFalls, nDo=6, dead=False, label='freeGrass'),
]

## Grass Information
O.materials.append(CohFrictMat(young=100,poisson=0.3,density=40,frictionAngle=np.radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='grass'))
rCyl = 0.0026 ## Grass was about 1.2 [mm] wide
nL = 4 ## No exact Number here, just trial and error
L = bhei ## Height of spheres

### Grass Creation
### Create all nodes first :
nodesIds=[]
idxc = -1
x_gap = 0.006
y_gap = 0.006
range_x = 2 ## finding the range for x
range_y = 2 ## finding the range for z
cen_y = -(range_y/2)*y_gap ## Allows the "box" of grass to be center in Z

for ii in range(0,range_y):
  cen_x = -(range_x/2)*x_gap # Allows the "box" of grass to be center in X
  for jj in range(0,range_x):
    for z in np.linspace(0,L,nL):
      nodesIds.append(O.bodies.append(gridNode([cen_x,cen_y-.04,z+sphereRadius+.004],rCyl,wire=False,fixed=False,material='grass')))
    idxc += 1
    d = idxc*nL ## Start of grass fiber
    cen_x += x_gap
#### Now create connection between the nodes
    for k,j in zip(nodesIds[d:d+nL-1],nodesIds[d+1:nodesIds[-1]+1]):
      O.bodies.append(gridConnection(k,j,rCyl))
  cen_y += y_gap

for kk in range(0,len(nodesIds)): ## First Blocking all DOF's until balls fall around.
  O.bodies[nodesIds[kk]].state.blockedDOFs='xyzXYZ'

def turnongrass():
 print("Turning on Grass")
 for kk in range(0,len(nodesIds)):
   O.bodies[nodesIds[kk]].state.blockedDOFs='' ## Unblocking all DOF's
 for kk in range(0,len(nodesIds),nL):
  O.bodies[nodesIds[kk]].state.blockedDOFs='xyzXYZ' ## Blocking DOF's for Bottom nodes
  O.bodies[nodesIds[kk+nL-1]].state.blockedDOFs='' ## Top of Grass
 freeGrass.dead = True

color=[255./255.,102./255.,0./255.]
steel_r = .005
box = []
box.append(O.bodies.append( gridNode([-boxDem[0],-boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([boxDem[0],-boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
box.append(O.bodies.append( gridNode([boxDem[0],boxDem[1],0],steel_r,wire=False,fixed=True,material='steel',color=color) ))
O.bodies.append( gridConnection(box[0],box[1],steel_r,color=color) )
O.bodies.append( gridConnection(box[1],box[2],steel_r,color=color) )
O.bodies.append( gridConnection(box[2],box[0],steel_r,color=color) )
O.bodies.append( pfacet(box[0],box[1],box[2],wire=False,color=color,material='steel') )

Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#8

I had a brief look at this and could reproduce your segmentation fault. At this stage I don't know where it is coming from. something I can tell is that it is not coming from the boundary conditions. I have a suspicion it might be related to the gridconnection-pfacet interaction since the gridconnection is split up in several gridconnections that are much smaller than the pfacet gridconnection. That's a case we didn't validate before. Also, for your applications, would it be possible to replace the pfacet with a wall? You could try that.

Klaus

Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#9

I have reported a bug [1], but not sure when I will be able to look into this.

Klaus

[1] https://bugs.launchpad.net/yade/+bug/1852197

Revision history for this message
Justin (justin-l-rittenhouse) said :
#10

Klaus,

Thanks for the reply, and sorry for the delay. Being the holiday season, I have been very busy and often gone.

Anyways, just to be sure we are on the same page, do you mean try aabbWalls from example triax-basic-with-clumps.py?

Thanks,
Justin

Revision history for this message
Justin (justin-l-rittenhouse) said :
#11

Klaus,

The error appears to actually be from the grid nodes interacting. I removed all other variables, and just let gravitational force make two grid nodes hit, and it causes the "Segmentation fault (core dumped)". Am I doing something wrong here? Thanks in advance.

Code is below

Thanks,
Justin

from yade.gridpfacet import *
import numpy as np
from yade import utils
from yade import ymport
import sys,time,math,random

from yade import qt
qt.View()

# Spheres information
sphereRadius = .004 # [m]
sphereFalls = 1000
blen = .07*2 ## Length of Ball pit
bhei = .025 ## Height of Ball pit

## Time step set to 20% of Rayleigh Wave
O.dt=.2*utils.RayleighWaveTimeStep() # 0.0011302534626965682
O.dt=0.00000011302534626965682/2

O.engines=[
  ###Reset all forces stored in Scene::forces (O.forces in python). Typically, this is the first engine to be run at every step. In addition, reset those energies that should be reset, if energy tracing is enabled.
  ## Resets forces and moments that act on bodies
  ForceResetter(),

  ## Using bounding boxes find possible body collisions.
  InsertionSortCollider([
  Bo1_Facet_Aabb(),
  Bo1_Sphere_Aabb(),
  Bo1_GridConnection_Aabb(),
  Bo1_PFacet_Aabb(),

  ]),
  InteractionLoop([
   Ig2_Facet_Sphere_ScGeom(),
   Ig2_Wall_PFacet_ScGeom(),
   Ig2_Wall_Sphere_ScGeom(),
   Ig2_Sphere_Sphere_ScGeom(),
   Ig2_Sphere_GridConnection_ScGridCoGeom(),
   Ig2_Sphere_PFacet_ScGridCoGeom(),
   Ig2_GridNode_GridNode_GridNodeGeom6D(),
   Ig2_GridConnection_GridConnection_GridCoGridCoGeom(),
   Ig2_GridConnection_PFacet_ScGeom(),
   Ig2_PFacet_PFacet_ScGeom(),
   ],
   [
   Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=True), # internal cylinder physics
   Ip2_FrictMat_FrictMat_FrictPhys() # physics for external interactions, i.e., cylinder-cylinder, sphere-sphere, cylinder-sphere
   ],
   [
   Law2_ScGeom_FrictPhys_CundallStrack(), # contact law for sphere-sphere
   Law2_ScGridCoGeom_FrictPhys_CundallStrack(), # contact law for cylinder-sphere
   Law2_ScGeom6D_CohFrictPhys_CohesionMoment(), # contact law for "internal" cylinder forces
   Law2_GridCoGridCoGeom_FrictPhys_CundallStrack(), # contact law for cylinder-cylinder interaction
  ]),
 NewtonIntegrator(damping=.2,gravity=[0,10,-9.81], label='newtonInt'),
 PyRunner(command='turnongrass()',firstIterRun=sphereFalls, nDo=6, dead=False, label='freeGrass'),
]

## Grass Information
O.materials.append(CohFrictMat(young=100,poisson=0.3,density=40,frictionAngle=np.radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='grass'))
rCyl = 0.0026 ## Grass was about 1.2 [mm] wide
nL = 3 ## No exact Number here, just trial and error
L = bhei ## Height of spheres

### Grass Creation
### Create all nodes first :
nodesIds=[]
idxc = -1
x_gap = 0.009 ## Between lumps is roughly 9 [mm]
y_gap = 0.01905 ## Between lines of backing is .75 inch apart
range_x = 1
range_y = 2
cen_y = -(range_y/2)*y_gap ## Allows the "box" of grass to be center in Z

for ii in range(0,range_y):
  cen_x = -(range_x/2)*x_gap # Allows the "box" of grass to be center in X
  for jj in range(0,range_x):
    for z in np.linspace(0,L,nL):
      nodesIds.append(O.bodies.append(gridNode([cen_x,cen_y,z+sphereRadius],rCyl,wire=False,fixed=False,material='grass')))
    idxc += 1
    d = idxc*nL ## Start of grass fiber
    cen_x += x_gap
#### Now create connection between the nodes
    for k,j in zip(nodesIds[d:d+nL-1],nodesIds[d+1:nodesIds[-1]+1]):
      O.bodies.append(gridConnection(k,j,rCyl))
  cen_y += y_gap

for kk in range(0,len(nodesIds)): ## First Blocking all DOF's until balls fall around.
  O.bodies[nodesIds[kk]].state.blockedDOFs='xyzXYZ'

def turnongrass():
 print("Turning on Grass")
 for kk in range(0,len(nodesIds)):
   O.bodies[nodesIds[kk]].state.blockedDOFs='' ## Unblocking all DOF's
 for kk in range(0,len(nodesIds),nL):
  O.bodies[nodesIds[kk]].state.blockedDOFs='xyzXYZ' ## Blocking DOF's for Bottom nodes
  O.bodies[nodesIds[kk+nL-1]].state.blockedDOFs='' ## Top of Grass
 freeGrass.dead = True

Revision history for this message
Yuri Bezmenov (yuribezmenov) said :
#12

Hi Justin & Klaus,
Do you guys find the solution? I'm getting the same error. It appears to me as soon as my grid interacts with Wall/Facet, it throws segmentation fault.

Revision history for this message
Justin (justin-l-rittenhouse) said :
#13

Yuri,

I no longer have the issue, but I have changed my code a lot since then. I believe removing PFacets was my solution, I switched to just importing .mesh files.

Try removing PFacets if that does not work, please post a MWE.

Thanks,
Justin

Revision history for this message
Yuri Bezmenov (yuribezmenov) said :
#14

Thanks Justin.
it helps.