evaluation FE function outside domain

78 views
Skip to first unread message

Mathieu

unread,
Jun 5, 2023, 4:59:28 PM6/5/23
to deal.II User Group
Hello everyone,

I was wondering if deal.II has built-in functions to evaluate continuous finite element functions (FEQ) at points outside the mesh?
E.g.: given a point P in 2d/3d, which is not contained in the 2d/3d mesh but close to the boundary, how could one evaluate (extrapolate) the FE function at P? Or is it not a good idea to extrapolate shape functions?

Thank you
Math

Bruno Turcksin

unread,
Jun 6, 2023, 3:55:09 PM6/6/23
to deal.II User Group
Math,

The basis functions are not defined outside of an element, so you cannot extrapolate them outside of the mesh. What are you trying to achieve?

Best,

Bruno

Mathieu

unread,
Jun 6, 2023, 4:25:04 PM6/6/23
to dea...@googlegroups.com
Hi Bruno, 

for a post-processing step, I have to evaluate my temperature field at some points outside the mesh close to its boundary. 

I know that shape functions are not defined outside the mesh, that's why I wanted to extrapolate them. 
My idea was to use the gradient of the temperature field to come up with an extrapolation. 
But I do not know if that's reasonable. 

Best,

Math

--
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 a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/RmYuqy3_3FY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/99afba6c-3f6a-4990-8bf1-230beb186f4cn%40googlegroups.com.

Bruno Turcksin

unread,
Jun 6, 2023, 4:48:29 PM6/6/23
to dea...@googlegroups.com
Math,

It really depends on your problem. If outside of your simulation domain, you have a domain that has the same properties and the solution changes slowly that's probably a good approximation. If outside of your domain, the solution changes quickly that's probably a bad approximation. If your solution has a shock, your approximation will be totally off. If you are solving the heat equation, the approximation is probably fine.

Best,

Bruno

Wolfgang Bangerth

unread,
Jun 7, 2023, 10:33:32 AM6/7/23
to dea...@googlegroups.com
On 6/6/23 14:24, Mathieu wrote:
>
> for a post-processing step, I have to evaluate my temperature field at some
> points outside the mesh close to its boundary.
>
> I know that shape functions are not defined outside the mesh, that's why I
> wanted to extrapolate them.
> My idea was to use the gradient of the temperature field to come up with an
> extrapolation.
> But I do not know if that's reasonable.

Like Bruno already said in other words, you are starting at the wrong end of
the question. In a first step, define mathematically *what* it is you want to
do (and justify why this is the right choice). Then, in a second step, one can
think about *how* to implement this.

Best
W.

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


Mathieu

unread,
Jun 7, 2023, 12:57:03 PM6/7/23
to deal.II User Group
"Like Bruno already said in other words, you are starting at the wrong end of
the question. In a first step, define mathematically *what* it is you want to
do (and justify why this is the right choice). Then, in a second step, one can
think about *how* to implement this."

I need this function (triangulation) for post-processing, but also during my assemble routine.
Basically, the values of this function at some points are assembled into my linear system.
But it may happen that I have to evaluate the function at a point which is not contained in its triangulation,
since I do not know the bounds a priori. 
Currently, my program is aborted if I would need to evaluate at a point outside the triangulation. 
I want to circumvent this by extrapolating the function somehow (bilinear, ...).
The function should be increasing in x-and y-direction and is quite smooth at the boundary.

Any suggestions?

Thank you,

Math

Wolfgang Bangerth

unread,
Jun 7, 2023, 1:23:46 PM6/7/23
to dea...@googlegroups.com
On 6/7/23 10:57, Mathieu wrote:
> "Like Bruno already said in other words, you are starting at the wrong end of
> the question. In a first step, define mathematically *what* it is you want to
> do (and justify why this is the right choice). Then, in a second step, one can
> think about *how* to implement this."
>
> [...]
> I want to circumvent this by extrapolating the function somehow (bilinear, ...).

You'll need to say what this "somehow" is supposed to be. I can think of a
half-dozen ways of extrapolating functions, but like Bruno already outlined,
which one is right depends on what you want to do.

In other words, come up with a *mathematical definition* of the operation you
want to do, and we can help with how that can be implemented.

Mathieu

unread,
Jun 7, 2023, 1:43:00 PM6/7/23
to dea...@googlegroups.com
A bilinear extrapolation seems to be a suitable first try since the shape functions are bilinear. 
Going this way, I would compute the gradient of the function at a point at the boundary to come up with the extrapolated function value. 
Call the point outside the grid P, I would project P to the closest at the boundary of the triangulation and evaluate the gradient there. 

