Computing and Visualization in Science

, Volume 12, Issue 8, pp 421–436 | Cite as

Expression templates implementation of continuous and discontinuous Galerkin methods

  • Daniele Antonio Di Pietro
  • Alessandro VenezianiEmail author
Regular article


Efficiency and flexibility are often mutually exclusive features in a code. This still prompts a large part of the Scientific Computing community to use traditional procedural languages. In the last years, however, new programming techniques have been introduced allowing for a high level of abstraction without loss of performance. In this paper we present an application of the Expression Templates technique introduced in (Veldhuizen in Expression templates. C++ Report magazine, vol 7, pp 26–31, 1995) to the assembly step of a finite element computation. We show that a suitable implementation, such that the compiler has the role of parsing abstract operations, allows for user-friendliness. Moreover, it gains in performance with respect to more traditional techniques for achieving this kind of abstraction. Both the cases of conforming and discontinuous Galerkin finite element discretization are considered. The proposed implementation is finally applied to a number of problems entailing different kind of complications.


Galerkin methods Finite elements implementation Object-Oriented programming Expression templates 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Arnold D.N., Brezzi F., Cockburn B., Marini D.: Unified analysis of discontinuous galerkin methods for elliptic problems. SIAM J. Numer. Anal. 39, 1749–1779 (2002)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Avgoustiniatos E., Colton C.: Effect of external oxygen mass transfer resistances on viability of immunoisolated tissue. Ann. NY. Acad. Sci. 831, 145–167 (1997)CrossRefGoogle Scholar
  3. 3.
    Cockburn B., Shu C.W.: Runge-kutta discontinuous galerkin methods for convection-dominated problems. J. Sci. Comp. 16, 173–261 (2001)zbMATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Furnish G.: Disambiguated glommable expression templates. Comp. Phys. 11, 263–269 (1997)Google Scholar
  5. 5.
    Haney, S.W.: Beating the abstraction penalty in c++ using expression templates. In: Computers in Physics, vol. 10, pp. 552–557. Correction in vol. 11, n. 14 (1996)Google Scholar
  6. 6.
    Johnson C.: Numerical Solution of Partial Differential Equations by the Finite Element Method. Cambridge University Press, Cambridge (1987)zbMATHGoogle Scholar
  7. 7.
    Langer, A., Kreft, K.: C++ expression templates. In: C/C++ Users Journal (2003)Google Scholar
  8. 8.
    Langtangen H.: Computational Partial Differential Equations. Springer, Heidelberg (1999)zbMATHGoogle Scholar
  9. 9.
    Pflaum C.: Epression templates for partial differential equations. Comp. Vis. Sci. 4, 1–8 (2001)zbMATHCrossRefGoogle Scholar
  10. 10.
    Quarteroni, A., Valli A.: Numerical approximation of partial differential equations, no. 23. In: Springer Series in Computational Mathematics. Springer, Berlin (1994)Google Scholar
  11. 11.
    Sethian J.A.: Level Set Methods and Fast Marching Methods. 2nd edn. Cambdridge Press, New York (1999)zbMATHGoogle Scholar
  12. 12.
    Stroustrup B.: The C++ Programming Language. Addison Wesley, Longman, Reading (2000)Google Scholar
  13. 13.
    Veldhuizen, T.: Expression templates. In: C++ Report Magazine, vol. 7, pp. 26–31. See also the web page (1995)
  14. 14.
    Veldhuizen, T., Jernigan, M.: Will c++ be faster than fortran? In: Proc. First International Scientific Computing in Object Oriented Parallel Environments ’97. Springer, Heidelberg (1997)Google Scholar

Copyright information

© Springer-Verlag 2008

Authors and Affiliations

  • Daniele Antonio Di Pietro
    • 1
  • Alessandro Veneziani
    • 2
    Email author
  1. 1.Département de Technologie, Informatique et Mathématiques AppliquéesInstitut Francais du PétroleRueil-Malmaison CedexFrance
  2. 2.Mathematics and Computer ScienceEmory UniversityAtlantaUSA

Personalised recommendations