why my particles don`t show in paraview?

Asked by Mahdeyeh on 2020-11-23

Hello
when I check model in paraview, just I see facets and there aren`t clumps or particles. why?

here is codes:

from yade import export,polyhedra_utils
import os
from yade import plot
import math
from yade import utils
import pylab
import matplotlib; matplotlib.rc('axes',grid=True)
from matplotlib import pyplot
from yade import qt
import numpy as np
from numpy import *
from yade import export as expt

# Materials type:

Dolomite = FrictMat()
Dolomite.density = 2870 #kg/m^3
Dolomite.young = 24.36e9 #Pa
Dolomite.poisson = 0.2
Dolomite.frictionAngle = radians(55.12) #rad

Bound = FrictMat()
Bound.density = 2870 #kg/m^3
Bound.young = 60e10 #Pa
Bound.poisson = 0.2
Bound.frictionAngle = radians(55.12) #rad

Shale = FrictMat()
Shale.density = 2750 #kg/m^3
Shale.young = 6e9 #Pa
Shale.poisson = 0.23
Shale.frictionAngle = radians(42) #rad

#O.materials.append(Dolomite)

SphCordns=np.genfromtxt('ring.txt',names=True,dtype=None)
ListSph=[]
LayNo=SphCordns[0][4]
for b in SphCordns:
    if LayNo!=b[4]:
        LayNo=b[4]
        O.bodies.appendClumped(ListSph)
        ListSph=[]
    ListSph.append(sphere([b[0],b[1],b[2]], radius=b[3], color=(0.1,0.5,0.2),material=Dolomite))

SphCordns=np.genfromtxt('waste.txt',names=True,dtype=None)
ListSph=[]
LayNo=SphCordns[0][4]
for b in SphCordns:
    if LayNo!=b[4]:
        LayNo=b[4]
        O.bodies.appendClumped(ListSph)
        ListSph=[]
    ListSph.append(sphere([b[0],b[1],b[2]], radius=b[3], color=(0.8,0.9,0.9),material=Shale))

