Elmer FEM heat transfer verification: error against exact solutions

Published by Ruggero Poletto on

Elmer FEM is an open-source finite element code from CSC (Finland) that many engineers use for heat transfer, structures, electromagnetics and fluids. Before trusting any solver for real work, it is worth asking a simple question: does it solve the equations it claims to solve, and does the error shrink at the rate theory predicts when the mesh is refined?

This post answers that question for steady heat conduction in Elmer 9.0, using two cases with exact solutions. All the files are included, so you can repeat the work.

1. Verification is not validation

Two terms are often mixed up:

  • Verification asks whether the equations are solved correctly. The reference is a mathematical solution, so the error can be measured exactly.
  • Validation asks whether the equations describe reality. The reference is an experiment.

This post is about verification. The two cases use analytical solutions, not experimental measurements, so no experimental data are involved. The distinction follows the standard V&V terminology (Oberkampf and Roy; ASME V&V 20). A validation study of Elmer would need a published experiment as reference, and that is a separate piece of work.

2. Setup

  • Solver: Elmer 9.0, compiled locally from the release-9.0 source of the official repository (GCC and OpenMPI). One optional module that these cases do not use was not built.
  • Meshes: Gmsh 4.15.2, converted with ElmerGrid.
  • Elements: linear and quadratic tetrahedra, trilinear hexahedra, linear and quadratic triangles.
  • Linear solver: conjugate gradients with ILU1 preconditioning, relative tolerance 1e-12. The algebraic error is far below the discretisation error in every run.
  • Error measurement: our own Python code reads the Elmer VTU output and integrates the error with Gauss quadrature on the actual element shapes. We report the relative L2 error of temperature, and the maximum nodal error as a second indicator.

The observed order of convergence between two meshes is

p = ln(eโ‚ / eโ‚‚) / ln(hโ‚ / hโ‚‚)

where e is the error and h the element size. Theory predicts p = 2 for linear elements and p = 3 for quadratic elements in the L2 norm.

3. Case A: a 3D cube with a manufactured solution

The method of manufactured solutions (Roache 2002; Salari and Knupp 2000) chooses the answer first and derives the problem that has it. We take

T(x, y, z) = sin(ฯ€x) sin(ฯ€y) sin(ฯ€z) on the unit cube.

With conductivity k = 1 and T = 0 on all six faces, this is the exact solution of โˆ’kโˆ‡ยฒT = q if the heat source is

q = 3ฯ€ยฒk sin(ฯ€x) sin(ฯ€y) sin(ฯ€z).

In the Elmer input file the source is one line:

Body Force 1
  Heat Source = Variable Coordinate
    Real MATC "3*pi*pi*sin(pi*tx(0))*sin(pi*tx(1))*sin(pi*tx(2))"
End

(Elmer’s Heat Source is per unit mass, so the density is set to 1.) We solve it on three mesh families with 4, 8, 16 and 24 divisions per edge: linear tetrahedra, quadratic tetrahedra and trilinear hexahedra.

Figure 1. Case A, mid-plane z = 0.5 (quadratic tetrahedra, 8 divisions per edge). The error is below 0.07% of the peak temperature.

4. Case B: a thick-walled hollow cylinder with convection

The second case is a physical problem found in heat transfer textbooks (Incropera and DeWitt; Carslaw and Jaeger). A hollow cylinder has inner radius rแตข = 1 m and outer radius rโ‚’ = 2 m, conductivity k = 45 W/(mยทK), an inner wall held at Tแตข = 200 ยฐC, and an outer wall cooled by convection with h = 100 W/(mยฒยทK) and Tโˆž = 20 ยฐC. We model a quarter of the section, with adiabatic symmetry planes.

For steady radial conduction the temperature is

T(r) = Tแตข + C ln(r / rแตข), C = โˆ’h (Tแตข โˆ’ Tโˆž) / (k/rโ‚’ + h ln(rโ‚’ / rแตข)).

With these numbers C = โˆ’196.047 K and the outer wall temperature is T(rโ‚’) = 64.1106 ยฐC.

This case adds three things that Case A lacks: a curved boundary, a convection (Robin) boundary condition, and realistic material values. In Elmer the convection condition takes two lines:

Boundary Condition 2
  Heat Transfer Coefficient = 100.0
  External Temperature = 20.0
End

Figure 2. Case B: boundary conditions and mesh (left), computed temperature field (right).

Figure 3. Case B: radial temperature profile against the exact solution (left) and nodal error for linear and quadratic triangles at h = 0.1 (right).

5. Results

Convergence

Relative L2 error and observed order. The mesh size h is the nominal Gmsh element size (1/N in Case A).

Case A, 3D cube

ElementshNodesRelative L2 errorMax nodal errorObserved order
Linear tetrahedra1/41502.861e-011.768e-01โ€“
1/88828.071e-024.832e-021.83
1/165,7802.146e-021.296e-021.91
1/2418,2009.534e-035.759e-032.00
Quadratic tetrahedra1/49091.195e-021.248e-02โ€“
1/86,0691.354e-031.423e-033.14
1/1642,6691.653e-041.940e-043.03
1/24137,8374.849e-056.554e-053.02
Trilinear hexahedra1/41251.895e-014.978e-02โ€“
1/87295.105e-021.275e-021.89
1/164,9131.301e-023.207e-031.97
1/2415,6255.801e-031.427e-031.99

Case B, hollow cylinder

