Visitor
Base class for visitors propagated recursively through the scenegraph
`Visitor` facilitates recursive traversal through the SOFA scenegraph, enabling operations such as node processing and object management.
- module
- Sofa.framework.Simulation.Core
- namespace
- sofa::simulation
- include
- sofa/simulation/Visitor.h
- description
The Visitor class in the SOFA framework is not directly involved with the mathematical or physical models used for simulating deformable systems. Instead, it serves as a foundational mechanism to propagate behaviors and operations throughout the scene graph hierarchy. This class does not contribute any specific governing equations, constitutive laws, or discretization methods on its own but rather provides the infrastructure through which these aspects can be applied consistently across the simulation environment.
-
Assembly Phase: The klzzwxh:0007 class facilitates the traversal of the scene graph to assemble contributions from various mechanical objects and components. It enables the execution of tasks that might involve assembling global matrices (like mass, stiffness) or computing internal forces.
-
Time Integration: While not directly involved in time integration methods like implicit Euler or Newmark schemes,
Visitorcan be used to execute custom logic that may influence how these steps are carried out. For example, operations performed during the traversal might affect state variables (positions, velocities) before and after each time step. -
Nonlinear Solution: During nonlinear solution phases, visitors can help manage complex interactions by applying constraints or projecting forces between different components of the scene graph.
Numerical Methods:
The Visitor class itself does not implement any specific numerical methods. However, it enables the use of such methods through its traversal mechanisms. For instance, operations like matrix assembly or force computation can be applied consistently across nodes and objects during a visitation process.
Constraint Handling:
While not directly managing constraints, visitors can be used to apply constraint-related logic during their traversal. Methods like begin and end, along with optional debugging methods (debug_write_state_before, debug_write_state_after), allow for the tracking of state changes that might include enforcing constraints.
Mapping:
The visitor mechanism does not directly handle mappings, but it can be used to apply logic related to mappings during traversal. For example, visitors can manage operations involving multi-resolution coupling or force consistency through various components in the scene graph.
Variational / Lagrangian Mechanics Framework:
The Visitor class supports the variational and Lagrangian mechanics framework by providing a means to consistently apply operations that contribute to the overall simulation. It ensures that all relevant nodes and objects are processed correctly, supporting the consistent application of physical laws and numerical methods throughout the scene graph.
Summary:
The Visitor is primarily an infrastructure component in SOFA, designed to enable recursive traversal of the scenegraph for applying various operations uniformly across different components. It does not directly contribute any mathematical or physical content but provides a robust framework within which these aspects can be effectively managed and applied.
Methods
const sofa::core::ExecParams *
execParams
()
Result
processNodeTopDown
(simulation::Node * )
virtual
void
processNodeBottomUp
(simulation::Node * )
virtual
bool
childOrderReversed
(simulation::Node * )
virtual
bool
treeTraversal
(TreeTraversalRepetition & repeat)
virtual
const char *
getCategoryName
()
virtual
int
getInfos
()
void
debug_write_state_before
(sofa::core::objectmodel::BaseObject * obj)
void
debug_write_state_after
(sofa::core::objectmodel::BaseObject * obj)
void
runVisitorTask
(VisitorType * visitor, VContext * ctx, void (VisitorType::*)(VContext *, ObjectType *) task, ObjectType * ptr, const int & typeInfo)
Result
runVisitorTask
(VisitorType * visitor, VContext * ctx, Result (VisitorType::*)(VContext *, ObjectType *) task, ObjectType * ptr, const int & typeInfo)
void
for_each
(Visit * visitor, VContext * ctx, const Container & list, void (Visit::*)(VContext *, PointedType *) task, const int & typeInfo)
Visitor::Result
for_each
(Visit * visitor, VContext * ctx, const Container & list, Visitor::Result (Visit::*)(VContext *, PointedType *) task, const int & typeInfo)
bool
testTags
(sofa::core::objectmodel::BaseObject * obj)
void
execute
(sofa::core::objectmodel::BaseContext * node, bool precomputedOrder)
virtual
ctime_t
begin
(simulation::Node * node, sofa::core::objectmodel::BaseObject * obj, const int & typeInfo)
virtual
void
end
(simulation::Node * node, sofa::core::objectmodel::BaseObject * obj, ctime_t t0)
virtual
ctime_t
begin
(simulation::Visitor::VisitorContext * node, sofa::core::objectmodel::BaseObject * obj, const int & typeInfo)
virtual
void
end
(simulation::Visitor::VisitorContext * node, sofa::core::objectmodel::BaseObject * obj, ctime_t t0)
virtual
bool
isThreadSafe
()
virtual
Visitor &
setTags
(const TagSet & t)
Visitor &
addTag
(Tag t)
Visitor &
removeTag
(Tag t)
{
"name": "Visitor",
"namespace": "sofa::simulation",
"module": "Sofa.framework.Simulation.Core",
"include": "sofa/simulation/Visitor.h",
"doc": "Base class for visitors propagated recursively through the scenegraph",
"inherits": [],
"templates": [],
"data_fields": [],
"links": [],
"methods": [
{
"name": "execParams",
"return_type": "const sofa::core::ExecParams *",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "processNodeTopDown",
"return_type": "Result",
"params": [
{
"name": "",
"type": "simulation::Node *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "processNodeBottomUp",
"return_type": "void",
"params": [
{
"name": "",
"type": "simulation::Node *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "childOrderReversed",
"return_type": "bool",
"params": [
{
"name": "",
"type": "simulation::Node *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "treeTraversal",
"return_type": "bool",
"params": [
{
"name": "repeat",
"type": "TreeTraversalRepetition &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getCategoryName",
"return_type": "const char *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getInfos",
"return_type": "int",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "debug_write_state_before",
"return_type": "void",
"params": [
{
"name": "obj",
"type": "sofa::core::objectmodel::BaseObject *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "debug_write_state_after",
"return_type": "void",
"params": [
{
"name": "obj",
"type": "sofa::core::objectmodel::BaseObject *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "runVisitorTask",
"return_type": "void",
"params": [
{
"name": "visitor",
"type": "VisitorType *"
},
{
"name": "ctx",
"type": "VContext *"
},
{
"name": "task",
"type": "void (VisitorType::*)(VContext *, ObjectType *)"
},
{
"name": "ptr",
"type": "ObjectType *"
},
{
"name": "typeInfo",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "runVisitorTask",
"return_type": "Result",
"params": [
{
"name": "visitor",
"type": "VisitorType *"
},
{
"name": "ctx",
"type": "VContext *"
},
{
"name": "task",
"type": "Result (VisitorType::*)(VContext *, ObjectType *)"
},
{
"name": "ptr",
"type": "ObjectType *"
},
{
"name": "typeInfo",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "for_each",
"return_type": "void",
"params": [
{
"name": "visitor",
"type": "Visit *"
},
{
"name": "ctx",
"type": "VContext *"
},
{
"name": "list",
"type": "const Container &"
},
{
"name": "task",
"type": "void (Visit::*)(VContext *, PointedType *)"
},
{
"name": "typeInfo",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "for_each",
"return_type": "Visitor::Result",
"params": [
{
"name": "visitor",
"type": "Visit *"
},
{
"name": "ctx",
"type": "VContext *"
},
{
"name": "list",
"type": "const Container &"
},
{
"name": "task",
"type": "Visitor::Result (Visit::*)(VContext *, PointedType *)"
},
{
"name": "typeInfo",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "testTags",
"return_type": "bool",
"params": [
{
"name": "obj",
"type": "sofa::core::objectmodel::BaseObject *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "execute",
"return_type": "void",
"params": [
{
"name": "node",
"type": "sofa::core::objectmodel::BaseContext *"
},
{
"name": "precomputedOrder",
"type": "bool"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "begin",
"return_type": "ctime_t",
"params": [
{
"name": "node",
"type": "simulation::Node *"
},
{
"name": "obj",
"type": "sofa::core::objectmodel::BaseObject *"
},
{
"name": "typeInfo",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "end",
"return_type": "void",
"params": [
{
"name": "node",
"type": "simulation::Node *"
},
{
"name": "obj",
"type": "sofa::core::objectmodel::BaseObject *"
},
{
"name": "t0",
"type": "ctime_t"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "begin",
"return_type": "ctime_t",
"params": [
{
"name": "node",
"type": "simulation::Visitor::VisitorContext *"
},
{
"name": "obj",
"type": "sofa::core::objectmodel::BaseObject *"
},
{
"name": "typeInfo",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "end",
"return_type": "void",
"params": [
{
"name": "node",
"type": "simulation::Visitor::VisitorContext *"
},
{
"name": "obj",
"type": "sofa::core::objectmodel::BaseObject *"
},
{
"name": "t0",
"type": "ctime_t"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "isThreadSafe",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setTags",
"return_type": "Visitor &",
"params": [
{
"name": "t",
"type": "const TagSet &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addTag",
"return_type": "Visitor &",
"params": [
{
"name": "t",
"type": "Tag"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "removeTag",
"return_type": "Visitor &",
"params": [
{
"name": "t",
"type": "Tag"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The `Visitor` class in the SOFA framework serves as a base for visitors that propagate recursively through the scenegraph, facilitating operations on nodes and objects within the simulation environment. It provides methods to handle node traversal and object processing, enabling custom behaviors during the visitation process.\n\n**Interactions with Other Components:**\n- `Visitor` interacts with `Node`, where it can perform callbacks (`processNodeTopDown`, `processNodeBottomUp`) as it traverses down or up through the scenegraph hierarchy.\n- It interfaces with `BaseContext`, allowing execution and management of tasks on objects within a simulation context.\n- The visitor can also manage tags associated with objects using methods like `testTags` to filter operations based on object properties.\n\n**Practical Usage Guidance:**\n- Developers should inherit from the `Visitor` class to implement specific behaviors, overriding virtual methods such as `processNodeTopDown`, `processNodeBottomUp`, and `execute` for custom processing logic.\n- Methods like `begin` and `end` provide hooks to log or debug state changes before and after visiting an object.\n- The use of tags (`addTag`, `removeTag`) allows selective operations on objects matching specific criteria.\n\n**Data Fields:**\n- `subsetsToManage`: A set of tags that the visitor uses to filter which objects it should operate on. This field helps in managing subsets of nodes or objects during a visitation process.",
"maths": "The `Visitor` class in the SOFA framework is not directly involved with the mathematical or physical models used for simulating deformable systems. Instead, it serves as a foundational mechanism to propagate behaviors and operations throughout the scene graph hierarchy. This class does not contribute any specific governing equations, constitutive laws, or discretization methods on its own but rather provides the infrastructure through which these aspects can be applied consistently across the simulation environment.\n\n### Role in the Global FEM Pipeline:\n\n- **Assembly Phase**: The `Visitor` class facilitates the traversal of the scene graph to assemble contributions from various mechanical objects and components. It enables the execution of tasks that might involve assembling global matrices (like mass, stiffness) or computing internal forces.\n\n- **Time Integration**: While not directly involved in time integration methods like implicit Euler or Newmark schemes, `Visitor` can be used to execute custom logic that may influence how these steps are carried out. For example, operations performed during the traversal might affect state variables (positions, velocities) before and after each time step.\n\n- **Nonlinear Solution**: During nonlinear solution phases, visitors can help manage complex interactions by applying constraints or projecting forces between different components of the scene graph.\n\n### Numerical Methods:\n\nThe `Visitor` class itself does not implement any specific numerical methods. However, it enables the use of such methods through its traversal mechanisms. For instance, operations like matrix assembly or force computation can be applied consistently across nodes and objects during a visitation process.\n\n### Constraint Handling:\n\nWhile not directly managing constraints, visitors can be used to apply constraint-related logic during their traversal. Methods like `begin` and `end`, along with optional debugging methods (`debug_write_state_before`, `debug_write_state_after`), allow for the tracking of state changes that might include enforcing constraints.\n\n### Mapping:\n\nThe visitor mechanism does not directly handle mappings, but it can be used to apply logic related to mappings during traversal. For example, visitors can manage operations involving multi-resolution coupling or force consistency through various components in the scene graph.\n\n### Variational / Lagrangian Mechanics Framework:\n\nThe `Visitor` class supports the variational and Lagrangian mechanics framework by providing a means to consistently apply operations that contribute to the overall simulation. It ensures that all relevant nodes and objects are processed correctly, supporting the consistent application of physical laws and numerical methods throughout the scene graph.\n\n### Summary:\n\nThe `Visitor` is primarily an infrastructure component in SOFA, designed to enable recursive traversal of the scenegraph for applying various operations uniformly across different components. It does not directly contribute any mathematical or physical content but provides a robust framework within which these aspects can be effectively managed and applied.",
"abstract": "`Visitor` facilitates recursive traversal through the SOFA scenegraph, enabling operations such as node processing and object management.",
"sheet": "# Visitor\n\n## Overview\nThe `Visitor` class serves as a base for visitors that propagate recursively through the scenegraph in the SOFA framework. It provides methods to handle node traversal and object processing, facilitating custom behaviors during visitation processes.\n\n## Dependencies and Connections\n- **Node**: The visitor interacts with nodes using callbacks such as `processNodeTopDown` and `processNodeBottomUp`, enabling operations on nodes and objects within the scenegraph hierarchy.\n- **BaseContext**: This component allows execution and management of tasks on objects within a simulation context, providing hooks for custom logic during visitation processes."
}