v1=((-2.4993,-0.01,2),(-2,-0.01,2),(-2.4993,-0.01,-2))
v2=((-2,-0.01,2),(-2,-0.01,-2),(-2.4993,-0.01,-2))
v3=((-1.99,-0.01,2),(-1.99,-0.01,-2),(-1,-0.01,2))
v4=((-1,-0.01,2),(-1,-0.01,-2),(-1.99,-0.01,-2))
v5=((-0.99,-0.01,2),(-0.99,-0.01,-2),(1,-0.01,2))
v6=((1,-0.01,2),(1,-0.01,-2),(-0.99,-0.01,-2))
v7=((1.01,-0.01,2),(1.01,-0.01,-2),(2,-0.01,2))
v8=((2,-0.01,2),(2,-0.01,-2),(1.01,-0.01,-2))
v9=((2.01,-0.01,2),(2.01,-0.01,-2),(3,-0.01,2))
v10=((3,-0.01,2),(3,-0.01,-2),(2.01,-0.01,-2))
v11=((3.01,-0.01,2),(3.01,-0.01,-2),(4.58,-0.01,2))
v12=((4.58,-0.01,2),(4.58,-0.01,-2),(3.01,-0.01,-2))
v13=((4.7,0.0059,2),(5.3,0.93,2),(4.7,0.0059,-2))
v14=((5.3,0.93,2),(5.3,0.93,-2),(4.7,0.0059,-2))
v15=((5.3,0.94,2),(5.3,0.94,-2),(6.47,2.57,2))
v16=((6.47,2.57,2),(6.47,2.57,-2),(5.3,0.94,-2))
v17=((6.47,2.58,2),(6.47,2.58,-2),(6.85,3.01,2))
v18=((6.85,3.01,2),(6.85,3.01,-2),(6.47,2.58,-2))
v19=((6.85,3.0162,2),(6.851,4,2),(6.85,3.0162,-2))
v20=((6.85,3.0162,-2),(6.851,4,-2),(6.851,4,2))
v21=((6.851,4.0079,2),(7.08,5.6,2),(6.851,4.0079,-2))
v22=((7.08,5.6,2),(7.08,5.6,-2),(6.851,4.0079,-2))
v23=((7.08,5.61,2),(7.08,5.61,-2),(7.35,7.01,2))
v24=((7.35,7.01,2),(7.35,7.01,-2),(7.08,5.61,-2))
v25=((7.35,7.02,2),(7.35,7.02,-2),(7.59,8.51,2))
v26=((7.59,8.51,2),(7.59,8.51,-2),(7.35,7.02,-2))
v27=((7.59,8.52,2),(7.59,8.52,-2),(7.85,10,2))
v28=((7.85,10,2),(7.85,10,-2),(7.59,8.52,-2))
v29=((7.85,10.01,2),(7.85,10.01,-2),(8.19,12,2))
v30=((8.19,12,2),(8.19,12,-2),(7.85,10.01,-2))
v31=((8.19,12.01,2),(8.19,12.01,-2),(8.55,14,2))
v32=((8.55,14,2),(8.55,14,-2),(8.19,12,-2))
v33=((8.55,14.01,2),(8.55,14.01,-2),(8.8,15.5,2))
v34=((8.8,15.5,2),(8.8,15.5,-2),(8.55,14.01,-2))
v35=((8.8,15.51,2),(8.8,15.51,-2),(9.1,16.9981,2))
v36=((9.1,16.9981,2),(9.1,16.9981,-2),(8.8,15.51,-2))
v37=((9.1,17.0187,2),(9.15,19,2),(9.1,17.087,-2))
v38=((9.15,19,2),(9.15,19,-2),(9.1,17.0187,-2))
v39=((9.15,19.01,2),(9.15,19.01,-2),(9.25,20.9992,2))
v40=((9.25,20.9992,2),(9.25,20.9992,-2),(9.15,19.01,-2))
v41=((9.29,21.1,2),(9.29,21.1,-2),(9.38,22.7,2))
v42=((9.38,22.7,2),(9.38,22.7,-2),(9.29,21.1,-2))
v43=((9.38,22.73,2),(9.38,22.73,-2),(9.40,25.3,2))
v44=((9.4,25.3,2),(9.4,25.3,-2),(9.38,22.73,-2))
v45=((5.45,25.3,2),(5.45,25.3,-2),(5.32,22.5,2))
v46=((5.32,22.5,2),(5.32,22.5,-2),(5.45,25.3,-2))
v47=((5.32,22.4,2),(5.32,22.4,-2),(5.32,20,2))
v48=((5.32,20,2),(5.32,20,-2),(5.32,22.4,-2))
v49=((5.32,19.96,2),(5.32,19.96,-2),(5.82,19.96,2))
v50=((5.82,19.96,2),(5.82,19.96,-2),(5.32,19.96,-2))
v51=((5.82,19.94,2),(5.82,19.94,-2),(5.57,18.5,2))
v52=((5.57,18.5,2),(5.57,18.5,-2),(5.82,19.94,-2))
v53=((5.53,18.45,2),(5.53,18.45,-2),(5.3,17.2,2))
v54=((5.3,17.2,2),(5.3,17.2,-2),(5.53,18.45,-2))
v55=((5.3,17.15,2),(5.3,17.15,-2),(5.1,16,2))
v56=((5.1,16,2),(5.1,16,-2),(5.3,17.15,-2))
v57=((5.1,15.98,2),(5.1,15.98,-2),(4.88,15,2))
v58=((4.88,15,2),(4.88,15,-2),(5.1,15.98,-2))
v59=((4.9,14.98,2),(4.9,14.98,-2),(4.77,14.3,2))
v60=((4.77,14.3,2),(4.77,14.3,-2),(4.9,14.98,-2))
v61=((4.77,14.27,2),(4.77,14.27,-2),(4.64,13.5,2))
v62=((4.64,13.5,2),(4.64,13.5,-2),(4.77,14.27,-2))
v63=((4.64,13.47,2),(4.64,13.47,-2),(4.54,13,2))
v64=((4.54,13,2),(4.54,13,-2),(4.64,13.47,-2))
v65=((4.54,12.98,2),(4.54,12.98,-2),(4.39,12.2,2))
v66=((4.39,12.2,2),(4.39,12.2,-2),(4.54,12.98,-2))
v67=((4.39,12.18,2),(4.39,12.18,-2),(4.24,11.4,2))
v68=((4.24,11.4,2),(4.24,11.4,-2),(4.39,12.18,-2))
v69=((4.24,11.38,2),(4.24,11.38,-2),(4.1,10.55,2))
v70=((4.1,10.55,2),(4.1,10.55,-2),(4.24,11.38,-2))
v71=((4.1,10.53,2),(4.1,10.53,-2),(4,9.97,2))
v72=((4,9.97,2),(4,9.97,-2),(4.1,10.53,-2))
v73=((4,9.94,2),(4,9.94,-2),(3.87,9,2))
v74=((3.87,9,2),(3.87,9,-2),(4,9.94,-2))
v75=((3.87,8.99,2),(3.87,8.99,-2),(3.69,8,2))
v76=((3.69,8,2),(3.69,8,-2),(3.87,8.99,-2))
v77=((3.69,7.99,2),(3.69,7.99,-2),(3.51,7,2))
v78=((3.51,7,2),(3.51,7,-2),(3.69,7.99,-2))
v79=((3.51,6.99,2),(3.51,6.99,-2),(3.34,5.99,2))
v80=((3.34,5.99,2),(3.34,5.99,-2),(3.51,6.99,-2))
v81=((3.34,5.98,2),(3.34,5.98,-2),(3.16,4.98,2))
v82=((3.16,4.98,2),(3.16,4.98,-2),(3.34,5.98,-2))
v83=((3.16,4.97,2),(3.16,4.97,-2),(2.95,4.0001,2))
v84=((2.95,4.0001,2),(2.95,4.0001,-2),(3.16,4.97,-2))
v85=((0,4,2),(0,4,-2),(2.9,3.9,2))
v86=((0,4,-2),(2.9,3.9,2),(2.9,3.9,-2))

