Hello, Which type of vector are you using? If you use `dealii::LinearAlgebra::Distributed::vector`, local_element() <https://dealii.org/current/doxygen/deal.II/classLinearAlgebra_1_1distributed_1_1Vector.html#aece21ea9363225c85b920cb70d2a6c2a> does what you want.
Best, Bruno On Sunday, September 21, 2025 at 4:35:22 PM UTC-4 [email protected] wrote: > 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. > -- 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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/dealii/9fc5695d-5a91-4c3e-8f11-ba5704fd77a8n%40googlegroups.com.
