Back

MechanicalVNormVisitor

sofa::simulation::mechanicalvisitor::MechanicalVNormVisitor
BaseMechanicalVisitor
Doc (from source)

Compute the norm of a vector. The type of norm is set by parameter @a l. Use 0 for the infinite norm. Note that the 2-norm is more efficiently computed using the square root of the dot product. @author Francois Faure, 2013

Abstract (AI generated)

The `MechanicalVNormVisitor` computes vector norms in mechanical states, supporting various types of norms specified by a parameter.

Metadata
module
Sofa.framework.Simulation.Core
namespace
sofa::simulation::mechanicalvisitor
include
sofa/simulation/mechanicalvisitor/MechanicalVNormVisitor.h
inherits
  • BaseMechanicalVisitor
description

The MechanicalVNormVisitor is designed to compute the norm of a vector, which can be interpreted in various contexts within the Finite Element Method (FEM) and broader computational mechanics framework. Specifically, this visitor handles different types of norms, as defined by the parameter $ l > 0 $, and computes them efficiently for vectors representing mechanical states.

Governing Equations or Operators

  • When $ l > 0 $:

    $$ \| v \|_l = \left( \sum_{i=0}^{\text{dim}(v)} |v[i]|^l \right)^{1/l} $$
  • For the infinite norm (when $ l = 0 $):

    $$ \| v \|_\infty = \max_{i=0}^{\text{dim}(v)} |v[i]| $$

Constitutive or Kinematic Laws Involved

  • Vector Norms: The visitor deals with general vector norms, which are not directly related to specific constitutive laws like elasticity or hyperelasticity. However, they can be used in the context of evaluating forces, displacements, or velocities.
  • These norms are useful for determining magnitudes of vectors such as velocity or force, which might be part of more complex mechanical systems described by Lagrangian mechanics and variational principles.

Role in the Global FEM Pipeline

  • Visitor Pattern: The MechanicalVNormVisitor operates within the visitor pattern framework. Specifically, it processes BaseMechanicalState, which represents mechanical states in Sofa simulations:
  • It accumulates values from these states to compute norms during the simulation.
  • This accumulation is done through methods like fwdMechanicalState, where it iterates over different components and computes partial sums for $$ \| v \|_l = \left( \sum_{i=0}^{\text{dim}(v)} |v[i]|^l \right)^{1/l} $$-norms or finds maximum absolute values for infinite norm.

Numerical Methods or Discretization Choices

  • Norm Calculation: The visitor employs specific numerical choices depending on the type of norm:
  • For finite norms ($ l = 0 $), it accumulates powers of vector components and then takes the root to compute the final value.
  • For the infinite norm, it simply tracks the maximum absolute value encountered during traversal.

Integration into Variational / Lagrangian Mechanics Framework

  • klzzwxh:0008: While not directly tied to variational or Lagrangian mechanics principles, this visitor provides general utility in evaluating vector magnitudes which can be part of larger mechanical systems described by such principles.
  • For instance, norms of velocity vectors might contribute to the kinetic energy term $ T(q,\dot{q}) $ in the Lagrangian formulation:

    $$ T = \frac{1}{2} \rho \|\dot{u}\|^2 $$
  • The visitor's role is more in post-processing or diagnostic purposes rather than core FEM operations like assembly, time integration, nonlinear solve, etc.

