Error of system after solving

38 views
Skip to first unread message

Léonhard YU

unread,
Apr 9, 2025, 8:52:27 AM4/9/25
to deal.II User Group
Dear all,
 I just wander how to estimate the error of system by 
Error = system_matrix * displacement - system_rhs 
in step-18. I wrote the following codes 
PETScWrappers::MPI::Vector error(locally_owned_dofs, mpi_communicator);
error.reinit(system_rhs);
system_matrix.vmult(error, distributed_incremental_displacement);
error -= system_rhs;
pcout << " l2_norm of system error " << error.l2_norm();
after solving section
cg.solve(system_matrix,
distributed_incremental_displacement,
system_rhs,
preconditioner);
But the result is very large. Is there any operation that I did wrong? Results are:

  Cycle 0:
    Number of active cells:       3712 (by partition: 616+624+616+616+624+616)
    Number of degrees of freedom: 17226 (by partition: 3177+2934+2763+2934+2790+2628)
    Assembling system... norm of rhs is 1.80592e+10
    l2_norm of error system 22537.2    Solver converged in 135 iterations.
    Updating quadrature point data...
  Cycle 1:
    Number of active cells:       12805 (by partition: 2136+2136+2134+2130+2137+2132)
    Number of degrees of freedom: 51744 (by partition: 8919+8433+8580+8376+8163+9273)
    Assembling system... norm of rhs is 3.60696e+10
    l2_norm of error system 32196.1    Solver converged in 139 iterations.
    Updating quadrature point data...
    Moving mesh...

Best Regards,
Leo


Daniel Arndt

unread,
Apr 9, 2025, 4:42:53 PM4/9/25
to dea...@googlegroups.com
Leo,

it's probably more interesting for you to look at the relative error
rather than the absolute one.
Also Vector::l2_norm() gives you the l2-norm of the entries, not the
L2-norm of the represented finite element function. Do you compute
that L2-norm, you would use VectorTools::integrate_difference as
demonstrated in step-11.

Best,
Daniel
> --
> 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/24b344a3-4acc-455a-b5d8-38a43a480ca2n%40googlegroups.com.

Wolfgang Bangerth

unread,
Apr 9, 2025, 4:58:29 PM4/9/25
to dea...@googlegroups.com

On 4/9/25 06:52, Léonhard YU wrote:
> But the result is very large. Is there any operation that I did wrong?
> Results are:
>
>   Cycle 0:
>     Number of active cells:       3712 (by partition:
> 616+624+616+616+624+616)
>     Number of degrees of freedom: 17226 (by partition:
> 3177+2934+2763+2934+2790+2628)
>     Assembling system... norm of rhs is 1.80592e+10
> *l2_norm of error system 22537.2 *

I'd like to point out a perspective I've raised here before: 22537 is
large if you're a snail and it refers to a distance of 22537 kilometers.
It is not large if you're a human and it refers to a duration of 22537
microseconds. The point is: 22537 is neither large nor small by itself
-- whether it is depends on what it is you are measuring, what the units
are, and what you compare it against.

In the current context, you are measuring the residual. You should be
comparing it to the norm of the right hand side, for example. Look at
residual.l2_norm() / right_hand_side.l2_norm()
to see whether the norm of the residual is large or small. In other
words, follow Daniel's suggestion of looking at the *relative* error.

Best
W.
Reply all
Reply to author
Forward
0 new messages