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

#include <RaggedShapeStorage_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::RaggedShapeStorage< vec_t, OpFamilies >

Efficiently stores shape functions of different lengths.

This class is used to store shape functions (stencil weights) generated for discretizations where supports of nodes have different sizes e.g. using FindBalancedSupport. 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 all nodes have the same size, use UniformShapeStorage 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:

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

Definition at line 22 of file DomainDiscretization_fwd.hpp.

+ Collaboration diagram for mm::RaggedShapeStorage< vec_t, OpFamilies >:

Public Member Functions

 RaggedShapeStorage ()
 < Number of nodes that shapes can be stored for. More...
 
int supportSize (int node) 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 }
 Store dimension of the domain. 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< RaggedShapeStorage< 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 i, int j) 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 i) const
 Returns pointer to the start of values for node-th node for. More...
 
template<typename T >
const T * access (const std::vector< T > &v, int i, int j) 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 i) const
 Returns const pointer to the start of values for node-th node. More...
 

Private Attributes

Range< int > support_sizes_
 Support sizes. More...
 
Range< int > support_starts_
 Indexes of starts of supports. Cumulative sums of support_sizes_. More...
 
int total_size_
 Sum of all support sizes. More...
 
friend base_t
 Be friends with derived class. 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

Store dimension of the domain.

Enumerator
dim 

Dimensionality of the domain.

Definition at line 58 of file RaggedShapeStorage_fwd.hpp.

Constructor & Destructor Documentation

◆ RaggedShapeStorage()

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

< Number of nodes that shapes can be stored for.

Constructs an empty shape storage with size 0.

Definition at line 80 of file RaggedShapeStorage_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::RaggedShapeStorage< vec_t, OpFamilies >::access ( const std::vector< T > &  v,
int  i 
) const
inlineprivate

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

Definition at line 103 of file RaggedShapeStorage_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::RaggedShapeStorage< vec_t, OpFamilies >::access ( const std::vector< T > &  v,
int  i,
int  j 
) const
inlineprivate

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

Definition at line 100 of file RaggedShapeStorage_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::RaggedShapeStorage< vec_t, OpFamilies >::access ( std::vector< T > &  v,
int  i 
) const
inlineprivate

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

Definition at line 97 of file RaggedShapeStorage_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::RaggedShapeStorage< vec_t, OpFamilies >::access ( std::vector< T > &  v,
int  i,
int  j 
) const
inlineprivate

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

Definition at line 94 of file RaggedShapeStorage_fwd.hpp.

◆ resize_()

template<typename vec_t , typename OpFamilies >
void mm::RaggedShapeStorage< 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, 12, 7} the class will allocate space for shapes for 3 nodes with sizes 9, 12 and 7. The containers are zero initialized.

Definition at line 19 of file RaggedShapeStorage.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::RaggedShapeStorage< vec_t, OpFamilies >::supportSize ( int  node) const
inline

Returns support size of node-th node.

Definition at line 83 of file RaggedShapeStorage_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::RaggedShapeStorage< vec_t, OpFamilies >::base_t
private

Be friends with derived class.

Definition at line 70 of file RaggedShapeStorage_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_sizes_

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
Range<int> mm::RaggedShapeStorage< vec_t, OpFamilies >::support_sizes_
private

Support sizes.

Definition at line 62 of file RaggedShapeStorage_fwd.hpp.

◆ support_starts_

template<typename vec_t , typename OpFamilies = std::tuple<Lap<vec_t::dim>, Der1s<vec_t::dim>, Der2s<vec_t::dim>>>
Range<int> mm::RaggedShapeStorage< vec_t, OpFamilies >::support_starts_
private

Indexes of starts of supports. Cumulative sums of support_sizes_.

Definition at line 64 of file RaggedShapeStorage_fwd.hpp.

◆ total_size_

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

Sum of all support sizes.

Definition at line 66 of file RaggedShapeStorage_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