19 virtual std::unique_ptr<MatrixCache>
copy()
const = 0;
21 virtual void init(
const size_t size) = 0;
22 virtual void init(
const size_t rows,
const size_t cols) = 0;
27 virtual void reserve(
const size_t size) = 0;
35 virtual void add_value(
const int e,
const int i,
const int j,
const double value) = 0;
53 inline std::unique_ptr<MatrixCache>
copy()
const override
56 return std::make_unique<SparseMatrixCache>(*
this,
true);
60 void init(
const size_t size)
override;
62 void init(
const size_t rows,
const size_t cols)
override;
77 inline bool is_sparse()
const override {
return true; }
85 void add_value(
const int e,
const int i,
const int j,
const double value)
override;
96 void prune()
override;
110 std::vector<std::vector<std::pair<int, size_t>>>
mapping_;
125 inline const std::vector<std::vector<std::pair<int, size_t>>> &
mapping()
const
145 inline std::unique_ptr<MatrixCache>
copy()
const override
147 return std::make_unique<DenseMatrixCache>(*
this);
150 void init(
const size_t size)
override;
151 void init(
const size_t rows,
const size_t cols)
override;
157 inline void reserve(
const size_t size)
override {}
162 inline bool is_sparse()
const override {
return false; }
164 void add_value(
const int e,
const int i,
const int j,
const double value)
override;
166 void prune()
override;
173 const Eigen::MatrixXd &
mat()
const {
return mat_; }
size_t entries_size() const override
std::shared_ptr< MatrixCache > operator+(const MatrixCache &a) const override
size_t non_zeros() const override
const Eigen::MatrixXd & mat() const
void init(const size_t size) override
StiffnessMatrix get_matrix(const bool compute_mapping=true) override
size_t capacity() const override
void add_value(const int e, const int i, const int j, const double value) override
bool is_sparse() const override
size_t triplet_count() const override
std::unique_ptr< MatrixCache > copy() const override
void reserve(const size_t size) override
void operator+=(const MatrixCache &o) override
abstract class used for caching
virtual void add_value(const int e, const int i, const int j, const double value)=0
virtual size_t triplet_count() const =0
virtual ~MatrixCache()=default
virtual void init(const MatrixCache &other)=0
virtual size_t entries_size() const =0
virtual void operator+=(const MatrixCache &o)=0
virtual void reserve(const size_t size)=0
virtual void set_zero()=0
virtual StiffnessMatrix get_matrix(const bool compute_mapping=true)=0
virtual void init(const size_t rows, const size_t cols)=0
virtual bool is_sparse() const =0
virtual std::shared_ptr< MatrixCache > operator+(const MatrixCache &a) const =0
virtual size_t capacity() const =0
virtual size_t non_zeros() const =0
virtual std::unique_ptr< MatrixCache > copy() const =0
virtual void init(const size_t size)=0
void operator+=(const MatrixCache &o) override
void add_value(const int e, const int i, const int j, const double value) override
e = element_index, i = global row_index, j = global column_index, value = value to add to matrix if t...
void set_zero() override
set matrix values to zero modifies tmp_, mat_, and values (setting all to zero)
size_t non_zeros() const override
size_t triplet_count() const override
std::vector< int > outer_index_
saves inner/outer indices for sparse matrix
void prune() override
if caches have yet to be constructed, add the saved triplets to mat_ modifies tmp_ and mat_,...
const SparseMatrixCache * main_cache_
size_t capacity() const override
std::shared_ptr< MatrixCache > operator+(const MatrixCache &a) const override
const std::vector< std::vector< std::pair< int, size_t > > > & mapping() const
std::vector< std::vector< std::pair< int, int > > > second_cache_entries_
maps element indices to global matrix indices
size_t entries_size() const override
const SparseMatrixCache * main_cache() const
size_t mapping_size() const
bool is_sparse() const override
std::vector< double > values_
buffer for values (corresponds to inner/outer_index_ structure for sparse matrix)
const StiffnessMatrix & mat() const
const std::vector< std::vector< int > > & second_cache() const
std::vector< Eigen::Triplet< double > > entries_
contains global matrix indices and corresponding value
std::vector< int > inner_index_
StiffnessMatrix get_matrix(const bool compute_mapping=true) override
if the cache is yet to be constructed, save the cached (ordered) indices in inner_index_ and outer_in...
void reserve(const size_t size) override
const std::vector< Eigen::Triplet< double > > & entries() const
void init(const size_t size) override
set matrix to be size x size
std::unique_ptr< MatrixCache > copy() const override
std::vector< std::vector< int > > second_cache_
maps element index to local index
std::vector< std::vector< std::pair< int, size_t > > > mapping_
maps row indices to column index/local index pairs
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix