Evaluating a field at a point

44 views
Skip to first unread message

andre...@gmail.com

unread,
Jul 28, 2022, 4:15:43 PM7/28/22
to deal.II User Group
I currently have the solution to a PDE stored in a Vector<double> solution. I need to compute the solution at some Point<2> loc. I accomplish this using the function 

VectorTools::point_value(dof_handler, solution, loc, val);

which fills val with the value I care about. Similarly, I get the gradient with point_gradient

This accomplishes what I need but if I have a lot of points like loc and have to do this every timestep then it quickly becomes a computational bottleneck. 

If I am not refining the mesh, is there a more efficient why of accomplishing this? I assume by storing the specific cell that loc is in? 

Wolfgang Bangerth

unread,
Jul 28, 2022, 7:09:38 PM7/28/22
to dea...@googlegroups.com
If you have multiple points, and if the points are always the same, you are in
luck that someone has already implemented what you are looking for in this
program:

https://dealii.org/developer/doxygen/deal.II/code_gallery_MCMC_Laplace.html

:-)

Best
W.


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

Peter Munch

unread,
Jul 29, 2022, 3:53:18 AM7/29/22
to deal.II User Group
I guess for your purpose, `VectorTools::point_values()` and `VectorTools::point_gradients()` are more useful and it works in parallel. If the location of the points do not change, they are cached in RemotePointEvaluation.

> If I am not refining the mesh, is there a more efficient why of accomplishing this? I assume by storing the specific cell that loc is in? 

Indeed, this is happening internally in RemotePointEvaluation. It stores the cell and the reference positions. In a second step the actual evaluation is done efficiently by FEPointEvaluation. If the interface is too high level for your purposes, you can take a look at the implementations of the setup routines, which uses GridTools::internal::distributed_compute_point_locations.

Hope this helps,
Peter
Reply all
Reply to author
Forward
0 new messages