Extract simulations results at specific points

Numerical methods and mathematical models of Elmer
Flaj
Posts: 19
Joined: 27 Feb 2012, 17:00
Antispam: Yes

Extract simulations results at specific points

Post by Flaj »

Hi,

I am relatively new to Elmer and I am trying to export the results of my simulations. I did not find much information on this in Elmer's available documentation (at least what I have). I've been trying to find an answer in other posts, but I only got fragments of information.

I simulate the diffusion of ions (my variable of interest is the concentration) within a structure and I do fine with exporting images and making videos with ElmerPost but I would also like to save the evolution of the concentration through time at maybe 2 or 3 points of interest (I have a total of 1875 nodes in my model). I want to import and visualize my data in MATLAB. Up to now I tried two methods:
1- I created an output ascii file by typing Output File = "OUTPUT.ascii" in the Simulation section of the .sif file. Of course the size of the file is monstruous. I can open it in a text editor, but what I get is a bit messy altough it appears to be correct. Here are the first lines:

Code: Select all

ASCII 1
!File started at: 2012/03/13 14:00:06
 Degrees of freedom: 
 concentration           1  :fs
 Total DOFs:            1
 Number Of Nodes:         1875
Time:       1      1  1.00000000E-001
concentration
Perm:         1875         1875
          1       1875
          2       1874
          3       1871
          4       1866



I understand that in the right-column are indicated the node index. Later on I have a vector of concentrations probably giving the concentration at each node for each time step. I don't know how to extract what I want. How can I select the data for a single node, and actually to what physical coordinate does each node correspond?

2- I found on this forum that people use SaveLine or SaveScalars but I do not know how to use that. What is the difference. I saw that someone used Polyline Coordinates (2,2) = Real 1e-3 0.0 3e-3. 30e-3. To what correspond the argument (2,2) and the right-hand side values 1e-3 0.0 3e-3. 30e-3? I am able to obtain, by luck, the data at some nodes for each time step and I can load it directly in MATLAB, but I would like to know if I can read the data for a specific coordinate in my structure.

If you need more information on my problem please don't hesitate. Any help would be highly appreciated,

P.S. Is there any documentation available on this. The only information I found was in the ElmerSolverManual, and I wasn't able to go on with this.

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

Re: Extract simulations results at specific points

Post by raback »

Hi Flaj

Use "SaveScalars" with keyword "Save Coordinates", see Ch. 46 in
http://www.nic.funet.fi/pub/sci/physics ... Manual.pdf

-Peter
Flaj
Posts: 19
Joined: 27 Feb 2012, 17:00
Antispam: Yes

Re: Extract simulations results at specific points

Post by Flaj »

Thank you Peter for your reply.

I tried the following:

Code: Select all

Solver 2
  Equation = "SaveScalars"
  Exec Solver = "after timestep"
  Procedure = File "SaveData" "SaveScalars"
  Filename = "model_output.dat"
  File Append = Logical False
  Variable 1 = String "Coordinate 1"
  Variable 2 = String "Coordinate 2"
  Variable 3 = String "Concentration"
  Save Coordinates (1,2) Real 19.0 17.0
End
I consider for the moment only one point in a two-dimensional xy plane (x=19.0; y=17.0). Something is not working. Any idea why?
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Extract simulations results at specific points

Post by raback »

Try

Code: Select all

Solver 2
  Equation = "SaveScalars"
  Exec Solver = "after timestep"
  Procedure = File "SaveData" "SaveScalars"
  Filename = "model_output.dat"
  File Append = Logical False
  Save Coordinates(1,2) = Real 19.0 17.0
End
Flaj
Posts: 19
Joined: 27 Feb 2012, 17:00
Antispam: Yes

Re: Extract simulations results at specific points

Post by Flaj »

Wow. It works.

Thank you Raback. Really appreciated.
Phlix
Posts: 11
Joined: 31 Aug 2018, 13:51
Antispam: Yes

Re: Extract simulations results at specific points

Post by Phlix »

Hi,

I have a problem how to figure out the coordinates of the geometries :oops:

E.G. the example \fem\tests\mgdyn_steady_wire

there is the line in the sif file:

Code: Select all

Polyline Coordinates(2,3) = -5.0e-3 0.0 5.0e-3 5.0e-3 0.0 5.0e-3
But how do I get to know these coordinates of the provided wire.grd geometry?

I highly appreciate if someone could help me.

Best regards,

Phlix
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Extract simulations results at specific points

Post by mzenker »

Hi,

the .grd file is human readable. You can consult the ElmerGrid Manual where the .grd file format is documented.
Alternatively, you can convert the mesh to gmsh format when you open a terminal, go to the mesh dirctory and say

ElmerGrid 2 4 mesh

Then you can open the generated mesh.msh with gmsh and examine it there.

HTH,
Matthias
Phlix
Posts: 11
Joined: 31 Aug 2018, 13:51
Antispam: Yes

Re: Extract simulations results at specific points

Post by Phlix »

Hi Matthias,

thank you very much for your fast response.

I was trying the second approach to use Gmsh (by converting the mesh data with ElmerGrid 2 4 mesh)

I found some instruction how to display the node coordinates here:
http://onelab.info/pipermail/gmsh/2017/011242.html

Use the Plugin NewView to create an empty post-processing view (View = 0, Dimension = 3)

Use MathEval on the new view (Expression0 = x, Expression1 = y, Expression2 = z, View = 0) to get a field with values (X,Y,Z)

In the Tools > Option menu, set the Intervals type display option for the MathEval view (should be View[1]) to be "Numeric values"
But when I do so (e.g. with the example geometry of the wire) the graphical representation explodes and the coordinates are not visible due to the
complexity
of the geometry...

Do you know a better approach (more suitable than the one i described above) how to handle the problem with Gmsh?

Or is the transformation (of general meshed geometries) into .grd-File via ElmerGrid recommended instead of using Gmsh?

Best regards,
Phlix
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Extract simulations results at specific points

Post by mzenker »

Hi,

you are right, displaying node coordinates is not easily possible in gmsh for an imported mesh.
If you just need a rough indication of the coordinates, you can use mesh->inspect, which gives you the centre coordinates of the selected element. But you cannot select nodes there. Examining the mesh in gmsh is useful to find out the numbers of surfaces and bodies after import into Elmer if you have difficulties to do it with ElmerGUI.
In this case, using ParaView for mesh inspection may be the better option - you will probably need it for postprocessing anyway.

ElmerGrid 2 5 mesh

will convert your mesh to vtu format which ParaView can read. In ParaView you can select nodes and display their coordinates.

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

Re: Extract simulations results at specific points

Post by raback »

Hi

Also if you just need the coordinates they are available in mesh/mesh.nodes, just say in Matlab/Octave

Code: Select all

load mesh.nodes
x=mesh(:,1);
y=mesh(:,2);
z=mesh(:,3);
Then you can play around with the coordinates as you wish.

What is the purpose in knowing the coordinates? You do realize that also SaveLine saves the coordinates with names Coordinate 1, Coordinate 2, etc.

-Peter
Post Reply