16 #ifndef dealii_constrained_linear_operator_h 17 #define dealii_constrained_linear_operator_h 19 #include <deal.II/lac/linear_operator.h> 20 #include <deal.II/lac/packaged_operation.h> 21 #include <deal.II/lac/constraint_matrix.h> 24 DEAL_II_NAMESPACE_OPEN
62 template <
typename Range,
typename Domain>
69 return_op.
vmult_add = [&constraint_matrix](Range &v,
const Domain &u)
72 ::
ExcMessage(
"The domain and range vectors must be different " 73 "storage locations"));
79 const auto &locally_owned_elements = v.locally_owned_elements();
80 for (
const auto &line : constraint_matrix.
get_lines())
82 const auto i = line.index;
83 if (locally_owned_elements.is_element(i))
86 const auto &entries = line.entries;
89 const auto pos = entries[j].first;
90 v(i) += u(pos) * entries[j].second;
98 return_op.
Tvmult_add = [&constraint_matrix](Domain &v,
const Range &u)
101 ::
ExcMessage(
"The domain and range vectors must be different " 102 "storage locations"));
108 const auto &locally_owned_elements = v.locally_owned_elements();
109 for (
const auto &line : constraint_matrix.
get_lines())
111 const auto i = line.index;
113 if (locally_owned_elements.is_element(i))
118 const auto &entries = line.entries;
121 const auto pos = entries[j].first;
122 if (locally_owned_elements.is_element(pos))
123 v(pos) += u(i) * entries[j].second;
131 const auto vmult_add = return_op.
vmult_add;
132 return_op.
vmult = [vmult_add](Range &v,
const Domain &u)
140 return_op.
Tvmult = [Tvmult_add](Domain &v,
const Range &u)
161 template <
typename Range,
typename Domain>
168 return_op.
vmult_add = [&constraint_matrix](Range &v,
const Domain &u)
170 const auto &locally_owned_elements = v.locally_owned_elements();
171 for (
const auto &line : constraint_matrix.
get_lines())
173 const auto i = line.index;
174 if (locally_owned_elements.is_element(i))
183 return_op.
Tvmult_add = [&constraint_matrix](Domain &v,
const Range &u)
185 const auto &locally_owned_elements = v.locally_owned_elements();
186 for (
const auto &line : constraint_matrix.
get_lines())
188 const auto i = line.index;
189 if (locally_owned_elements.is_element(i))
199 const auto vmult_add = return_op.
vmult_add;
200 return_op.
vmult = [vmult_add](Range &v,
const Domain &u)
208 return_op.
Tvmult = [Tvmult_add](Domain &v,
const Range &u)
255 template <
typename Range,
typename Domain>
265 return Ct * linop * C + Id_c;
303 template <
typename Range,
typename Domain>
307 const Range &right_hand_side)
314 [&constraint_matrix, &linop, &right_hand_side](Range &v)
322 linop.reinit_domain_vector(*k,
false);
325 v += Ct * (right_hand_side - linop **k);
329 const auto apply_add = return_comp.
apply_add;
330 return_comp.
apply = [apply_add](Range &v)
341 DEAL_II_NAMESPACE_CLOSE
std::function< void(Range &v)> apply
LinearOperator< Range, Domain > project_to_constrained_linear_operator(const ConstraintMatrix &constraint_matrix, const LinearOperator< Range, Domain > &exemplar)
std::function< void(Range &v, bool omit_zeroing_entries)> reinit_vector
std::function< void(Range &v, bool omit_zeroing_entries)> reinit_range_vector
std::function< void(Domain &v, const Range &u)> Tvmult_add
std::function< void(Domain &v, const Range &u)> Tvmult
LinearOperator< Domain, Range, Payload > transpose_operator(const LinearOperator< Range, Domain, Payload > &op)
static ::ExceptionBase & ExcMessage(std::string arg1)
LinearOperator< Range, Domain > constrained_linear_operator(const ConstraintMatrix &constraint_matrix, const LinearOperator< Range, Domain > &linop)
PackagedOperation< Range > constrained_right_hand_side(const ConstraintMatrix &constraint_matrix, const LinearOperator< Range, Domain > &linop, const Range &right_hand_side)
unsigned int global_dof_index
#define Assert(cond, exc)
std::function< void(Range &v, const Domain &u)> vmult
std::function< void(Range &v)> apply_add
void distribute(VectorType &vec) const
std::function< void(Range &v, const Domain &u)> vmult_add
LinearOperator< Range, Domain > distribute_constraints_linear_operator(const ConstraintMatrix &constraint_matrix, const LinearOperator< Range, Domain > &exemplar)
const LineRange get_lines() const
static bool equal(const T *p1, const T *p2)