O.bodies.append(utils.facet(v1,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v2,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v3,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v4,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v5,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v6,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v7,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v8,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v9,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v10,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v11,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v12,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v13,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v14,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v15,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v16,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v17,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v18,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v19,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v20,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v21,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v22,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v23,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v24,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v25,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v26,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v27,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v28,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v29,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v30,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v31,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v32,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v33,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v34,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v35,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v36,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v37,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v38,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v39,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v40,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v41,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v42,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v43,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v44,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v45,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v46,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v47,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v48,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v49,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v50,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v51,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v52,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v53,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v54,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v55,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v56,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v57,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v58,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v59,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v60,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v61,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v62,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v63,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v64,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v65,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v66,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v67,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v68,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v69,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v70,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v71,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v72,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v73,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v74,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v75,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v76,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v77,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v78,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v79,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v80,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v81,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v82,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v83,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v84,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v85,color=(1,0,1), material=Bound))
O.bodies.append(utils.facet(v86,color=(1,0,1), material=Bound))

for b in O.bodies:
    if b.material is Dolomite or b.material is Shale:
        b.state.blockedDOFs='zXY'
        b.state.angMom[2]=0
        b.state.angVel[2]=0
        b.state.vel[2]=0

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()],verletDist=0.001),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_ScGeom_FrictPhys_CundallStrack()]
   ),
   NewtonIntegrator(gravity=(0,-9.81,0),damping=0.2),
]

utils.calm()
O.dt=10e-6
O.run(1000,True)
O.run()

os.mkdir(O.tags['id'])
O.engines=O.engines+[PyRunner(iterPeriod=10000,command='VTKview()',label="VTKview")]
ClumpVtkData = expt.VTKExporter(O.tags['id']+'/'+'clumpData')
def VTKview():
    ClumpVtkData.exportSpheres(ids='all', what={('color','b.shape.color')})
    ClumpVtkData.exportFacets(ids='all', what={('color','b.shape.color')})

thanks a lot

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2020-12-05
Last query:
2020-12-05
Last reply:
2020-12-03
Robert Caulk (rcaulk) said : #1

Can you please provide an MWE [1] that doesn't involve unnecessary code.

[1]https://www.yade-dem.org/wiki/Howtoask

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

