# How to make each polyhedron break only once?

Dear all,

In the example, there are three identical polyhedrons with different strengths, and the polyhedrons broke at different times under the compression of the wall. I want each polyhedron to break only once, and the broken fragments will not break under the continuous compression of the wall. I wonder what I should do?

Jie

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
 Revision history for this message  Jan Stránský (honzik) said on 2021-08-09: #1

Hello,

one option: before the splitter, check and change material to a non-breakable one for the polyhedrons that are not "original"

###
# -*- encoding=utf-8 -*-
# This script demonstrates polyhedra splitting/crushing under compression.

gravel1 = PolyhedraMat()
gravel1.IsSplitable = True
gravel1.strength = 1e0
gravel2 = PolyhedraMat()
gravel2.IsSplitable = True
gravel2.strength = 2e0
gravel3 = PolyhedraMat()
gravel3.IsSplitable = True
gravel3.strength = 4e0

# new non splitable material
nonSplitableMat = PolyhedraMat()
#nonSplitableMat.IsSplitable = False # False is default?

steel = PolyhedraMat()
steel.young = 1e10

d = .05
p1 = polyhedra_utils.polyhedra(gravel1, size=(d,d,d), seed=1)
p2 = polyhedra_utils.polyhedra(gravel2, size=(d,d,d), seed=1)
p3 = polyhedra_utils.polyhedra(gravel3, size=(d,d,d), seed=1)
p2.state.pos = (2*d,0,0)
p3.state.pos = (4*d,0,0)
p2.state.ori = p3.state.ori = p1.state.ori

d = .035
w1 = utils.wall(+d, axis=1, sense=-1, material=steel)
w2 = utils.wall(-d, axis=1, sense=+1, material=steel)
v = 5e-1
w1.state.vel = (0,-v,0)
w2.state.vel = (0,+v,0)
O.bodies.append((p1,p2,p3,w1,w2))

# IDs of original bodies
originalIds = set(b.id for b in O.bodies)
def changeMaterial():
for b in O.bodies:
if not isinstance(b.shape,Polyhedra): # only polyhedrons
continue
if b.id not in originalIds: # only non-original polyhedrons
b.mat = nonSplitableMat # set the non splitable material

O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Polyhedra_Aabb(),Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Wall_Polyhedra_PolyhedraGeom(), Ig2_Polyhedra_Polyhedra_PolyhedraGeom()],
[Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys()],
[Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()]
),
NewtonIntegrator(),
# check / change material before splitting
PyRunner(iterPeriod=100,command="changeMaterial()"),
PolyhedraSplitter(iterPeriod=100),
]

O.dt=1e-6

try:
qt.Controller()
v = qt.View()
v.ortho = True
except:
pass

O.run(30000)
###

Cheers
Jan

 Revision history for this message weijie (amandajoe) said on 2021-08-09: #2

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