Grid connections error/bug?

Asked by Justin

Why, in my code, do half of the nodes/grid connections just disappear once the fixed BC is turned of?

I notice the same thing with CohesiveCylinderSphere.py (gridConnections) in the examples/grid folder [*].

In the for loop:
for i in linspace(0,L,nL):
  nodesIds.append( O.bodies.append(
    gridNode([i,0,0],rCyl,wire=False,fixed=False,material='gridNodeMat') ) )

If you change the axis as such:
for i in linspace(0,L,nL):
  nodesIds.append( O.bodies.append(
    gridNode([0,i,0],rCyl,wire=False,fixed=False,material='gridNodeMat') ) )

or:
for i in linspace(0,L,nL):
  nodesIds.append( O.bodies.append(
    gridNode([0,0,i],rCyl,wire=False,fixed=False,material='gridNodeMat') ) )

All middle nodes and the grid connection disappear once you hit play. Is this a bug?

My Complete Code:

from yade import qt
from yade.gridpfacet import *
import numpy as np

qt.View()

### Engines need to be defined first since the function gridConnection creates the interaction
O.engines=[
 ForceResetter(),
 InsertionSortCollider([
  Bo1_Sphere_Aabb(),
  Bo1_GridConnection_Aabb(),
 ]),
 InteractionLoop(
  # Geometric interactions
  [
          Ig2_GridNode_GridNode_GridNodeGeom6D(),
          Ig2_Sphere_GridConnection_ScGridCoGeom(), # used for the cohesive sphere-cylinder interaction
        ],
  [
  # Interaction phusics
          Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False),
        ],
  # Interaction law
  [
          Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),
          Law2_ScGridCoGeom_CohFrictPhys_CundallStrack(), # used for the cohesive sphere-cylinder interaction
        ]
 ),
 NewtonIntegrator(gravity=(0,-9.81,0),damping=0.3,label='newton'),
 PyRunner(command='main()',initRun=1000),
]

O.dt=5e-07

O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='grass')) ## Properties Need to be corrected

blen = 0.21230 ## Length of Ball pit
bhei = .025 ## Height of Ball pit

#rCyl = (0.00635+0.003175)/4 ## Lump with of "grass" on back is 1/4 X 1/8 inch, Note 4 is due to radius times two average of the two.
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]
z_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_z = int(math.floor(blen/z_gap)) ## finding the range for z
cen_z = -(range_z/2)*z_gap ## Allows the "box" of grass to be center in Z
#sys.exit()

for ii in range(0,range_z):
  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 y in np.linspace(0,L,nL):
      nodesIds.append(O.bodies.append(gridNode([cen_x,y,cen_z],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,material='grass'))
  cen_z += z_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 main():
 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

[*]

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Klaus Thoeni (klaus.thoeni) said :
#1

Hi,

your main() function doesn't really make sense. What exactly are you trying to do?

Also, I would recommend you start with one single grass/gridconnection. You might also want to have a look at the scripts in examples/cylinders.

HTH
Klaus

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

"your main() function doesn't really make sense. What exactly are you trying to do?"

I block all DOF's of the nodes in the grid connections at first (outside of the main), while under stuff will be taking place (not in the script above). Then I unblocked all nodes, and re-block the bottom nodes' DOF. Basically, I block all the nodes' DOF for x-amount of iterations, then only have the bottom nodes' DOF block.

"Also, I would recommend you start with one single grass/gridconnection. You might also want to have a look at the scripts in examples/cylinders."

I did at start with one at first and it seems find. I just do not get how some of the nodes/connections stay and others disappear. That makes zero sense to me, because they are created in the same for loops. And why does the example have the same problem when I change axis?

I am recreating using the cylinders, and do not have exactly what I want, but it does appear it will work. But I always get the warning, that I should use Grid Connections and Cylinders will be removed in a later update.

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

Hm, I did some more testing based on the CohesiveCylinderSphere.py script and can confirm the behaviour. In facts the behaviour seems to depend on the number of gridconnections. I think you are right, there might be a bug somewhere. Not sure yet where.

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

Hi Klaus,
Does it mean a regression or the existing examples work as usual?
B

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

Hi Bruno,

yes, regression and existing examples seem to be all fine. Below is the MWE to reproduce the problem based on CohesiveCylinderSphere.py as Justin mentioned. The script works for nL=1-4, but once you set it to 5 you get the indicated problem. I can't debug at the moment so not sure what's going on but definitely smells like a bug to me. However, doesn't seem to be related to the DOFs. I added a little printout file at the end and the State of a GridNode shows some nan after the first step:

{'refOri': Quaternion((1,0,0),0), 'se3': (Vector3(nan,nan,nan), Quaternion((nan,nan,nan),6.283185307179586)), 'isDamped': True, 'refPos': Vector3(0,0,0), 'blockedDOFs': 0, 'angMom': Vector3(0,0,0), 'mass': 0.016964600329384884, 'densityScaling': 1.0, 'vel': Vector3(nan,nan,nan), 'inertia': Vector3(2.442902447431423e-7,2.442902447431423e-7,2.442902447431423e-7), 'angVel': Vector3(nan,nan,nan)}

The same for the other/working direction:

{'refOri': Quaternion((1,0,0),0), 'se3': (Vector3(1.727013593861354e-25,0,0), Quaternion((1,0,0),0)), 'isDamped': True, 'refPos': Vector3(0,0,0), 'blockedDOFs': 0, 'angMom': Vector3(0,0,0), 'mass': 0.016964600329384884, 'densityScaling': 1.0, 'vel': Vector3(3.4540271877227086e-19,0,0), 'inertia': Vector3(2.442902447431423e-7,2.442902447431423e-7,2.442902447431423e-7), 'angVel': Vector3(0,0,0)}

That's how far I cam without properly debugging.

Klaus

MWE:
------------------------------------------------------------

from yade import qt
from yade.gridpfacet import *
from numpy import linspace

qt.View()

### Engines need to be defined first since the function gridConnection creates the interaction
O.engines=[
    ForceResetter(),
    InsertionSortCollider([
        Bo1_Sphere_Aabb(),
        Bo1_GridConnection_Aabb(),
    ]),
    InteractionLoop(
        # Geometric interactions
        [
          Ig2_GridNode_GridNode_GridNodeGeom6D(),
          Ig2_Sphere_GridConnection_ScGridCoGeom(), # used for the cohesive sphere-cylinder interaction
        ],
        [
        # Interaction phusics
          Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False),
        ],
        # Interaction law
        [
          Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),
          Law2_ScGridCoGeom_CohFrictPhys_CundallStrack(), # used for the cohesive sphere-cylinder interaction
        ]
    ),from yade import qt
from yade.gridpfacet import *
from numpy import linspace

qt.View()

### Engines need to be defined first since the function gridConnection creates the interaction
O.engines=[
    ForceResetter(),
    InsertionSortCollider([
        Bo1_Sphere_Aabb(),
        Bo1_GridConnection_Aabb(),
    ]),
    InteractionLoop(
        # Geometric interactions
        [
          Ig2_GridNode_GridNode_GridNodeGeom6D(),
          Ig2_Sphere_GridConnection_ScGridCoGeom(), # used for the cohesive sphere-cylinder interaction
        ],
        [
        # Interaction phusics
          Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False),
        ],
        # Interaction law
        [
          Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),
          Law2_ScGridCoGeom_CohFrictPhys_CundallStrack(), # used for the cohesive sphere-cylinder interaction
        ]
    ),
    NewtonIntegrator(gravity=(0,0,0),damping=0.3,label='newton'),
]

O.dt=5e-07

O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='gridNodeMat'))

O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='gridCoMat'))

