RHS function represented by an interpolation

49 views
Skip to first unread message

Alexander Kiselyov

unread,
Jul 15, 2022, 10:37:02 AM7/15/22
to dea...@googlegroups.com
Dear deal.II users,

I'd like to ask a question concerning the use of RHS function represented by a DoF vector from another solver.

I'm trying to build RHS of one solver (A) using solution obtained with another solver (B) , i.e. instead of Function there is a DoF vector. Both solvers have the same coarse Triangulation (but differently refined), but with different finite element systems: RHS source (solver B) uses FESystem(FE_DGQ<dim>, 1, FESystem(FE_DGQ<dim>, dim), 1), the solver A uses FESystem(FE_Q<dim>, 1, FE_Nedelec<dim>, 1). I have devised the following scheme:

  1. Solver A contains two DoFHandlers: one for RHS vector (dof_handler_rhs), and another for the equation to solve (dof_handler);
  2. The solver B's output gets interpolated via VectorTools::interpolate_to_different_mesh using dof_handler_rhs as the destination space;
  3. During solver A's assembly phase a separate FEValues is created for RHS vector which is initialized to the same cell as the FEValues corresponding to the equation;
  4. FEValues::get_function_values gives RHS function values at the quadrature points.

The problem here is the step 3: somehow I need to specify the same geometric cell for two FEValues with different finite element systems while preserving the ability to use get_function_values. Surprisingly, there doesn't seem to be any obvious way to convert CellAccessor given by Triangulation::active_cell_iterators() to TriaIterator<DoFCellAccessor> needed for a "full reinit".

Of course, one can use VectorTools::point_value (or FEFieldFunction) directly without interpolating, but it seems that the performance would be very low: because of differing finite element systems, I cannot even pass a cell hint. There is also an option to interpolate the B's solution to the FE system used to solve A, but there might be an RHS incompatible with FE_Nedelec elements.

Which tools could be used to overcome this problem? Or is my approach deficient in general?

Best regards,
Alexander Kiselyov

Wolfgang Bangerth

unread,
Jul 15, 2022, 3:36:25 PM7/15/22
to dea...@googlegroups.com
On 7/15/22 08:36, Alexander Kiselyov wrote:
>
> Which tools could be used to overcome this problem? Or is my approach
> deficient in general?

Alexander:
You want to evaluate the solution obtained on one DoFHandler at quadrature
points so that you can form the right hand side for a system that lives on a
different DoFHandler (but if I understand correctly, the same mesh).

In that case, just use two different FEValues objects. You will just iterate
through the cells of the two DoFHandler objects in synch (the order of cells
in a DoFHandler is the same as in a triangulation, so they will always point
to the same cells), re-init the two FEValues objects on these two cells, and
then use one via get_function_values() to obtain the values of the previous
solution, and the other to obtain the values of shape functions of the other
DoFHandler. Your right hand side is then simply the product of the two, summed
over the quadrature points.

Using this scheme, you never need the (expensive) function
VectorTools::interpolate_to_different_mesh.

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Jean-Paul Pelteret

unread,
Jul 15, 2022, 4:51:30 PM7/15/22
to dea...@googlegroups.com
Hi Alexander,

The answer that Wolfgang gave is the one that you want to follow. But I can give some input into your one question.

The problem here is the step 3: somehow I need to specify the same geometric cell for two FEValues with different finite element systems while preserving the ability to use get_function_values. Surprisingly, there doesn't seem to be any obvious way to convert CellAccessor given by Triangulation::active_cell_iterators() to TriaIterator<DoFCellAccessor> needed for a "full reinit”.

There is, actually. Its a common question to which you can find the answer here:

Having seen enough people ask this, I decided to open a PR to wrap this in a convenience function. (see  https://github.com/dealii/dealii/pull/14143 ). This might simplify things in the future.

Best,
Jean-Paul


--
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 on the web visit https://groups.google.com/d/msgid/dealii/917cdbad-e6f6-dc39-84ba-af7829952022%40colostate.edu.

Alexander Kiselyov

unread,
Jul 18, 2022, 6:21:45 AM7/18/22
to dea...@googlegroups.com
Thank you very much for the answer! I was unsure that the cell
iteration order is stable, that helps a lot!

Regarding the mesh, I'm not sure I use the correct terms, but for two
solvers I'm going to use the same "starting" mesh but with different
refinement (two solvers having their own mesh refinement loops). It
seems that in this case VectorTools::interpolate_to_different_mesh has
to be used, am I right?

Best regards,
Alexander Kiselyov

Alexander Kiselyov

unread,
Jul 18, 2022, 6:23:46 AM7/18/22
to dea...@googlegroups.com
Thank you very much, Jean-Paul! I have totally forgot that deal.II has a wiki in addition to doxygen documentation!

Best regards,
Alexander Kiselyov

Wolfgang Bangerth

unread,
Jul 18, 2022, 12:12:17 PM7/18/22
to dea...@googlegroups.com
On 7/18/22 04:21, Alexander Kiselyov wrote:
> Regarding the mesh, I'm not sure I use the correct terms, but for two
> solvers I'm going to use the same "starting" mesh but with different
> refinement (two solvers having their own mesh refinement loops). It
> seems that in this case VectorTools::interpolate_to_different_mesh has
> to be used, am I right?

Yes. Or some other way to evaluate the solution on one mesh on the quadrature
points of another mesh.

Best
W.

--
------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages