How to obtain parallel solution with the mass-lumping matrix

35 views
Skip to first unread message

Giang Huynh

unread,
Sep 21, 2025, 4:35:22 PMSep 21
to deal.II User Group

Hi all,

I am trying to write a code that doesn't require a linear solver by using the mass lumping technique. My current implementation looks like this:

active_set.clear(); active_set.set_size(dof_handler.n_dofs()); std::vector<types::global_dof_index> local_dof_indices(fe.dofs_per_cell); typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell != endc; ++cell) { if (! cell->is_locally_owned()) continue; cell->get_dof_indices(local_dof_indices); for (unsigned int i=0; i<fe.dofs_per_cell; ++i) { const types::global_dof_index idx = local_dof_indices[i]; if (active_set.is_element(idx)|| constraints_hanging_nodes.is_constrained(idx)) continue; newton_update(idx) = rhs_relevant(idx)/diag_total_relevant(idx); active_set.add_index(idx); } } newton_update.compress(VectorOperation::insert); constraints_update.distribute(newton_update);

It works well. However, the only issue is that looping over cell in typename DoFHandler::active_cell_iterator degrades the performance greatly, which is slower than solving the linear system by an iterative solver like GMRES. I wish I can write a parallel code like this:

for(int idx=0; idx< newton_update.size(); idx++) if(diag_total_relevant(idx)>1e-20) newton_update(idx) = rhs_relevant(idx)/diag_total_relevant(idx);

However, it only works for single core. I really appreciate if anyone has any idea to paralellize the solve part with the mass lumping technique.

Bruno Turcksin

unread,
Sep 22, 2025, 12:54:54 PMSep 22
to deal.II User Group
Hello,

Which type of vector are you using? If you use `dealii::LinearAlgebra::Distributed::vector`, local_element() does what you want.

Best,

Bruno

Giang Huynh

unread,
Sep 27, 2025, 7:00:20 PMSep 27
to dea...@googlegroups.com
Hello Bruno,

Thanks a lot. It works perfectly with local_element() and a lot faster than looping over cells.

Best,
Giang

--
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/885e5cc4-f5f0-4aff-8cfc-2459dd7e7c22n%40googlegroups.com.

Bruno Turcksin

unread,
Sep 29, 2025, 9:10:52 AMSep 29
to deal.II User Group
Great. I am glad it does what you needed.

Best,

Bruno
Reply all
Reply to author
Forward
0 new messages