How to get the solution of a point diffeent from node

Post processing utility for Elmer
Post Reply
stoykov
Posts: 26
Joined: 11 May 2012, 13:18
Antispam: Yes

How to get the solution of a point diffeent from node

Post by stoykov »

Hello,

I need to obtain the solution of a problem at an arbitrary point inside the domain. I did not find an appropriate subroutine for this purpose. Is there a subroutine which gives you this value of a point, if you give as input the coordinates of the point? Something like:
GetResult(x, y, z, res), where (x, y, z) are the coordinates of the point (global) and res is the obtained solution at that point.

Regards,
Stan
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: How to get the solution of a point diffeent from node

Post by raback »

Hi Stan

There is the SaveScalars solver that gives that writes that in a file.

If you want to do it internally it depends... Basically the problem is that if you have just one or few values (as in SaveScalars) the problem is totally different than if you have to map one mesh to another. The former is easily done with a dummy search, and the latter with octree based data structure. In both you have a function PointInElement that tests whether you're in the element and what the local variables are. There aren't anything quite like you wish, probably because there is seldom the need to have just one field value in one point. If you want to evaluate many fields the coder must have access to more variables, such as the local coordinates, element, etc.

So probably easiest would be to copy the dummy search in SaveScalars. That functionality might deserve a place in the library though.

-Peter
stoykov
Posts: 26
Joined: 11 May 2012, 13:18
Antispam: Yes

Re: How to get the solution of a point diffeent from node

Post by stoykov »

Thank you again Peter!

It was not difficult to implement such a function by using the values of the shape functions at that point and the corresponding values of the nodal coordinates.

Regards,
Stan
stoykov
Posts: 26
Joined: 11 May 2012, 13:18
Antispam: Yes

Re: How to get the solution of a point diffeent from node

Post by stoykov »

Hi Peter,

There is a small problem. I am using the vector of solutions, i.e. the values of the nodal points. I take it from the solver, after calling DefaultSolve(), by

vector => Solver % Variable % Values

When I generate the mesh using Elmer the values are the same as in .ep file.
Bu if I generate the mesh using Gmsh, the values are the same, but the order is different. And because of the wrong order, I cannot get the value of an arbitrary point? Could you please comment?

Best regards,
Stan
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: How to get the solution of a point diffeent from node

Post by raback »

Hi

A variable, say Var, is usually associated with a permutation vector. So whereas you get, say X-coordinates of an element with

Code: Select all

Mesh % Nodes % x(Element % NodeIndexes)
You get the corresponding field values with

Code: Select all

Var % Values( Var % Perm( Element % NodeIndexes ) ) 
-Peter
Post Reply