<ol>
<li>New: There is now a method to copy the content from a
- PETScWrappers::MPI::Vector to deal.II's parallel distributed vector.
+ PETScWrappers::MPI::Vector and TrilinosWrappers::MPI::Vector to
+ deal.II's parallel distributed vector.
<br>
- (Ben Thompson, 2014/01/31)
+ (Ben Thompson, Martin Kronbichler, 2014/01/31)
<li>Fixed: The SolutionTransfer class had all sorts of problems when
used with hp::DoFHandler that made its results at least questionable.
#include <deal.II/lac/block_vector_base.h>
#include <deal.II/lac/parallel_vector.h>
+#include <deal.II/lac/petsc_parallel_block_vector.h>
+#include <deal.II/lac/trilinos_parallel_block_vector.h>
+
+
#include <cstdio>
#include <vector>
DEAL_II_NAMESPACE_OPEN
-
namespace parallel
{
namespace distributed
BlockVector &
operator= (const Vector<Number> &V);
+#ifdef DEAL_II_WITH_PETSC
+ /**
+ * Copy the content of a PETSc vector into the calling vector. This
+ * function assumes that the vectors layouts have already been
+ * initialized to match.
+ *
+ * This operator is only available if deal.II was configured with PETSc.
+ */
+ BlockVector<Number> &
+ operator = (const PETScWrappers::MPI::BlockVector &petsc_vec);
+#endif
+
+#ifdef DEAL_II_WITH_TRILINOS
+ /**
+ * Copy the content of a Trilinos vector into the calling vector. This
+ * function assumes that the vectors layouts have already been
+ * initialized to match.
+ *
+ * This operator is only available if deal.II was configured with
+ * Trilinos.
+ */
+ BlockVector<Number> &
+ operator = (const TrilinosWrappers::MPI::BlockVector &trilinos_vec);
+#endif
+
/**
* Reinitialize the BlockVector to contain <tt>num_blocks</tt> blocks of
* size <tt>block_size</tt> each.
+#ifdef DEAL_II_WITH_PETSC
+
+ template <typename Number>
+ BlockVector<Number> &
+ BlockVector<Number>::operator = (const PETScWrappers::MPI::BlockVector &petsc_vec)
+ {
+ AssertDimension(this->n_blocks(), petsc_vec.n_blocks());
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
+ this->block(i) = petsc_vec.block(i);
+
+ return *this;
+ }
+
+#endif
+
+
+
+#ifdef DEAL_II_WITH_TRILINOS
+
+ template <typename Number>
+ BlockVector<Number> &
+ BlockVector<Number>::operator = (const TrilinosWrappers::MPI::BlockVector &trilinos_vec)
+ {
+ AssertDimension(this->n_blocks(), trilinos_vec.n_blocks());
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
+ this->block(i) = trilinos_vec.block(i);
+
+ return *this;
+ }
+
+#endif
+
+
+
template <typename Number>
inline
void
}
#endif
+#ifdef DEAL_II_WITH_TRILINOS
+namespace TrilinosWrappers
+{
+ namespace MPI
+ {
+ class Vector;
+ }
+}
+#endif
+
namespace parallel
{
#ifdef DEAL_II_WITH_PETSC
/**
- * Copy the content of a PETSc vector into a vector. This function
- * assumes that the vectors layouts have already been initialized to
- * match.
+ * Copy the content of a PETSc vector into the calling vector. This
+ * function assumes that the vectors layouts have already been
+ * initialized to match.
*
* This operator is only available if deal.II was configured with PETSc.
*/
operator = (const PETScWrappers::MPI::Vector &petsc_vec);
#endif
+#ifdef DEAL_II_WITH_TRILINOS
+ /**
+ * Copy the content of a Trilinos vector into the calling vector. This
+ * function assumes that the vectors layouts have already been
+ * initialized to match.
+ *
+ * This operator is only available if deal.II was configured with
+ * Trilinos.
+ */
+ Vector<Number> &
+ operator = (const TrilinosWrappers::MPI::Vector &trilinos_vec);
+#endif
+
/**
* This method copies the local range from another vector with the same
* local range, but possibly different layout of ghost indices.
#include <deal.II/base/config.h>
#include <deal.II/lac/parallel_vector.h>
+#include <deal.II/lac/vector_view.h>
#include <deal.II/lac/petsc_parallel_vector.h>
+#include <deal.II/lac/trilinos_vector.h>
DEAL_II_NAMESPACE_OPEN
#ifdef DEAL_II_WITH_PETSC
template <typename Number>
- inline
Vector<Number> &
Vector<Number>::operator = (const PETScWrappers::MPI::Vector &petsc_vec)
{
AssertThrow (ierr == 0, ExcPETScError(ierr));
// spread ghost values between processes?
- bool must_update_ghost_values = vector_is_ghosted ||
- petsc_vec.has_ghost_elements();
- if (must_update_ghost_values)
+ if (vector_is_ghosted || petsc_vec.has_ghost_elements())
+ update_ghost_values();
+
+ // return a pointer to this object per normal c++ operator overloading
+ // semantics
+ return *this;
+ }
+
+#endif
+
+
+
+#ifdef DEAL_II_WITH_TRILINOS
+
+ template <typename Number>
+ Vector<Number> &
+ Vector<Number>::operator = (const TrilinosWrappers::MPI::Vector &trilinos_vec)
+ {
+ Assert(trilinos_vec.locally_owned_elements() == locally_owned_elements(),
+ StandardExceptions::ExcInvalidState());
+
+ // create on trilinos data
+ const VectorView<double> in_view (local_size(), trilinos_vec.begin());
+ static_cast<::dealii::Vector<Number>&>(vector_view) =
+ static_cast<const ::dealii::Vector<double>&>(in_view);
+
+ // spread ghost values between processes?
+ if (vector_is_ghosted || trilinos_vec.has_ghost_elements())
update_ghost_values();
// return a pointer to this object per normal c++ operator overloading