PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
pbat::fem::SymmetricLaplacianMatrix< TMesh > Struct Template Reference

A matrix-free representation of the symmetric part of the Laplacian \(\Delta u\) of a finite element discretized function \( u(X) \) under Galerkin projection. More...

#include <LaplacianMatrix.h>

Public Types

using SelfType = SymmetricLaplacianMatrix<TMesh>
 Self type.
 
using MeshType = TMesh
 Mesh type.
 
using ElementType = typename TMesh::ElementType
 Element type.
 

Public Member Functions

 SymmetricLaplacianMatrix (MeshType const &mesh, Eigen::Ref< IndexVectorX const > const &eg, Eigen::Ref< VectorX const > const &wg, Eigen::Ref< MatrixX const > const &GNegg, int dims=1)
 Construct a new symmetric Laplacian operator.
 
SelfTypeoperator= (SelfType const &)=delete
 
template<class TDerivedIn, class TDerivedOut>
void Apply (Eigen::MatrixBase< TDerivedIn > const &x, Eigen::DenseBase< TDerivedOut > &y) const
 Applies this matrix as a linear operator on x, adding result to y.
 
CSCMatrix ToMatrix () const
 Transforms this matrix-free matrix representation into sparse compressed format.
 
Index InputDimensions () const
 Number of columns.
 
Index OutputDimensions () const
 Number of rows.
 
void ComputeElementLaplacians ()
 Compute and store the element laplacians.
 
void CheckValidState () const
 Check if the state of this Laplacian matrix is valid.
 

Public Attributes

MeshType const & mesh
 The finite element mesh.
 
Eigen::Ref< IndexVectorX const > eg
 |# quad.pts.|x1 array of elements associated with quadrature points
 
Eigen::Ref< VectorX const > wg
 |# quad.pts.|x1 array of quadrature weights
 
Eigen::Ref< MatrixX const > GNeg
 
MatrixX deltag
 
int dims
 

Static Public Attributes

static int constexpr kOrder
 Polynomial order of the Laplacian matrix.
 

Detailed Description

template<CMesh TMesh>
struct pbat::fem::SymmetricLaplacianMatrix< TMesh >

A matrix-free representation of the symmetric part of the Laplacian \(\Delta u\) of a finite element discretized function \( u(X) \) under Galerkin projection.

The precise definition of the Laplacian matrix's symmetric part is given by \( \mathbf{L}_{ij} = \int_\Omega -\nabla \phi_i \cdot \nabla \phi_j d\Omega \).

Todo
Explain the Laplacian matrix and its construction and link to my higher-level FEM crash course doc.

This matrix-free Laplacian requires the following inputs:

  • A finite element mesh satisfying concept CMesh
  • A vector of element indices eg, associating each quadrature point with an element
  • A vector of quadrature weights wg
  • A matrix GNegg of element shape function gradients at quadrature points (see ShapeFunctionGradients())
  • An integer dims specifying the dimensionality of the image of the FEM function space
Note
The user-provided quadrature rule is injected into the Laplacian operator, allowing for arbitrary quadrature rules to be used. Since Laplacians of higher-dimensional functions are only one-dimensional Laplacian 'kroneckered' with the identity matrix, the Laplacian matrix is actually \( L \otimes I_{d \times d} \) where \( d \) is the function's dimensionality, but we need not store the duplicate entries.
Template Parameters
TMeshType satisfying concept CMesh

Constructor & Destructor Documentation

◆ SymmetricLaplacianMatrix()

template<CMesh TMesh>
pbat::fem::SymmetricLaplacianMatrix< TMesh >::SymmetricLaplacianMatrix ( MeshType const & mesh,
Eigen::Ref< IndexVectorX const > const & eg,
Eigen::Ref< VectorX const > const & wg,
Eigen::Ref< MatrixX const > const & GNegg,
int dims = 1 )
inline

Construct a new symmetric Laplacian operator.

Parameters
meshFinite element mesh
egElement indices associating each quadrature point with an element
wgQuadrature weights
GNeggElement shape function gradients at quadrature points
dimsDimensionality of the image of the FEM function space
Precondition
eg.size() == wg.size() and GNegg.rows() == mesh.E.rows() and dims >= 1

Member Function Documentation

◆ Apply()

template<CMesh TMesh>
template<class TDerivedIn, class TDerivedOut>
void pbat::fem::SymmetricLaplacianMatrix< TMesh >::Apply ( Eigen::MatrixBase< TDerivedIn > const & x,
Eigen::DenseBase< TDerivedOut > & y ) const
inline

Applies this matrix as a linear operator on x, adding result to y.

Template Parameters
TDerivedInInput matrix type
TDerivedOutOutput matrix type
Parameters
xInput matrix
yOutput matrix
Precondition
x.rows() == InputDimensions() and y.rows() == OutputDimensions() and y.cols() == x.cols()

◆ InputDimensions()

template<CMesh TMesh>
Index pbat::fem::SymmetricLaplacianMatrix< TMesh >::InputDimensions ( ) const
inline

Number of columns.

Returns
Number of columns

◆ OutputDimensions()

template<CMesh TMesh>
Index pbat::fem::SymmetricLaplacianMatrix< TMesh >::OutputDimensions ( ) const
inline

Number of rows.

Returns
Number of rows

◆ ToMatrix()

template<CMesh TMesh>
CSCMatrix pbat::fem::SymmetricLaplacianMatrix< TMesh >::ToMatrix ( ) const
inline

Transforms this matrix-free matrix representation into sparse compressed format.

Returns
Sparse compressed column matrix representation of this Laplacian matrix

Member Data Documentation

◆ deltag

template<CMesh TMesh>
MatrixX pbat::fem::SymmetricLaplacianMatrix< TMesh >::deltag

|# element nodes| x |# element nodes * # quad.pts.| matrix of element laplacians at quadrature points

◆ dims

template<CMesh TMesh>
int pbat::fem::SymmetricLaplacianMatrix< TMesh >::dims

Dimensionality of image of FEM function space, i.e. this Laplacian matrix is actually \( L \otimes I_{d} \). Must have dims >= 1.

◆ GNeg

template<CMesh TMesh>
Eigen::Ref<MatrixX const> pbat::fem::SymmetricLaplacianMatrix< TMesh >::GNeg

|# element nodes|x|# dims * # quad.pts. * # elements| matrix of element shape function gradients at quadrature points

◆ kOrder

template<CMesh TMesh>
int constexpr pbat::fem::SymmetricLaplacianMatrix< TMesh >::kOrder
staticconstexpr
Initial value:
=
2 * (ElementType::kOrder - 1)

Polynomial order of the Laplacian matrix.


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