#include <deal.II/lac/block_vector_base.h>
#include <cstdio>
-#include <functional>
#include <vector>
DEAL_II_NAMESPACE_OPEN
}
-#ifdef DEAL_II_WITH_CXX11
-
namespace internal
{
namespace LinearOperator
{
- template <typename> class ReinitRangeFactory;
- template <typename> class ReinitDomainFactory;
+ template <typename> class ReinitHelper;
/**
- * A factory class internally used in linear_operator.h.
+ * A helper class internally used in linear_operator.h.
* Specialization for BlockVector<number>.
*/
template<typename number>
- class ReinitRangeFactory<BlockVector<number> >
+ class ReinitHelper<BlockVector<number> >
{
public:
template <typename Matrix>
- std::function<void(BlockVector<number> &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_range_vector (const Matrix &matrix,
+ BlockVector<number> &v,
+ bool fast)
{
- return [&matrix](BlockVector<number> &v, bool fast)
- {
- v.reinit(matrix.get_row_indices(), fast);
- };
+ v.reinit(matrix.get_row_indices(), fast);
}
- };
- /**
- * A factory class internally used in linear_operator.h.
- * Specialization for BlockVector<number>.
- */
- template<typename number>
- class ReinitDomainFactory<BlockVector<number> >
- {
- public:
template <typename Matrix>
- std::function<void(BlockVector<number> &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_domain_vector(const Matrix &matrix,
+ BlockVector<number> &v,
+ bool fast)
{
- return [&matrix](BlockVector<number> &v, bool fast)
- {
- v.reinit(matrix.get_column_indices(), fast);
- };
+ v.reinit(matrix.get_column_indices(), fast);
}
};
+
} /* namespace LinearOperator */
} /* namespace internal */
-#endif /* DEAL_II_WITH_CXX11 */
-
DEAL_II_NAMESPACE_CLOSE
#endif
* Application of the LinearOperator object to a vector u of the @tref
* Domain space giving a vector v of the @tref Range space.
*/
- std::function<const void(Range &v, const Domain &u)> vmult;
+ std::function<void(Range &v, const Domain &u)> vmult;
/**
* Application of the LinearOperator object to a vector u of the @tref
* Domain space. The result is added to the vector v.
*/
- std::function<const void(Range &v, const Domain &u)> vmult_add;
+ std::function<void(Range &v, const Domain &u)> vmult_add;
/**
* Application of the transpose LinearOperator object to a vector u of
* the @tref Range space giving a vector v of the @tref Domain
* space.
*/
- std::function<const void(Domain &v, const Range &u)> Tvmult;
+ std::function<void(Domain &v, const Range &u)> Tvmult;
/**
* Application of the transpose LinearOperator object to a vector @p u of
* the @tref Range space.The result is added to the vector @p v.
*/
- std::function<const void(Domain &v, const Range &u)> Tvmult_add;
+ std::function<void(Domain &v, const Range &u)> Tvmult_add;
/**
* Initializes a vector v of the Range space to be directly usable
namespace LinearOperator
{
/**
- * A factory class that is responsible for the creation of a
- * reinit_range_vector object for a given pair of vector type Range and matrix
- * type Matrix.
+ * A helper class that is responsible for the initialization of a
+ * vector to be directly usable as the destination parameter, or source
+ * parameter in an application of vmult of a matrix.
*
* The generic version of this class just calls
- * <code>Range::reinit()</code> with the result of
- * <code>Matrix::m()</code>. This class is specialized for more complicated
- * data structures, such as TrilinosWrappers::MPI::Vector, etc.
+ * <code>Vector::reinit()</code> with the result of
+ * <code>Matrix::m()</code> or <code>Matrix::n()</code>, respectively.
+ * This class is specialized for more complicated data structures, such
+ * as TrilinosWrappers::MPI::Vector, etc.
*/
- template<typename Range>
- class ReinitRangeFactory
+ template<typename Vector>
+ class ReinitHelper
{
public:
+ /**
+ * Initializes a vector v of the Range space to be directly usable
+ * as the destination parameter in an application of vmult. Similar to
+ * the reinit functions of the vector classes, the boolean determines
+ * whether a fast initalization is done, i.e., if it is set to false the
+ * content of the vector is set to 0.
+ *
+ * The generic version of this class just calls
+ * <code>Vector::reinit()</code> with the result of
+ * <code>Matrix::m()</code>.
+ */
template <typename Matrix>
- std::function<void(Range &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_range_vector (const Matrix &matrix, Vector &v, bool fast)
{
- return [&matrix](Range &v, bool fast)
- {
- v.reinit(matrix.m(), fast);
- };
+ v.reinit(matrix.m(), fast);
}
- };
-
- /**
- * A factory class that is responsible for the creation of a
- * reinit_domain_vector object for a given pair of vector type Domain and
- * matrix type Matrix.
- *
- * The generic version of this class just calls
- * <code>Domain::reinit()</code> with the result of
- * <code>Matrix::n()</code>. This class is specialized for more complicated
- * data structures, such as TrilinosWrappers::MPI::Vector, etc.
- */
- template<typename Domain>
- class ReinitDomainFactory
- {
- public:
+ /**
+ * Initializes a vector of the Domain space to be directly usable as the
+ * source parameter in an application of vmult. Similar to the reinit
+ * functions of the vector classes, the boolean determines whether a fast
+ * initalization is done, i.e., if it is set to false the content of the
+ * vector is set to 0.
+ *
+ * The generic version of this class just calls
+ * <code>Vector::reinit()</code> with the result of
+ * <code>Matrix::n()</code>.
+ */
template <typename Matrix>
- std::function<void(Domain &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_domain_vector (const Matrix &matrix, Vector &v, bool fast)
{
- return [&matrix](Domain &v, bool fast)
- {
- v.reinit(matrix.n(), fast);
- };
+ v.reinit(matrix.n(), fast);
}
};
} /* namespace LinearOperator */
// creation of a LinearOperator wrapper is respected - further a matrix
// or an operator_exemplar cannot usually be copied...
- return_op.reinit_range_vector =
- internal::LinearOperator::ReinitRangeFactory<Range>().operator()(
- operator_exemplar);
+ return_op.reinit_range_vector = [&operator_exemplar](Range &v, bool fast)
+ {
+ internal::LinearOperator::ReinitHelper<Range>::reinit_range_vector(operator_exemplar, v, fast);
+ };
- return_op.reinit_domain_vector =
- internal::LinearOperator::ReinitDomainFactory<Domain>().operator()(
- operator_exemplar);
+ return_op.reinit_domain_vector = [&operator_exemplar](Domain &v, bool fast)
+ {
+ internal::LinearOperator::ReinitHelper<Domain>::reinit_domain_vector(operator_exemplar, v, fast);
+ };
typename std::conditional<
has_vmult_add<Range, Domain, Matrix>::type::value,
# include <deal.II/lac/block_vector_base.h>
# include <deal.II/lac/exceptions.h>
-# include <functional>
-
DEAL_II_NAMESPACE_OPEN
// forward declaration
/*@}*/
-#ifdef DEAL_II_WITH_CXX11
-
namespace internal
{
namespace LinearOperator
{
- template <typename> class ReinitRangeFactory;
- template <typename> class ReinitDomainFactory;
+ template <typename> class ReinitHelper;
/**
- * A factory class internally used in linear_operator.h. Specialization
- * for TrilinosWrappers::BlockVector.
+ * A helper class internally used in linear_operator.h.
+ * Specialization for TrilinosWrappers::BlockVector.
*/
template<>
- class ReinitRangeFactory<TrilinosWrappers::BlockVector>
+ class ReinitHelper<TrilinosWrappers::BlockVector>
{
public:
template <typename Matrix>
- std::function<void(TrilinosWrappers::BlockVector &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_range_vector (const Matrix &matrix,
+ TrilinosWrappers::BlockVector &v,
+ bool fast)
{
- return [&matrix](TrilinosWrappers::BlockVector &v, bool fast)
- {
- v.reinit(matrix.range_partitioner(), fast);
- };
+ v.reinit(matrix.range_partitioner(), fast);
}
- };
- /**
- * A factory class internally used in linear_operator.h. Specialization
- * for TrilinosWrappers::BlockVector.
- */
- template<>
- class ReinitDomainFactory<TrilinosWrappers::BlockVector>
- {
- public:
template <typename Matrix>
- std::function<void(TrilinosWrappers::BlockVector &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_domain_vector(const Matrix &matrix,
+ TrilinosWrappers::BlockVector &v,
+ bool fast)
{
- return [&matrix](TrilinosWrappers::BlockVector &v, bool fast)
- {
- v.reinit(matrix.domain_partitioner(), fast);
- };
+ v.reinit(matrix.domain_partitioner(), fast);
}
};
+
} /* namespace LinearOperator */
} /* namespace internal */
-#endif /* DEAL_II_WITH_CXX11 */
-
DEAL_II_NAMESPACE_CLOSE
/*@}*/
-#ifdef DEAL_II_WITH_CXX11
-
namespace internal
{
namespace LinearOperator
{
- template <typename> class ReinitRangeFactory;
- template <typename> class ReinitDomainFactory;
+ template <typename> class ReinitHelper;
/**
- * A factory class internally used in linear_operator.h. Specialization
- * for TrilinosWrappers::MPI::BlockVector.
+ * A helper class internally used in linear_operator.h.
+ * Specialization for TrilinosWrappers::MPI::BlockVector.
*/
template<>
- class ReinitRangeFactory<TrilinosWrappers::MPI::BlockVector>
+ class ReinitHelper<TrilinosWrappers::MPI::BlockVector>
{
public:
template <typename Matrix>
- std::function<void(TrilinosWrappers::MPI::BlockVector &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_range_vector (const Matrix &matrix,
+ TrilinosWrappers::MPI::BlockVector &v,
+ bool fast)
{
- return [&matrix](TrilinosWrappers::MPI::BlockVector &v, bool fast)
- {
- v.reinit(matrix.range_partitioner(), fast);
- };
+ v.reinit(matrix.range_partitioner(), fast);
}
- };
- /**
- * A factory class internally used in linear_operator.h. Specialization
- * for TrilinosWrappers::MPI::BlockVector.
- */
- template<>
- class ReinitDomainFactory<TrilinosWrappers::MPI::BlockVector>
- {
- public:
template <typename Matrix>
- std::function<void(TrilinosWrappers::MPI::BlockVector &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_domain_vector(const Matrix &matrix,
+ TrilinosWrappers::MPI::BlockVector &v,
+ bool fast)
{
- return [&matrix](TrilinosWrappers::MPI::BlockVector &v, bool fast)
- {
- v.reinit(matrix.domain_partitioner(), fast);
- };
+ v.reinit(matrix.domain_partitioner(), fast);
}
};
+
} /* namespace LinearOperator */
} /* namespace internal */
-#endif /* DEAL_II_WITH_CXX11 */
-
DEAL_II_NAMESPACE_CLOSE
# include "Epetra_LocalMap.h"
DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
-# include <functional>
-
DEAL_II_NAMESPACE_OPEN
/*@}*/
-#ifdef DEAL_II_WITH_CXX11
-
namespace internal
{
namespace LinearOperator
{
- template <typename> class ReinitRangeFactory;
- template <typename> class ReinitDomainFactory;
+ template <typename> class ReinitHelper;
/**
- * A factory class internally used in linear_operator.h. Specialization
- * for TrilinosWrappers::MPI::Vector.
+ * A helper class internally used in linear_operator.h.
+ * Specialization for TrilinosWrappers::MPI::Vector.
*/
template<>
- class ReinitRangeFactory<TrilinosWrappers::MPI::Vector>
+ class ReinitHelper<TrilinosWrappers::MPI::Vector>
{
public:
template <typename Matrix>
- std::function<void(TrilinosWrappers::MPI::Vector &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_range_vector (const Matrix &matrix,
+ TrilinosWrappers::MPI::Vector &v,
+ bool fast)
{
- return [&matrix](TrilinosWrappers::MPI::Vector &v, bool fast)
- {
- v.reinit(matrix.range_partitioner(), fast);
- };
+ v.reinit(matrix.range_partitioner(), fast);
}
- };
- /**
- * A factory class internally used in linear_operator.h. Specialization
- * for TrilinosWrappers::MPI::Vector.
- */
- template<>
- class ReinitDomainFactory<TrilinosWrappers::MPI::Vector>
- {
- public:
template <typename Matrix>
- std::function<void(TrilinosWrappers::MPI::Vector &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_domain_vector(const Matrix &matrix,
+ TrilinosWrappers::MPI::Vector &v,
+ bool fast)
{
- return [&matrix](TrilinosWrappers::MPI::Vector &v, bool fast)
- {
- v.reinit(matrix.domain_partitioner(), fast);
- };
+ v.reinit(matrix.domain_partitioner(), fast);
}
};
/**
- * A factory class internally used in linear_operator.h. Specialization
- * for TrilinosWrappers::MPI::Vector.
+ * A helper class internally used in linear_operator.h.
+ * Specialization for TrilinosWrappers::Vector.
*/
template<>
- class ReinitRangeFactory<TrilinosWrappers::Vector>
+ class ReinitHelper<TrilinosWrappers::Vector>
{
public:
template <typename Matrix>
- std::function<void(TrilinosWrappers::Vector &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_range_vector (const Matrix &matrix,
+ TrilinosWrappers::Vector &v,
+ bool fast)
{
- return [&matrix](TrilinosWrappers::Vector &v, bool fast)
- {
- v.reinit(matrix.range_partitioner(), fast);
- };
+ v.reinit(matrix.range_partitioner(), fast);
}
- };
- /**
- * A factory class internally used in linear_operator.h. Specialization
- * for TrilinosWrappers::MPI::Vector.
- */
- template<>
- class ReinitDomainFactory<TrilinosWrappers::Vector>
- {
- public:
template <typename Matrix>
- std::function<void(TrilinosWrappers::Vector &, bool)>
- operator()(const Matrix &matrix)
+ static
+ void reinit_domain_vector(const Matrix &matrix,
+ TrilinosWrappers::Vector &v,
+ bool fast)
{
- return [&matrix](TrilinosWrappers::Vector &v, bool fast)
- {
- v.reinit(matrix.domain_partitioner(), fast);
- };
+ v.reinit(matrix.domain_partitioner(), fast);
}
};
+
} /* namespace LinearOperator */
} /* namespace internal */
-#endif /* DEAL_II_WITH_CXX11 */
-
DEAL_II_NAMESPACE_CLOSE