In addition, the example uses MATC parameters in the grid file to allow you to adjust the mesh density and heat source geometry. Any MATC variables or calculations are enclosed in $. Comments in the files are noted with exclamation points (!).
As a steady state simulation, Elmer Post can be used to view the final solution. Note that you cannot currently use ElmerPost to view adaptive meshes for transient simulations, as it does not save changing mesh condition for each timestep in EP format. The SaveLine function also has issues with the mesh changing between iterations. For a transient simulation, you can use the SaveScalars function with a list of points to get temperatures at certain locations for each timestep. You can also use ResultOutputSolver to save the results in a format that stores each mesh iteration, such as VTU format. Other postprocessors, such as ParaView and VisIt can view these results. The VTU output commands are included in this example as Solver 2.
PROCEDURE (running elmersolver from the command line, assuming elmer files are in the system Path):
- Create a new folder and save the adapt.grd and adapt.sif to it.
- Create the base mesh:
elmergrid 1 2 adapt
- Run the solver:
Viewing Results with Elmerpost:
you can use Elmerpost to view the results in several ways
1) view the adapt.ep file in the adapt subfolder. this is based on the initial mesh, and will have a coarser output. I believe the solution shown is the projection of the final solution on the initial mesh **confirmation requested**
2) view the adapt.ep files in the various "RefinedMesh#" folders. The program only makes 10 folders, and then reuses them. The one with highest mesh density, and usually the largest filesize will be the last one containing the final refined result. Note the much higher mesh refinement around the heat source. The maximum temperature is also slightly higher, as this better captured the peak temperature.
Viewing Result in VisIt:
1) in the vtuoutput folder will be a single vtu file. Open visit and select this file as the Source to open. Under Plots, select Add, Mesh, mesh. Then Draw. Select Add, Pseudocolor, Temperature. Then Draw.
2) You can change the VTU output to show each 'timestep' (or steady state iteration) by changing "after all" to "after timestep" in the Solver 2 section of the .sif file. This will create a group of numbered vtu files in the vtuoutput folder. Select this group as the source in Visit, and you can click 'play' to see the gradual mesh refinement. This is the same procedure you would use to visualize an actual transient model.
You can adjust the parameter values in the .grd file to see the effect on refinement. You can also change the adaptive mesh convergence criteria in the .sif file Simulation section. These will all affect the amount of mesh refinement required to achieve a satisfactory solution.
adapt.grd file text:
- Code: Select all
***** ElmerGrid input file for structured grid generation *****
Version = 210903
!Elmergrid requires you to explicitly turn on MATC
MATC = True
$totalwidth = 3e-3$
$heated = 1e-3$
$meshdensity = 100$
$unheated = (totalwidth - heated)/2$
Coordinate System = Cartesian 2D
Subcell Divisions in 2D = 3 3
Subcell Sizes 1 = $unheated heated unheated$
Subcell Sizes 2 = 1e-3 1e-3 1e-3
Material Structure in 2D
2 1 2
2 2 2
2 2 2
Materials Interval = 1 2
!set hot boundary to the top of Material 1, and cold to the bottom of 2.
!Special boundary 'out' notation:
!-1 down, -2 right, -3 top and -4 left -11 smaller, -9 bigger, and -10 anything
! type out int double of the boundaries
1 -1 2 1
2 -3 1 1
Surface Elements = $meshdensity$
Triangles = logical True !needed for RGB adaptive meshing
Element Degree = 1s
adapt.sif file text:
- Code: Select all
CHECK KEYWORDS Warn
Mesh DB "." "adapt"
Max Output Level = 5
Coordinate System = "Cartesian 2D"
Coordinate Mapping(3) = 1 2 3
Simulation Type = "Steady State"
Steady State Max Iterations = 5
Post File = adapt.ep
Target Bodies(2) = 1 2
Equation = 1
Material = 1
Heat Equation = True
Active Solvers(1) = 1
Exec Solver = "Always"
Equation = "Heat Equation"
Procedure = "HeatSolve" "HeatSolver"
Variable = "Temperature"
Variable Dofs = 1
Optimize Bandwidth = True
Linear System Solver = "Direct"
Linear System Direct Method = "umfpack"
Steady State Convergence Tolerance = 1.0e-5
Stabilize = True
Nonlinear System Convergence Tolerance = 1.0e-4
Nonlinear System Max Iterations = 3
Nonlinear System Newton After Iterations = 2
Nonlinear System Newton After Tolerance = 1.0e-3
Nonlinear System Relaxation Factor = 1.0
Adaptive Mesh Refinement = true
Adaptive Remesh = false
Adaptive Save Mesh = true
Adaptive Error Limit = 1e-4
Exec Solver = String "after all"
Equation = String "ResultOutput"
Procedure = File "ResultOutputSolve" "ResultOutputSolver"
Output File Name = String "adapt."
Vtu Format = Logical True
Ascii Output = Logical True
Scalar Field 1 = String "Temperature"
Mesh Name = String "RefinedMesh"
Output Directory = String vtuoutput
Density = 1
Heat Conductivity = 1
Boundary Condition 1
Target Boundaries(1) = 1
Name = HOT
Heat Flux BC = True
Heat Flux = 100
Boundary Condition 2
Target Boundaries(1) = 2
Name = COLD
Temperature = 0