6#include <boost/numeric/mtl/matrix/compressed2D.hpp>
7#include <boost/numeric/mtl/matrix/inserter.hpp>
8#include <boost/numeric/mtl/utility/property_map.hpp>
9#include <boost/numeric/mtl/utility/range_wrapper.hpp>
11#include <amdis/linearalgebra/Constraints.hpp>
12#include <amdis/linearalgebra/SymmetryStructure.hpp>
13#include <amdis/linearalgebra/mtl/MatrixBackend.hpp>
14#include <amdis/linearalgebra/mtl/VectorBackend.hpp>
24 template <
class BitVector,
class Associations>
25 static void periodicBC(
Matrix& mat,
Vector& sol,
Vector& rhs, BitVector
const& left, Associations
const& left2right,
bool setDiagonal =
true)
27 SymmetryStructure
const symmetry = mat.
symmetry();
28 if (symmetry == SymmetryStructure::spd ||
29 symmetry == SymmetryStructure::symmetric ||
30 symmetry == SymmetryStructure::hermitian)
31 symmetricPeriodicBC(mat.
matrix(), sol.
vector(), rhs.
vector(), left, left2right, setDiagonal);
33 unsymmetricPeriodicBC(mat.
matrix(), sol.
vector(), rhs.
vector(), left, left2right, setDiagonal);
37 template <
class Mat,
class Vec,
class BitVector,
class Associations>
38 static void symmetricPeriodicBC(Mat& mat, Vec& sol, Vec& rhs, BitVector
const& left, Associations
const& left2right,
bool setDiagonal =
true)
40 error_exit(
"Not implemented");
44 template <
class Value>
51 template <
class Mat,
class Vec,
class BitVector,
class Associations>
52 static void unsymmetricPeriodicBC(Mat& mat, Vec& sol, Vec& rhs, BitVector
const& left, Associations
const& left2right,
bool setDiagonal =
true)
54 std::vector<Triplet<typename Mat::value_type>> rowValues;
55 rowValues.reserve(left2right.size()*std::size_t(mat.nnz()/(0.9*num_rows(mat))));
59 auto col = mtl::mat::col_map(mat);
60 auto value = mtl::mat::value_map(mat);
63 std::size_t slotSize = 0;
64 for (
auto r : mtl::rows_of(mat)) {
65 if (left[r.value()]) {
66 slotSize = std::max(slotSize, std::size_t(mat.nnz_local(r.value())));
67 std::size_t right = left2right.at(r.value());
69 for (
auto i : mtl::nz_of(r)) {
70 rowValues.push_back({right,col(i),value(i)});
76 mtl::mat::inserter<Mat, mtl::update_plus<typename Mat::value_type> > ins(mat, 2*slotSize);
77 for (
auto const& t : rowValues)
78 ins[t.row][t.col] += t.value;
80 for (std::size_t i = 0; i < mtl::size(left); ++i) {
82 std::size_t j = left2right.at(i);
The basic container that stores a base matrix.
Definition: MatrixBackend.hpp:25
SymmetryStructure symmetry() const
Symmetry of the matrix entries.
Definition: MatrixBackend.hpp:244
BaseMatrix & matrix()
Return a reference to the data-matrix matrix.
Definition: MatrixBackend.hpp:49
The basic container that stores a base vector data.
Definition: VectorBackend.hpp:20
BaseVector const & vector() const
Return the data-vector vector_.
Definition: VectorBackend.hpp:43
Definition: Constraints.hpp:14