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.


> On 29 Apr 2025, at 10:08, Alex <[email protected]> wrote:
> 
> 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
> 
> 
> -- 
> 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/867b3052-f441-4d64-9621-3fd34b9c4c36n%40googlegroups.com.

-- 
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/165EB1FB-50F6-4031-B789-B4710D6A2B1E%40gmail.com.

Reply via email to