Adaptive mesh, transient sim, elmerpost?

Post processing utility for Elmer
NJank
Posts: 99
Joined: 05 Dec 2009, 00:05
Location: Baltimore, MD, USA

Adaptive mesh, transient sim, elmerpost?

Post by NJank »

Doing a 2D transient simulation with phase change (enthalpy method). Runs fine without adaptive meshing. Turning on the adaptive meshing, it generates a bunch of RefinedMesh# folders (# from 0 to 9). When it's finished, there are .ep files in all of those folders plus the normal mesh&results folder. Since the process overwrites the RefinedMesh folders, I can scan through them looking for the files with the latest "Date Modified" to know where it ended. When I try to open differene .ep files in ElmerPost, however, I get very different results.

Thinking the resulting transient solution set would be stored in the normal results folder, I opened ElmerPost, clicked Read Model File and selected that .ep file. File information correctly showed 160 timesteps, but still showed the 572 nodes, 1202 elements from the initial mesh. Reading in the file, displaying the color mesh, and stepping through the timesteps, however, shows only a static temperature map. (Viewing the model without Adaptive meshing shows a nicely changing temperature profile over the timesteps.) It does sweep through the 160 steps, but the color map is static.

Now, if I load the .ep file in the last RefinedMesh# folders, the file information shows me a much increased number of nodes and elements, same 160 Timesteps, and an extra DoF for error information. When I read in the file, however, I get:

WARNING: ElmerPost: Not enough data for all timesteps requested, REQUEST: 160, GOT: 30

I assume that means it only used this mesh for the final 30 timesteps. The header, however, still indicates that there should be 160. Trying to display the color map just shows the domain all in white (pegged at the upper temp in the scale) and unchanging if I time-step through the 30 steps in the file.

I have save scalars running to pick off max and avg temperatures at each time step and those data files are filled with seemingly correct data (correct for the model run, at least.). The data is different from the model with no adaptive meshing, and seems to change in the way I'd expect from a model with better refinement.

So, it seems like the model with and without Adaptive meshing is running as expected. I just don't know if there's a way to visualize it using ElmerPost. Should the .ep file in the main solution folder have all of the simulation data? I realize that from adaptive mesh to mesh the nodal solutions will no longer match nodes from the previous mesh. Is that the problem? Is there no way to visualize the solution in ElmerPost, or am I just doing something wrong? I obviously can't piece together .ep files from the different RefinedMesh# folders, since they overwrite.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Adaptive mesh, transient sim, elmerpost?

Post by raback »

Hi

Perhaps you could alternatively use some output formats that by default saves also the mesh at each step: vtk and vtu formats do that. Use ResultOutputSolve module and Paraview for visualization, for example. ElmerPost should also work since there exists adaptive animations but may require some minor scripting.

-Peter
NJank
Posts: 99
Joined: 05 Dec 2009, 00:05
Location: Baltimore, MD, USA

Re: Adaptive mesh, transient sim, elmerpost?

Post by NJank »

sorry to bring back an old thread, but just got back to working on this.

I had added the following solver code to my sif file:

Code: Select all

Solver 4
  Exec Solver = String "after timestep"   
  Equation = String "ResultOutput"
  Procedure = File "ResultOutputSolve" "ResultOutputSolver"
  Output File Name = String "refinedout."
  Vtu Format = Logical True
  Scalar Field 1 = String "Temperature"
End
if I have adaptive meshing turned off, it runs fine. I use VisIT to open the VTU fileset, and it displays the mesh and temperature color plot fine for each timestep.

