Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::la::Tensor Class Reference

Ultra-lightweight wrapper for PETSc Vec with Eigen mapping. Loads only the data and maps it using externally provided cell IDs. For now it considers only tensors which are stored in a flatten array. More...

#include <tensor.hpp>

Public Types

template<int Dim>
using LocalMap

Public Member Functions

 Tensor (const std::string &filename, const std::string &dataset_name)
 Construct a Tensor by loading data from HDF5. The class can manage only cell constant tensors.
 Tensor (const Tensor &)=delete
Tensor & operator= (const Tensor &)=delete
template<int Dim>
LocalMap< Dim > getEigenMap (PetscInt local_index) const
 Get the tensor for a specific local cell id throw an Eigen Map.
template<int Dim, typename IndexT>
auto getEvaluation (IndexT local_index) const
 Get the evaluated tensor for a specific local cell id.
 ~Tensor ()

Private Attributes

Vec m_vec_data
 Store the complete flat tensor in a PETsc vector.
const PetscScalar * m_raw_ptr = nullptr
 Pointer to the PETSc data. Used to avoid multiple redefinition.

Detailed Description

Ultra-lightweight wrapper for PETSc Vec with Eigen mapping. Loads only the data and maps it using externally provided cell IDs. For now it considers only tensors which are stored in a flatten array.

TODO: general form of tensor (N, Ni,Nj).

Member Typedef Documentation

◆ LocalMap

template<int Dim>
using vulpes::la::Tensor::LocalMap
Initial value:
Eigen::Map<const Eigen::Matrix<double, Dim, Dim, Eigen::RowMajor>>

Constructor & Destructor Documentation

◆ Tensor() [1/2]

vulpes::la::Tensor::Tensor ( const std::string & filename,
const std::string & dataset_name )
inlineexplicit

Construct a Tensor by loading data from HDF5. The class can manage only cell constant tensors.

Parameters
filenamePath to the .h5 file.
dataset_nameInternal HDF5 path (e.g., "/DTI/vector_0").
Note
The tensor must be stored in a flatten way and the values must be stored using the cell id order. The starting location in the flatten version of the tensor inside the file for cell id \( i \) is given by \(i * Dim * Dim \).

◆ Tensor() [2/2]

vulpes::la::Tensor::Tensor ( const Tensor & )
delete

◆ ~Tensor()

vulpes::la::Tensor::~Tensor ( )
inline

Member Function Documentation

◆ getEigenMap()

template<int Dim>
LocalMap< Dim > vulpes::la::Tensor::getEigenMap ( PetscInt local_index) const
inline

Get the tensor for a specific local cell id throw an Eigen Map.

Template Parameters
DimSpatial dimension (2 or 3).
Parameters
local_indexThe local index of the cell (from 0 to n_local_cells - 1).
Returns
An Eigen::Map pointing to the cell's tensor.

◆ getEvaluation()

template<int Dim, typename IndexT>
auto vulpes::la::Tensor::getEvaluation ( IndexT local_index) const
inline

Get the evaluated tensor for a specific local cell id.

Template Parameters
DimSpatial dimension (2 or 3).
IndexTType of the index (automatically converted to PetscInt).
Parameters
local_indexThe local index of the cell.
Returns
The evaluated Eigen matrix as a dense matrix.

◆ operator=()

Tensor & vulpes::la::Tensor::operator= ( const Tensor & )
delete

Member Data Documentation

◆ m_raw_ptr

const PetscScalar* vulpes::la::Tensor::m_raw_ptr = nullptr
mutableprivate

Pointer to the PETSc data. Used to avoid multiple redefinition.

◆ m_vec_data

Vec vulpes::la::Tensor::m_vec_data
private

Store the complete flat tensor in a PETsc vector.


The documentation for this class was generated from the following file: