<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Design Patterns for Object-Oriented Scientific Software</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Serhii Choporov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Serhii Gomenyuk</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Oleksii Kudin</string-name>
          <email>alexkudin@znu.edu.ua</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andrii Lisnyak</string-name>
          <email>andrey.lisnyak@gmail.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Zaporizhzhya National University</institution>
          ,
          <addr-line>Zaporizhzhya</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Software design patterns are general reusable object-oriented solution. In software engineering, patterns have been proven to offer many benefits. Scientific software also becomes more object-oriented and the importance of design patterns increases. We present a set of design patterns for object-oriented scientific software. Particularly we develop computer-aided engineering software based on the Finite element method. Initially, we decompose the problem into subsystems by applying the commonality and variability analysis. A set of commonalities includes following terms: a representation scheme, a mesh, a solver, etc. A representation scheme is an interface that allows to check whether a point belong to a solid or not. A mesh is the discrete representation of the solid via a set of simple geometric shapes. Four basic design patterns for the scientific software development have been presented in this paper. There are developed UIModel-Analysis, Representation-Mesh, Element-Mesh, and FEA Problem patterns. These design patterns separate pre-processing, the analysis solver, and post-processing of results.</p>
      </abstract>
      <kwd-group>
        <kwd>Software Engineering</kwd>
        <kwd>Software Design Patterns</kwd>
        <kwd>Scientific Software</kwd>
        <kwd>Finite Element Method</kwd>
        <kwd>Object-oriented Approach</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Software design patterns as general reusable solutions were introduced in the end of the
1980s and, since that time, they have been actively explored in software engineering
[
        <xref ref-type="bibr" rid="ref1 ref2 ref3">1-3</xref>
        ]. Until recently, scientific programmers have usually avoided object-oriented