Hello,

> when I check model in paraview

please be more specific and describe the steps you are using for "checking". As it is, we can merely guess where the problem could be..
Are you aware of [1]?

cheers
Jan

[1] https://yade-dem.org/doc/user.html#rendering-spherical-particles-glyphs

Mahdeyeh (mahdiye.sky) said : #3

Hi
these codes are for saving data in file which can be opened with Paraview:

os.mkdir(O.tags['id'])
O.engines=O.engines+[PyRunner(iterPeriod=10000,command='VTKview()',label="VTKview")]
ClumpVtkData = expt.VTKExporter(O.tags['id']+'/'+'clumpData')
def VTKview():
    ClumpVtkData.exportSpheres(ids='all', what={('color','b.shape.color')})
    ClumpVtkData.exportFacets(ids='all', what={('color','b.shape.color')})

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

Hello,

> when I check model in paraview

please be more specific and describe the steps (IN PARAVIEW) you are using for "checking". As it is, we can merely guess where the problem could be..
Are you aware of [1]?

cheers
Jan

[1] https://yade-dem.org/doc/user.html#rendering-spherical-particles-glyphs

Mahdeyeh (mahdiye.sky) said : #5

Sorry for the delay in reply.

Thank you Jan Stránský , with your link about "Rendering spherical particles. Glyphs" I can see spherical particles in paraview by these command:
"Spheres will only appear as points. To make them look as spheres, you have to add “glyph” to the p1-spheres.* item in the pipeline using the paraview-glyph-icon icon. Then set (in the Object inspector)

    “Glyph type” to Sphere
    “Radius” to 1
    “Scale mode” to Scalar (Scalar is set above to be the radii value saved in the file, therefore spheres with radius 1 will be scaled by their true radius)
    “Set scale factor” to 1
    optionally uncheck “Mask points” and “Random mode” (they make some particles not to be rendered for performance reasons, controlled by the “Maximum Number of Points”)

After clicking “Apply”, spheres will appear. They will be rendered over the original white points, which you can disable by clicking on the eye icon next to p1-spheres.* in the Pipeline browser."

But in the Object inspector there is not any icon for setting “Radius” to 1 ! If I do all steps except setting "“Radius” to 1", could see spherical particles but they do not show in real radius as be in my main code.

What should I do to see spheres in Paraview exactly with true radius in Yade?

Thank you a lot

Mahdeyeh (mahdiye.sky) said : #6

my Paraview is :

5.4.1 64-bit

Mahdeyeh (mahdiye.sky) said : #7

1- shall I set Glyph mode to All points (in Masking) for seeing spheres in Paraview exactly with true radius in Yade?
I did this and I think, worked!!

2- In Yade, my sphere particles are in two colour which I can distinguish them, so in Paraview for having two colour for them: should I set coloring to Glyphvector (in Display (Geom))?

Thank you

Best Jan Stránský (honzik) said : #8

> But in the Object inspector there is not any icon for setting “Radius” to 1

when you choose "GlyhpType" to "Sphere", just two lines below there is "Radius". Set it to 1 and then
somewhat below there is "Scaling" section, set "Scale Mode" to "scalar" and "Scale Factor" to 1

> but they do not show in real radius as be in my main code.

how do you know?

> shall I set Glyph mode to All points (in Masking) for seeing spheres in Paraview exactly with true radius in Yade?

"All points" just displays all points (paraview has some default limit on amount on shown particles).
It has NO influence on radius

> In Yade, my sphere particles are in two colour which I can distinguish them, so in Paraview for having two colour for them: should I set coloring to Glyphvector (in Display (Geom))?

if you use color just to distinguish two (or a few) "types" of particles, I suggest not to export color itself, but rather some "id", something like:
###
def color2scalar(color):
    if color == (1,0,0): return 1 # red
    if color == (0,0,1): return 2 # blue
    return 0 # or raise error
...exportSpheres(..., what={('color','color2scalar(b.shape.color)')})
###
then in paraview you can easily color it by the color scalar

cheers
Jan

Mahdeyeh (mahdiye.sky) said : #9

Thanks Jan Stránský, that solved my question.