Copying trilinos vector to dealii vector

18 views
Skip to first unread message

Praveen C

unread,
Aug 26, 2026, 6:37:00 AM (10 days ago) Aug 26
to Deal.II Googlegroup
Hello

I am trying to copy a   

TrilinosWrappers::MPI::Vector tmp;

into a 

LinearAlgebra::distributed::Vector euler;

Code is below.

This seems to work with one rank in the sense that my code runs as expected.

But not with more than one rank; my code fails at a later stage and I suspect this copying is not working correctly.

Both vector use same triangulation and dofhandler.

Is there a proper way to do this ?

I have seen ReadWriteVector; should I use this to transfer b/w the two vectors ?

thanks
praveen

  const FESystem<dim> fe(FE_Q<dim>(degree), dim);
  dof_handler.clear();
  dof_handler.distribute_dofs(fe);
  TrilinosWrappers::MPI::Vector tmp;
  Winslow::compute_mapping(degree,
                           *triangulation,
                           dof_handler,
                           tmp); // compute tmp vector

  // Copy tmp into euler
  const auto &locally_owned_dofs = dof_handler.locally_owned_dofs();
  const auto locally_relevant_dofs =
      DoFTools::extract_locally_relevant_dofs(dof_handler);

  euler.reinit(locally_owned_dofs,
               locally_relevant_dofs,
               dof_handler.get_mpi_communicator());

  // Copy local elements
  std::copy_n(tmp.trilinos_vector().Values(),
              tmp.locally_owned_elements().n_elements(),
              euler.begin());

  euler.update_ghost_values();

Daniel Arndt

unread,
Aug 26, 2026, 1:58:27 PM (9 days ago) Aug 26
to dea...@googlegroups.com
Praveen,

Yes, ReadWriteVector is the right tool for that.

Best,
Daniel
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/dealii/CAEvUdMJ3gYfSnRdgCySDyN2byPqfqs9cQnqFXuHgbi%2B5LQYDdw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages