Skip to content

Commit 9169d14

Browse files
committed
update to latest contact detection and model
1 parent 7bf371e commit 9169d14

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/compas_dem/analysis/cra.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,25 @@
33
from compas_cra.equilibrium import cra_penalty_solve as _cra_penalty_solve
44
from compas_cra.equilibrium import rbe_solve as _rbe_solve
55

6-
from compas_dem.elements import BlockElement
7-
from compas_dem.interactions import FrictionContact
86
from compas_dem.models import BlockModel
97

108

119
def _blockmodel_to_assembly(model: BlockModel) -> Assembly:
12-
element: BlockElement
1310
element_block: dict[int, int] = {}
1411

1512
assembly = Assembly()
1613

1714
for element in model.elements():
1815
block: Block = element.modelgeometry.copy(cls=Block)
19-
x, y, z = block.centroid()
16+
x, y, z = element.point
2017
node = assembly.add_block(block, x=x, y=y, z=z, is_support=element.is_support)
2118
element_block[element.graphnode] = node
2219

2320
for edge in model.graph.edges():
24-
u = element_block[edge[0]]
21+
u = element_block[edge[0]] # type: ignore
2522
v = element_block[edge[1]]
2623

27-
contacts: list[FrictionContact] = model.graph.edge_attribute(edge, name="contacts")
24+
contacts = model.graph.edge_attribute(edge, name="contacts") # type: ignore
2825
assembly.graph.add_edge(u, v, interfaces=contacts)
2926

3027
return assembly
@@ -60,3 +57,9 @@ def cra_penalty_solve(
6057
verbose=verbose,
6158
timer=timer,
6259
)
60+
for edge in assembly.graph.edges():
61+
interfaces = assembly.graph.edge_attribute(edge, name="interfaces")
62+
contacts = model.graph.edge_attribute(edge, name="contacts")
63+
if interfaces and contacts:
64+
for interface, contact in zip(interfaces, contacts):
65+
contact.forces = interface.forces
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
from .block import BlockMesh
21
from .block import BlockFeature
3-
from .block import BlockElement
2+
from .block import Block
43

54
__all__ = [
6-
"BlockElement",
5+
"Block",
76
"BlockFeature",
8-
"BlockMesh",
97
]

src/compas_dem/viewers/blockmodelviewer.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from compas_viewer.scene import BufferGeometry
77
from compas_viewer.scene import GroupObject
88

9-
from compas_dem.elements import BlockElement
10-
from compas_dem.elements import BlockMesh
9+
from compas_dem.elements import Block
1110
from compas_dem.models import BlockModel
1211

1312

@@ -57,9 +56,9 @@ def __init__(self, blockmodel, **kwargs):
5756

5857
self.model: BlockModel = blockmodel
5958

60-
self.supports: GroupObject = None
61-
self.blocks: GroupObject = None
62-
self.interfaces: GroupObject = None
59+
self.supports = None
60+
self.blocks = None
61+
self.interfaces = None
6362

6463
self.color_block: Color = Color(0.9, 0.9, 0.9)
6564
self.color_support: Color = Color.red().lightened(75)
@@ -126,11 +125,11 @@ def init_blockmodel(self):
126125

127126
def init_blocks(self):
128127
"""Initialise the blocks."""
129-
supports: list[BlockMesh] = []
130-
blocks: list[BlockMesh] = []
128+
supports: list[tuple] = []
129+
blocks: list[tuple] = []
131130

132131
for element in self.model.elements():
133-
element: BlockElement
132+
element: Block
134133
if element.is_support:
135134
supports.append((element.modelgeometry, {"name": f"Support_{len(supports)}"}))
136135
else:

0 commit comments

Comments
 (0)