ElementshNodesRelative L2 errorMax nodal error [K]Observed orderOuter wall T [ยฐC]
Linear triangles0.2961.533e-032.803e-01โ€“64.0860
0.13323.680e-044.774e-022.0664.1008
0.051,2009.095e-051.377e-022.0264.1052
0.0254,5672.289e-054.284e-031.9964.1097
Quadratic triangles0.23476.242e-051.496e-02โ€“64.1089
0.11,2577.806e-061.725e-033.0064.1104
0.054,6621.024e-062.050e-042.9364.1105
0.02517,9961.313e-072.834e-052.9664.1106

Exact outer wall temperature: 64.1106 ยฐC.

Figure 4. Relative L2 error against element size. The dotted lines show the theoretical slopes (hยฒ and hยณ).

The observed orders match theory in both cases and for every element type. Linear elements converge at order 2 and quadratic elements at order 3, within a few percent on the finer meshes. The maximum nodal error is noisier, since it depends on a single node; we rely on the L2 error to judge the order.

Accuracy per unknown

Quadratic elements cost more per element but give much more accuracy for the same number of nodes:

  • Case A: quadratic tetrahedra with 8 divisions per edge (6,069 nodes) reach a relative error of 1.35e-3. Linear tetrahedra need 24 divisions (18,200 nodes) and still only reach 9.53e-3, which is 7 times larger with 3 times more nodes.
  • Case B: with about 4,600 nodes, linear triangles give 2.29e-5 and quadratic triangles give 1.02e-6, which is 22 times smaller. The curved boundary is represented with second-order geometry in the quadratic case.

Figure 5. Relative L2 error against number of nodes.

For smooth problems like these, quadratic elements are the better choice. For problems with singularities or discontinuities the advantage shrinks, so this conclusion should not be extended without checking.

6. Does a parallel run give the same answer?

We also ran one mesh of each case on 4 MPI processes, with the mesh split by ElmerGrid using METIS (Karypis and Kumar). The relative L2 errors agree with the serial runs to seven digits:

CaseMeshSerial4 MPI processes
Aquadratic tetrahedra, 8 divisions1.353532e-031.353532e-03
Bquadratic triangles, h = 0.051.024297e-061.024297e-06

Case B was first solved with a direct solver (UMFPACK), which Elmer cannot use in parallel. We switched to conjugate gradients with ILU1 and confirmed that all serial errors stayed identical to four digits.

7. What this does not show

  • No experimental validation. Exact solutions verify the numerics, not the physics.
  • Steady, linear, smooth problems only. Temperature-dependent conductivity, transient behaviour, radiation, singularities and coupled physics are not covered.
  • One run per mesh, with our own error code. Its credibility rests on the fact that the observed orders match theory in all five series.
  • A local compilation. The results come from a local Elmer 9.0 compilation, not from the cloudHPC image. They are expected to match, but this has not been checked yet.
  • Small parallel test. The parallel check used 4 processes on small meshes. It says nothing about scalability.

8. Next: Elmer on cloudHPC, and scalability

The next step is to repeat these cases on the elmerSolver-9.0 solver available on cloudHPC, and to add a strong-scaling test of Case A on a mesh with millions of elements. Published results from the Elmer team (CSC, PARA2012 tutorial) report a Poisson problem with 100 million unknowns solved on up to 2,176 cores, and suggest about 10โด unknowns per partition as a lower limit for good scaling. We will test how well that guideline holds on cloudHPC machines and add the results to this post.

References

  1. Oberkampf, W. L. and Roy, C. J. Verification and Validation in Scientific Computing. Cambridge University Press, 2010. DOI: 10.1017/CBO9780511760396.
  2. ASME V&V 20-2009. Standard for Verification and Validation in Computational Fluid Dynamics and Heat Transfer. American Society of Mechanical Engineers.
  3. Roache, P. J. Code verification by the method of manufactured solutions. Journal of Fluids Engineering 124(1), 4-10, 2002.
  4. Salari, K. and Knupp, P. Code verification by the method of manufactured solutions. Sandia National Laboratories report SAND2000-1444, 2000. Sandia publication page.
  5. Incropera, F. P., DeWitt, D. P., Bergman, T. L. and Lavine, A. S. Fundamentals of Heat and Mass Transfer. Wiley (radial conduction in cylinders; any edition).
  6. Carslaw, H. S. and Jaeger, J. C. Conduction of Heat in Solids, 2nd ed. Oxford University Press, 1959.
  7. CSC – IT Center for Science. Elmer FEM, ElmerSolver Manual and Elmer Models Manual. elmerfem.org; source code: github.com/ElmerCSC/elmerfem, tag release-9.0.
  8. ElmerTeam, CSC. Elmer scaling, PARA2012 tutorial, Helsinki, 2012. PDF.
  9. Geuzaine, C. and Remacle, J.-F. Gmsh: a three-dimensional finite element mesh generator with built-in pre- and post-processing facilities. International Journal for Numerical Methods in Engineering 79(11), 1309-1331, 2009.
  10. Karypis, G. and Kumar, V. A fast and high quality multilevel scheme for partitioning irregular graphs. SIAM Journal on Scientific Computing 20(1), 359-392, 1998.

CloudHPC is a HPC provider to run engineering simulations on the cloud. CloudHPC provides from 1 to 224 vCPUs for each process in several configuration of HPC infrastructure - both multi-thread and multi-core. Current software ranges includes several CAE, CFD, FEA, FEM software among which OpenFOAM, FDS, Blender and several others.

New users benefit of a FREE trial of 300 vCPU/Hours to be used on the platform in order to test the platform, all each features and verify if it is suitable for their needs


Categories: ElmerFEM