approaches because of their heavy computational over-head [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. However, scientific
software becomes larger and requires flexibility, extensibility and maintainability [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
Design patterns deal with these issues providing generic object-oriented solutions.
      </p>
      <p>CAE software is a kind of scientific software that areas may include the stress
analysis, the thermal analysis, the fluid flow analysis, the multibody dynamics etc. In
general, a CAE system consists of three subsystems: pre-processing, an analysis solver,
and post-processing of results.</p>
    </sec>
    <sec id="sec-2">
      <title>Catalogue of Design Patterns</title>
      <p>Consider a generic CAE system that uses the finite element method in the solver
subsystem. We can assume that every solid’s model is initially defined by some
representation scheme and then this model is discretized into a mesh.
2.1</p>
      <sec id="sec-2-1">
        <title>UI–Model–Analysis Pattern</title>
        <p>The most modern CAE software have integrated graphical user interface (UI). Using
UI controls, user defines the model of the problem and performs the analysis. Hence,
three main packages participate in the high-level decomposition.</p>
        <p>The UI package contains classes that implement UI-related responsibilities of
software. The analysis package is responsible for the numerical analysis. The model
package defines the interface that allows to check whether a point belong to a solid or not.
Naturally, there should be no coupling between the analysis and UI subsystems.
However, the UI package is dependent on pre-processing, the solver and post-processing.
2.2</p>
      </sec>
      <sec id="sec-2-2">
        <title>Representation-Mesh Pattern</title>
        <p>We suppose that a domain model is described in terms of some representation scheme.
Boundary representation (BRep), constructive solid geometry (CSG), and function
representation (FRep) are the most commonly used schemes. A common property of CSG
and FRep that it is easy to check whether arbitrary point belong to the solid or not. We
also can assume that a mesh is an abstract interface that allows generating and iterating
over a collection of elements. In this case, concrete classes derived from the Mesh class
generate collections of elements with appropriate shape using an abstract
representation’ interface to classify a point. Both Representation and Mesh classes participate in
the Representation–Mesh pattern (see Fig. 2). The intent of this pattern is to separate
responsibilities between representations and mesh generation classes.</p>
        <p>
          Both Representation and Mesh classes are an application of the Strategy pattern [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ].
The Mesh class and its derivatives can also be implemented as Iterator [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ] to traverse a
collection of elements. In addition, some meshing algorithms may be implemented as
Template Methods [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ].
        </p>
        <sec id="sec-2-2-1">
          <title>Representation</title>
          <p>+isInside
FunctionRepresentation
+isInside
Uses
Uses</p>
        </sec>
        <sec id="sec-2-2-2">
          <title>Mesh</title>
          <p>+isInside
TriangleMesh
+isInside
has
has</p>
        </sec>
        <sec id="sec-2-2-3">
          <title>Element</title>
          <p>Triangle
Fig. 1. The Representation–Mesh pattern
Abstract
Concrete
2.3</p>
        </sec>
      </sec>
      <sec id="sec-2-3">
        <title>Element–Node Pattern</title>
        <p>In general, an element is a collection of nodes in order is significant. Both two- and
three-dimensional elements have edges (an edge is a straight-line segment connecting
two nodes). In addition, three-dimensional elements have faces that are flat elements
enclosed by edges. Thus, the concrete face is an object of the class that inherits the
Element interface. Hence, Element, Face, Edge, and Node are structural elements of
the Element–Node pattern (see Fig. 2).</p>
        <p>
          The Element class and its derivatives (including faces) can be implemented as
Iterator [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ] to traverse collections of points and edges. The Iterator pattern can also be
employed in the Node class and its derivatives to iterate a set of adjacent elements.
        </p>
        <sec id="sec-2-3-1">
          <title>Element</title>
        </sec>
        <sec id="sec-2-3-2">
          <title>Node</title>
          <p>has</p>
          <p>Edge
has Face
has</p>
          <p>Edge
Hexahedron</p>
          <p>
            Node3d
has Quadrilateral
has
has
has
has
The FEA Problem pattern can be derived from the Template Method Pattern [
            <xref ref-type="bibr" rid="ref1">1</xref>
            ] adding
mesh, boundary conditions, and forces (see Fig. 3). The intent of this pattern is to define
a skeleton of a FEA algorithm and the object composition for boundary conditions and
forces, which participate in the problem.
          </p>
          <p>
            Forces and boundary conditions implement the FeaValue interface. This interface
allows to obtain the direction and the value in any point. Forces and boundary
conditions are usually specified by the UI or DSL model. However, using the Adapter pattern
[
            <xref ref-type="bibr" rid="ref1">1</xref>
            ], we can implement the FeaValue interface.
          </p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Conclusion</title>
      <p>This paper has been proposed an approach for the development of scientific software
using design patterns. Particularly, four basic design patterns for the finite element
programming have been presented in this paper. The first, the UI–Model–Analysis pattern
decomposes software into high-level subsystems. The second, the Representation–
Mesh pattern separates relations between representations and mesh generation classes.
Next, the Element–Node pattern uses object decomposition to define elements of a
mesh. Last, the FEA Problem pattern defines the structure for a generic finite element
problem. These patterns show how object can be organized for greater flexibility and
maintainability. Patterns represent abstractions of the CAE design without restrictions
on the source code.</p>
      <p>Acknowledgments. This research is funded by The Ministry of Education and
Science of Ukraine.</p>
      <p>FeaProblem
+assemblyGlobalMatrix()
+assemblyGlobalVector()
+processInitialValues()
+solveLinearSystem()
+processSolution()
+analyse()
assemblyGlobalMatrix();
assemblyGlobalVector();
processInitialValues();
solveLinearSystem();
processSolution();
boundaryConditions
mesh
forces
+direction(Point)
+value(Point)</p>
      <p>elements</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Gamma</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Helm</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          , Johnson, R.,
          <string-name>
            <surname>Vlissides</surname>
          </string-name>
          , J.: Design Patterns:
          <article-title>Elements of Reusable Object-Oriented Software</article-title>
          .
          <string-name>
            <surname>Addison-Wesley</surname>
          </string-name>
          (
          <year>1994</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Alexandrescu</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <string-name>
            <surname>Modern</surname>
            <given-names>C</given-names>
          </string-name>
          +
          <article-title>+ Design: Generic Programming and Design Patterns Applied</article-title>
          . Addison-Wesley (
          <year>2001</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Shalloway</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Trott</surname>
            ,
            <given-names>J.R.</given-names>
          </string-name>
          :
          <article-title>Design Patterns Explained: A New Perspective on Object-Oriented Design</article-title>
          .
          <string-name>
            <surname>Addison-Wesley</surname>
          </string-name>
          (
          <year>2004</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Blilie</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>Patterns in Scientific Software: an Introduction</article-title>
          .
          <source>Computing in Science and Engineering</source>
          <volume>4</volume>
          (
          <issue>3</issue>
          ),
          <fpage>48</fpage>
          -
          <lpage>53</lpage>
          (
          <year>2002</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Cickovski</surname>
          </string-name>
          , Tr.,
          <string-name>
            <surname>Matthey</surname>
            ,
            <given-names>Th.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Izaguirre</surname>
            ,
            <given-names>J.A.</given-names>
          </string-name>
          :
          <article-title>Design Patterns for Generic Object-Oriented Scientific Software</article-title>
          .
          <source>Technical Report TR 2004-29</source>
          . University of Notre Dame, Notre
          <string-name>
            <surname>Dame</surname>
          </string-name>
          (
          <year>2004</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Heng</surname>
            ,
            <given-names>B.C.P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mackie</surname>
            ,
            <given-names>R.I.</given-names>
          </string-name>
          :
          <article-title>Using design patterns in object-oriented finite element programming</article-title>
          .
          <source>Computers and Structures</source>
          <volume>87</volume>
          (
          <fpage>15</fpage>
          -
          <lpage>16</lpage>
          ),
          <fpage>952</fpage>
          -
          <lpage>961</lpage>
          (
          <year>2009</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>