Wildmeshing Toolkit
wmtk::function::PerSimplexAutodiffFunction Class Referenceabstract

This is an extension of the PerSimplexFunction class that uses autodiff encoding for differentiations. More...

#include <PerSimplexAutodiffFunction.hpp>

Inheritance diagram for wmtk::function::PerSimplexAutodiffFunction:
[legend]
Collaboration diagram for wmtk::function::PerSimplexAutodiffFunction:
[legend]

Public Types

using DScalar = DScalar2< double, Eigen::Matrix< double, -1, 1 >, Eigen::Matrix< double, -1, -1 > >
 
using Scalar = typename DScalar::Scalar
 
using DSVec = Eigen::VectorX< DScalar >
 

Public Member Functions

 PerSimplexAutodiffFunction (const Mesh &mesh, const PrimitiveType primitive_type, const attribute::MeshAttributeHandle &variable_attribute_handle)
 
 ~PerSimplexAutodiffFunction ()
 
double get_value (const simplex::Simplex &domain_simplex) const override
 This function is defined over a simplex (normally a triangle or tetrahedron). More...
 
Eigen::VectorXd get_gradient (const simplex::Simplex &domain_simplex, const simplex::Simplex &variable_simplex) const override
 
Eigen::MatrixXd get_hessian (const simplex::Simplex &domain_simplex, const simplex::Simplex &variable_simplex) const override
 
- Public Member Functions inherited from wmtk::function::PerSimplexFunction
 PerSimplexFunction (const Mesh &mesh, const PrimitiveType primitive_type, const attribute::MeshAttributeHandle &variable_attribute_handle)
 
virtual ~PerSimplexFunction ()
 
const Meshmesh () const
 
const attribute::MeshAttributeHandleattribute_handle () const
 
int64_t embedded_dimension () const
 

Protected Member Functions

std::vector< DSVecget_coordinates (const simplex::Simplex &domain_simplex, const std::optional< simplex::Simplex > &variable_simplex_opt={}) const
 This is a helper function that obtains the coordinates of the variables for the function f(x) where f is defined over a domain consists of the input argument domain_tuples. More...
 
std::vector< DSVecget_coordinates (const attribute::Accessor< double > &accessor, const simplex::Simplex &domain_simplex, const std::optional< simplex::Simplex > &variable_simplex_opt={}) const
 
virtual DScalar eval (const simplex::Simplex &domain_simplex, const std::vector< DSVec > &coordinates) const =0
 This function defines a function f(x) where f is defined over a simplex domain and the variables for f are the n vertices coordinates of the simplex. More...
 

Additional Inherited Members

- Protected Attributes inherited from wmtk::function::PerSimplexFunction
const PrimitiveType m_primitive_type
 

Detailed Description

This is an extension of the PerSimplexFunction class that uses autodiff encoding for differentiations.

Definition at line 18 of file PerSimplexAutodiffFunction.hpp.

Member Typedef Documentation

◆ DScalar

using wmtk::function::PerSimplexAutodiffFunction::DScalar = DScalar2<double, Eigen::Matrix<double, -1, 1>, Eigen::Matrix<double, -1, -1> >

Definition at line 21 of file PerSimplexAutodiffFunction.hpp.

◆ DSVec

◆ Scalar

Constructor & Destructor Documentation

◆ PerSimplexAutodiffFunction()

wmtk::function::PerSimplexAutodiffFunction::PerSimplexAutodiffFunction ( const Mesh mesh,
const PrimitiveType  primitive_type,
const attribute::MeshAttributeHandle variable_attribute_handle 
)

Definition at line 10 of file PerSimplexAutodiffFunction.cpp.

◆ ~PerSimplexAutodiffFunction()

wmtk::function::PerSimplexAutodiffFunction::~PerSimplexAutodiffFunction ( )
default

Member Function Documentation

◆ eval()

virtual DScalar wmtk::function::PerSimplexAutodiffFunction::eval ( const simplex::Simplex domain_simplex,
const std::vector< DSVec > &  coordinates 
) const
protectedpure virtual

This function defines a function f(x) where f is defined over a simplex domain and the variables for f are the n vertices coordinates of the simplex.

The input coordinates are obtained through the get_coordinates function. They are encoded in autodiff type so that the function can be differentiated through autodiff.