So, given P, how can I find the closest point at the boundary? 
Or would you choose a different point at the boundary? 

-Math


--
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/ade0d3bc-05c8-fdc0-6ff1-2ca228dea1a6%40colostate.edu.

Wolfgang Bangerth

unread,
Jun 8, 2023, 6:49:53 PM6/8/23
to dea...@googlegroups.com
On 6/7/23 11:42, Mathieu wrote:
> A bilinear extrapolation seems to be a suitable first try since the shape
> functions are bilinear.
> Going this way, I would compute the gradient of the function at a point at the
> boundary to come up with the extrapolated function value.
> Call the point outside the grid P, I would project P to the closest at the
> boundary of the triangulation and evaluate the gradient there.
>
> So, given P, how can I find the closest point at the boundary?
> Or would you choose a different point at the boundary?

This is feasible, though finding the closest vertex is an expensive operation.
For this to work, you will have to find which cell is closest to the point in
question, for which I would use
GridTools::find_closest_vertex()
and
GridTools::find_cells_adjacent_to_vertex()

Mathieu

unread,
Jun 9, 2023, 10:23:15 AM6/9/23
to dea...@googlegroups.com
" This is feasible, though finding the closest vertex is an expensive operation.
For this to work, you will have to find which cell is closest to the point in
question, for which I would use
   GridTools::find_closest_vertex()
and
   GridTools::find_cells_adjacent_to_vertex() "

I was not aware that GridTools::find_closest_vertex() works if the point
is outside the domain.

Say, P=(Px,Py) is the point outside the domain,
T=(Tx, Tx) the closest vertex at the boundary as computed above,
and grad_T the gradient of the finite element function at T.
Then I would compute the function value at P as
f(P) = f(T) + grad_T[0]*(Px-Tx) + grad_T[1]*(Py-Ty).
Is that reasonable?

Thanks,
Math


--
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.

Wolfgang Bangerth

unread,
Jun 9, 2023, 11:03:59 AM6/9/23
to dea...@googlegroups.com
On 6/9/23 08:27, Mathieu wrote:
>
> Say, P=(Px,Py) is the point outside the domain,
> T=(Tx, Tx) the closest vertex at the boundary as computed above,
> and grad_T the gradient of the finite element function at T.
> Then I would compute the function value at P as
> f(P) = f(T) + grad_T[0]*(Px-Tx) + grad_T[1]*(Py-Ty).
> Is that reasonable?

Yes, that is just a linear extrapolation and that's reasonable if your
solution is smooth and if P is close to T.

If T is a vertex, then the solution generally has a kink there and the
gradient can have several values depending on which adjacent cell you take it
on. Whether that matters to you is a separate question -- it may be sufficient
to simply take the gradient from one of the adjacent cells.

Mathieu

unread,
Jun 9, 2023, 11:20:29 AM6/9/23
to dea...@googlegroups.com
" If T is a vertex, then the solution generally has a kink there and the
gradient can have several values depending on which adjacent cell you take it
on. "

To have a unique gradient, it would be better to not search for the closest vertex,
but rather to the closest point at the boundary, which may be a point at the line connecting two vertices.
But there is no straightforward way to obtain this point, right?
At least, I did not find a functionality in the GridTools namespace, which is probably the right place to look for.

-Math

--
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 a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/RmYuqy3_3FY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/dcf478b6-5810-4fcf-e174-1f7ed33050f5%40colostate.edu.

Wolfgang Bangerth

unread,
Jun 9, 2023, 11:39:15 AM6/9/23
to dea...@googlegroups.com
On 6/9/23 09:24, Mathieu wrote:
>
> To have a unique gradient, it would be better to not search for the closest
> vertex,
> but rather to the closest point at the boundary, which may be a point at the
> line connecting two vertices.

Perhaps, but it is not clear to me that this would actually be more accurate.


> But there is no straightforward way to obtain this point, right?
> At least, I did not find a functionality in the GridTools namespace, which is
> probably the right place to look for.

Correct.

Mathieu

unread,
Jun 13, 2023, 10:40:15 AM6/13/23
to dea...@googlegroups.com
"
Say, P=(Px,Py) is the point outside the domain,
T=(Tx, Tx) the closest vertex at the boundary as computed above,
and grad_T the gradient of the finite element function at T.
Then I would compute the function value at P as
f(P) = f(T) + grad_T[0]*(Px-Tx) + grad_T[1]*(Py-Ty). "

Let me clarify one last thing:
The gradient (deriv. with regards to x and y) of the above extrapolation is given by
[ grad_T[0]; grad_T[1] ].
Correct?

-Math
 

--
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 a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/RmYuqy3_3FY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages