Commit 8224b9c
[Simulation] Mapping graph visitors (#6087)
* start implementation of mapping graph visitor
* continue
* implement interface of MappingGraph
* start replacement
* remove template
* continue replacement
* try to fix on non-Windows
* fix getBottomUpMappingsFrom
* documentation
* remove debug log
* factorization
* know if a node is mapped
* Enhance graph traversal with scoped visitation
Adds support for targeted node traversal in `MappingGraph::traverseTopDown` using defined scopes:
* `ONLY_MAPPED_NODES`: Visits only components involved in mappings.
* `ONLY_MAIN_NODES`: Visits component groups that do not rely on external mapping inputs.
This change updates the API to provide fine-grained control over which nodes are processed during traversal, and includes new tests validating these scoped behaviors.
* feat(core): Support scoped visitation in bottom-up mapping graph traversal
Updates `MappingGraph::traverseBottomUp` to accept a `VisitorApplication` scope, ensuring consistent node filtering logic with top-down traversal.
This allows targeted processing of nodes (e.g., only mapped or main nodes) when traversing dependencies from the bottom up. Tests are updated to validate scoped bottom-up behavior.
* Cache mapped status using optional type
Updates `BaseMappingGraphNode::isMapped()` to use `std::optional<bool>` for managing and lazily computing the node's mapped status, improving efficiency of repeated checks.
* Add scoped visitation to component group traversal
Updates `MappingGraph::traverseComponentGroups` to accept a scope parameter, allowing controlled filtering and processing of component groups during graph traversal.
* Refactor: Prefix names with component type in graph traversal tests
Updates `MappingGraph2_test` to prepend descriptive prefixes (e.g., `[STATE]`, `[MAPPING]`) to node names visited during traversals, ensuring clear identification of the component type for accurate testing results.
* Move classes in their own file
* Add callable visitor support for graph traversal
Implements overloads for `traverseTopDown_` and `traverseBottomUp_` in `MappingGraph`, allowing users to pass a callable object or lambda directly.
This approach simplifies graph traversal by leveraging the new `CallableVisitor` pattern, which automatically handles invoking the provided logic against visited components. Tests are updated to validate lambda usage during complex graph traversals.
* Add clear functionality to MappingGraph
Introduces a `clear()` method for `MappingGraph` to reset the entire graph state. This function ensures that all internal members, such as root node pointers, build flags, mapping status tracking, and associated data containers, are properly initialized back to their default empty state.
* Add callable visitor support for component group traversal
Introduces `traverseComponentGroups_` in `MappingGraph`, allowing users to pass a callable object or lambda directly for graph component group traversal. This standardizes the usage of callable visitors across all major graph traversal methods, improving API consistency and reducing boilerplate code.
* use MappingGraph in EulerExplicitSolver
* use MappingGraph to know if all masses are diagonal
* implement computeForce using mapping graph
* use iterators for reverse traversal because clang on CI does not support views
* Encapsulate graph traversal logic into MappingGraphAlgorithms
Extracts all core graph traversal methods (Top-Down, Bottom-Up, component group traversals) from `MappingGraph` and moves their implementation to a dedicated `MappingGraphAlgorithms` class. This improves modularity by separating the algorithm details from the main graph structure API.
Updates headers and tests to utilize the new `algorithms` member struct for all traversal calls.
* documentation
* Enhance graph traversal with parallel execution support
Adds an overloaded `traverse` method to `MappingGraphAlgorithms`. This overload allows the graph traversal process to utilize a `TaskScheduler`, executing node visits concurrently for improved performance when processing large graphs on multi-threaded environments. It falls back to synchronous traversal if no scheduler is provided.
* start test with interaction force field
* more details
* more helper functions
* export mapping graph as DOT format
* prevent data races in component groups
* fix
* compute force using mapping graph
* implement addMBKv
* Refactor graph accessors using getters
Replaces direct member variable access for internal graph structures (e.g., `m_allNodes`, `m_children`) with public accessor methods like `getAllNodes()` and `getChildren()`.
* Refactors ODESolvers and core simulation logic to utilize `MappingGraphMechanicalOperations`
* fix wrong comparison
* support visits of projective constraint nodes
* implement projectResponse in MappingGraphMechanicalOperations
---------
Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
Co-authored-by: Paul Baksic <30337881+bakpaul@users.noreply.github.com>1 parent 8da6f85 commit 8224b9c
25 files changed
Lines changed: 2281 additions & 491 deletions
File tree
- Sofa
- Component
- LinearSystem/src/sofa/component/linearsystem
- ODESolver
- Backward/src/sofa/component/odesolver/backward
- Forward/src/sofa/component/odesolver/forward
- framework/Simulation/Core
- src/sofa/simulation
- mappinggraph
- test
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
| 205 | + | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| |||
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
89 | | - | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | | - | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
| |||
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
150 | | - | |
| 152 | + | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
| |||
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
160 | | - | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
Lines changed: 29 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
| |||
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
| 67 | + | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
| 270 | + | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
| 280 | + | |
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
| 312 | + | |
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
| 320 | + | |
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 345 | + | |
388 | 346 | | |
389 | | - | |
390 | | - | |
| 347 | + | |
391 | 348 | | |
392 | 349 | | |
393 | 350 | | |
| |||
397 | 354 | | |
398 | 355 | | |
399 | 356 | | |
400 | | - | |
401 | | - | |
402 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
403 | 364 | | |
| 365 | + | |
404 | 366 | | |
405 | 367 | | |
406 | | - | |
407 | | - | |
408 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
409 | 374 | | |
410 | 375 | | |
411 | 376 | | |
Lines changed: 13 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | | - | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | | - | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | | - | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
| 120 | + | |
120 | 121 | | |
121 | | - | |
| 122 | + | |
122 | 123 | | |
123 | | - | |
| 124 | + | |
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
127 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
79 | 89 | | |
80 | 90 | | |
81 | 91 | | |
| |||
169 | 179 | | |
170 | 180 | | |
171 | 181 | | |
| 182 | + | |
172 | 183 | | |
173 | 184 | | |
174 | 185 | | |
| |||
213 | 224 | | |
214 | 225 | | |
215 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
216 | 232 | | |
217 | 233 | | |
218 | 234 | | |
| |||
0 commit comments