Non-analytical Matrix-Free coefficient

73 views
Skip to first unread message

Thomas Cheetham

unread,
Jul 11, 2025, 11:26:22 AMJul 11
to deal.II User Group
Hello everyone,

I am currently developing a matrix-free code which has a non-analytical spatially varying coefficient. As in step-37 I am using a  Table<2, VectorizedArray<number>> to store evaluations of the  coefficient at all the quadrature points for a given cell batch.

I read my coefficient in from a CSV file corresponding to the values at DOF in a structured mesh which I am using to generate a FEFieldFunction object which i call for all quadrature points to initialize the values in the matrix-free coefficient table. This approach is fairly slow but works okay for the finest level (where the parallel distributed triangulation is the same as the structured mesh). However for coarser multigrid levels I run into issues where the cell within which I am trying to evaluate points is no longer owned by the current processor.

I was wondering if anyone has any suggestions as to how to get around this, or perhaps has any ideas for a faster approach?

Many thanks,

Tom 

Timo Heister

unread,
Jul 23, 2025, 10:40:25 AMJul 23
to dea...@googlegroups.com
Hi Tom,

What we do in ASPECT is the following:
1. evaluate the coefficient on the active cells and store in a Table
(for each Q point)
2. Project into a FE_DGQ(k) on each cell and store in a finite element
coefficient vector (you can pick k, k=0 would be a constant per cell)
3. interpolate_to_mg() to get a coefficient vector on each multigrid level
4. convert to a Table (interpolate to quadrature points or store a
constant per cell)

You can see this in action here:
https://github.com/geodynamics/aspect/blob/0a1784a421d555240c7710b77fe157aea12bb66c/source/simulator/solver/stokes_matrix_free_local_smoothing.cc#L371

We do this because coefficient data is not available on coarser levels
and because, even if it was, it is unlikely to improve the convergence
to have the real coefficient on the coarser levels.
> --
> 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/3f0dd574-5f3a-4300-8803-9a80dd2f318bn%40googlegroups.com.

Thomas Cheetham

unread,
Aug 13, 2025, 7:54:01 AMAug 13
to deal.II User Group
Thank you for your help Timo, that worked well.

Best wishes,

Tom

Reply all
Reply to author
Forward
0 new messages