Methods
SReal getResult ()
Result fwdMechanicalState (VisitorContext * ctx, sofa::core::behavior::BaseMechanicalState * mm) virtual
int getInfos ()
bool isThreadSafe () virtual
{
  "name": "MechanicalVNormVisitor",
  "namespace": "sofa::simulation::mechanicalvisitor",
  "module": "Sofa.framework.Simulation.Core",
  "include": "sofa/simulation/mechanicalvisitor/MechanicalVNormVisitor.h",
  "doc": "Compute the norm of a vector.\nThe type of norm is set by parameter @a l. Use 0 for the infinite norm.\nNote that the 2-norm is more efficiently computed using the square root of the dot product.\n@author Francois Faure, 2013",
  "inherits": [
    "BaseMechanicalVisitor"
  ],
  "templates": [],
  "data_fields": [],
  "links": [],
  "methods": [
    {
      "name": "getResult",
      "return_type": "SReal",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "fwdMechanicalState",
      "return_type": "Result",
      "params": [
        {
          "name": "ctx",
          "type": "VisitorContext *"
        },
        {
          "name": "mm",
          "type": "sofa::core::behavior::BaseMechanicalState *"
        }
      ],
      "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": "isThreadSafe",
      "return_type": "bool",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `MechanicalVNormVisitor` is part of the Sofa simulation framework and inherits from `BaseMechanicalVisitor`. Its primary role is to compute the norm of a vector in mechanical simulations, with the type of norm specified by a parameter `l`. It supports various types of norms including the infinite norm (when `l=0`). This visitor efficiently computes different norms using accumulation and specific mathematical operations.\n\nIn interactions with other components, it primarily works with `BaseMechanicalState`, which represents mechanical states in Sofa. The method `fwdMechanicalState` is a virtual function from the base class that processes these states to compute vector norms.\n\nThe component's public methods include `getResult()` for retrieving the computed norm and `getInfos()` for providing information about the visitor's operation. It also overrides `isThreadSafe()`, indicating its thread-safe implementation.\n\nPractical usage involves setting up the visitor with specific parameters such as execution context, vector ID (`a`), and norm type (`l`). The visitor processes mechanical states to compute norms and can be used for various debugging or profiling purposes.",
  "maths": "The `MechanicalVNormVisitor` is designed to compute the norm of a vector, which can be interpreted in various contexts within the Finite Element Method (FEM) and broader computational mechanics framework. Specifically, this visitor handles different types of norms, as defined by the parameter \\(l\\), and computes them efficiently for vectors representing mechanical states.\n\n### Governing Equations or Operators\n- **Norm Computation**: The norm computation can be used to evaluate the magnitude or size of a vector in various contexts. For instance:\n  - When \\( l > 0 \\):\n    \n    \\[ \\| v \\|_l = \\left( \\sum_{i=0}^{\\text{dim}(v)} |v[i]|^l \\right)^{1/l} \\]\n\n  - For the infinite norm (when \\( l = 0 \\)):\n    \n    \\[ \\| v \\|_\\infty = \\max_{i=0}^{\\text{dim}(v)} |v[i]| \\]\n\n### Constitutive or Kinematic Laws Involved\n- **Vector Norms**: The visitor deals with general vector norms, which are not directly related to specific constitutive laws like elasticity or hyperelasticity. However, they can be used in the context of evaluating forces, displacements, or velocities.\n  - These norms are useful for determining magnitudes of vectors such as velocity or force, which might be part of more complex mechanical systems described by Lagrangian mechanics and variational principles.\n\n### Role in the Global FEM Pipeline\n- **Visitor Pattern**: The `MechanicalVNormVisitor` operates within the visitor pattern framework. Specifically, it processes `BaseMechanicalState`, which represents mechanical states in Sofa simulations:\n  - It accumulates values from these states to compute norms during the simulation.\n  - This accumulation is done through methods like `fwdMechanicalState`, where it iterates over different components and computes partial sums for \\(l\\)-norms or finds maximum absolute values for infinite norm.\n\n### Numerical Methods or Discretization Choices\n- **Norm Calculation**: The visitor employs specific numerical choices depending on the type of norm:\n  - For finite norms (\\( l > 0 \\)), it accumulates powers of vector components and then takes the root to compute the final value.\n  - For the infinite norm, it simply tracks the maximum absolute value encountered during traversal.\n\n### Integration into Variational / Lagrangian Mechanics Framework\n- **General Utility**: While not directly tied to variational or Lagrangian mechanics principles, this visitor provides general utility in evaluating vector magnitudes which can be part of larger mechanical systems described by such principles.\n  - For instance, norms of velocity vectors might contribute to the kinetic energy term \\( T(q,\\dot{q}) \\) in the Lagrangian formulation:\n    \n    \\[ T = \\frac{1}{2} \\rho \\|\\dot{u}\\|^2 \\]\n\n  - The visitor's role is more in post-processing or diagnostic purposes rather than core FEM operations like assembly, time integration, nonlinear solve, etc.\n",
  "abstract": "The `MechanicalVNormVisitor` computes vector norms in mechanical states, supporting various types of norms specified by a parameter.",
  "sheet": "# MechanicalVNormVisitor\n\n## Overview\nThe `MechanicalVNormVisitor` is part of the Sofa simulation framework and inherits from `BaseMechanicalVisitor`. It processes `BaseMechanicalState` components to compute vector norms efficiently. The type of norm is set by the parameter `l`, where `0` denotes the infinite norm.\n\n## Mathematical Model\nThe visitor computes different types of norms for vectors representing mechanical states:\n- For finite norms (\\( l > 0 \\)):\n  \n  \\[ \\| v \\|_l = \\left( \\sum_{i=0}^{\\text{dim}(v)} |v[i]|^l \\right)^{1/l} \\]\n\n- For the infinite norm (when \\( l = 0 \\)):\n  \n  \\[ \\| v \\|_\\infty = \\max_{i=0}^{\\text{dim}(v)} |v[i]| \\]\n\n## Dependencies and Connections\nThe `MechanicalVNormVisitor` primarily interacts with `BaseMechanicalState`, which represents mechanical states in Sofa simulations. It processes these states to compute norms.\n\n## Practical Notes\nThis visitor is thread-safe, as indicated by the overridden method `isThreadSafe()`. Efficient computation of vector norms can be crucial for debugging or profiling purposes."
}