Medusa  1.1
Coordinate Free Mehless Method implementation
mm::UniformShapeStorage< vec_t, OpFamilies > Class Template Reference

#include <UniformShapeStorage_fwd.hpp>

Detailed Description

template<typename vec_t, typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
class mm::UniformShapeStorage< vec_t, OpFamilies >

Efficiently stores shape functions of uniform length.

This class is used to store shape functions (stencil weights) generated for discretizations where supports of all nodes have equal size e.g. the support consists of 9 closest nodes. This class is more efficient than storing the shapes in a nested type, such as std::vector<std::vector<T>>, see technical report.

If supports of node vary in size, use RaggedShapeStorage instead.

  • Template Parameters
    vec_tVector type used in computations, specifies the dimensionality of the domain and scalar type for numerical computations.
    OpFamiliesA list of operator families for which the shapes will be stored. The basic operator families are Lap, Der1s and Der2s representing the Laplacian, 1st and 2nd derivatives, respectively. All these operators are computed if the template parameters are not explicitly specified.
    If you try to call a function that need other shapes than the computed ones, you will get a compile time error like:
    error: static_assert failed due to requirement '!std::is_same<std::tuple<>, std::tuple<> >::value' "Could not find type `T` in given `Tuple`"
    static_assert(!std::is_same<Tuple, std::tuple<>>::value, // Did you access invalid operators?
    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Usage example:

UniformShapeStorage<Vec3d, std::tuple<Lap<3>, Der1s<3>>> storage;
Range<int> sizes = {5, 5, 5, 5, 5, 5};
storage.resize(sizes);
storage.size(); // 6
Eigen::VectorXd lap(5);
lap << 1.2, 3.4, 5.6, 7.8, 9.0; // compute the shapes
storage.setLaplace(2, lap); // set lap as laplace shape for node 2.
storage.laplace(2, 3); // returns 7.8
storage.d1(1, 3); // d/dy shape in node 3 (returns 0, because it is not set yet)
std::cout << storage << std::endl;
See also
sh, RaggedShapeStorage, ShapeStorage, computeShapes

Definition at line 55 of file UniformShapeStorage_fwd.hpp.

+ Inheritance diagram for mm::UniformShapeStorage< vec_t, OpFamilies >:
+ Collaboration diagram for mm::UniformShapeStorage< vec_t, OpFamilies >:

Public Member Functions

 UniformShapeStorage ()
 < Number of nodes that shapes can be stored for. More...
 
int supportSize (int) const
 Returns support size of node-th node. More...
 
int size () const
 < Number of operators stored in this storage. More...
 

Static Public Attributes

constexpr static int num_operators
 Number of operator families in this storage. More...
 

Public Types

enum  { dim = vec_t::dim }
 Bitmask telling us which shapes to create. More...
 
typedef vec_t vector_t
 Vector type used. More...
 
typedef vec_t::scalar_t scalar_t
 Scalar type used. More...
 

Private Types

typedef ShapeStorage< UniformShapeStorage< vec_t, OpFamilies >, vec_t, OpFamilies > base_t
 Parent class. More...
 

Private Member Functions

void resize_ (const std::vector< int > &support_sizes)
 Resizes the storage to accommodate shapes of given sizes. More...
 
template<typename T >
T * access (std::vector< T > &v, int op, int node) const
 Returns pointer to the start of values for node-th node for op-th operator. More...
 
template<typename T >
T * access (std::vector< T > &v, int node) const
 Returns pointer to the start of values for node-th node. More...
 
template<typename T >
const T * access (const std::vector< T > &v, int op, int node) const
 Returns const pointer to the start of values for node-th node for op-th operator. More...
 
template<typename T >
const T * access (const std::vector< T > &v, int node) const
 Returns const pointer to the start of values for node-th node. More...
 

Private Attributes

friend base_t
 Be friends with derived class. More...
 
int support_size_
 Support size. More...
 

Member Enumeration Documentation

◆ anonymous enum

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
anonymous enum

Bitmask telling us which shapes to create.

Enumerator
dim 

Dimensionality of the domain.

Definition at line 61 of file UniformShapeStorage_fwd.hpp.

Constructor & Destructor Documentation

◆ UniformShapeStorage()

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
mm::UniformShapeStorage< vec_t, OpFamilies >::UniformShapeStorage ( )
inline

< Number of nodes that shapes can be stored for.

Constructs an empty shape storage with size 0.

Definition at line 79 of file UniformShapeStorage_fwd.hpp.

Member Function Documentation

◆ access() [1/4]

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
template<typename T >
const T* mm::UniformShapeStorage< vec_t, OpFamilies >::access ( const std::vector< T > &  v,
int  node 
) const
inlineprivate

Returns const pointer to the start of values for node-th node.

Definition at line 103 of file UniformShapeStorage_fwd.hpp.

◆ access() [2/4]

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
template<typename T >
const T* mm::UniformShapeStorage< vec_t, OpFamilies >::access ( const std::vector< T > &  v,
int  op,
int  node 
) const
inlineprivate

Returns const pointer to the start of values for node-th node for op-th operator.

Definition at line 100 of file UniformShapeStorage_fwd.hpp.

◆ access() [3/4]

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
template<typename T >
T* mm::UniformShapeStorage< vec_t, OpFamilies >::access ( std::vector< T > &  v,
int  node 
) const
inlineprivate

Returns pointer to the start of values for node-th node.

Definition at line 97 of file UniformShapeStorage_fwd.hpp.

◆ access() [4/4]

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
template<typename T >
T* mm::UniformShapeStorage< vec_t, OpFamilies >::access ( std::vector< T > &  v,
int  op,
int  node 
) const
inlineprivate

Returns pointer to the start of values for node-th node for op-th operator.

Definition at line 94 of file UniformShapeStorage_fwd.hpp.

◆ resize_()

template<typename vec_t , typename OpFamilies >
void mm::UniformShapeStorage< vec_t, OpFamilies >::resize_ ( const std::vector< int > &  support_sizes)
private

Resizes the storage to accommodate shapes of given sizes.

If support sizes are {9, 9, 9} the class will allocate space for shapes for 3 nodes with 9 support nodes each. The containers are zero initialized.

Exceptions
Assertionfails if the elements of support_sizes are not all the same.

Definition at line 19 of file UniformShapeStorage.hpp.

◆ size()

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
int mm::ShapeStorage< Derived, vec_t, OpFamilies >::size
inline

< Number of operators stored in this storage.

Definition at line 87 of file ShapeStorage_fwd.hpp.

◆ supportSize()

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
int mm::UniformShapeStorage< vec_t, OpFamilies >::supportSize ( int  ) const
inline

Returns support size of node-th node.

Definition at line 82 of file UniformShapeStorage_fwd.hpp.

Member Data Documentation

◆ base_t

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
friend mm::UniformShapeStorage< vec_t, OpFamilies >::base_t
private

Be friends with derived class.

Definition at line 66 of file UniformShapeStorage_fwd.hpp.

◆ num_operators

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
constexpr static int mm::ShapeStorage< Derived, vec_t, OpFamilies >::num_operators
staticconstexpr

Number of operator families in this storage.

Definition at line 50 of file ShapeStorage_fwd.hpp.

◆ support_size_

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
int mm::UniformShapeStorage< vec_t, OpFamilies >::support_size_
private

Support size.

Definition at line 72 of file UniformShapeStorage_fwd.hpp.


The documentation for this class was generated from the following files:
mm::sh::lap
static const shape_flags lap
Indicates to calculate laplace shapes.
Definition: shape_flags.hpp:24