If I set "Adaptive Mesh Refinement = True", things run fine without that Solver 4 block. If I turn it on, elmersolver crashes (no error message other than the Windows "ElmerSolver.exe has stopped working / Close the program" dialog. Here's the set of elmersolver outputs from ResultOutputSolver before the crash:

Code: Select all

ResultOutputSolver: -------------------------------------
CreateListForSaving: Field Variables for Saving
CreateListForSaving: Scalar Field 1: temperature
CreateListForSaving: Scalar Field 2: temperature.error
ResultOutputSolver: Working on mesh: RefinedMesh1
ResultOutputSolver: Dimension of mesh: *
ResultOutputSolver: Saving in Unstructured VTK XML (.vtu) format
I did notice if I set Exec Solver = String "before timestep" that the program will not crash until the second call to the output solver. the output from the 'successful' call to the solver is:

Code: Select all

ResultOutputSolver: -------------------------------------
CreateListForSaving: Field Variables for Saving
CreateListForSaving: Scalar Field 1: temperature
CreateListForSaving: Scalar Field 2: temperature.error
ResultOutputSolver: Working on mesh: RefinedMesh1
ResultOutputSolver: Dimension of mesh: *
ResultOutputSolver: Saving in Unstructured VTK XML (.vtu) format
which is identical to the case when it crashes, so no real info there. Any ideas? If I set it to VTK instead of VTU, it runs, but opening the VTK set only shows the results of the first timestep while it is supposedly animating. not sure if it's the data that's bad or VisIt reading the VTK. (running the version in the Elmer-svn5081-2011-03-06.exe installer)
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Adaptive mesh, transient sim, elmerpost?

Post by raback »

Hi

There might be a problem with some static allocations which is different in adaptive case when returning to the solver 2nd time. Perhaps you could sent a minimalistic example.

-Peter
NJank
Posts: 99
Joined: 05 Dec 2009, 00:05
Location: Baltimore, MD, USA

Re: Adaptive mesh, transient sim, elmerpost?

Post by NJank »

Simple example grd and sif attached. Should run as-is.

model is a simple rectangle. small boundary on top (boundary 1) is to create constricted heating. Bottom boundary (2) is for cooling. mesh has triangle splitting turned on so that elmer can do its own RGB splitting for local refinement.

running the model as it is now, without modification, should complete without error. It'll generate seven RefinedMesh folders, with the last one showing a mesh adapted nicely for the constricted heat flow.

Now, as mentioned above, I haven't managed to get Elmerpost to display the time dependent results with mesh refinement. So, you can un-comment out the Solver 2 (ResultOutput ) block to try to dump to VTU format. It should crash. If you set VTK output it will run, and create a vtk fileset, but I'm unable to display the results. whether it's my postprocessor, my use of the postprocessor, or the files, it doesn't show an updated mesh or anything. if I set "Adaptive Mesh Refinement = False", I can output to VTU just fine, and display it as well. Oh, Solver 2 is also currently set to Exec Solver = String "after timestep" . Setting it to 'before timestep' it crashes on the second call to the VTU output.

Finally, I did notice a warning message that pops up when I try to do the VTU output:

Model Input: Unlisted keyword: [vtu format] in section: [solver 2]

but it seems to try, so not sure what the deal is there.
Attachments
Model1_pulse.sif
Simple thermal transient problem. Heating on the small top boundary, Cooling on the bottom boundary. 10 timesteps. Adaptive mesh refinement turned on. Solver 2 is for the ResultOutput solver, currently commented out.
(2.17 KiB) Downloaded 473 times
Model1.grd
Simple rectangular structure. small topside boundary for constricted heating, bottom edge for cooling
(519 Bytes) Downloaded 460 times
NJank
Posts: 99
Joined: 05 Dec 2009, 00:05
Location: Baltimore, MD, USA

Re: Adaptive mesh, transient sim, elmerpost?

Post by NJank »

2 follow-up questions:

(1) I did set the "Output File = Model1_pulse.res" option. I notice that there are .res files in several of the RefinedMesh folders. I assume it puts the file in the folder with the mesh that satisfies the criteria for that timestep. Hence folder 1 has one, but not 2... etc. Now, for longer simulations I have noticed that after 10 folders it starts reusing the folders from 1. Does this mean that it will overwrite the .res file, or will it append. I can forsee scripting a re-assembly of the info into a single file or something, but only if the data isn't overwritten.

(2) I added a SaveLine solver to grab the temperature profile along the top surface. Without adaptive meshing this works fine. With adaptive meshing, it only saves the first timestep.
Here's the sif code:

Code: Select all

Solver 2
 Equation = "SaveLine"
 Exec Solver = "after timestep"
 Procedure = File "SaveData" "SaveLine"
 Filename = "test2.dat"
 File Append = Logical False
 Variable 1 = String "Temperature"
 Polyline Coordinates (2,2) = Real 0.0 0.75e-3 0.3e-3 0.75e-3
End
Here's the output from the first (successful) call to Saveline

Code: Select all

SaveLine: -----------------------------------------
SaveLine: Saving data on given lines
WARNING:: SaveLine: Dimension of points smaller than that of mesh
SaveLine: ------------------------------------------
SaveLine:  Saving line data to file test2.dat
SaveLine: ------------------------------------------
SaveLine:  Number of nodes in specified boundary            0
SaveLine:  Number of nodes in specified lines            7
SaveLine: All donesaves the first timespe
Here's the output from all the subsequent calls:

Code: Select all

SaveLine: -----------------------------------------
SaveLine: Saving data on given lines
WARNING:: SaveLine: Dimension of points smaller than that of mesh
SaveLine: ------------------------------------------
SaveLine:  Saving line data to file test2.dat
SaveLine: ------------------------------------------
SaveLine:  Number of nodes in specified lines            0
SaveLine: All done
I attached the newer sif file with this solver added. Changed the commented out VTU solver to "Solver 3".
Attachments
Model1_pulse_new.sif
(2.3 KiB) Downloaded 432 times
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Adaptive mesh, transient sim, elmerpost?

Post by raback »

Hi

I had a look at the case. There seems to be indeed problems in several places. Probably the adaptivity has been fairly little used since many output features does not seem to be working with that. I tried to solve the problems with the vtu output which is perhaps the easiest way to visualization since the support for multiple .ep files requires manual srcipting. I noticed that the logic to write the results to the newly created mesh file was unfortunate since in transient case, there is no consistancy between mesh file index and result index. So I created an optional "Output Directory" that is used by the "vtu" format to write all files to the same directory. Also some other things were modified. The modifications are in rev. 5127 submitted some five minutes ago. Below is the part I used to save the .vtu files

Code: Select all

Solver 4
  Exec Solver = String "after timestep"   
  Equation = String "ResultOutput"
  Procedure = File "ResultOutputSolve" "ResultOutputSolver"
  Output File Name = String "refined"
  Vtu Format = Logical True

! automatically saves all 
!  Scalar Field 1 = String "Temperature"

! only save the refined meshes (not the original)
  Mesh Name = String "RefinedMesh"

! more compact in binary
  Binary Output = True

! often enough
  Single Precision = True

! to ensure that results are written to one directory only
  Output Directory = String RefinedResults
End
-Peter
NJank
Posts: 99
Joined: 05 Dec 2009, 00:05
Location: Baltimore, MD, USA

Re: Adaptive mesh, transient sim, elmerpost?

Post by NJank »

thanks for the speedy reply. I'll have to wait on the win32 build, though. I kind of guessed that this was my fault for trying to combine the adaptive mesher with transient solutions. I could have fun and try to get the adaptive timestep running, too :lol:
NJank
Posts: 99
Joined: 05 Dec 2009, 00:05
Location: Baltimore, MD, USA

Re: Adaptive mesh, transient sim, elmerpost?

Post by NJank »

actually, I noticed that the only changes in 5127 are to ResultOutputSolve.src . If I download that, compile it from the command line with elmerf90, and copy the resulting dll over top of the current one in the share/elmersolver folder, will that take care of things? or will I be missing something by not recompiling the program as a whole?

Edit: yeah, just realized that doesn't work. elmerf90 is looking for an f90 file, and calling gfortran-elmer without the -O f90 option creates a dll missing a few hundred Kb compared to the current file.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Adaptive mesh, transient sim, elmerpost?

Post by raback »

The .src files just go through a preprocessor and usually you can just rename it .f90 and compile as is. -Peter
Post Reply