AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
Constraints.hpp
1 #pragma once
2 
3 #include <amdis/Output.hpp>
4 #include <amdis/linearalgebra/Constraints.hpp>
5 #include <amdis/linearalgebra/istl/MatrixBackend.hpp>
6 #include <amdis/linearalgebra/istl/VectorBackend.hpp>
7 
8 namespace AMDiS
9 {
10  template <class T, class C>
12  {
14  using Vector = ISTLBlockVector<T>;
15 
16  template <class BitVector>
17  static void dirichletBC(Matrix& mat, Vector& sol, Vector& rhs, BitVector const& nodes, bool setDiagonal = true)
18  {
19  // loop over the matrix rows
20  for (std::size_t i = 0; i < mat.matrix().N(); ++i) {
21  if (nodes[i]) {
22  auto cIt = mat.matrix()[i].begin();
23  auto cEndIt = mat.matrix()[i].end();
24  // loop over nonzero matrix entries in current row
25  for (; cIt != cEndIt; ++cIt)
26  *cIt = (setDiagonal && i == cIt.index() ? T(1) : T(0));
27  }
28  }
29 
30  // copy solution dirichlet data to rhs vector
31  for (std::size_t i = 0; i < sol.vector().size(); ++i) {
32  if (nodes[i])
33  rhs.vector()[i] = sol.vector()[i];
34  }
35  }
36 
37  template <class BitVector, class Associations>
38  static void periodicBC(Matrix& mat, Vector& sol, Vector& rhs, BitVector const& left, Associations const& left2right,
39  bool setDiagonal = true)
40  {
41  error_exit("Not implemented");
42  }
43  };
44 
45 } // end namespace AMDiS
BaseMatrix const & matrix() const
Return the data-vector vector.
Definition: MatrixBackend.hpp:51
void error_exit(std::string const &str, Args &&... args)
print a message and exit
Definition: Output.hpp:142
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
BaseVector const & vector() const
Return the data-vector vector.
Definition: VectorBackend.hpp:54
Definition: MatrixBackend.hpp:28
Definition: Constraints.hpp:13
Definition: VectorBackend.hpp:26