Parameters
coordinates
Returns
DScalar

Implemented in wmtk::function::TriangleAMIPS.

Referenced by get_gradient(), get_hessian(), and get_value().

Here is the caller graph for this function:

◆ get_coordinates() [1/2]

std::vector< PerSimplexAutodiffFunction::DSVec > wmtk::function::PerSimplexAutodiffFunction::get_coordinates ( const attribute::Accessor< double > &  accessor,
const simplex::Simplex domain_simplex,
const std::optional< simplex::Simplex > &  variable_simplex_opt = {} 
) const
protected

Definition at line 27 of file PerSimplexAutodiffFunction.cpp.

References wmtk::function::utils::get_simplex_attributes(), wmtk::function::PerSimplexFunction::m_primitive_type, wmtk::function::PerSimplexFunction::mesh(), and wmtk::simplex::Simplex::tuple().

Here is the call graph for this function:

◆ get_coordinates() [2/2]

std::vector< PerSimplexAutodiffFunction::DSVec > wmtk::function::PerSimplexAutodiffFunction::get_coordinates ( const simplex::Simplex domain_simplex,
const std::optional< simplex::Simplex > &  variable_simplex_opt = {} 
) const
protected

This is a helper function that obtains the coordinates of the variables for the function f(x) where f is defined over a domain consists of the input argument domain_tuples.

The second input argument variable_simplex_opt is an optional simplex that is in the domain that's defined by the domain_tuples. For example, the domain_tuples for a function defined over a triangle is the vector of three vertex tuples of the triangle. And the variable_simplex, when exists, can be one of the three vertices. The function f can then be differentiable wrt the variable_simplex.

Template Parameters
NThe number of the tuples that consist of the domain of the function f(x)
Parameters
domain_tuplesThe domain of the function f(x)
variable_simplex_optThe optional variable_simplex that the function f(x) is differentiating wrt.
Returns
std::array<DSVec, N> The coordinates of the variables for the function f(x) that are in autodiff type

Definition at line 19 of file PerSimplexAutodiffFunction.cpp.

References wmtk::function::PerSimplexFunction::attribute_handle(), wmtk::Mesh::create_const_accessor(), and wmtk::function::PerSimplexFunction::mesh().

Referenced by get_gradient(), get_hessian(), and get_value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_gradient()

Eigen::VectorXd wmtk::function::PerSimplexAutodiffFunction::get_gradient ( const simplex::Simplex domain_simplex,
const simplex::Simplex variable_simplex 
) const
overridevirtual

Reimplemented from wmtk::function::PerSimplexFunction.

Definition at line 59 of file PerSimplexAutodiffFunction.cpp.

References wmtk::function::PerSimplexFunction::embedded_dimension(), eval(), get_coordinates(), and DScalar2< _Scalar, _Gradient, _Hessian >::getGradient().

Here is the call graph for this function:

◆ get_hessian()

Eigen::MatrixXd wmtk::function::PerSimplexAutodiffFunction::get_hessian ( const simplex::Simplex domain_simplex,
const simplex::Simplex variable_simplex 
) const
overridevirtual

Reimplemented from wmtk::function::PerSimplexFunction.

Definition at line 69 of file PerSimplexAutodiffFunction.cpp.

References wmtk::function::PerSimplexFunction::embedded_dimension(), eval(), get_coordinates(), and DScalar2< _Scalar, _Gradient, _Hessian >::getHessian().

Here is the call graph for this function:

◆ get_value()

double wmtk::function::PerSimplexAutodiffFunction::get_value ( const simplex::Simplex domain_simplex) const
overridevirtual

This function is defined over a simplex (normally a triangle or tetrahedron).

And the domain of the function is represented by the input argument domain_simplex.

Parameters
domain_simplexThe domain that the function is defined over.
Returns
double The numerical value of the function at the input domain.

Implements wmtk::function::PerSimplexFunction.

Definition at line 51 of file PerSimplexAutodiffFunction.cpp.

References wmtk::function::PerSimplexFunction::embedded_dimension(), eval(), get_coordinates(), and DScalar2< _Scalar, _Gradient, _Hessian >::getValue().

Here is the call graph for this function:

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