Metafunction for generating a discretization stencil. More...
#include <stencil.hpp>
Classes | |
struct | item_type |
Public Types | |
using | value_type = value_t |
using | weight_manager_type = DiscreteStencilWeightManager<weight_t, value_t> |
using | weight_type = weight_t |
Public Member Functions | |
DiscreteStencil (const weight_t &zero=weight_t()) | |
DiscreteStencil (std::size_t nItems, const weight_t &zero=weight_t()) | |
DiscreteStencil (std::size_t size, const long *pattern, const weight_t &zero=weight_t()) | |
DiscreteStencil (std::size_t size, const long *pattern, const weight_t *weights, const weight_t &zero=weight_t()) | |
void | addComplementToZero (long id) |
void | appendItem (long id, const weight_t &weight) |
void | appendItem (long id, weight_t &&weight) |
weight_t & | at (long id) |
const weight_t & | at (long id) const |
void | clear (bool release=false) |
void | display (std::ostream &out, double factor=1.) const |
size_t | getBinarySize () const |
weight_t & | getConstant () |
const weight_t & | getConstant () const |
long & | getPattern (std::size_t pos) |
const long & | getPattern (std::size_t pos) const |
weight_t & | getWeight (std::size_t pos) |
const weight_t & | getWeight (std::size_t pos) const |
void | initialize (const DiscreteStencil< weight_t, value_t > &other) |
void | initialize (std::size_t nItems, const weight_t &zero=weight_t()) |
void | initialize (std::size_t size, const long *pattern, const weight_t &zero=weight_t()) |
void | initialize (std::size_t size, const long *pattern, const weight_t *weights, const weight_t &zero=weight_t()) |
DiscreteStencil< weight_t, value_t > & | operator*= (double factor) |
DiscreteStencil< weight_t, value_t > & | operator+= (const DiscreteStencil< weight_t, value_t > &other) |
DiscreteStencil< weight_t, value_t > & | operator-= (const DiscreteStencil< weight_t, value_t > &other) |
DiscreteStencil< weight_t, value_t > & | operator/= (double factor) |
weight_t & | operator[] (long id) |
void | optimize (double tolerance=1.e-12) |
long * | patternData () |
const long * | patternData () const |
template<typename Mapper > | |
void | renumber (const Mapper &mapper) |
void | renumber (const std::unordered_map< long, long > &map) |
void | reserve (std::size_t nItems) |
void | resize (std::size_t nItems) |
void | setConstant (const weight_t &constant) |
void | setConstant (weight_t &&constant) |
void | setItem (std::size_t pos, long id, const weight_t &weight) |
void | setItem (std::size_t pos, long id, weight_t &&weight) |
void | setPattern (std::size_t pos, long id) |
void | setWeight (std::size_t pos, const weight_t &weight) |
void | setWeight (std::size_t pos, weight_t &&weight) |
std::size_t | size () const |
void | sum (const DiscreteStencil< weight_t, value_t > &other, double factor) |
void | sumConstant (const weight_t &constant, double factor=1.) |
void | sumItem (long id, const weight_t &weight, double factor=1.) |
void | sumWeight (std::size_t pos, const weight_t &weight, double factor=1.) |
weight_t * | weightData () |
const weight_t * | weightData () const |
void | zero () |
void | zeroConstant () |
void | zeroWeight (std::size_t pos) |
Static Public Member Functions | |
static const weight_manager_type & | getWeightManager () |
Public Attributes | |
long | NULL_ID = - std::numeric_limits<long>::max() |
Protected Member Functions | |
virtual void | appendWeight (const weight_t &weight) |
virtual void | appendWeight (weight_t &&weight) |
virtual void | clearWeights (bool release) |
Protected Attributes | |
weight_t | m_constant |
std::vector< long > | m_pattern |
std::vector< weight_t > | m_weights |
weight_t | m_zero |
Static Protected Attributes | |
static const weight_manager_type | m_weightManager = typename DiscreteStencil<weight_t>::weight_manager_type() |
Friends | |
template<typename W , typename V > | |
OBinaryStream & | operator<<) (OBinaryStream &buffer, const DiscreteStencil< W, V > &stencil) |
template<typename W , typename V > | |
IBinaryStream & | operator>>) (IBinaryStream &buffer, DiscreteStencil< W, V > &stencil) |
Metafunction for generating a discretization stencil.
weight_t | is the type of the weights stored in the stencil |
Definition at line 59 of file stencil.hpp.
using bitpit::DiscreteStencil< weight_t, value_t >::value_type = value_t |
Definition at line 72 of file stencil.hpp.
using bitpit::DiscreteStencil< weight_t, value_t >::weight_manager_type = DiscreteStencilWeightManager<weight_t, value_t> |
Definition at line 70 of file stencil.hpp.
using bitpit::DiscreteStencil< weight_t, value_t >::weight_type = weight_t |
Definition at line 69 of file stencil.hpp.
bitpit::DiscreteStencil< weight_t, value_t >::DiscreteStencil | ( | const weight_t & | zero = weight_t() | ) |
Constructor
zero | is the value to be used as zero |
Definition at line 108 of file stencil.tpp.
bitpit::DiscreteStencil< weight_t, value_t >::DiscreteStencil | ( | std::size_t | size, |
const weight_t & | zero = weight_t() ) |
Constructor
size | is the stencil size, expressed in number of elements |
zero | is the value to be used as zero |
Definition at line 120 of file stencil.tpp.
bitpit::DiscreteStencil< weight_t, value_t >::DiscreteStencil | ( | std::size_t | size, |
const long * | pattern, | ||
const weight_t & | zero = weight_t() ) |
Constructor
size | is the stencil size, expressed in number of elements |
pattern | is the patterns of the stencil |
zero | is the value to be used as zero |
Definition at line 135 of file stencil.tpp.
bitpit::DiscreteStencil< weight_t, value_t >::DiscreteStencil | ( | std::size_t | size, |
const long * | pattern, | ||
const weight_t * | weights, | ||
const weight_t & | zero = weight_t() ) |
Constructor
size | is the stencil size, expressed in number of elements |
pattern | is the patterns of the stencil |
weights | are the weights of the stencil |
zero | is the value to be used as zero |
Definition at line 151 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::addComplementToZero | ( | long | id | ) |
Add a new item that complements the stencil to zero.
id | is the index associated to the new item |
Definition at line 684 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::appendItem | ( | long | id, |
const weight_t & | weight ) |
Append an item the stencil.
The item will be appended to the stencil also if the stencil already contains an item with the same id.
id | is the index that will be set |
weight | is the weight that will be set |
Definition at line 506 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::appendItem | ( | long | id, |
weight_t && | weight ) |
Append an item the stencil.
The item will be appended to the stencil also if the stencil already contains an item with the same id.
id | is the index that will be set |
weight | is the weight that will be set |
Definition at line 522 of file stencil.tpp.
|
protectedvirtual |
Append a weight to the stencil.
weight | is the weight that will be appended |
Reimplemented in bitpit::MPDiscreteStencil< weight_t, value_t >.
Definition at line 771 of file stencil.tpp.
|
protectedvirtual |
Append a weight to the stencil.
weight | is the weight that will be appended |
Definition at line 760 of file stencil.tpp.
weight_t & bitpit::DiscreteStencil< weight_t, value_t >::at | ( | long | id | ) |
Get a reference to a weight associated with an item with the specified index.
If there are no items with the specified index, an exception will be thrown. If there are multiple items associated with the specified id, the first one will be returned.
id | is the index associated to the item |
Definition at line 843 of file stencil.tpp.
const weight_t & bitpit::DiscreteStencil< weight_t, value_t >::at | ( | long | id | ) | const |
Get a constant reference to a weight associated with an item with the specified index.
If there are no items with the specified index, an exception will be thrown. If there are multiple items associated with the specified id, the first one will be returned.
id | is the index associated to the item |
Definition at line 860 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::clear | ( | bool | release = false | ) |
Clears the items of the stencil.
Removes all items from the stencil (which are destroyed), leaving it with a size of 0.
release | if it's true the memory hold by the stencil will be released, otherwise the stencil will be cleared but its memory will not be relased |
Definition at line 604 of file stencil.tpp.
|
protectedvirtual |
Clears the weights of the stencil.
Removes all weights from the stencil (which are destroyed), leaving the weight container with a size of 0.
release | if it's true the memory hold by the weight container will be released, otherwise the weight container will be cleared but its memory will not be relased |
Reimplemented in bitpit::MPDiscreteStencil< weight_t, value_t >.
Definition at line 787 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::display | ( | std::ostream & | out, |
double | factor = 1. ) const |
Display the stencil.
out | is the stream that will be used for the output |
factor | is an optional factor the weights will be muliplied for |
Definition at line 802 of file stencil.tpp.
size_t bitpit::DiscreteStencil< weight_t, value_t >::getBinarySize | ( | ) | const |
Returns the buffer size (in bytes) required to store the stencil.
Definition at line 824 of file stencil.tpp.
weight_t & bitpit::DiscreteStencil< weight_t, value_t >::getConstant | ( | ) |
Get a reference to the constant associated to the stencil.
Definition at line 545 of file stencil.tpp.
const weight_t & bitpit::DiscreteStencil< weight_t, value_t >::getConstant | ( | ) | const |
Get a constant reference to the constant associated to the stencil.
Definition at line 534 of file stencil.tpp.
long & bitpit::DiscreteStencil< weight_t, value_t >::getPattern | ( | std::size_t | pos | ) |
Get a reference to the specified element of the pattern.
pos | is the position of the pattern element |
Definition at line 298 of file stencil.tpp.
const long & bitpit::DiscreteStencil< weight_t, value_t >::getPattern | ( | std::size_t | pos | ) | const |
Get a constant reference to the specified element of the pattern.
pos | is the position of the pattern element |
Definition at line 310 of file stencil.tpp.
weight_t & bitpit::DiscreteStencil< weight_t, value_t >::getWeight | ( | std::size_t | pos | ) |
Get a reference to the specified weight of the stencil.
pos | is the position of the weight |
Definition at line 357 of file stencil.tpp.
const weight_t & bitpit::DiscreteStencil< weight_t, value_t >::getWeight | ( | std::size_t | pos | ) | const |
Get a constant reference to the specified weight of the stencil.
pos | is the position of the weight |
Definition at line 369 of file stencil.tpp.
|
static |
Get a constant reference to the weight manager.
Definition at line 42 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::initialize | ( | const DiscreteStencil< weight_t, value_t > & | other | ) |
Initialize the stencil.
other | is another stencil of the same time, whose items will be used to initialize this stencil |
Definition at line 248 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::initialize | ( | std::size_t | size, |
const weight_t & | zero = weight_t() ) |
Initialize the stencil.
size | is the stencil size, expressed in number of elements |
zero | is the value to be used as zero |
Definition at line 165 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::initialize | ( | std::size_t | size, |
const long * | pattern, | ||
const weight_t & | zero = weight_t() ) |
Initialize the stencil.
size | is the stencil size, expressed in number of elements |
pattern | is the patterns of the stencil |
zero | is the value to be used as zero |
Definition at line 190 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::initialize | ( | std::size_t | size, |
const long * | pattern, | ||
const weight_t * | weights, | ||
const weight_t & | zero = weight_t() ) |
Initialize the stencil.
size | is the stencil size, expressed in number of elements |
pattern | is the patterns of the stencil |
weights | are the weights of the stencil |
zero | is the value to be used as zero |
Definition at line 219 of file stencil.tpp.
DiscreteStencil< weight_t, value_t > & bitpit::DiscreteStencil< weight_t, value_t >::operator*= | ( | double | factor | ) |
The binary multiplication assignment operator.
factor | is the factor of the multiplication |
Definition at line 901 of file stencil.tpp.
DiscreteStencil< weight_t, value_t > & bitpit::DiscreteStencil< weight_t, value_t >::operator+= | ( | const DiscreteStencil< weight_t, value_t > & | other | ) |
The binary sum assignment operator.
other | is the stencil that will be summed |
Definition at line 935 of file stencil.tpp.
DiscreteStencil< weight_t, value_t > & bitpit::DiscreteStencil< weight_t, value_t >::operator-= | ( | const DiscreteStencil< weight_t, value_t > & | other | ) |
The binary subtraction assignment operator.
other | is the stencil that will be subtracted |
Definition at line 949 of file stencil.tpp.
DiscreteStencil< weight_t, value_t > & bitpit::DiscreteStencil< weight_t, value_t >::operator/= | ( | double | factor | ) |
The binary division assignment operator.
factor | is the factor of the division |
Definition at line 918 of file stencil.tpp.
weight_t & bitpit::DiscreteStencil< weight_t, value_t >::operator[] | ( | long | id | ) |
Get a reference to a weight associated with an item with the specified index.
If there are no items with the specified id, a new empty item will be added to the stencil and its reference will be returned. If there are multiple items associated with the specified id, the first one will be returned.
id | is the index associated to the item |
Definition at line 882 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::optimize | ( | double | tolerance = 1.e-12 | ) |
Optimize the stencil.
The negligible elements will be removed from the stencil.
Definition at line 639 of file stencil.tpp.
long * bitpit::DiscreteStencil< weight_t, value_t >::patternData | ( | ) |
Get a pointer to the underlying array serving as pattern storage.
Definition at line 321 of file stencil.tpp.
const long * bitpit::DiscreteStencil< weight_t, value_t >::patternData | ( | ) | const |
Get a constant pointer to the underlying array serving as pattern storage.
Definition at line 333 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::renumber | ( | const Mapper & | map | ) |
Renumber the indexes of the stencil according to the specified map.
map | is the functor that will perform the mapping, the functor should have an operator() that take as an argument the original id and return the renumbered id. |
Definition at line 671 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::renumber | ( | const std::unordered_map< long, long > & | map | ) |
Renumber the indexes of the stencil according to the specified map.
map | is the renumbering map |
Definition at line 658 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::reserve | ( | std::size_t | capacity | ) |
Requests a change in capacity.
Requests that the stencil capacity be at least the specified value.
capacity | is the minimum number of items that the stencil should be able to contain |
Definition at line 285 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::resize | ( | std::size_t | size | ) |
Resizes the container so that it contains the specified number of items.
size | is the new stencil size, expressed in number of elements |
Definition at line 270 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::setConstant | ( | const weight_t & | constant | ) |
Set the value of the constant associated to the stencil.
constant | is the constant that will be set |
Definition at line 556 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::setConstant | ( | weight_t && | constant | ) |
Set the value of the constant associated to the stencil.
constant | is the constant that will be set |
Definition at line 567 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::setItem | ( | std::size_t | pos, |
long | id, | ||
const weight_t & | weight ) |
Set the specified item of the stencil.
pos | is the position of the weight |
id | is the index that will be set |
weight | is the weight that will be set |
Definition at line 452 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::setItem | ( | std::size_t | pos, |
long | id, | ||
weight_t && | weight ) |
Set the specified item of the stencil.
pos | is the position of the weight |
id | is the index that will be set |
weight | is the weight that will be set |
Definition at line 466 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::setPattern | ( | std::size_t | pos, |
long | id ) |
Set the index of the specified element of the pattern.
pos | is the position of the pattern element |
id | is the index that will be set |
Definition at line 345 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::setWeight | ( | std::size_t | pos, |
const weight_t & | weight ) |
Set the value of the specified weight of the stencil.
pos | is the position of the weight |
weight | is the value that will be set |
Definition at line 403 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::setWeight | ( | std::size_t | pos, |
weight_t && | weight ) |
Set the value of the specified weight of the stencil.
pos | is the position of the weight |
weight | is the value that will be set |
Definition at line 415 of file stencil.tpp.
std::size_t bitpit::DiscreteStencil< weight_t, value_t >::size | ( | ) | const |
Get the total size of the stencil, expressed in number of items.
Definition at line 259 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::sum | ( | const DiscreteStencil< weight_t, value_t > & | other, |
double | factor ) |
Sum the specified stencil.
other | is the stencil that will be summed |
factor | is the factor by which the other stencil will be multiplied |
Definition at line 623 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::sumConstant | ( | const weight_t & | constant, |
double | factor = 1. ) |
Sum the specified constant to the constant associated to the stencil.
constant | is the constant that will be summed |
factor | is the factor by which the constant will be multiplied |
Definition at line 579 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::sumItem | ( | long | id, |
const weight_t & | weight, | ||
double | factor = 1. ) |
Sum the given weight to the item of the stencil with the specified index.
If an item with the same id already exists, the given weight will be summed to the weight of the existing item. Otherwise, a new item will be appended.
id | is the index of the item |
weight | is the weight that will be summed |
factor | is the factor by which the weight will be multiplied |
Definition at line 483 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::sumWeight | ( | std::size_t | pos, |
const weight_t & | weight, | ||
double | factor = 1. ) |
Sum the given weight to the one at the specified position of the stencil.
pos | is the position of the weight |
weight | is the value that will be summed |
factor | is the factor by which the weight will be multiplied |
Definition at line 428 of file stencil.tpp.
weight_t * bitpit::DiscreteStencil< weight_t, value_t >::weightData | ( | ) |
Get a pointer to the underlying array serving as weight storage.
Definition at line 380 of file stencil.tpp.
const weight_t * bitpit::DiscreteStencil< weight_t, value_t >::weightData | ( | ) | const |
Get a constant pointer to the underlying array serving as weight storage.
Definition at line 391 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::zero | ( | ) |
Set weights and constant to zero.
Definition at line 703 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::zeroConstant | ( | ) |
Zero the constant associated to the stencil.
Definition at line 588 of file stencil.tpp.
void bitpit::DiscreteStencil< weight_t, value_t >::zeroWeight | ( | std::size_t | pos | ) |
Zeros the weight at the specified position of the stencil.
pos | is the position of the weight |
Definition at line 439 of file stencil.tpp.
|
protected |
Definition at line 160 of file stencil.hpp.
|
protected |
Definition at line 158 of file stencil.hpp.
|
staticprotected |
The weight manager.
Definition at line 155 of file stencil.hpp.
|
protected |
Definition at line 159 of file stencil.hpp.
|
protected |
Definition at line 157 of file stencil.hpp.
long bitpit::DiscreteStencil< weight_t, value_t >::NULL_ID = - std::numeric_limits<long>::max() |
Definition at line 67 of file stencil.hpp.