Compute the error residual for a specific DOF component

34 views
Skip to first unread message

Alex

unread,
Apr 29, 2025, 4:08:53 AM4/29/25
to deal.II User Group

Dear deal.II users, 

I'm working on a monolithic coupled problem using deal.II  where I'm solving for multiple variables (e.g., displacement u, concentration c, etc.) using a single DoFHandler and a full matrix system (i.e., not using block structures). I use FEValuesExtractors to access individual components.

I want to compute the error residual (e.g., L2 norm) for a specific component only, such as displacement, by extracting only the relevant DOFs from the global residual vector system_rhs.

Here is the simplified version of what I’m doing:

Vector<double> system_rhs; // UMFPACK   

Vector<double> error_res(dof_handler.n_dofs());
for (unsigned int i = 0; i < dof_handler.n_dofs(); ++i)
  if (!constraints.is_constrained(i))
    error_res(i) = system_rhs(i);
error_residual.norm = error_res.l2_norm();


This computes the total residual, but how can I correctly isolate and compute the residual only for the displacement component (or any other specific field).

Thanks in advance!


Regards,

Alex


Luca Heltai

unread,
Apr 29, 2025, 4:32:12 AM4/29/25
to Deal.II Users
You could use:

auto mask = fe.component_mask(extractor);
auto indices = DoFTools::extract_dofs(dh, mask);

for(const auti i: indices)
if (!constraints.is_constrained(i))



https://www.dealii.org/current/doxygen/deal.II/namespaceDoFTools.html#a45f4d01f1c4c6337e4be6f10a81fbdab


Best,
Luca.
> --
> 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/867b3052-f441-4d64-9621-3fd34b9c4c36n%40googlegroups.com.

Alex

unread,
Apr 29, 2025, 7:29:36 AM4/29/25
to deal.II User Group
Thank you for your support.
Reply all
Reply to author
Forward
0 new messages