@DEAL_II_EXPAND_TRILINOS_MPI_VECTOR@;
@DEAL_II_EXPAND_EPETRA_VECTOR@;
- @DEAL_II_EXPAND_TPETRA_VECTOR@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_DOUBLE@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT@;
@DEAL_II_EXPAND_PETSC_MPI_VECTOR@;
@DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR@;
@DEAL_II_EXPAND_TRILINOS_MPI_VECTOR@;
@DEAL_II_EXPAND_EPETRA_VECTOR@;
- @DEAL_II_EXPAND_TPETRA_VECTOR@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_DOUBLE@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT@;
@DEAL_II_EXPAND_PETSC_MPI_VECTOR_REAL@;
@DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR@;
@DEAL_II_EXPAND_TRILINOS_MPI_VECTOR@;
@DEAL_II_EXPAND_EPETRA_VECTOR@;
- @DEAL_II_EXPAND_TPETRA_VECTOR@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_DOUBLE@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT@;
@DEAL_II_EXPAND_PETSC_MPI_VECTOR_REAL@;
}
EXTERNAL_PARALLEL_VECTORS := { @DEAL_II_EXPAND_TRILINOS_MPI_VECTOR@;
@DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR@;
@DEAL_II_EXPAND_EPETRA_VECTOR@;
- @DEAL_II_EXPAND_TPETRA_VECTOR@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_DOUBLE@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT@;
@DEAL_II_EXPAND_PETSC_MPI_VECTOR@;
@DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR@
}
@DEAL_II_EXPAND_TRILINOS_MPI_VECTOR@;
@DEAL_II_EXPAND_EPETRA_VECTOR@;
- @DEAL_II_EXPAND_TPETRA_VECTOR@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_DOUBLE@;
+ @DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT@;
@DEAL_II_EXPAND_PETSC_MPI_VECTOR@;
}
SET(DEAL_II_EXPAND_TRILINOS_MPI_VECTOR "TrilinosWrappers::MPI::Vector")
IF (TRILINOS_WITH_MPI)
SET(DEAL_II_EXPAND_EPETRA_VECTOR "LinearAlgebra::EpetraWrappers::Vector")
- SET(DEAL_II_EXPAND_TPETRA_VECTOR "LinearAlgebra::TpetraWrappers::Vector")
+ SET(DEAL_II_EXPAND_TPETRA_VECTOR_DOUBLE "LinearAlgebra::TpetraWrappers::Vector<double>")
+ #SET(DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT "LinearAlgebra::TpetraWrappers::Vector<float>")
ENDIF()
IF(${DEAL_II_TRILINOS_WITH_SACADO})
# Note: Only CMake 3.0 and greater support line continuation with the "\" character
- template <typename ForwardIterator>
+ template <typename ForwardIterator, typename Number>
static void
- extract_subvector_to(const LinearAlgebra::TpetraWrappers::Vector &values,
- const types::global_dof_index *cache_begin,
- const types::global_dof_index *cache_end,
- ForwardIterator local_values_begin)
+ extract_subvector_to(
+ const LinearAlgebra::TpetraWrappers::Vector<Number> &values,
+ const types::global_dof_index * cache_begin,
+ const types::global_dof_index * cache_end,
+ ForwardIterator local_values_begin)
{
std::vector<unsigned int> sorted_indices_pos =
sort_indices(cache_begin, cache_end);
IndexSet index_set(cache_indices.back() + 1);
index_set.add_indices(cache_indices.begin(), cache_indices.end());
index_set.compress();
- LinearAlgebra::ReadWriteVector<double> read_write_vector(index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_vector(index_set);
read_write_vector.import(values, VectorOperation::insert);
// Copy the elements from read_write_vector and reorder them.
# ifdef DEAL_II_WITH_MPI
- template <int dim, int spacedim>
+ template <int dim, int spacedim, typename Number>
void
- reinit_distributed(const DoFHandler<dim, spacedim> & dh,
- LinearAlgebra::TpetraWrappers::Vector &vector)
+ reinit_distributed(const DoFHandler<dim, spacedim> & dh,
+ LinearAlgebra::TpetraWrappers::Vector<Number> &vector)
{
const parallel::distributed::Triangulation<dim, spacedim> *parallel_tria =
dynamic_cast<
AssertThrow(false, ExcNotImplemented());
}
- template <int dim, int spacedim>
+ template <int dim, int spacedim, typename Number>
void
back_interpolate(
const DoFHandler<dim, spacedim> &,
const AffineConstraints<
- typename LinearAlgebra::TpetraWrappers::Vector::value_type> &,
- const LinearAlgebra::TpetraWrappers::Vector &,
+ typename LinearAlgebra::TpetraWrappers::Vector<Number>::value_type> &,
+ const LinearAlgebra::TpetraWrappers::Vector<Number> &,
const DoFHandler<dim, spacedim> &,
const AffineConstraints<
- typename LinearAlgebra::TpetraWrappers::Vector::value_type> &,
- LinearAlgebra::TpetraWrappers::Vector &)
+ typename LinearAlgebra::TpetraWrappers::Vector<Number>::value_type> &,
+ LinearAlgebra::TpetraWrappers::Vector<Number> &)
{
AssertThrow(false, ExcNotImplemented());
}
* performance.
*/
void
- import(const TpetraWrappers::Vector &tpetra_vec,
- VectorOperation::values operation,
+ import(const TpetraWrappers::Vector<Number> &tpetra_vec,
+ VectorOperation::values operation,
const std::shared_ptr<const CommunicationPatternBase>
&communication_pattern =
std::shared_ptr<const CommunicationPatternBase>());
* used directly.
*/
void
- import(const Tpetra::Vector<> &tpetra_vector,
- const IndexSet & locally_owned_elements,
- VectorOperation::values operation,
- const MPI_Comm & mpi_comm,
+ import(const Tpetra::Vector<Number> &tpetra_vector,
+ const IndexSet & locally_owned_elements,
+ VectorOperation::values operation,
+ const MPI_Comm & mpi_comm,
const std::shared_ptr<const CommunicationPatternBase>
&communication_pattern);
template <typename Number>
void
ReadWriteVector<Number>::import(
- const Tpetra::Vector<> &vector,
- const IndexSet & source_elements,
- VectorOperation::values operation,
- const MPI_Comm & mpi_comm,
+ const Tpetra::Vector<Number> &vector,
+ const IndexSet & source_elements,
+ VectorOperation::values operation,
+ const MPI_Comm & mpi_comm,
const std::shared_ptr<const CommunicationPatternBase>
&communication_pattern)
{
Tpetra::Export<> tpetra_export(tpetra_comm_pattern->get_tpetra_export());
- Tpetra::Vector<> target_vector(tpetra_export.getSourceMap());
+ Tpetra::Vector<Number> target_vector(tpetra_export.getSourceMap());
target_vector.doImport(vector, tpetra_export, Tpetra::REPLACE);
const auto *new_values = target_vector.getData().get();
const auto size = target_vector.getLocalLength();
- using size_type = std::decay<decltype(size)>::type;
+ using size_type = typename std::decay<decltype(size)>::type;
Assert(size == 0 || values != nullptr, ExcInternalError("Export failed."));
AssertDimension(size, stored_elements.n_elements());
template <typename Number>
void
ReadWriteVector<Number>::import(
- const LinearAlgebra::TpetraWrappers::Vector &trilinos_vec,
- VectorOperation::values operation,
+ const LinearAlgebra::TpetraWrappers::Vector<Number> &trilinos_vec,
+ VectorOperation::values operation,
const std::shared_ptr<const CommunicationPatternBase>
&communication_pattern)
{
* initialize the matrix with a sparsity pattern to fix the matrix
* structure before inserting elements.
*/
+ template <typename Number>
+ void
+ set(const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const Number * values,
+ const bool elide_zero_values = false);
+
void
set(const size_type row,
const size_type n_cols,
/**
* This class implements a wrapper to the Trilinos distributed vector
* class Tpetra::Vector. This class is derived from the
- * LinearAlgebra::VectorSpaceVector class. Note however that Tpetra only
- * works with Number = double.
+ * LinearAlgebra::VectorSpaceVector class.
*
* @ingroup TrilinosWrappers
* @ingroup Vectors
* @author Daniel Arndt, 2018
*/
- class Vector : public VectorSpaceVector<double>, public Subscriptor
+ template <typename Number>
+ class Vector : public VectorSpaceVector<Number>, public Subscriptor
{
public:
+ using value_type = Number;
+
+ using size_type = typename VectorSpaceVector<Number>::size_type;
+
/**
* Constructor. Create a vector of dimension zero.
*/
* copied.
*/
virtual void
- reinit(const VectorSpaceVector<double> &V,
+ reinit(const VectorSpaceVector<Number> &V,
const bool omit_zeroing_entries = false) override;
/**
* only allowed if @p s is equal to zero.
*/
virtual Vector &
- operator=(const double s) override;
+ operator=(const Number s) override;
/**
* Imports all the elements present in the vector's IndexSet from the
*/
virtual void
import(
- const ReadWriteVector<double> & V,
+ const ReadWriteVector<Number> & V,
VectorOperation::values operation,
std::shared_ptr<const CommunicationPatternBase> communication_pattern =
std::shared_ptr<const CommunicationPatternBase>()) override;
* Multiply the entire vector by a fixed factor.
*/
virtual Vector &
- operator*=(const double factor) override;
+ operator*=(const Number factor) override;
/**
* Divide the entire vector by a fixed factor.
*/
virtual Vector &
- operator/=(const double factor) override;
+ operator/=(const Number factor) override;
/**
* Add the vector @p V to the present one.
*/
virtual Vector &
- operator+=(const VectorSpaceVector<double> &V) override;
+ operator+=(const VectorSpaceVector<Number> &V) override;
/**
* Subtract the vector @p V from the present one.
*/
virtual Vector &
- operator-=(const VectorSpaceVector<double> &V) override;
+ operator-=(const VectorSpaceVector<Number> &V) override;
/**
* Return the scalar product of two vectors. The vectors need to have the
* same layout.
*/
- virtual double
- operator*(const VectorSpaceVector<double> &V) const override;
+ virtual Number
+ operator*(const VectorSpaceVector<Number> &V) const override;
/**
* Add @p a to all components. Note that @p is a scalar not a vector.
*/
virtual void
- add(const double a) override;
+ add(const Number a) override;
/**
* Simple addition of a multiple of a vector, i.e. <tt>*this +=
* a*V</tt>. The vectors need to have the same layout.
*/
virtual void
- add(const double a, const VectorSpaceVector<double> &V) override;
+ add(const Number a, const VectorSpaceVector<Number> &V) override;
/**
* Multiple addition of multiple of a vector, i.e. <tt>*this> +=
* a*V+b*W</tt>. The vectors need to have the same layout.
*/
virtual void
- add(const double a,
- const VectorSpaceVector<double> &V,
- const double b,
- const VectorSpaceVector<double> &W) override;
+ add(const Number a,
+ const VectorSpaceVector<Number> &V,
+ const Number b,
+ const VectorSpaceVector<Number> &W) override;
/**
* Scaling and simple addition of a multiple of a vector, i.e. <tt>*this
* = s*(*this)+a*V</tt>.
*/
virtual void
- sadd(const double s,
- const double a,
- const VectorSpaceVector<double> &V) override;
+ sadd(const Number s,
+ const Number a,
+ const VectorSpaceVector<Number> &V) override;
/**
* Scale each element of this vector by the corresponding element in the
* vectors need to have the same layout.
*/
virtual void
- scale(const VectorSpaceVector<double> &scaling_factors) override;
+ scale(const VectorSpaceVector<Number> &scaling_factors) override;
/**
* Assignment <tt>*this = a*V</tt>.
*/
virtual void
- equ(const double a, const VectorSpaceVector<double> &V) override;
+ equ(const Number a, const VectorSpaceVector<Number> &V) override;
/**
* Return whether the vector contains only elements with value zero.
/**
* Return the mean value of the element of this vector.
*/
- virtual double
+ virtual Number
mean_value() const override;
/**
* Return the l<sub>1</sub> norm of the vector (i.e., the sum of the
* absolute values of all entries among all processors).
*/
- virtual double
+ virtual typename LinearAlgebra::VectorSpaceVector<Number>::real_type
l1_norm() const override;
/**
* Return the l<sub>2</sub> norm of the vector (i.e., the square root of
* the sum of the square of all entries among all processors).
*/
- virtual double
+ virtual typename LinearAlgebra::VectorSpaceVector<Number>::real_type
l2_norm() const override;
/**
* Return the maximum norm of the vector (i.e., the maximum absolute value
* among all entries and among all processors).
*/
- virtual double
+ virtual typename LinearAlgebra::VectorSpaceVector<Number>::real_type
linfty_norm() const override;
/**
* implemented as
* $\left<v,w\right>=\sum_i v_i \bar{w_i}$.
*/
- virtual double
- add_and_dot(const double a,
- const VectorSpaceVector<double> &V,
- const VectorSpaceVector<double> &W) override;
+ virtual Number
+ add_and_dot(const Number a,
+ const VectorSpaceVector<Number> &V,
+ const VectorSpaceVector<Number> &W) override;
/**
* This function always returns false and is present only for backward
* compatibility.
* Return a const reference to the underlying Trilinos
* Tpetra::Vector class.
*/
- const Tpetra::Vector<> &
+ const Tpetra::Vector<Number> &
trilinos_vector() const;
/**
* Return a (modifyable) reference to the underlying Trilinos
* Tpetra::Vector class.
*/
- Tpetra::Vector<> &
+ Tpetra::Vector<Number> &
trilinos_vector();
/**
/**
* Pointer to the actual Tpetra vector object.
*/
- std::unique_ptr<Tpetra::Vector<>> vector;
+ std::unique_ptr<Tpetra::Vector<Number>> vector;
/**
* IndexSet of the elements of the last imported vector.
};
+ template <typename Number>
inline bool
- Vector::has_ghost_elements() const
+ Vector<Number>::has_ghost_elements() const
{
return false;
}
/**
* Declare dealii::LinearAlgebra::TpetraWrappers::Vector as distributed vector.
*/
-template <>
-struct is_serial_vector<LinearAlgebra::TpetraWrappers::Vector> : std::false_type
+template <typename Number>
+struct is_serial_vector<LinearAlgebra::TpetraWrappers::Vector<Number>>
+ : std::false_type
{};
DEAL_II_NAMESPACE_CLOSE
template <>
inline void
- ElementAccess<LinearAlgebra::TpetraWrappers::Vector>::add(
- const double value,
- const types::global_dof_index i,
- LinearAlgebra::TpetraWrappers::Vector &V)
+ ElementAccess<LinearAlgebra::TpetraWrappers::Vector<double>>::add(
+ const double value,
+ const types::global_dof_index i,
+ LinearAlgebra::TpetraWrappers::Vector<double> &V)
{
// Extract local indices in the vector.
- Tpetra::Vector<> vector = V.trilinos_vector();
+ Tpetra::Vector<double> vector = V.trilinos_vector();
TrilinosWrappers::types::int_type trilinos_i =
vector.getMap()->getLocalElement(
static_cast<TrilinosWrappers::types::int_type>(i));
// We're going to modify the data on host.
vector.modify<Kokkos::HostSpace>();
vector_1d(trilinos_i) += value;
- vector.sync<Tpetra::Vector<>::device_type::memory_space>();
+ vector.sync<Tpetra::Vector<double>::device_type::memory_space>();
}
template <>
inline void
- ElementAccess<LinearAlgebra::TpetraWrappers::Vector>::set(
- const double value,
- const types::global_dof_index i,
- LinearAlgebra::TpetraWrappers::Vector &V)
+ ElementAccess<LinearAlgebra::TpetraWrappers::Vector<float>>::add(
+ const float value,
+ const types::global_dof_index i,
+ LinearAlgebra::TpetraWrappers::Vector<float> &V)
+ {
+ // Extract local indices in the vector.
+ Tpetra::Vector<float> vector = V.trilinos_vector();
+ TrilinosWrappers::types::int_type trilinos_i =
+ vector.getMap()->getLocalElement(
+ static_cast<TrilinosWrappers::types::int_type>(i));
+
+ vector.sync<Kokkos::HostSpace>();
+ auto vector_2d = vector.getLocalView<Kokkos::HostSpace>();
+ auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
+ // We're going to modify the data on host.
+ vector.modify<Kokkos::HostSpace>();
+ vector_1d(trilinos_i) += value;
+ vector.sync<Tpetra::Vector<float>::device_type::memory_space>();
+ }
+
+
+
+ template <>
+ inline void
+ ElementAccess<LinearAlgebra::TpetraWrappers::Vector<double>>::set(
+ const double value,
+ const types::global_dof_index i,
+ LinearAlgebra::TpetraWrappers::Vector<double> &V)
+ {
+ // Extract local indices in the vector.
+ Tpetra::Vector<double> vector = V.trilinos_vector();
+ TrilinosWrappers::types::int_type trilinos_i =
+ vector.getMap()->getLocalElement(
+ static_cast<TrilinosWrappers::types::int_type>(i));
+
+ vector.sync<Kokkos::HostSpace>();
+ auto vector_2d = vector.getLocalView<Kokkos::HostSpace>();
+ auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
+ // We're going to modify the data on host.
+ vector.modify<Kokkos::HostSpace>();
+ vector_1d(trilinos_i) = value;
+ vector.sync<Tpetra::Vector<double>::device_type::memory_space>();
+ }
+
+
+
+ template <>
+ inline void
+ ElementAccess<LinearAlgebra::TpetraWrappers::Vector<float>>::set(
+ const float value,
+ const types::global_dof_index i,
+ LinearAlgebra::TpetraWrappers::Vector<float> &V)
{
// Extract local indices in the vector.
- Tpetra::Vector<> vector = V.trilinos_vector();
+ Tpetra::Vector<float> vector = V.trilinos_vector();
TrilinosWrappers::types::int_type trilinos_i =
vector.getMap()->getLocalElement(
static_cast<TrilinosWrappers::types::int_type>(i));
// We're going to modify the data on host.
vector.modify<Kokkos::HostSpace>();
vector_1d(trilinos_i) = value;
- vector.sync<Tpetra::Vector<>::device_type::memory_space>();
+ vector.sync<Tpetra::Vector<float>::device_type::memory_space>();
}
+
template <>
inline double
- ElementAccess<LinearAlgebra::TpetraWrappers::Vector>::get(
- const LinearAlgebra::TpetraWrappers::Vector &V,
- const types::global_dof_index i)
+ ElementAccess<LinearAlgebra::TpetraWrappers::Vector<double>>::get(
+ const LinearAlgebra::TpetraWrappers::Vector<double> &V,
+ const types::global_dof_index i)
+ {
+ // Extract local indices in the vector.
+ Tpetra::Vector<double> vector = V.trilinos_vector();
+ TrilinosWrappers::types::int_type trilinos_i =
+ vector.getMap()->getLocalElement(
+ static_cast<TrilinosWrappers::types::int_type>(i));
+
+ vector.sync<Kokkos::HostSpace>();
+ auto vector_2d = vector.getLocalView<Kokkos::HostSpace>();
+ auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
+ // We're going to modify the data on host.
+ return vector_1d(trilinos_i);
+ }
+
+
+
+ template <>
+ inline float
+ ElementAccess<LinearAlgebra::TpetraWrappers::Vector<float>>::get(
+ const LinearAlgebra::TpetraWrappers::Vector<float> &V,
+ const types::global_dof_index i)
{
// Extract local indices in the vector.
- Tpetra::Vector<> vector = V.trilinos_vector();
+ Tpetra::Vector<float> vector = V.trilinos_vector();
TrilinosWrappers::types::int_type trilinos_i =
vector.getMap()->getLocalElement(
static_cast<TrilinosWrappers::types::int_type>(i));
};
# ifdef DEAL_II_WITH_MPI
- template <>
- struct MatrixSelector<dealii::LinearAlgebra::TpetraWrappers::Vector>
+ template <typename Number>
+ struct MatrixSelector<dealii::LinearAlgebra::TpetraWrappers::Vector<Number>>
{
using Sparsity = ::dealii::TrilinosWrappers::SparsityPattern;
using Matrix = ::dealii::TrilinosWrappers::SparseMatrix;
Assert(dof_cell->active() == true, ExcInactiveCell());
// now get the values of the shift vectors at the vertices
- Vector<double> mapping_values(shiftmap_dof_handler->get_fe().dofs_per_cell);
+ Vector<typename VectorType::value_type> mapping_values(
+ shiftmap_dof_handler->get_fe().dofs_per_cell);
dof_cell->get_dof_values(*euler_transform_vectors, mapping_values);
for (unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell; ++i)
namespace internal
{
template <typename VectorType>
- double *
+ typename VectorType::value_type *
begin(VectorType &V)
{
return V.begin();
}
template <typename VectorType>
- const double *
+ const typename VectorType::value_type *
begin(const VectorType &V)
{
return V.begin();
}
template <typename VectorType>
- double *
+ typename VectorType::value_type *
end(VectorType &V)
{
return V.end();
}
template <typename VectorType>
- const double *
+ const typename VectorType::value_type *
end(const VectorType &V)
{
return V.end();
return V.trilinos_vector()[0] + V.trilinos_vector().MyLength();
}
- template <>
- double *
- begin(LinearAlgebra::TpetraWrappers::Vector &V)
+ template <typename Number>
+ Number *
+ begin(LinearAlgebra::TpetraWrappers::Vector<Number> &V)
{
return V.trilinos_vector().getDataNonConst().get();
}
- template <>
- const double *
- begin(const LinearAlgebra::TpetraWrappers::Vector &V)
+ template <typename Number>
+ const Number *
+ begin(const LinearAlgebra::TpetraWrappers::Vector<Number> &V)
{
return V.trilinos_vector().getData().get();
}
- template <>
- double *
- end(LinearAlgebra::TpetraWrappers::Vector &V)
+ template <typename Number>
+ Number *
+ end(LinearAlgebra::TpetraWrappers::Vector<Number> &V)
{
return V.trilinos_vector().getDataNonConst().get() +
V.trilinos_vector().getLocalLength();
}
- template <>
- const double *
- end(const LinearAlgebra::TpetraWrappers::Vector &V)
+ template <typename Number>
+ const Number *
+ end(const LinearAlgebra::TpetraWrappers::Vector<Number> &V)
{
return V.trilinos_vector().getData().get() +
V.trilinos_vector().getLocalLength();
+ template <typename Number>
+ void
+ SparseMatrix::set(const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const Number * values,
+ const bool elide_zero_values)
+ {
+ std::vector<TrilinosScalar> trilinos_values(n_cols);
+ std::copy(values, values + n_cols, trilinos_values.begin());
+ this->set(
+ row, n_cols, col_indices, trilinos_values.data(), elide_zero_values);
+ }
+
+
+
void
SparseMatrix::set(const size_type row,
const size_type n_cols,
template void
SparseMatrix::vmult(MPI::Vector &, const MPI::Vector &) const;
+
template void
SparseMatrix::vmult(dealii::Vector<double> &,
const dealii::Vector<double> &) const;
+
template void
SparseMatrix::vmult(
dealii::LinearAlgebra::distributed::Vector<double> &,
const dealii::LinearAlgebra::distributed::Vector<double> &) const;
+
# ifdef DEAL_II_WITH_MPI
template void
SparseMatrix::vmult(
- dealii::LinearAlgebra::TpetraWrappers::Vector &,
- const dealii::LinearAlgebra::TpetraWrappers::Vector &) const;
+ dealii::LinearAlgebra::TpetraWrappers::Vector<double> &,
+ const dealii::LinearAlgebra::TpetraWrappers::Vector<double> &) const;
+
+ /*template void
+ SparseMatrix::vmult(
+ dealii::LinearAlgebra::TpetraWrappers::Vector<float> &,
+ const dealii::LinearAlgebra::TpetraWrappers::Vector<float> &) const;*/
template void
SparseMatrix::vmult(
dealii::LinearAlgebra::EpetraWrappers::Vector &,
const dealii::LinearAlgebra::EpetraWrappers::Vector &) const;
# endif
+
template void
SparseMatrix::Tvmult(MPI::Vector &, const MPI::Vector &) const;
+
template void
SparseMatrix::Tvmult(dealii::Vector<double> &,
const dealii::Vector<double> &) const;
+
template void
SparseMatrix::Tvmult(
dealii::LinearAlgebra::distributed::Vector<double> &,
const dealii::LinearAlgebra::distributed::Vector<double> &) const;
+
# ifdef DEAL_II_WITH_MPI
template void
SparseMatrix::Tvmult(
- dealii::LinearAlgebra::TpetraWrappers::Vector &,
- const dealii::LinearAlgebra::TpetraWrappers::Vector &) const;
+ dealii::LinearAlgebra::TpetraWrappers::Vector<double> &,
+ const dealii::LinearAlgebra::TpetraWrappers::Vector<double> &) const;
template void
SparseMatrix::Tvmult(
dealii::LinearAlgebra::EpetraWrappers::Vector &,
const dealii::LinearAlgebra::EpetraWrappers::Vector &) const;
# endif
+
template void
SparseMatrix::vmult_add(MPI::Vector &, const MPI::Vector &) const;
+
template void
SparseMatrix::vmult_add(dealii::Vector<double> &,
const dealii::Vector<double> &) const;
+
template void
SparseMatrix::vmult_add(
dealii::LinearAlgebra::distributed::Vector<double> &,
const dealii::LinearAlgebra::distributed::Vector<double> &) const;
+
# ifdef DEAL_II_WITH_MPI
template void
SparseMatrix::vmult_add(
- dealii::LinearAlgebra::TpetraWrappers::Vector &,
- const dealii::LinearAlgebra::TpetraWrappers::Vector &) const;
+ dealii::LinearAlgebra::TpetraWrappers::Vector<double> &,
+ const dealii::LinearAlgebra::TpetraWrappers::Vector<double> &) const;
template void
SparseMatrix::vmult_add(
dealii::LinearAlgebra::EpetraWrappers::Vector &,
const dealii::LinearAlgebra::EpetraWrappers::Vector &) const;
# endif
+
template void
SparseMatrix::Tvmult_add(MPI::Vector &, const MPI::Vector &) const;
+
template void
SparseMatrix::Tvmult_add(dealii::Vector<double> &,
const dealii::Vector<double> &) const;
+
template void
SparseMatrix::Tvmult_add(
dealii::LinearAlgebra::distributed::Vector<double> &,
const dealii::LinearAlgebra::distributed::Vector<double> &) const;
+
# ifdef DEAL_II_WITH_MPI
template void
SparseMatrix::Tvmult_add(
- dealii::LinearAlgebra::TpetraWrappers::Vector &,
- const dealii::LinearAlgebra::TpetraWrappers::Vector &) const;
+ dealii::LinearAlgebra::TpetraWrappers::Vector<double> &,
+ const dealii::LinearAlgebra::TpetraWrappers::Vector<double> &) const;
template void
SparseMatrix::Tvmult_add(
{
namespace TpetraWrappers
{
- Vector::Vector()
- : vector(new Tpetra::Vector<>(Teuchos::RCP<Tpetra::Map<>>(
+ template <typename Number>
+ Vector<Number>::Vector()
+ : vector(new Tpetra::Vector<Number>(Teuchos::RCP<Tpetra::Map<>>(
new Tpetra::Map<>(0, 0, Utilities::Trilinos::tpetra_comm_self()))))
{}
- Vector::Vector(const Vector &V)
+ template <typename Number>
+ Vector<Number>::Vector(const Vector<Number> &V)
: Subscriptor()
- , vector(new Tpetra::Vector<>(V.trilinos_vector(), Teuchos::Copy))
+ , vector(new Tpetra::Vector<Number>(V.trilinos_vector(), Teuchos::Copy))
{}
- Vector::Vector(const IndexSet ¶llel_partitioner,
- const MPI_Comm &communicator)
- : vector(new Tpetra::Vector<>(Teuchos::rcp(new Tpetra::Map<>(
+ template <typename Number>
+ Vector<Number>::Vector(const IndexSet ¶llel_partitioner,
+ const MPI_Comm &communicator)
+ : vector(new Tpetra::Vector<Number>(Teuchos::rcp(new Tpetra::Map<>(
parallel_partitioner.make_tpetra_map(communicator, false)))))
{}
+ template <typename Number>
void
- Vector::reinit(const IndexSet ¶llel_partitioner,
- const MPI_Comm &communicator,
- const bool omit_zeroing_entries)
+ Vector<Number>::reinit(const IndexSet ¶llel_partitioner,
+ const MPI_Comm &communicator,
+ const bool omit_zeroing_entries)
{
Tpetra::Map<> input_map =
parallel_partitioner.make_tpetra_map(communicator, false);
if (vector->getMap()->isSameAs(input_map) == false)
- vector = std_cxx14::make_unique<Tpetra::Vector<>>(
+ vector = std_cxx14::make_unique<Tpetra::Vector<Number>>(
Teuchos::rcp(new Tpetra::Map<>(input_map)));
else if (omit_zeroing_entries == false)
{
+ template <typename Number>
void
- Vector::reinit(const VectorSpaceVector<double> &V,
- const bool omit_zeroing_entries)
+ Vector<Number>::reinit(const VectorSpaceVector<Number> &V,
+ const bool omit_zeroing_entries)
{
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&V) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&V) != nullptr,
ExcVectorTypeNotCompatible());
// Downcast V. If fails, throws an exception.
- const Vector &down_V = dynamic_cast<const Vector &>(V);
+ const Vector<Number> &down_V = dynamic_cast<const Vector<Number> &>(V);
reinit(down_V.locally_owned_elements(),
down_V.get_mpi_communicator(),
- Vector &
- Vector::operator=(const Vector &V)
+ template <typename Number>
+ Vector<Number> &
+ Vector<Number>::operator=(const Vector<Number> &V)
{
// Distinguish three cases:
// - First case: both vectors have the same layout.
Tpetra::REPLACE);
}
else
- vector =
- std_cxx14::make_unique<Tpetra::Vector<>>(V.trilinos_vector());
+ vector = std_cxx14::make_unique<Tpetra::Vector<Number>>(
+ V.trilinos_vector());
}
return *this;
- Vector &
- Vector::operator=(const double s)
+ template <typename Number>
+ Vector<Number> &
+ Vector<Number>::operator=(const Number s)
{
- Assert(s == 0., ExcMessage("Only 0 can be assigned to a vector."));
+ Assert(s == Number(0.),
+ ExcMessage("Only 0 can be assigned to a vector."));
vector->putScalar(s);
+ template <typename Number>
void
- Vector::import(
- const ReadWriteVector<double> & V,
+ Vector<Number>::import(
+ const ReadWriteVector<Number> & V,
VectorOperation::values operation,
std::shared_ptr<const CommunicationPatternBase> communication_pattern)
{
}
Tpetra::Export<> tpetra_export(tpetra_comm_pattern->get_tpetra_export());
- Tpetra::Vector<> source_vector(tpetra_export.getSourceMap());
+ Tpetra::Vector<Number> source_vector(tpetra_export.getSourceMap());
- source_vector.sync<Kokkos::HostSpace>();
- auto x_2d = source_vector.getLocalView<Kokkos::HostSpace>();
+ source_vector.template sync<Kokkos::HostSpace>();
+ auto x_2d = source_vector.template getLocalView<Kokkos::HostSpace>();
auto x_1d = Kokkos::subview(x_2d, Kokkos::ALL(), 0);
- source_vector.modify<Kokkos::HostSpace>();
+ source_vector.template modify<Kokkos::HostSpace>();
const size_t localLength = source_vector.getLocalLength();
auto values_it = V.begin();
for (size_t k = 0; k < localLength; ++k)
x_1d(k) = *values_it++;
- source_vector.sync<Tpetra::Vector<double>::device_type::memory_space>();
+ source_vector.template sync<
+ typename Tpetra::Vector<Number>::device_type::memory_space>();
if (operation == VectorOperation::insert)
vector->doExport(source_vector, tpetra_export, Tpetra::REPLACE);
else if (operation == VectorOperation::add)
- Vector &
- Vector::operator*=(const double factor)
+ template <typename Number>
+ Vector<Number> &
+ Vector<Number>::operator*=(const Number factor)
{
AssertIsFinite(factor);
vector->scale(factor);
- Vector &
- Vector::operator/=(const double factor)
+ template <typename Number>
+ Vector<Number> &
+ Vector<Number>::operator/=(const Number factor)
{
AssertIsFinite(factor);
- Assert(factor != 0., ExcZero());
- *this *= 1. / factor;
+ Assert(factor != Number(0.), ExcZero());
+ *this *= Number(1.) / factor;
return *this;
}
- Vector &
- Vector::operator+=(const VectorSpaceVector<double> &V)
+ template <typename Number>
+ Vector<Number> &
+ Vector<Number>::operator+=(const VectorSpaceVector<Number> &V)
{
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&V) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&V) != nullptr,
ExcVectorTypeNotCompatible());
// Downcast V. If fails, throws an exception.
- const Vector &down_V = dynamic_cast<const Vector &>(V);
+ const Vector<Number> &down_V = dynamic_cast<const Vector<Number> &>(V);
// If the maps are the same we can Update right away.
if (vector->getMap()->isSameAs(*(down_V.trilinos_vector().getMap())))
{
data_exchange,
Tpetra::ADD);*/
- Tpetra::Vector<> dummy(vector->getMap(), false);
- Tpetra::Import<> data_exchange(dummy.getMap(),
+ Tpetra::Vector<Number> dummy(vector->getMap(), false);
+ Tpetra::Import<> data_exchange(dummy.getMap(),
down_V.trilinos_vector().getMap());
dummy.doExport(down_V.trilinos_vector(),
- Vector &
- Vector::operator-=(const VectorSpaceVector<double> &V)
+ template <typename Number>
+ Vector<Number> &
+ Vector<Number>::operator-=(const VectorSpaceVector<Number> &V)
{
this->add(-1., V);
- double Vector::operator*(const VectorSpaceVector<double> &V) const
+ template <typename Number>
+ Number Vector<Number>::operator*(const VectorSpaceVector<Number> &V) const
{
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&V) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&V) != nullptr,
ExcVectorTypeNotCompatible());
// Downcast V. If fails, throws an exception.
- const Vector &down_V = dynamic_cast<const Vector &>(V);
+ const Vector<Number> &down_V = dynamic_cast<const Vector<Number> &>(V);
Assert(this->size() == down_V.size(),
ExcDimensionMismatch(this->size(), down_V.size()));
Assert(vector->getMap()->isSameAs(*down_V.trilinos_vector().getMap()),
+ template <typename Number>
void
- Vector::add(const double a)
+ Vector<Number>::add(const Number a)
{
AssertIsFinite(a);
- vector->sync<Kokkos::HostSpace>();
- auto vector_2d = vector->getLocalView<Kokkos::HostSpace>();
+ vector->template sync<Kokkos::HostSpace>();
+ auto vector_2d = vector->template getLocalView<Kokkos::HostSpace>();
auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
- vector->modify<Kokkos::HostSpace>();
+ vector->template modify<Kokkos::HostSpace>();
const size_t localLength = vector->getLocalLength();
for (size_t k = 0; k < localLength; ++k)
{
vector_1d(k) += a;
}
- vector->sync<Tpetra::Vector<double>::device_type::memory_space>();
+ vector->template sync<
+ typename Tpetra::Vector<Number>::device_type::memory_space>();
}
+ template <typename Number>
void
- Vector::add(const double a, const VectorSpaceVector<double> &V)
+ Vector<Number>::add(const Number a, const VectorSpaceVector<Number> &V)
{
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&V) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&V) != nullptr,
ExcVectorTypeNotCompatible());
// Downcast V. If fails, throws an exception.
- const Vector &down_V = dynamic_cast<const Vector &>(V);
+ const Vector<Number> &down_V = dynamic_cast<const Vector<Number> &>(V);
AssertIsFinite(a);
Assert(vector->getMap()->isSameAs(*(down_V.trilinos_vector().getMap())),
ExcDifferentParallelPartitioning());
+ template <typename Number>
void
- Vector::add(const double a,
- const VectorSpaceVector<double> &V,
- const double b,
- const VectorSpaceVector<double> &W)
+ Vector<Number>::add(const Number a,
+ const VectorSpaceVector<Number> &V,
+ const Number b,
+ const VectorSpaceVector<Number> &W)
{
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&V) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&V) != nullptr,
ExcVectorTypeNotCompatible());
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&W) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&W) != nullptr,
ExcVectorTypeNotCompatible());
// Downcast V. If fails, throws an exception.
- const Vector &down_V = dynamic_cast<const Vector &>(V);
+ const Vector<Number> &down_V = dynamic_cast<const Vector<Number> &>(V);
// Downcast W. If fails, throws an exception.
- const Vector &down_W = dynamic_cast<const Vector &>(W);
+ const Vector<Number> &down_W = dynamic_cast<const Vector<Number> &>(W);
Assert(vector->getMap()->isSameAs(*(down_V.trilinos_vector().getMap())),
ExcDifferentParallelPartitioning());
Assert(vector->getMap()->isSameAs(*(down_W.trilinos_vector().getMap())),
+ template <typename Number>
void
- Vector::sadd(const double s,
- const double a,
- const VectorSpaceVector<double> &V)
+ Vector<Number>::sadd(const Number s,
+ const Number a,
+ const VectorSpaceVector<Number> &V)
{
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&V) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&V) != nullptr,
ExcVectorTypeNotCompatible());
*this *= s;
// Downcast V. It fails, throws an exception.
- const Vector &down_V = dynamic_cast<const Vector &>(V);
- Vector tmp(down_V);
+ const Vector<Number> &down_V = dynamic_cast<const Vector<Number> &>(V);
+ Vector<Number> tmp(down_V);
tmp *= a;
*this += tmp;
}
+ template <typename Number>
void
- Vector::scale(const VectorSpaceVector<double> &scaling_factors)
+ Vector<Number>::scale(const VectorSpaceVector<Number> &scaling_factors)
{
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&scaling_factors) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&scaling_factors) != nullptr,
ExcVectorTypeNotCompatible());
// Downcast scaling_factors. If fails, throws an exception.
- const Vector &down_scaling_factors =
- dynamic_cast<const Vector &>(scaling_factors);
+ const Vector<Number> &down_scaling_factors =
+ dynamic_cast<const Vector<Number> &>(scaling_factors);
Assert(vector->getMap()->isSameAs(
*(down_scaling_factors.trilinos_vector().getMap())),
ExcDifferentParallelPartitioning());
+ template <typename Number>
void
- Vector::equ(const double a, const VectorSpaceVector<double> &V)
+ Vector<Number>::equ(const Number a, const VectorSpaceVector<Number> &V)
{
// Check that casting will work.
- Assert(dynamic_cast<const Vector *>(&V) != nullptr,
+ Assert(dynamic_cast<const Vector<Number> *>(&V) != nullptr,
ExcVectorTypeNotCompatible());
// Downcast V. If fails, throws an exception.
- const Vector &down_V = dynamic_cast<const Vector &>(V);
+ const Vector<Number> &down_V = dynamic_cast<const Vector<Number> &>(V);
// If we don't have the same map, copy.
if (vector->getMap()->isSameAs(*down_V.trilinos_vector().getMap()) ==
false)
+ template <typename Number>
bool
- Vector::all_zero() const
+ Vector<Number>::all_zero() const
{
// get a representation of the vector and
// loop over all the elements
- double * start_ptr = vector->getDataNonConst().get();
- const double *ptr = start_ptr,
+ Number * start_ptr = vector->getDataNonConst().get();
+ const Number *ptr = start_ptr,
*eptr = start_ptr + vector->getLocalLength();
unsigned int flag = 0;
while (ptr != eptr)
{
- if (*ptr != 0)
+ if (*ptr != Number(0))
{
flag = 1;
break;
- double
- Vector::mean_value() const
+ template <typename Number>
+ Number
+ Vector<Number>::mean_value() const
{
return vector->meanValue();
}
- double
- Vector::l1_norm() const
+ template <typename Number>
+ typename LinearAlgebra::VectorSpaceVector<Number>::real_type
+ Vector<Number>::l1_norm() const
{
return vector->norm1();
}
- double
- Vector::l2_norm() const
+ template <typename Number>
+ typename LinearAlgebra::VectorSpaceVector<Number>::real_type
+ Vector<Number>::l2_norm() const
{
return vector->norm2();
}
- double
- Vector::linfty_norm() const
+ template <typename Number>
+ typename LinearAlgebra::VectorSpaceVector<Number>::real_type
+ Vector<Number>::linfty_norm() const
{
return vector->normInf();
}
- double
- Vector::add_and_dot(const double a,
- const VectorSpaceVector<double> &V,
- const VectorSpaceVector<double> &W)
+ template <typename Number>
+ Number
+ Vector<Number>::add_and_dot(const Number a,
+ const VectorSpaceVector<Number> &V,
+ const VectorSpaceVector<Number> &W)
{
this->add(a, V);
- Vector::size_type
- Vector::size() const
+ template <typename Number>
+ typename Vector<Number>::size_type
+ Vector<Number>::size() const
{
return vector->getGlobalLength();
}
+ template <typename Number>
MPI_Comm
- Vector::get_mpi_communicator() const
+ Vector<Number>::get_mpi_communicator() const
{
const auto tpetra_comm = dynamic_cast<const Teuchos::MpiComm<int> *>(
vector->getMap()->getComm().get());
+ template <typename Number>
::dealii::IndexSet
- Vector::locally_owned_elements() const
+ Vector<Number>::locally_owned_elements() const
{
IndexSet is(size());
// easy case: local range is contiguous
if (vector->getMap()->isContiguous())
{
-# ifndef DEAL_II_WITH_64BIT_INDICES
is.add_range(vector->getMap()->getMinGlobalIndex(),
vector->getMap()->getMaxGlobalIndex() + 1);
-# else
- is.add_range(vector->getMap()->getMinGlobalIndex(),
- vector->getMap()->getMaxGlobalIndex() + 1);
-# endif
}
else if (vector->getLocalLength() > 0)
{
- const Tpetra::Vector<> &
- Vector::trilinos_vector() const
+ template <typename Number>
+ const Tpetra::Vector<Number> &
+ Vector<Number>::trilinos_vector() const
{
return *vector;
}
- Tpetra::Vector<> &
- Vector::trilinos_vector()
+ template <typename Number>
+ Tpetra::Vector<Number> &
+ Vector<Number>::trilinos_vector()
{
return *vector;
}
+ template <typename Number>
void
- Vector::print(std::ostream & out,
- const unsigned int precision,
- const bool scientific,
- const bool across) const
+ Vector<Number>::print(std::ostream & out,
+ const unsigned int precision,
+ const bool scientific,
+ const bool across) const
{
AssertThrow(out, ExcIO());
boost::io::ios_flags_saver restore_flags(out);
else
out.setf(std::ios::fixed, std::ios::floatfield);
- vector->sync<Kokkos::HostSpace>();
- auto vector_2d = vector->getLocalView<Kokkos::HostSpace>();
- auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
+ vector->template sync<Kokkos::HostSpace>();
+ auto vector_2d = vector->template getLocalView<Kokkos::HostSpace>();
+ auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
const size_t local_length = vector->getLocalLength();
if (across)
+ template <typename Number>
std::size_t
- Vector::memory_consumption() const
+ Vector<Number>::memory_consumption() const
{
return sizeof(*this) +
vector->getLocalLength() *
- (sizeof(double) + sizeof(TrilinosWrappers::types::int_type));
+ (sizeof(Number) + sizeof(TrilinosWrappers::types::int_type));
}
+ template <typename Number>
void
- Vector::create_tpetra_comm_pattern(const IndexSet &source_index_set,
- const MPI_Comm &mpi_comm)
+ Vector<Number>::create_tpetra_comm_pattern(const IndexSet &source_index_set,
+ const MPI_Comm &mpi_comm)
{
source_stored_elements = source_index_set;
tpetra_comm_pattern =
std::make_shared<TpetraWrappers::CommunicationPattern>(
locally_owned_elements(), source_index_set, mpi_comm);
}
+
+ template class Vector<float>;
+ template class Vector<double>;
+ template class Vector<std::complex<float>>;
+ template class Vector<std::complex<double>>;
+
} // namespace TpetraWrappers
} // namespace LinearAlgebra
// Check LinearAlgebra::TpetraWrappers::Vector assignment and import
-
+template <typename Number>
void
test()
{
}
parallel_partitioner_1.compress();
parallel_partitioner_2.compress();
- LinearAlgebra::TpetraWrappers::Vector a;
- LinearAlgebra::TpetraWrappers::Vector b(parallel_partitioner_1,
- MPI_COMM_WORLD);
- LinearAlgebra::TpetraWrappers::Vector c(b);
+ LinearAlgebra::TpetraWrappers::Vector<Number> a;
+ LinearAlgebra::TpetraWrappers::Vector<Number> b(parallel_partitioner_1,
+ MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<Number> c(b);
AssertThrow(a.size() == 0, ExcMessage("Vector has the wrong size."));
AssertThrow(b.size() == 10, ExcMessage("Vector has the wrong size."));
read_write_index_set.add_range(4, 10);
read_write_index_set.compress();
- LinearAlgebra::ReadWriteVector<double> read_write_1(read_write_index_set);
- LinearAlgebra::ReadWriteVector<double> read_write_2(read_write_index_set);
- LinearAlgebra::ReadWriteVector<double> read_write_3(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_1(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_2(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_3(read_write_index_set);
if (rank == 0)
{
for (unsigned int i = 0; i < 6; ++i)
b.import(read_write_1, VectorOperation::insert);
c.import(read_write_1, VectorOperation::insert);
- const double val = b * c;
+ const Number val = b * c;
AssertThrow(val == 285., ExcMessage("Problem in operator *."));
}
Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv, 1);
- test();
+ test<double>();
+ test<float>();
deallog << "OK" << std::endl;
// Check LinearAlgebra::TpetraWrappers::Vector add and sadd.
+template <typename Number>
void
test()
{
}
parallel_partitioner_1.compress();
parallel_partitioner_2.compress();
- LinearAlgebra::TpetraWrappers::Vector a(parallel_partitioner_1,
- MPI_COMM_WORLD);
- LinearAlgebra::TpetraWrappers::Vector b(parallel_partitioner_1,
- MPI_COMM_WORLD);
- LinearAlgebra::TpetraWrappers::Vector c(parallel_partitioner_2,
- MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<Number> a(parallel_partitioner_1,
+ MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<Number> b(parallel_partitioner_1,
+ MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<Number> c(parallel_partitioner_2,
+ MPI_COMM_WORLD);
IndexSet read_write_index_set(10);
if (rank == 0)
read_write_index_set.add_range(5, 10);
read_write_index_set.compress();
- LinearAlgebra::ReadWriteVector<double> read_write_1(read_write_index_set);
- LinearAlgebra::ReadWriteVector<double> read_write_2(read_write_index_set);
- LinearAlgebra::ReadWriteVector<double> read_write_3(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_1(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_2(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_3(read_write_index_set);
if (rank == 0)
{
for (unsigned int i = 0; i < 5; ++i)
AssertThrow(b.l1_norm() == 95., ExcMessage("Problem in l1_norm."));
- const double eps = 1e-6;
+ const Number eps = 1e-6;
AssertThrow(std::fabs(b.l2_norm() - 31.3847096) < eps,
ExcMessage("Problem in l2_norm"));
AssertThrow(b.linfty_norm() == 14., ExcMessage("Problem in linfty_norm."));
a.import(read_write_1, VectorOperation::insert);
- const double val = a.add_and_dot(2., a, b);
+ const Number val = a.add_and_dot(2., a, b);
AssertThrow(val == 1530., ExcMessage("Problem in add_and_dot"));
}
Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv, 1);
- test();
+ test<double>();
+ test<float>();
deallog << "OK" << std::endl;
#include "../tests.h"
+template <typename Number>
void
test()
{
locally_owned.add_range(my_id * 2, my_id * 2 + 2);
locally_owned.compress();
- LinearAlgebra::TpetraWrappers::Vector v(locally_owned, MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<Number> v(locally_owned,
+ MPI_COMM_WORLD);
IndexSet workaround_set(n_procs * 2);
unsigned int my_first_index = (my_id * 2 + 2) % (n_procs * 2);
workaround_set.add_index(my_second_index);
workaround_set.add_index(0);
workaround_set.compress();
- LinearAlgebra::ReadWriteVector<double> rw_vector(workaround_set);
+ LinearAlgebra::ReadWriteVector<Number> rw_vector(workaround_set);
rw_vector(my_first_index) = my_id + 10;
rw_vector(my_second_index) = my_id + 100;
argc, argv, testing_max_num_threads());
MPILogInitAll log;
- test();
+ test<double>();
+ test<float>();
}
[0]: 4.000e+00
[1]: 2.000e+02
[2]: 1.000e+02
+DEAL:0::Tpetra first import add:
+2.000e+00 1.000e+02
+IndexSet: {[0,2]}
+
+[0]: 1.000e+00
+[1]: 1.000e+02
+[2]: 1.000e+01
+DEAL:0::Tpetra second import add:
+4.000e+00 2.000e+02
+IndexSet: {[0,2]}
+
+[0]: 2.000e+00
+[1]: 2.000e+02
+[2]: 2.000e+01
+DEAL:0::ReadWrite import add:
+IndexSet: {[0,2]}
+
+[0]: 6.000e+00
+[1]: 4.000e+02
+[2]: 5.000e+01
+DEAL:0::ReadWrite import min:
+IndexSet: {[0,2]}
+[0]: 4.000e+00
+[1]: 1.000e+00
+[2]: 3.000e+01
+DEAL:0::ReadWrite import max:
+IndexSet: {[0,2]}
+
+[0]: 4.000e+00
+[1]: 2.000e+02
+[2]: 1.000e+02
+
+DEAL:1::Tpetra first import add:
+1.000e+01 1.010e+02
+IndexSet: {0, 3}
+
+[0]: 1.000e+00
+[3]: 1.010e+02
+DEAL:1::Tpetra second import add:
+3.000e+01 2.010e+02
+IndexSet: {0, 3}
+
+[0]: 2.000e+00
+[3]: 2.010e+02
+DEAL:1::ReadWrite import add:
+IndexSet: {0, 3}
+
+[0]: 6.000e+00
+[3]: 4.020e+02
+DEAL:1::ReadWrite import min:
+IndexSet: {0, 3}
+
+[0]: 4.000e+00
+[3]: 1.000e+00
+DEAL:1::ReadWrite import max:
+IndexSet: {0, 3}
+
+[0]: 4.000e+00
+[3]: 2.010e+02
DEAL:1::Tpetra first import add:
1.000e+01 1.010e+02
IndexSet: {0, 3}
DEAL:0::ReadWrite import max:
IndexSet: {[0,2]}
+[0]: 8.000e+00
+[1]: 2.000e+02
+[2]: 1.000e+02
+DEAL:0::Tpetra first import add:
+4.000e+00 1.000e+02
+IndexSet: {[0,2]}
+
+[0]: 1.000e+00
+[1]: 1.000e+02
+[2]: 1.000e+01
+DEAL:0::Tpetra second import add:
+8.000e+00 2.000e+02
+IndexSet: {[0,2]}
+
+[0]: 2.000e+00
+[1]: 2.000e+02
+[2]: 2.000e+01
+DEAL:0::ReadWrite import add:
+IndexSet: {[0,2]}
+
+[0]: 1.000e+01
+[1]: 4.000e+02
+[2]: 5.000e+01
+DEAL:0::ReadWrite import min:
+IndexSet: {[0,2]}
+
+[0]: 4.000e+00
+[1]: 1.000e+00
+[2]: 3.000e+01
+DEAL:0::ReadWrite import max:
+IndexSet: {[0,2]}
+
[0]: 8.000e+00
[1]: 2.000e+02
[2]: 1.000e+02
DEAL:1::ReadWrite import max:
IndexSet: {0, [3,4]}
+[0]: 8.000e+00
+[3]: 2.010e+02
+[4]: 1.010e+02
+DEAL:1::Tpetra first import add:
+1.000e+01 1.010e+02
+IndexSet: {0, [3,4]}
+
+[0]: 1.000e+00
+[3]: 1.010e+02
+[4]: 1.100e+01
+DEAL:1::Tpetra second import add:
+3.000e+01 2.010e+02
+IndexSet: {0, [3,4]}
+
+[0]: 2.000e+00
+[3]: 2.010e+02
+[4]: 2.100e+01
+DEAL:1::ReadWrite import add:
+IndexSet: {0, [3,4]}
+
+[0]: 1.000e+01
+[3]: 4.020e+02
+[4]: 5.300e+01
+DEAL:1::ReadWrite import min:
+IndexSet: {0, [3,4]}
+
+[0]: 4.000e+00
+[3]: 1.000e+00
+[4]: 3.200e+01
+DEAL:1::ReadWrite import max:
+IndexSet: {0, [3,4]}
+
[0]: 8.000e+00
[3]: 2.010e+02
[4]: 1.010e+02
[0]: 8.000e+00
[5]: 2.020e+02
[6]: 1.020e+02
+DEAL:2::Tpetra first import add:
+1.100e+01 1.020e+02
+IndexSet: {0, [5,6]}
+[0]: 1.000e+00
+[5]: 1.020e+02
+[6]: 1.200e+01
+DEAL:2::Tpetra second import add:
+3.200e+01 2.020e+02
+IndexSet: {0, [5,6]}
+[0]: 2.000e+00
+[5]: 2.020e+02
+[6]: 2.200e+01
+DEAL:2::ReadWrite import add:
+IndexSet: {0, [5,6]}
+
+[0]: 1.000e+01
+[5]: 4.040e+02
+[6]: 5.600e+01
+DEAL:2::ReadWrite import min:
+IndexSet: {0, [5,6]}
+
+[0]: 4.000e+00
+[5]: 1.000e+00
+[6]: 3.400e+01
+DEAL:2::ReadWrite import max:
+IndexSet: {0, [5,6]}
+
+[0]: 8.000e+00
+[5]: 2.020e+02
+[6]: 1.020e+02
+
+
+DEAL:3::Tpetra first import add:
+1.200e+01 1.030e+02
+IndexSet: {0, 7}
+
+[0]: 1.000e+00
+[7]: 1.030e+02
+DEAL:3::Tpetra second import add:
+3.400e+01 2.030e+02
+IndexSet: {0, 7}
+
+[0]: 2.000e+00
+[7]: 2.030e+02
+DEAL:3::ReadWrite import add:
+IndexSet: {0, 7}
+
+[0]: 1.000e+01
+[7]: 4.060e+02
+DEAL:3::ReadWrite import min:
+IndexSet: {0, 7}
+
+[0]: 4.000e+00
+[7]: 1.000e+00
+DEAL:3::ReadWrite import max:
+IndexSet: {0, 7}
+
+[0]: 8.000e+00
+[7]: 2.030e+02
DEAL:3::Tpetra first import add:
1.200e+01 1.030e+02
IndexSet: {0, 7}