16 #ifndef dealii_packaged_operation_h 17 #define dealii_packaged_operation_h 19 #include <deal.II/base/config.h> 21 #include <deal.II/base/exceptions.h> 23 #include <deal.II/lac/vector_memory.h> 27 DEAL_II_NAMESPACE_OPEN
30 template <
typename Number>
32 template <
typename Range,
typename Domain,
typename Payload>
34 template <
typename Range = Vector<
double>>
103 template <
typename Range>
114 apply = [](Range &) {
117 "Uninitialized PackagedOperation<Range>::apply called"));
123 "Uninitialized PackagedOperation<Range>::apply_add called"));
128 ExcMessage(
"Uninitialized PackagedOperation<Range>::reinit_vector " 170 apply = [&u](Range &v) { v = u; };
175 v.reinit(u, omit_zeroing_entries);
187 operator Range()
const 192 apply(result_vector);
194 return result_vector;
208 *
this = *
this + second_comp;
219 *
this = *
this - second_comp;
251 *
this = *
this * number;
260 std::function<void(Range &v)>
apply;
292 template <
typename Range>
304 return_comp.
apply = [first_comp, second_comp](Range &v) {
309 return_comp.
apply_add = [first_comp, second_comp](Range &v) {
325 template <
typename Range>
337 return_comp.
apply = [first_comp, second_comp](Range &v) {
338 second_comp.
apply(v);
343 return_comp.
apply_add = [first_comp, second_comp](Range &v) {
361 template <
typename Range>
363 typename Range::value_type number)
372 return_comp.
apply = [](Range &v) { v = 0.; };
378 return_comp.
apply = [comp, number](Range &v) {
383 return_comp.
apply_add = [comp, number](Range &v) {
401 template <
typename Range>
405 return comp * number;
416 template <
typename Range>
431 template <
typename Range>
446 template <
typename Range>
463 template <
typename Range>
480 namespace PackagedOperationImplementation
486 template <
typename T>
487 class has_vector_interface
489 template <
typename C>
490 static std::false_type
493 template <
typename C>
494 static std::true_type
495 test(decltype(&C::operator+=),
496 decltype(&C::operator-=),
497 decltype(&C::l2_norm));
503 using type = decltype(test<T>(
nullptr,
nullptr,
nullptr));
523 template <
typename Range,
524 typename =
typename std::enable_if<
525 internal::PackagedOperationImplementation::has_vector_interface<
526 Range>::type::value>::type>
535 return_comp.
reinit_vector = [&u](Range &x,
bool omit_zeroing_entries) {
536 x.reinit(u, omit_zeroing_entries);
539 return_comp.
apply = [&u, &v](Range &x) {
544 return_comp.
apply_add = [&u, &v](Range &x) {
568 template <
typename Range,
569 typename =
typename std::enable_if<
570 internal::PackagedOperationImplementation::has_vector_interface<
571 Range>::type::value>::type>
580 return_comp.
reinit_vector = [&u](Range &x,
bool omit_zeroing_entries) {
581 x.reinit(u, omit_zeroing_entries);
584 return_comp.
apply = [&u, &v](Range &x) {
589 return_comp.
apply_add = [&u, &v](Range &x) {
612 template <
typename Range,
613 typename =
typename std::enable_if<
614 internal::PackagedOperationImplementation::has_vector_interface<
615 Range>::type::value>::type>
617 typename Range::value_type number)
637 template <
typename Range,
638 typename =
typename std::enable_if<
639 internal::PackagedOperationImplementation::has_vector_interface<
640 Range>::type::value>::type>
664 template <
typename Range,
typename Domain,
typename Payload>
675 return_comp.
apply = [op, &u](Range &v) { op.
vmult(v, u); };
699 template <
typename Range,
typename Domain,
typename Payload>
710 return_comp.
apply = [op, &u](Domain &v) { op.
Tvmult(v, u); };
726 template <
typename Range,
typename Domain,
typename Payload>
738 return_comp.
apply = [op, comp](Domain &v) {
748 return_comp.
apply_add = [op, comp](Domain &v) {
770 template <
typename Range,
typename Domain,
typename Payload>
782 return_comp.
apply = [op, comp](Domain &v) {
792 return_comp.
apply_add = [op, comp](Domain &v) {
807 DEAL_II_NAMESPACE_CLOSE
PackagedOperation< Range > & operator+=(const PackagedOperation< Range > &second_comp)
PackagedOperation(const Range &u)
std::function< void(Range &v)> apply
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
PackagedOperation< Range > & operator-=(const PackagedOperation< Range > &second_comp)
SymmetricTensor< rank_, dim, typename ProductType< Number, OtherNumber >::type > operator+(const SymmetricTensor< rank_, dim, Number > &left, const SymmetricTensor< rank_, dim, OtherNumber > &right)
LinearAlgebra::distributed::Vector< Number > Vector
SymmetricTensor< rank_, dim, typename ProductType< Number, OtherNumber >::type > operator-(const SymmetricTensor< rank_, dim, Number > &left, const SymmetricTensor< rank_, dim, OtherNumber > &right)
PackagedOperation< Range > & operator=(const PackagedOperation< Range > &)=default
static ::ExceptionBase & ExcMessage(std::string arg1)
PackagedOperation< Range > & operator=(const Range &u)
#define Assert(cond, exc)
std::function< void(Range &v, const Domain &u)> vmult
std::function< void(Domain &v, bool omit_zeroing_entries)> reinit_domain_vector
PackagedOperation< Range > & operator*=(typename Range::value_type number)
std::function< void(Range &v)> apply_add
std::function< void(Range &v, const Domain &u)> vmult_add
PackagedOperation< Range > & operator+=(const Range &offset)
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator*(const OtherNumber) const
PackagedOperation< Range > & operator-=(const Range &offset)