OGS
SimpleMatrixVectorProvider.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <map>
14#include <memory>
15
16#include "MatrixProvider.h"
17#include "VectorProvider.h"
18
19namespace NumLib
20{
30 public VectorProvider
31{
32public:
34
35 // no copies
38 delete;
39
40 GlobalVector& getVector(std::size_t& id) override;
41
42 GlobalVector& getVector(GlobalVector const& x) override;
43 GlobalVector& getVector(GlobalVector const& x, std::size_t& id) override;
44
47 std::size_t& id) override;
48
49 void releaseVector(GlobalVector const& x) override;
50
51 GlobalMatrix& getMatrix(std::size_t& id) override;
52
54 std::size_t& id) override;
55
56 void releaseMatrix(GlobalMatrix const& A) override;
57
58 void clear();
59
61
62private:
63 template <typename... Args>
64 std::pair<GlobalMatrix*, bool> getMatrix_(std::size_t& id, Args&&... args);
65
66 template <typename... Args>
67 std::pair<GlobalVector*, bool> getVector_(std::size_t& id, Args&&... args);
68
69 // returns a pair with the pointer to the matrix/vector and
70 // a boolean indicating if a new object has been built (then true else
71 // false)
72 template <typename MatVec, typename... Args>
73 std::pair<MatVec*, bool> get_(std::size_t& id,
74 std::map<MatVec*, std::size_t>& used_map,
75 Args&&... args);
76
77 std::size_t _next_id = 1;
78
79 std::map<GlobalMatrix*, std::size_t> _used_matrices;
80
81 std::map<GlobalVector*, std::size_t> _used_vectors;
82};
83
84} // namespace NumLib
Global vector based on Eigen vector.
Definition EigenVector.h:25
std::pair< GlobalVector *, bool > getVector_(std::size_t &id, Args &&... args)
void releaseVector(GlobalVector const &x) override
GlobalVector & getVector(std::size_t &id) override
Get an uninitialized vector with the given id.
std::pair< GlobalMatrix *, bool > getMatrix_(std::size_t &id, Args &&... args)
std::map< GlobalMatrix *, std::size_t > _used_matrices
SimpleMatrixVectorProvider(SimpleMatrixVectorProvider const &)=delete
SimpleMatrixVectorProvider & operator=(SimpleMatrixVectorProvider const &)=delete
std::pair< MatVec *, bool > get_(std::size_t &id, std::map< MatVec *, std::size_t > &used_map, Args &&... args)
GlobalMatrix & getMatrix(std::size_t &id) override
Get an uninitialized matrix with the given id.
std::map< GlobalVector *, std::size_t > _used_vectors
void releaseMatrix(GlobalMatrix const &A) override