OGS
|
Manages storage for matrices and vectors.
This is a simple implementation of the MatrixProvider and VectorProvider interfaces.
It is simple insofar it does not reuse released matrices/vectors, but keeps them in memory until they are acquired again by the user.
Definition at line 29 of file SimpleMatrixVectorProvider.h.
#include <SimpleMatrixVectorProvider.h>
Public Member Functions | |
SimpleMatrixVectorProvider ()=default | |
SimpleMatrixVectorProvider (SimpleMatrixVectorProvider const &)=delete | |
SimpleMatrixVectorProvider & | operator= (SimpleMatrixVectorProvider const &)=delete |
GlobalVector & | getVector (std::size_t &id) override |
Get an uninitialized vector with the given id . | |
GlobalVector & | getVector (GlobalVector const &x) override |
Get a copy of x . | |
GlobalVector & | getVector (GlobalVector const &x, std::size_t &id) override |
Get a copy of x in the storage of the vector with the given id . | |
GlobalVector & | getVector (MathLib::MatrixSpecifications const &ms) override |
Get a vector according to the given specifications. | |
GlobalVector & | getVector (MathLib::MatrixSpecifications const &ms, std::size_t &id) override |
void | releaseVector (GlobalVector const &x) override |
GlobalMatrix & | getMatrix (std::size_t &id) override |
Get an uninitialized matrix with the given id . | |
GlobalMatrix & | getMatrix (MathLib::MatrixSpecifications const &ms, std::size_t &id) override |
void | releaseMatrix (GlobalMatrix const &A) override |
void | clear () |
~SimpleMatrixVectorProvider () override | |
Public Member Functions inherited from NumLib::MatrixProvider | |
virtual | ~MatrixProvider ()=default |
Public Member Functions inherited from NumLib::VectorProvider | |
virtual | ~VectorProvider ()=default |
Private Member Functions | |
template<typename... Args> | |
std::pair< GlobalMatrix *, bool > | getMatrix_ (std::size_t &id, Args &&... args) |
template<typename... Args> | |
std::pair< GlobalVector *, bool > | getVector_ (std::size_t &id, Args &&... args) |
template<typename MatVec , typename... Args> | |
std::pair< MatVec *, bool > | get_ (std::size_t &id, std::map< MatVec *, std::size_t > &used_map, Args &&... args) |
Private Attributes | |
std::size_t | _next_id = 1 |
std::map< GlobalMatrix *, std::size_t > | _used_matrices |
std::map< GlobalVector *, std::size_t > | _used_vectors |
|
default |
|
delete |
|
override |
Definition at line 167 of file SimpleMatrixVectorProvider.cpp.
References clear().
void NumLib::SimpleMatrixVectorProvider::clear | ( | ) |
Definition at line 137 of file SimpleMatrixVectorProvider.cpp.
References _used_matrices, _used_vectors, and WARN().
Referenced by ~SimpleMatrixVectorProvider().
|
private |
Definition at line 25 of file SimpleMatrixVectorProvider.cpp.
References _next_id.
Referenced by getMatrix_(), and getVector_().
|
overridevirtual |
Get a matrix according to the given specifications in the storage of the matrix with the given id
.
Implements NumLib::MatrixProvider.
Definition at line 49 of file SimpleMatrixVectorProvider.cpp.
References getMatrix_().
|
overridevirtual |
Get an uninitialized matrix with the given id
.
Implements NumLib::MatrixProvider.
Definition at line 44 of file SimpleMatrixVectorProvider.cpp.
References getMatrix_().
|
private |
Definition at line 38 of file SimpleMatrixVectorProvider.cpp.
References _used_matrices, and get_().
Referenced by getMatrix(), and getMatrix().
|
overridevirtual |
Get a copy of x
.
Implements NumLib::VectorProvider.
Definition at line 99 of file SimpleMatrixVectorProvider.cpp.
References MathLib::LinAlg::copy(), and getVector_().
|
overridevirtual |
Get a copy of x
in the storage of the vector with the given id
.
Implements NumLib::VectorProvider.
Definition at line 110 of file SimpleMatrixVectorProvider.cpp.
References MathLib::LinAlg::copy(), and getVector_().
|
overridevirtual |
Get a vector according to the given specifications.
Implements NumLib::VectorProvider.
Definition at line 84 of file SimpleMatrixVectorProvider.cpp.
References getVector_().
|
overridevirtual |
Get a vector according to the given specifications in the storage of the vector with the given id
.
Implements NumLib::VectorProvider.
Definition at line 92 of file SimpleMatrixVectorProvider.cpp.
References getVector_().
|
overridevirtual |
Get an uninitialized vector with the given id
.
Implements NumLib::VectorProvider.
Definition at line 79 of file SimpleMatrixVectorProvider.cpp.
References getVector_().
|
private |
Definition at line 73 of file SimpleMatrixVectorProvider.cpp.
References _used_vectors, and get_().
Referenced by getVector(), getVector(), getVector(), getVector(), and getVector().
|
delete |
|
overridevirtual |
Release the given matrix.
A
must have been acquired before, i.e., you must not call this method twice in a row in the same A!
Implements NumLib::MatrixProvider.
Definition at line 56 of file SimpleMatrixVectorProvider.cpp.
References _used_matrices, and OGS_FATAL.
|
overridevirtual |
Release the given vector.
x
must have been acquired before, i.e., you must not call this method twice in a row in the same x!
Implements NumLib::VectorProvider.
Definition at line 121 of file SimpleMatrixVectorProvider.cpp.
References _used_vectors, and OGS_FATAL.
|
private |
Definition at line 77 of file SimpleMatrixVectorProvider.h.
Referenced by get_().
|
private |
Definition at line 79 of file SimpleMatrixVectorProvider.h.
Referenced by clear(), getMatrix_(), and releaseMatrix().
|
private |
Definition at line 81 of file SimpleMatrixVectorProvider.h.
Referenced by clear(), getVector_(), and releaseVector().