FENothing and `VectorTools::integrate_difference`

27 views
Skip to first unread message

Davit Gyulamiryan

unread,
Oct 16, 2024, 11:56:54 AM10/16/24
to deal.II User Group
Hi,

I am trying to calculate the error of a solver (I am solving Oseen equation with the analytical solution as the convective field). To do this I both used `VectorTools::integrate_difference` and implemented my own error calculating function (for comparison).

My domain is slightly bigger than the physical domain where I want to solve the problem (it's sort of similar to cut-cell) so I have two FE objects: one for the fluid domain with (dim + 1) FE_Q<dim> components, and another one for the empty domain with (dim + 1) FE_Nothing<dim> components.

Additionally, I am running a convergence test with adaptive refinement of the boundary and the interior of the physical domain. Hanging nodes constraints are applied where needed.

Error calculation using deal.ii `VectorTools::integrate_difference`:
      const ComponentSelectFunction<dim> velocity_mask(
std::make_pair(0, dim),
                                                  dim + 1);
      Vector<double> cellwise_errors(triangulation.n_active_cells());
      QGauss<dim>    quadrature(velocity_degree + 2);
      cellwise_errors = 0.0;
      VectorTools::integrate_difference(dof_handler,
                                        locally_relevant_solution,
                                        exact_solution_function,
                                        cellwise_errors,
                                        quadrature,
                                        VectorTools::L2_norm,
                                        &velocity_mask);

On the initial grid (cycle 0) `VectorTools::integrate_difference` gives the same error estimate as my function, but on the next grid and thereafter `VectorTools::integrate_difference` computes an unreasonable error:

Error on the initial grid is ~1.6e-3
Error on the second grid is ~9.2
Error on the third grid is ~11.5

My function:
1.578e-03
3.956e-04
1.021e-04

My implementation is rather long and is not really relevant to the question itself. It seems to be working so can just use it instead of the built-in functions, but I was interested if I have a bug somewhere in the code.

Has anyone ever had this or similar problem, or know how to use the built-in funcionality of deal.ii for my case?

Many thanks,
Davit

Wolfgang Bangerth

unread,
Oct 16, 2024, 1:34:28 PM10/16/24
to dea...@googlegroups.com

On 10/16/24 09:53, Davit Gyulamiryan wrote:
>
> Error on the initial grid is ~1.6e-3
> Error on the second grid is ~9.2
> Error on the third grid is ~11.5
>
> My function:
> 1.578e-03
> 3.956e-04
> 1.021e-04
>
> My implementation is rather long and is not really relevant to the
> question itself. It seems to be working so can just use it instead of
> the built-in functions, but I was interested if I have a bug somewhere
> in the code.
>
> Has anyone ever had this or similar problem, or know how to use the
> built-in funcionality of deal.ii for my case?

It's of course hard to tell without seeing the complete code, but just
in case here's a guess:
* On the cells where you use the FE_Nothing, your finite element
solution is zero.
* On those same cells, your exact solution is probably *not* zero.
* VectorTools::integrate_difference() integrates over *all* cells.
* As a consequence, on the cells with FE_Nothing, you don't compute
|| u_h - u ||
but instead
|| -u ||
and that would probably not be what you want.

Best
W.

Davit Gyulamiryan

unread,
Oct 17, 2024, 4:58:14 PM10/17/24
to deal.II User Group
Yes, this seems to be the case. Thank you.

Best,
Davit
Reply all
Reply to author
Forward
0 new messages