Fast FE evaluation over several points and several functions

47 views
Skip to first unread message

Juan Carlos Araujo Cabarcas

unread,
Jun 22, 2016, 8:31:35 AM6/22/16
to deal.II User Group

Dear all,

I am solving an eigenvalue problem similar than step-36. After solving for the eigenpairs, I evaluate the eigenfunctions in the standard way:

        VectorTools::point_value ( mapping, dof_handler, efun[m], q_points[j], Uq );

where: efun[m] is the m-th eigenfunction from step-36,
q_points[j] are selected quadrature points,
Uq is where I store the FE evaluation.

As expected, this operation is awfully slow! it takes seconds for a single point evaluation with a decent discretization and having m eigenfunctions makes it worse!

1) I wonder if there is a way to evaluate the whole vector q_points with a single (and clever) call instead of looping on j and calling VectorTools::point_value(... , q_points[j], ...).

I remember when coding basic FEM in matlab, I had loops over several points in order to reduce the overhead of evaluating the FE

for c in cells
    for x in q_points
        if x is in cell
            evaluate FE: evaluate FE:  loop over shape functions with support in c,
            U(x)=sum ...
        end
    end
end

2) My issue today goes beyond evaluating in several points ... I also require to evaluate several FE vectors (eigenfunctions). Intuitively, one would evaluate the FE like:

for c in cells
    for x in q_points
        if x is in cell
            for m ... in eigenfunctions
                evaluate FE:  loop over shape functions with support in c,
                Um(x)=sum ...
            end
        end
    end
end

Any ideas how to achieve this?
Thanks in advance.

Juan Carlos Araújo
Umeå Universitet


Wolfgang Bangerth

unread,
Jun 22, 2016, 1:38:35 PM6/22/16
to dea...@googlegroups.com

> I am solving an eigenvalue problem similar than step-36. After solving for the
> eigenpairs, I evaluate the eigenfunctions in the standard way:
>
> VectorTools::point_value ( mapping, dof_handler, efun[m],
> q_points[j], Uq );
>
> where: efun[m] is the m-th eigenfunction from step-36,
> q_points[j] are selected quadrature points,
> Uq is where I store the FE evaluation.
>
> As expected, this operation is awfully slow! it takes seconds for a single
> point evaluation with a decent discretization and having m eigenfunctions
> makes it worse!

Yes. But there is a much more efficient way to do this:
FEValues fe_values (...);
std::vector<double> sol_at_q_points (...);
for (cell=...)
{
fe_values.reinit (cell);
fe_values.get_function_values (efun[m], sol_at_q_points);

This gives you the values of efun[m] at all quadrature points on the current
cell at once, and this approach is efficient and independent of the overall
size of the problem.

Best
W.

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

Juan Carlos Araujo Cabarcas

unread,
Jun 23, 2016, 9:12:32 AM6/23/16
to deal.II User Group
Thanks for the fast reply, this is exactly what I needed!
Reply all
Reply to author
Forward
0 new messages