Using Design Patterns and XML to Construct an Extensible Finite Element System

J. Barr von Oehsen, Christopher L. Cox, Eric C. Cyr, Brian A. Malloy

Abstract

Traditional Finite Element Method (FEM) software often suffers from architectural rigidity and performance bottlenecks in the assembly phase. This paper presents a modern software engineering approach using Design Patterns and XML to create a highly extensible and efficient FEM system. By implementing Factory and Singleton patterns, the authors achieved up to a 3.3x speedup in assembly routines. Furthermore, the use of XML and XSLT transformations decouples simulation data from specific visualization tools, enhancing the system's flexibility and longevity.

1. Introduction

Finite Element Method (FEM) software is a cornerstone of computational engineering, yet it is notoriously difficult to maintain and extend. Historically, optimization efforts have focused almost exclusively on the solver—the mathematical engine—while the assembly phase, which constructs the system of equations, remains a rigid, procedural bottleneck.

The authors identify three primary challenges in legacy FEM systems:

  1. Rigidity: Hard-coded logic makes adding new material parameters or governing equations cumbersome.
  2. Data Silos: Proprietary output formats lock simulation results into specific visualization tools like Matlab or Tecplot.
  3. Efficiency: The constant creation and destruction of complex objects (like basis functions) during assembly creates significant computational overhead when dealing with millions of unknowns.

2. System Architecture and Methodology

To address these issues, the researchers developed an object-oriented FEM package designed for simulating viscoelastic flows. The architecture leverages two primary "force multipliers": Design Patterns and XML-based data handling.

2.1 Design Patterns for Extensibility and Performance

The system utilizes the Factory Method to decouple the creation of elements and basis functions from the core assembly routine. This allows the software to support 1D, 2D, or 3D models interchangeably without modifying the central logic.

To optimize performance, the Singleton Pattern is employed. Since FEM calculations frequently reuse the same basis functions and quadrature rules on a "canonical" element, Singletons ensure that only one instance of these objects exists in memory. This avoids the overhead of millions of redundant object allocations during the assembly of large systems.

System architecture illustrating the integration of Design Patterns (Factories and Singletons) and the XML/XSLT translation pipeline.

2.2 XML and XSLT for Data Interoperability

The system adopts XML for all input and output operations, including mesh data and polymer properties. A key innovation is the "Translator" component. Instead of hard-coding exporters for various visualization tools, the solver generates a generic XML solution file. XSLT (Extensible Stylesheet Language Transformations) is then used to translate this XML into formats for Tecplot, Matlab, HTML, or HDF on the fly, making the system "future-proof" against new visualization standards.

3. Performance Evaluation

The system was evaluated using a prototype viscous flow problem (the Stokes Problem) and a polymer database. The "Patterned C++" approach was benchmarked against a "Non-Patterned" version that followed traditional procedural logic translated directly to C++.

Number of Unknowns C++ No Patterns (sec) Patterned C++ (sec) Speedup
5,477 27.76 8.63 ~3.2x
22,202 113.82 34.82 ~3.3x
89,402 697.50 382.43 ~1.8x

The results demonstrate that clean, object-oriented code can significantly outperform procedural code by reducing object management overhead. Qualitatively, the system proved much easier to maintain; for instance, adding 3D support required only localized changes to the relevant Factory rather than a rewrite of the entire assembly routine.

4. Discussion and Future Work

This research challenges the myth that object-oriented design necessarily compromises performance in scientific computing. By using the Singleton pattern to reuse data structures across the mesh, the authors reduced CPU cycles while improving code clarity. The decoupling of visualization via XML/XSLT ensures that the simulation remains compatible with evolving software ecosystems.

Future work will focus on:

  • Benchmarking: Comparing the system against optimized C and Fortran implementations to quantify the absolute overhead of object-oriented abstractions.
  • Complexity: Extending the code to handle non-Newtonian flows in complex 3D geometries.
  • Parallelization: Porting the flexible assembly phase to parallel environments to distribute tasks across multiple processors.

Summary updated

Abstract

We present an object-oriented finite element software package which employs XML and design patterns in order to solve a problem which is fundamental to the simulation of viscoelastic flows. The XML format increases flexibility in data handling, while design patterns provide a high-level organizational structure. The application problem and the finite element methodology are described, along with the opportunities presented for incorporation of the software tools. Numerical experiments comparing results with and without XML and design patterns are also presented.
BibTeX
@inproceedings{oehsen2002using,
  author = {J. Barr von Oehsen and Christopher L. Cox and Eric C. Cyr and Brian A. Malloy},
  title = {{Using Design Patterns and XML to Construct an Extensible Finite Element System}},
  booktitle = {International Conference on Computational Science},
  year = {2002},
  doi = {10.1007/3-540-47789-6\_76},
}
Figure