Data Structures for Multilevel Adaptive Methods and Iterative Solvers

4 downloads 1361 Views 175KB Size Report
Sep 15, 1992 - and Iterative Solvers. U. R UDE. Institut f ur Informatik .... speci cation and development of software, see Denert 19]. The mathematical notion of ...
Data Structures for Multilevel Adaptive Methods and Iterative Solvers U. RU DE Institut fur Informatik Technische Universitat Munchen Arcisstr. 21, D-8000 Munchen 2 Germany e-mail: [email protected] September 15, 1992 Abstract

The adaptive solution of partial di erential equations by nite elements must be supported by suitable data structures. Besides an overview of existing adaptive mesh techniques, our analysis provides an abstract treatment discussing the necessary functionality independent of concrete representations. The di erent aspects can be organized in topological, geometric and the algebraic components. Further considerations are necessary to support self-adaptivity in a multilevel context. We distinguish between element based and node based data structures and will discuss their implementation in an object oriented language. Keywords. Finite elements, data structures, adaptivity, multilevel methods, object oriented programming, C++.

1

Contents

1 Introduction 1.1 1.2 1.3 1.4 1.5

Overview : : : : : : : : : Relations : : : : : : : : : Speci cation of software : Eciency and Modularity Mathematical Problem : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

Classi cation : : : : : : : : : : : : : : : : : : Triangulations : : : : : : : : : : : : : : : : : Topological structure of a nite element mesh Geometric structure : : : : : : : : : : : : : : Algebraic structure : : : : : : : : : : : : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: 8 : 9 : 11 : 14 : 15

Uniform meshes : : : : : : : : : : : : : : : : : : : : : : Quasi-uniform meshes : : : : : : : : : : : : : : : : : : Data structures for uniform and quasi-uniform meshes Piecewise uniform and piecewise quasi-uniform meshes Unstructured meshes : : : : : : : : : : : : : : : : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : :

: : : : : : : :

: : : : : : : :

: : : : : : : :

: : : : : : : :

: : : : : : : :

: : : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

2 Finite Element Meshes 2.1 2.2 2.3 2.4 2.5

3 Special cases of nite element meshes 3.1 3.2 3.3 3.4 3.5

4 Adaptive Techniques 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8

A-priori adaptivity : : : : : : : : : : : : : : : : : : Self-adaptive re nement : : : : : : : : : : : : : : : Algorithmic requirements : : : : : : : : : : : : : : Nested triangulations : : : : : : : : : : : : : : : : : Regular re nement : : : : : : : : : : : : : : : : : : Re nement by bisection : : : : : : : : : : : : : : : Self-adaptive re nement based on uniform patches Virtual global re nement : : : : : : : : : : : : : :

: : : : : : : :

: : : : : : : :

5 Data structures for hierarchical nite element meshes 5.1 5.2 5.3 5.4 5.5 5.6 5.7

5

: : : : :

Relations in the multilevel hierarchy Element based data structures : : : Node based data structures : : : : : Classi cation of nodes : : : : : : : : (Semi-)edges and connections : : : : Incompletely re ned meshes : : : : : Characteristic sets : : : : : : : : : :

2

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

: : : : : : :

5 5 6 6 8

8

19 19 21 22 24 25

26 27 27 29 30 31 32 34 35

37 37 38 40 42 44 45 47

6 Implementation using C++ 6.1 6.2 6.3 6.4

Node classes : : : : : : : : : : : : : : : : : : : : : : : : : : : Eciency for special cases requiring limited mesh exibility Virtual overloaded functions : : : : : : : : : : : : : : : : : : The role of C++ : : : : : : : : : : : : : : : : : : : : : : : :

7 Conclusion

: : : :

: : : :

: : : :

49 49 51 53 54

55

3

List of Figures 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

Plot of example solution on an adapted triangular nite element mesh : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Nonconforming triangulation : : : : : : : : : : : : : : : : : : : : Relations between basic entities : : : : : : : : : : : : : : : : : : Generation of uniform meshes by ane transformations : : : : : Quasi-uniform mesh : : : : : : : : : : : : : : : : : : : : : : : : : Uniform mesh with boundary modi cation. : : : : : : : : : : : : Data structures for piecewise ane quasi-uniform mesh : : : : : Piecewise quasi-uniform mesh : : : : : : : : : : : : : : : : : : : Two-level FAC mesh : : : : : : : : : : : : : : : : : : : : : : : : : Mesh with four or eight semi-edges at each interior node. : : : : Classical Solution Strategies for Elliptic Problems : : : : : : : : : Integrated Solution Strategy for Elliptic Problems : : : : : : : : Nested triangulations : : : : : : : : : : : : : : : : : : : : : : : : Regular re nement of a triangle : : : : : : : : : : : : : : : : : : Regularly re ned mesh with nonconforming nodes : : : : : : : : Regular re nement induced by two nonconforming nodes on different sides : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Regular re nement induced by two nonconforming nodes on the same side : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : Four similarity classes generated by newest node bisection : : : Plot of live nodes in a virtual global re nement : : : : : : : : : : Construction of a triangle tree by successive re nement : : : : : : Hierarchy of two grid levels : : : : : : : : : : : : : : : : : : : : : Di erent types of nodes : : : : : : : : : : : : : : : : : : : : : : : Class hierarchy for node data type : : : : : : : : : : : : : : : : : Hierarchy of two grid levels with incompletely re ned mesh : : : Basic node data type de nition : : : : : : : : : : : : : : : : : : : Initial node data type de nition : : : : : : : : : : : : : : : : : : : Application of abstract node iterator : : : : : : : : : : : : : : : :

4

10 11 12 20 21 22 23 25 26 27 28 28 30 31 32 33 33 34 36 38 40 43 44 47 50 51 53

1 Introduction 1.1 Overview

This paper contains a systematic discussion of adaptive techniques for elliptic problems from the perspective of data structures. Though the study uses the model situation of a simple scalar equation discretized by linear triangular elements as a reference problem, the techniques have much broader applicability. After de ning the model situation, the paper gives an abstract discussion of the structure of nite element discretizations. The topological properties of a mesh are discussed in Section 2. This is extended by geometric and algebraic information,thus providing the basis for the design of practical implementations. In Section 3 we study several special cases of re nement structures. In this Section the perspective is static, that is we examine the suitability of mesh structures without discussing the process of their generation. The dynamic viewpoint is elaborated in Section 4, where we discuss techniques appropriate when the mesh structure is generated as part of the solution process. The special requirements of the algorithmic structure lead to a hierarchical system of meshes that are studied in Section 5. Techniques for an object oriented implementation of such structures are nally addressed in Section 6, where we discuss programming techniques suitable for the ecient, high level formulation of numerical algorithms. The programming language C++ provides a basis to implement adaptive algorithms with advanced software techniques.

1.2 Relations

A relation R of k sets M1 ;    ; Mk is a subset of the cartesian product R  M1      M k : Relations and their application to describe the data structures are e.g. discussed by Rembold [44]. As basis we will use binary relations R  M1  M2 . The fact that (m1 ; m2) 2 "is-related-to" can then be read as "m1 is-related-to m2 ". Generally, relations have a xed number k of arguments. In our context this is not always suitable, because e.g. an element can be a triangle or a quadrilateral and thus have either 3 or 4 edges. Similarly a node can be endpoint of a variable number of edges. In this situation we will use the power set P(M) that is the set of all subsets of M and use relations of the form R  M1  P(M2 ). If these relations are unique in the rst argument, they can be interpreted as functions R P(M ): M1 ?! 2

5

To this end the relation may have to be supplemented by adding tuples (m1 ; ;), m1 2 M1 such that the function is de ned for all elements of M1 . The augmented relation (M1  P(M2 )) can be represented by a list of pointers for each element in M1 . Relations play an important role in the speci cation and construction of software, e.g. in relational databases, or the entity-relationship approach for the speci cation and development of software, see Denert [19]. The mathematical notion of relations is generally well suited to describe abstract structures and thus we will also use it as a means to discuss the structure of adaptive nite element meshes.