rCyl=0.006
nL=5 # <- it seems to be working for 1-4
L=0.3

### Create all nodes first :
nodesIds=[]
for i in linspace(0,L,nL):
  nodesIds.append( O.bodies.append(
    #gridNode([i,0,0],rCyl,color=[1,1,0],wire=False,fixed=False,material='gridNodeMat') ) ) # this works
    gridNode([0,i,0],rCyl,color=[1,1,0],wire=False,fixed=False,material='gridNodeMat') ) ) # <- change of orientation gives problem

### Now create connection between the nodes
for i,j in zip( nodesIds[:-1], nodesIds[1:]):
  O.bodies.append( gridConnection(i,j,rCyl,color=[1,1,0],material='gridCoMat') )

### Set fixed nodes <- does not seem to influence the problem
#O.bodies[nodesIds[0]].state.blockedDOFs='xyzXYZ'
#O.bodies[nodesIds[-1]].state.blockedDOFs='xyzXYZ'

O.saveTmp()

    NewtonIntegrator(gravity=(0,0,0),damping=0.3,label='newton'),
]

O.dt=5e-07

O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='gridNodeMat'))

O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='gridCoMat'))

rCyl=0.006
nL=5 # <- it seems to be working for 1-4
L=0.3

### Create all nodes first :
nodesIds=[]
for i in linspace(0,L,nL):
  nodesIds.append( O.bodies.append(
    #gridNode([i,0,0],rCyl,color=[1,1,0],wire=False,fixed=False,material='gridNodeMat') ) ) # this works
    gridNode([0,i,0],rCyl,color=[1,1,0],wire=False,fixed=False,material='gridNodeMat') ) ) # <- change of orientation gives problem

### Now create connection between the nodes
for i,j in zip( nodesIds[:-1], nodesIds[1:]):
  O.bodies.append( gridConnection(i,j,rCyl,color=[1,1,0],material='gridCoMat') )

### Set fixed nodes
O.bodies[nodesIds[0]].state.blockedDOFs='xyzXYZ'
O.bodies[nodesIds[-1]].state.blockedDOFs='xyzXYZ'

O.saveTmp()

def getInfo():
 #fid = open( 'X_'+str(O.iter)+'.txt', 'w' )
 fid = open( 'Y_'+str(O.iter)+'.txt', 'w' )
 for b in O.bodies:
  fid.write(str(b.id)+"\n")
  fid.write(str(b.dict())+"\n")
  fid.write(str(b.shape.dict())+"\n")
  fid.write(str(b.state.dict())+"\n")
  fid.write("- - - - - - - - - - - - -\n")
 fid.close()

getInfo()

O.step()

getInfo()

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

Here is the list of initial interactions (iteration 0, ),

* for the x-aligned beam:

Yade [1]: for i in O.interactions:
    print i.id1,i.id2,i.phys.normalForce
     ...:
0 1 Vector3(-1.6741768790441432e-14,-0,-0)
1 2 Vector3(-1.6741768790441432e-14,-0,-0)
2 3 Vector3(-1.6741768790441436e-14,-0,-0)
3 4 Vector3(-1.674176879044143e-14,-0,-0)

* for the y-aligned beam:

0 1 Vector3(-0,-1.6741768790441432e-14,-0)
1 2 Vector3(-0,-1.6741768790441432e-14,-0)
2 3 Vector3(-0,-1.6741768790441436e-14,-0)
3 4 Vector3(-0,-1.674176879044143e-14,-0)
8 7 Vector3(nan,nan,nan)
7 6 Vector3(nan,nan,nan)
6 5 Vector3(nan,nan,nan)

The question is, why do we get these additional interactions only in one case... not sure yet.
Nevertheless, adding Ig2_GridConnection_GridConnection_GridCoGridCoGeom() to the functors solve the problem.

Bruno

Can you help with this problem?

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

To post a message you must log in.