Will locally_relevant_dofs be needed when reinit a vector?

21 views
Skip to first unread message

yy.wayne

unread,
Oct 28, 2022, 2:50:58 AM10/28/22
to deal.II User Group
I have a question that if ghost_indices should be past to a vector's reinit? In step-40 and line 89 of this test, system_rhs and solution are reinit with reinit(local_dofs, mpi_communicator) only. But in line 95 of that test, we need ghost_indices as argument. That's same for one of my code, where I found a bug because I didn't use locally_relevant_dofs when reinit a system_rhs. To reduce mistakes, should vectors always be reinit with ghost_indices then ?

Thank you

Wolfgang Bangerth

unread,
Oct 28, 2022, 10:50:37 AM10/28/22
to dea...@googlegroups.com
On 10/28/22 00:50, 'yy.wayne' via deal.II User Group wrote:
> I have a question that if ghost_indices should be past to a vector's reinit?
> In step-40 and line 89 of this test
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdealii%2Fdealii%2Fblob%2Fmaster%2Ftests%2Fmpi%2Fsolution_transfer_04.cc%23%3A~%3Atext%3Dsolution.reinit(locally_owned_dofs%2C%2520MPI_COMM_WORLD)%3B&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7C7703891c22db47014d6308dab8b0c6be%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638025366645029265%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Q%2FZxqQEdJR%2FeoBSz8SNn0LAocgqvLtSV6tAmkUeeCeA%3D&reserved=0>,
> system_rhs and solution are reinit with reinit(local_dofs, mpi_communicator)
> only. But in line 95 of that test
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdealii%2Fdealii%2Fblob%2Fmaster%2Ftests%2Fmpi%2Fsolution_transfer_04.cc%23%3A~%3Atext%3Dold_solution.reinit(locally_owned_dofs%2C&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7C7703891c22db47014d6308dab8b0c6be%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638025366645029265%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=YI0OrnoL5OxFwMaqTC7lxVpwgqL%2BS3dbkNDMPfI%2FmUo%3D&reserved=0>,
> we need ghost_indices as argument. That's same for one of my code, where I
> found a bug because I didn't use locally_relevant_dofs when reinit a
> system_rhs. To reduce mistakes, should vectors always be reinit with
> ghost_indices then ?

No. The question is whether you need ghost elements in the vector or not, and
that is typically a question on whether you need to *read* individual entries.
When you build the right hand side and when you call a solver to compute the
solution vector, we use "completely distributed vectors" that do not have
ghost elements. When you want to output the solution graphically, however, you
need to be able to read individual vector elements also for ghost entries, and
so then you need the locally relevant dofs. Vectors with ghost elements are
read-only.

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

yy.wayne

unread,
Oct 29, 2022, 4:10:49 AM10/29/22
to deal.II User Group
Thank you!
Reply all
Reply to author
Forward
0 new messages