1.3 Speci cation of software

The advantage of this abstract approach is that the features of the nite element structure can be discussed and analyzed without referring to a concrete representation. Elements, edges and nodes are abstract entities de ned only by certain operations and relations between them. We consciously separate the functionality required, and the data representation that is used to implement this functionality. This software engineering approach is also related to object oriented programming, where a class of objects is de ned by the operations it can perform and not by its internal representation. In object oriented programming the operations that a class can perform and the internal representation of the class are designed separately. From outside, the representation is irrelevant, only the operations that can be performed are of interest. This concept of data hiding improves the modularity, exibility and extensibility of the software. Our discussion may also be interpreted as the informal use of abstract data types. The informal description could be extended to the de nition of a rigorous abstract data type that includes a consistent system of laws that speci es the data structure axiomatically (see e.g. Bauer and Wossner [8] and the CIP report [25]). In this paper we will not attempt a rigorous de nition of the abstract data type, but refer to the thesis by Loew [32], Adler [1], and Stark [52] that attempt a rigorous approach. Though the use of abstract data types as a rigorous software development method for nite element problems is beyond the scope of this present work, we will demonstrate that the informal use of these techniques is a useful design method.

1.4 Eciency and Modularity

The nite element algorithms determine which operations must be de ned for the data type. The optimal internal representation in turn depends on the operations that must be performed with it. In the language of relations one goal 6

may e.g. be to nd a minimal representation with as few relations as possible. In this case the other relations must then be constructed whenever needed. Though the functionality will be described independent of the internal representation, it is clear that the design of the internal representation has of course great impact on the eciency. Storage requirements must be balanced with run-time performance, and for an optimal design we must carefully analyze the behavior of the operations implemented on that data structure. Di erent implementations of the same abstract type of course in uence the quality of the software. In Sections 5.2 and 5.3 we will e.g. compare speci c advantages of an element-based representation versus a node based representation of nite element meshes. Both representations can be extended to provide the same abstract operations, but they will di er in how e ectively certain operations are performed. But the problem is even more complex. The nal goal is not to implement nite element meshes, but to solve certain partial di erential equations. To perform this task for a speci c problem, the full exibility of general nite elements may not be needed, at least not in all cases of interest. Implementing the full scope of operations and structures necessarily introduces a signi cant overhead. This is especially true, if the program is to be implemented for a high performance computer of vector or parallel type. Exploiting these architectures is only possible if the data structures have a certain uniformity. On uniform rectangular meshes certain basic operations are inherently more ecient than on fully adaptive unstructured grids that create more organizational overhead. Of course it depends on the problem at hand whether the increased exibility of unstructured meshes leads to a overall solver that is more ecient than an equivalent solution on a more rigid data structure where the computational eciency may be better but much work may be wasted because the structure can not be suitably adapted to the problem features. In other cases a uniform mesh may be appropriate for the problem under study and then a code based on unstructured meshes will not be competitive. This is a motivation to study the restricted mesh structures in Section 3. Resolving these con icting goals is a great challenge for the software architecture. Our goal is to develop a concept that includes the uniform, easily vectorizable structures up to the fully unstructured adaptive meshes, yielding full eciency in the one, and maximal exibility in the other case. We will demonstrate that this can be accomplished by very careful modularization using concepts beyond the simple functional software decomposition common in implementations based on classical procedural languages. In Section 6 we will demonstrate how advanced software engineering techniques can be used to achieve some of these goals.

7

1.5 Mathematical Problem

We will illustrate the various techniques using the model problem of an elliptic partial di erential equation (PDE) in a closed, polygonal domain  IR2 . In variational formulation the problem is to nd u 2 H( ) such that A (u; v) ? (f; v) = 0 for all v 2 H( ):

(1)

For scalar, self-adjoint, second order equations H( ) = Hg1( ) is the usual Sobolev space enforcing the essential boundary condition u = g(x; y) on ?0  @ ; where

A (u; v) =

and are bilinear forms.

ZZ



(ru)T A(x; y)rv dxdy;

(u; v) =

ZZ



(2)

uv dxdy

2 Finite Element Meshes 2.1 Classi cation

The structure of a nite element problem has four di erent aspects: topological, geometric, physical, and algebraic. From a topological viewpoint a mesh only consists of elements, edges and vertices. These are abstract entities that must satisfy certain neighbor relations that guarantee that the mesh is logically consistent. The geometric aspect adds metric information to the topology, including the location of vertices, the length of edges, the area of elements, angles, distances, etc. The geometric component is essential for the adaption process and has great impact on the accuracy of the solution. Another set of information is of physical-mathematical nature. Physical components of the problem description include data associated with the problem to be solved, like material coecients, and force or source terms. Using the nite element process we nally derive the algebraic aspect as a discrete representation of the physical problem. In this step we introduce nodal variables forming a system of unknowns to be solved. The physical equation is transformed to discrete equations that are described by entities like the sti ness and mass matrix. 8

This concept of separating the nite element data structure into a basic topological structure, that is successively enriched with the geometry and algebra will later be re ected in our object oriented software design. The topology corresponds to the basic data structure that is extended by geometric and algebraic information through the inheritance mechanism discussed in Section 6. The physical components could be added analogously. However, this will not be discussed because physical information is not directly relevant for the solution process which is the main focus of this present paper.

2.2 Triangulations

Equation (1) can be discretized by nite elements. We assume the polygon

is partitioned by a triangulation T consisting of t triangles and quadrilaterals T = fT1 ;    ; Ttg: The vertices of all triangles and quadrilaterals together are n nodes (or vertices) of the triangulation. Finally, there is the set of edges, consisting of e lines connecting the vertices. For an example nite element function on a triangulated domain see Figure 1. The formal de nition for this situation is given by N = fN1 ;    ; Nn g [ [ fN1; N2 ; N3; N4 g; fN1 ; N2; N3 g [ = Q(N1 N2 N3 N4 )2T

T (N1 N2 N3 )2T

E = fE1; [  ; Eeg fN1 N2 ; N2N3 ; N1 N3 g [ = T (N1 N2 N3 )2T [

Q(N1 N2 N3 N4 )2T

fN1 N2; N2 N3 ; N3N4 ; N4 N1 g

The Ciarlet Conditions

To be suitable for the nite element process, a triangulation (T ; N ; E ) must satisfy the following requirements (see Ciarlet [18]):

T1 The closure of the region is the union of the elements in T

 =

[

T 2T

T

T2 Each element T 2 T is closed and its interior is non-empty: T 6= ;. 9

Figure 1: Plot of example solution on an adapted triangular nite element mesh

10

Z  ZZZ  uhh ZZ hhhhhZhZ   Zhu    u h hhhhu u

Figure 2: Nonconforming triangulation 



T3 For each distinct pair of elements T1 ; T2 2 T one has T1 \ T2= ;. Conforming triangulations

We call a triangulation conforming, if in addition to T1-T3 condition T4 holds:

T4 Any edge of any element T1 is either a subset of the boundary @ , or an edge of another element T2 2 T . To be conforming, nodes may only be located at the endpoints of edges.1 In conforming triangulations two adjacent triangles intersect in a common edge, and any two distinct triangles are either disjoint, or they intersect in one common node or in one common edge. For an example of a triangulation with a nonconforming node see Figure 2. In the set of vertices N we also distinguish between constrained vertices ND lying on a Dirichlet boundary, and the set of free vertices NI in the interior of the domain or on a part of the boundary not constrained by a Dirichlet condition. With the system of sets (T ; N ; E ) we can describe the topological structure of a mesh if additional conditions are satis ed.

2.3 Topological structure of a nite element mesh

We will now discuss the abstract topological structure of a nite element mesh (T ; N ; E ).

Here we are only discussing topological and geometric aspects. Algebraic nodes for higher order basis function are of course often located on the midpoints of edges. 1

11