16 #ifndef dealii__packaged_operation_h 17 #define dealii__packaged_operation_h 19 #include <deal.II/base/config.h> 20 #include <deal.II/base/exceptions.h> 21 #include <deal.II/lac/vector_memory.h> 23 #ifdef DEAL_II_WITH_CXX11 27 DEAL_II_NAMESPACE_OPEN
30 template <
typename Number>
class Vector;
31 template <
typename Range,
typename Domain,
typename Payload>
class LinearOperator;
111 ExcMessage(
"Uninitialized PackagedOperation<Range>::apply called"));
117 ExcMessage(
"Uninitialized PackagedOperation<Range>::apply_add called"));
123 ExcMessage(
"Uninitialized PackagedOperation<Range>::reinit_vector " 163 apply = [&u](Range &v)
175 v.reinit(u, omit_zeroing_entries);
187 operator Range()
const 192 apply(result_vector);
194 return result_vector;
207 *
this = *
this + second_comp;
217 *
this = *
this - second_comp;
246 *
this = *
this * number;
255 std::function<void(Range &v)>
apply;
287 template <
typename Range>
299 return_comp.
apply = [first_comp, second_comp](Range &v)
305 return_comp.
apply_add = [first_comp, second_comp](Range &v)
322 template <
typename Range>
334 return_comp.
apply = [first_comp, second_comp](Range &v)
336 second_comp.
apply(v);
341 return_comp.
apply_add = [first_comp, second_comp](Range &v)
360 template <
typename Range>
363 typename Range::value_type number)
372 return_comp.
apply = [](Range &v)
383 return_comp.
apply = [comp, number](Range &v)
389 return_comp.
apply_add = [comp, number](Range &v)
408 template <
typename Range>
413 return comp * number;
424 template <
typename Range>
439 template <
typename Range>
454 template <
typename Range>
471 template <
typename Range>
492 template <
typename T>
493 class has_vector_interface
495 template <
typename C>
496 static std::false_type test(...);
498 template <
typename C>
499 static std::true_type test(decltype(&C::operator+=),
500 decltype(&C::operator-=),
501 decltype(&C::l2_norm));
507 typedef decltype(test<T>(0, 0, 0)) type;
526 template <typename Range,
527 typename = typename
std::enable_if<has_vector_interface<Range>::type::value>::type>
535 return_comp.
reinit_vector = [&u](Range &x,
bool omit_zeroing_entries)
537 x.reinit(u, omit_zeroing_entries);
540 return_comp.
apply = [&u, &v](Range &x)
546 return_comp.
apply_add = [&u, &v](Range &x)
571 template <
typename Range,
572 typename =
typename std::enable_if<has_vector_interface<Range>::type::value>::type>
580 return_comp.
reinit_vector = [&u](Range &x,
bool omit_zeroing_entries)
582 x.reinit(u, omit_zeroing_entries);
585 return_comp.
apply = [&u, &v](Range &x)
591 return_comp.
apply_add = [&u, &v](Range &x)
615 template <
typename Range,
616 typename =
typename std::enable_if<has_vector_interface<Range>::type::value>::type>
618 typename Range::value_type number)
638 template <
typename Range,
639 typename =
typename std::enable_if<has_vector_interface<Range>::type::value>::type>
663 template <
typename Range,
typename Domain,
typename Payload>
675 return_comp.
apply = [op, &u](Range &v)
680 return_comp.
apply_add = [op, &u](Range &v)
705 template <
typename Range,
typename Domain,
typename Payload>
717 return_comp.
apply = [op, &u](Domain &v)
722 return_comp.
apply_add = [op, &u](Domain &v)
739 template <
typename Range,
typename Domain,
typename Payload>
751 return_comp.
apply = [op, comp](Domain &v)
755 Range *i = vector_memory.
alloc();
761 vector_memory.
free(i);
764 return_comp.
apply_add = [op, comp](Domain &v)
768 Range *i = vector_memory.
alloc();
774 vector_memory.
free(i);
789 template <
typename Range,
typename Domain,
typename Payload>
801 return_comp.
apply = [op, comp](Domain &v)
805 Range *i = vector_memory.
alloc();
811 vector_memory.
free(i);
814 return_comp.
apply_add = [op, comp](Domain &v)
818 Range *i = vector_memory.
alloc();
824 vector_memory.
free(i);
832 DEAL_II_NAMESPACE_CLOSE
834 #endif // DEAL_II_WITH_CXX11 PackagedOperation< Range > & operator+=(const PackagedOperation< Range > &second_comp)
PackagedOperation< Range > operator*(const LinearOperator< Range, Domain, Payload > &op, const PackagedOperation< Domain > &comp)
PackagedOperation< Range > operator*(const LinearOperator< Range, Domain, Payload > &op, const Domain &u)
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)
PackagedOperation< Range > operator*(const Range &u, typename Range::value_type number)
PackagedOperation< Range > operator+(const PackagedOperation< Range > &comp, const Range &offset)
PackagedOperation< Domain > operator*(const PackagedOperation< Range > &comp, const LinearOperator< Range, Domain, Payload > &op)
PackagedOperation< Range > operator-(const Range &offset, const PackagedOperation< Range > &comp)
PackagedOperation< Range > & operator=(const PackagedOperation< Range > &)=default
PackagedOperation< Range > operator-(const Range &u, const Range &v)
static ::ExceptionBase & ExcMessage(std::string arg1)
PackagedOperation< Range > & operator=(const Range &u)
virtual VectorType * alloc()
#define Assert(cond, exc)
std::function< void(Range &v, const Domain &u)> vmult
virtual void free(const VectorType *const)
PackagedOperation< Range > operator-(const PackagedOperation< Range > &first_comp, const PackagedOperation< Range > &second_comp)
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, const PackagedOperation< Range > &comp)
PackagedOperation< Range > & operator+=(const Range &offset)
PackagedOperation< Range > operator-(const PackagedOperation< Range > &comp, const Range &offset)
PackagedOperation< Domain > operator*(const Range &u, const LinearOperator< Range, Domain, Payload > &op)
PackagedOperation< Range > operator*(const PackagedOperation< Range > &comp, typename Range::value_type number)
PackagedOperation< Range > operator*(typename Range::value_type number, const PackagedOperation< Range > &comp)
PackagedOperation< Range > operator*(typename Range::value_type number, const Range &u)
PackagedOperation< Range > operator+(const PackagedOperation< Range > &first_comp, const PackagedOperation< Range > &second_comp)
PackagedOperation< Range > & operator-=(const Range &offset)