Lagrange
Attributes iterators

Iterating over mesh attributes. More...

Sequential iteration for read operations

template<std::underlying_type_t< AttributeElement > mask = BitField<AttributeElement>::all(), typename Visitor , typename Scalar , typename Index >
void seq_foreach_named_attribute_read (const SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
 Applies a function to each attribute of a mesh. More...
 
template<std::underlying_type_t< AttributeElement > mask = BitField<AttributeElement>::all(), typename Visitor , typename Scalar , typename Index >
void seq_foreach_attribute_read (const SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
 Applies a function to each attribute of a mesh. More...
 

Sequential iteration for write operations

template<std::underlying_type_t< AttributeElement > mask = BitField<AttributeElement>::all(), typename Visitor , typename Scalar , typename Index >
void seq_foreach_named_attribute_write (SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
 Applies a function to each attribute of a mesh. More...
 
template<std::underlying_type_t< AttributeElement > mask = BitField<AttributeElement>::all(), typename Visitor , typename Scalar , typename Index >
void seq_foreach_attribute_write (SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
 Applies a function to each attribute of a mesh. More...
 

Parallel iteration for read operations

template<std::underlying_type_t< AttributeElement > mask = BitField<AttributeElement>::all(), typename Visitor , typename Scalar , typename Index >
void par_foreach_named_attribute_read (const SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
 Applies a function in parallel to each attribute of a mesh. More...
 
template<std::underlying_type_t< AttributeElement > mask = BitField<AttributeElement>::all(), typename Visitor , typename Scalar , typename Index >
void par_foreach_attribute_read (const SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
 Applies a function in parallel to each attribute of a mesh. More...
 

Parallel iteration for write operations

template<std::underlying_type_t< AttributeElement > mask = BitField<AttributeElement>::all(), typename Visitor , typename Scalar , typename Index >
void par_foreach_named_attribute_write (SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
 Applies a function in parallel to each attribute of a mesh. More...
 
template<std::underlying_type_t< AttributeElement > mask = BitField<AttributeElement>::all(), typename Visitor , typename Scalar , typename Index >
void par_foreach_attribute_write (SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
 Applies a function in parallel to each attribute of a mesh. More...
 

Detailed Description

Iterating over mesh attributes.

These utility functions use generic lambdas to iterate over mesh attributes of different types. Because a generic lambda is templated, the type of each attribute is accessible at compile type within the lambda function:

seq_foreach_attribute_read(mesh, [](auto&& attr) {
using AttributeType = std::decay_t<decltype(attr)>;
using ValueType = typename AttributeType::ValueType;
lagrange::logger().info("Mesh attribute value type has size {}", sizeof(ValueType));
});
LA_CORE_API spdlog::logger & logger()
Retrieves the current logger.
Definition: Logger.cpp:40
void seq_foreach_attribute_read(const SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
Applies a function to each attribute of a mesh.
Definition: foreach_attribute.h:233

To iterate over mesh attributes while accessing their names, use the named_ variants:

seq_foreach_named_attribute_read(mesh, [&](std::string_view name, auto&& attr) {
"Mesh attribute named '{} with {} rows', name, attr.get_num_elements()");
});
void seq_foreach_named_attribute_read(const SurfaceMesh< Scalar, Index > &mesh, Visitor &&vis)
Applies a function to each attribute of a mesh.
Definition: foreach_attribute.h:207

There are read and write variants of the functions above, depending on what type of access is needed over the mesh attributes. Finally, the par_* variants call the visitor function in parallel for each mesh attribute.

Function Documentation

◆ seq_foreach_named_attribute_read()

void seq_foreach_named_attribute_read ( const SurfaceMesh< Scalar, Index > &  mesh,
Visitor &&  vis 
)

#include <lagrange/foreach_attribute.h>

Applies a function to each attribute of a mesh.

The visitor function iterates over a pair of (name x attribute).

Parameters
[in]meshMesh on whose attribute to apply the visitor function.
[in]visVisitor function to apply to each mesh attribute. Typically a generic lambda.
Template Parameters
maskBit field mask to filter attribute based on their element types.
VisitorType of the visitor function, which should be template<typename T> void(std::string_view, const Attribute<T> &);
ScalarMesh scalar type.
IndexMesh index type.

◆ seq_foreach_attribute_read()

void seq_foreach_attribute_read ( const SurfaceMesh< Scalar, Index > &  mesh,
Visitor &&  vis 
)

#include <lagrange/foreach_attribute.h>

Applies a function to each attribute of a mesh.

Parameters
[in]meshMesh on whose attribute to apply the visitor function.
[in]visVisitor function to apply to each mesh attribute. Typically a generic lambda.
Template Parameters
maskBit field mask to filter attribute based on their element types.
VisitorType of the visitor function, which should be template<typename T> void(const Attribute<T> &);
ScalarMesh scalar type.
IndexMesh index type.

◆ seq_foreach_named_attribute_write()

void seq_foreach_named_attribute_write ( SurfaceMesh< Scalar, Index > &  mesh,
Visitor &&  vis 
)

#include <lagrange/foreach_attribute.h>

Applies a function to each attribute of a mesh.

The visitor function iterates over a pair of (name x attribute). In this variant, the attribute is passed as a writable reference to the visitor function.

Parameters
[in]meshMesh on whose attribute to apply the visitor function.
[in]visVisitor function to apply to each mesh attribute. Typically a generic lambda.
Template Parameters
maskBit field mask to filter attribute based on their element types.
VisitorType of the visitor function, which should be template<typename T> void(std::string_view, const Attribute<T> &);
ScalarMesh scalar type.
IndexMesh index type.

◆ seq_foreach_attribute_write()

void seq_foreach_attribute_write ( SurfaceMesh< Scalar, Index > &  mesh,
Visitor &&  vis 
)

#include <lagrange/foreach_attribute.h>

Applies a function to each attribute of a mesh.

In this variant, the attribute is passed as a writable reference to the visitor function.

Parameters
[in,out]meshMesh on whose attribute to apply the visitor function.
[in]visVisitor function to apply to each mesh attribute. Typically a generic lambda.
Template Parameters
maskBit field mask to filter attribute based on their element types.
VisitorType of the visitor function, which should be template<typename T> void(Attribute<T> &);
ScalarMesh scalar type.
IndexMesh index type.

◆ par_foreach_named_attribute_read()

void par_foreach_named_attribute_read ( const SurfaceMesh< Scalar, Index > &  mesh,
Visitor &&  vis 
)

#include <lagrange/foreach_attribute.h>

Applies a function in parallel to each attribute of a mesh.

The visitor function iterates over a pair of (name x attribute).

Parameters
[in]meshMesh on whose attribute to apply the visitor function.
[in]visVisitor function to apply to each mesh attribute. Typically a generic lambda.
Template Parameters
maskBit field mask to filter attribute based on their element types.
VisitorType of the visitor function, which should be template<typename T> void(std::string_view, const Attribute<T> &);
ScalarMesh scalar type.
IndexMesh index type.

◆ par_foreach_attribute_read()

void par_foreach_attribute_read ( const SurfaceMesh< Scalar, Index > &  mesh,
Visitor &&  vis 
)

#include <lagrange/foreach_attribute.h>

Applies a function in parallel to each attribute of a mesh.

Parameters
[in]meshMesh on whose attribute to apply the visitor function.
[in]visVisitor function to apply to each mesh attribute. Typically a generic lambda.
Template Parameters
maskBit field mask to filter attribute based on their element types.
VisitorType of the visitor function, which should be template<typename T> void(const Attribute<T> &);
ScalarMesh scalar type.
IndexMesh index type.

◆ par_foreach_named_attribute_write()

void par_foreach_named_attribute_write ( SurfaceMesh< Scalar, Index > &  mesh,
Visitor &&  vis 
)

#include <lagrange/foreach_attribute.h>

Applies a function in parallel to each attribute of a mesh.

The visitor function iterates over a pair of (name x attribute). In this variant, the attribute is passed as a writable reference to the visitor function.

Parameters
[in]meshMesh on whose attribute to apply the visitor function.
[in]visVisitor function to apply to each mesh attribute. Typically a generic lambda.
Template Parameters
maskBit field mask to filter attribute based on their element types.
VisitorType of the visitor function, which should be template<typename T> void(std::string_view, const Attribute<T> &);
ScalarMesh scalar type.
IndexMesh index type.

◆ par_foreach_attribute_write()

void par_foreach_attribute_write ( SurfaceMesh< Scalar, Index > &  mesh,
Visitor &&  vis 
)

#include <lagrange/foreach_attribute.h>

Applies a function in parallel to each attribute of a mesh.

In this variant, the attribute is passed as a writable reference to the visitor function.

Parameters
[in,out]meshMesh on whose attribute to apply the visitor function.
[in]visVisitor function to apply to each mesh attribute. Typically a generic lambda.
Template Parameters
maskBit field mask to filter attribute based on their element types.
VisitorType of the visitor function, which should be template<typename T> void(Attribute<T> &);
ScalarMesh scalar type.
IndexMesh index type.