 # Dörfler marking with minimal cardinality is a linear complexity problem

Most adaptive finite element strategies employ the Dörfler marking strategy to single out certain elements M⊆T of a triangulation T for refinement. In the literature, different algorithms have been proposed to construct M, where usually two goals compete: On the one hand, M should contain a minimal number of elements. On the other hand, one aims for linear costs with respect to the cardinality of T. Unlike expected in the literature, we formulate and analyze an algorithm, which constructs a minimal set M at linear costs. Throughout, pseudocodes are given.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1. Introduction

In the last decade, the mathematical understanding of adaptive finite element methods (AFEM) has matured. For many elliptic model problems, one can mathematically prove that AFEM leads to optimal convergence behavior; see, e.g., [CFPP14] and the references therein. Starting from an initial mesh , the usual AFEM algorithms iterate the loop

 solve→estimate→mark→refine (1)

The latter generates a sequence of successively refined meshes together with the associated FEM solutions and a posteriori

error estimators

, where the index is the step counter of the adaptive loop. Formally, the algorithm reads as follows: For all , iterate the following steps:

• Compute the FEM solution corresponding to .

• Compute certain refinement indicators for all .

• Determine a subset of elements for refinement.

• Generate a new mesh by refinement of (at least) all marked elements.

Usually, the set from then contains the elements with the largest contributions . Often (and, in particular, for the analysis of rate optimality [CFPP14]), the Dörfler marking criterion [Dör96] is used: Given , construct such that

 θη2ℓ≤∑T∈Mℓηℓ(T)2, (2)

i.e., the marked elements control a fixed percentage of the overall error estimator. Clearly, one aims to choose the set with as few elements as possible.

As far as convergence of AFEM is concerned, also other marking criteria can be considered [MSV08, Sie11]. When the focus comes to the overall computational cost of AFEM, then the (quasi-) minimal Dörfler marking (2) becomes necessary [CFPP14] and it is important that all steps can be performed at linear cost with respect to the number of elements . This is usually a reasonable assumption if employs iterative solvers like PCG [FHPS18] or multigrid [Ste07], and it requires appropriate data structures for and .

If aims for a set , which satisfies (3) with minimal cardinality, then linear cost is less obvious: The work [Dör96] notes that a possible strategy is to sort the indicators, which, however, results in log-linear costs. Instead, the work [Ste07] employs an approximate sorting by binning. While this leads to linear costs, the resulting set has only minimal cardinality up to a multiplicative factor , and [Ste07, Section 5] notes:

Selecting that satisfies (2) with true minimal cardinality would require sorting all by the values of , which takes operations.

The present work bridges the approaches of [Dör96, Ste07] and proves that the latter statement is wrong: Based on ideas of the (Quick-) Selection algorithm [Hoa61], we present a linear-cost algorithm for , which provides a set , which satisfies the Dörfler criterion (2) with minimal cardinality.

The outline of the present work reads as follows: In Section 2, we formulate the Dörfler marking and briefly discuss the algorithms from [Dör96, Ste07]. In Section 3, we present and analyze our new approach for named QuickMark. Section 3.4 concludes with a C++11 STL-based implementation of the new algorithm.

## 2. Dörfler marking

### 2.1. Setting

Let and

. Given a vector

, an index set satisfies the Dörfler criterion, if

 θ∑j∈Ixj≤∑j∈Mxj. (3)

By , we denote the number of elements in . Let denote the minimal number of indices which are required to satisfy the Dörfler criterion (3). We note that the minimizing set is not unique in general, e.g., if for all and .

Remark 1. For , the set of minimal cardinality satisfying (3) is unique and given by . Clearly, this set can be determined at linear costs.

We say that an algorithm realizes the minimal Dörfler marking, if, for all , for all , and for all , the algorithm constructs a set , which satisfies (3) with . We say that an algorithm realizes the quasi-minimal Dörfler marking, if, for all , there exists a constant such that, for all and for all , the algorithm constructs a set , which satisfies (3) with .

For current proofs of rate optimality of AFEM, the marking algorithm has to realize the quasi-minimal Dörfler marking [CFPP14], while available results on optimal computational costs require also that the marking step has linear costs [Ste07, GHPS18, FHPS18].

### 2.2. Minimal Dörfler marking based on sorting

It is already noted in [Dör96] that a set , which satisfies (3) as well as , can easily be constructed by sorting.

Algorithm 2.  For the setting from Section 2.1, perform the following steps (i)–(iii):

• Determine a permutation such that .

• Compute .

• Determine the minimal index such that .

Output:

In practice, step (i) of Algorithm 2.2 will be performed by sorting the vector . This leads to operations for, e.g., the Introsort algorithm [Mus97].

Proposition 3. The set generated by Algorithm 2.2 satisfies (3) as well as , i.e., Algorithm 2.2 realizes the minimal Dörfler marking. Up to step (i), the computational cost of Algorithm 2.2 is linear.

###### Proof.

Let satisfy (3) with . By construction of , it holds that

 n−1∑i=1xπ(i)

Hence, we see that . This implies that . It is obvious that step (ii)–(iii) of Algorithm 2.2 have linear cost . ∎

### 2.3. Dörfler marking without sorting

To avoid sorting, the work [Dör96] proposes (a variant of) the following algorithm; see [Dör96, Section 5.2].

Algorithm 4.  For the setting from Section 2.1 and given , perform the following steps (i)–(vi):

• Initialize , and for all .

• Compute and .

• For , iterate the following steps:

• For all with , iterate the following steps:

• if , then define and update

• if , then terminate.

Output:

Remark 5. The algorithm proposed in [Dör96, Section 5.2] has the stopping criterion (vi) as part of step (iii), i.e., steps (iv)–(v) are iterated, until . If is constant, i.e., for all , then this variant leads to for all and hence does not realize quasi-minimal Dörfler marking. Our formulation of Algorithm 2.3 excludes such a simple counterexample.

Proposition 6.  Algorithm 2.3 terminates after finitely many steps. The computational cost of Algorithm 2.3 is . The set generated by Algorithm 2.3 realizes (3), but it is not quasi-minimal in general.

###### Proof.

Steps (i)–(ii) have linear costs . Obviously, if in step (vi) the sum is rather updated than recomputed, step (iii)–(vi) lead to total costs for Algorithm 2.3. To see that satisfies (3), note that (at latest) for , it holds that and hence is satisfied for all . It only remains to show that Algorithm 2.3 does not realize the quasi-minimal Dörfler marking.

Let and be arbitrary. We aim to show that for any constant , there exist and such that the set generated by Algorithm 2.3 satisfies . Without loss of generality, we may assume . The idea now is the following:

• For some and , define the vector of the form

 x=(1,ε,…,εCR % times,δ,…,δR−1 times)∈RN,i.e.,xj:=⎧⎨⎩1if j=1,εif 2≤j≤N−R+1,δif N−R+2≤j≤N.
• Then, choose and such that satisfies (3), but neither nor do.

• If moreover and are chosen such that the condition in Step (v) of Algorithm 2.3 is not satisfied for any of the indices and any of the loop iterations of Step (iii), then for the last loop iteration , starting from the index , all indices will be added to until (3) is satisfied.

• Now, if is chosen small enough, then the set returned by Algorithm 2.3 will be a superset of , i.e., .

• Since satisfies (3), it holds that and hence .

It remains to define , and such that the desired properties hold. Define

 δ :=⌈(1−ν(⌈1/ν⌉−1))−1⌉−1,R:=⌈(2−θ)/θ⌉/δ+1,N:=(C+1)R, ε :=(CR)−1min{1,(1−θ)(1+⌈(2−θ)/θ⌉)/θ};

Note that implies that . First, note that

 θN∑j=1xj =θ+θCRε+θ(R−1)δ=θ+θCRε+θ⌈(2−θ)/θ⌉ =1+⌈(2−θ)/θ⌉=1+(R−1)δ=∑j∈M′xj.

Hence, satisfies (3) and therefore . Next, we claim that Algorithm 2.3 will construct a set , which thus contains more than indices: Observe that

 0 <ε≤(CR)−1≤C−1δ⌈(2−θ)/θ⌉−1≤C−1δθ/(2−θ)<δ =⌈(1−ν(⌈1/ν⌉−1))−1⌉−1≤1−ν(⌈1/ν⌉−1).

This proves that . Together with , this implies that the condition in Step (v) of Algorithm 2.3 will not be satisfied for any before the last iteration of the loop in Step (iii) of Algorithm 2.3 (i.e., before ). Thus, for , we have , , and for all . Note, that

 θN∑j=1xj =θ+θCRε+θ(R−1)δ >θ+θ(R−1)δ=θ+θ⌈(2−θ)/θ⌉≥2≥1+CRε=CR+1∑j=1xj.

Consequently, after the last iteration of the -loop it holds that for all and . Hence, the set returned by Algorithm 2.3 satisfies . This concludes the proof. ∎

### 2.4. Quasi-minimal Dörfler marking with linear complexity by binning

The following strategy has been proposed in the seminal work [Ste07], which gave the first optimality proof for a standard AFEM loop of type (1) for the 2D Poisson problem. The main observation is the following: If the reduction of the threshold in step (v) of Algorithm 2.3 is done by multiplication instead of subtraction, then the resulting algorithm satisfies the quasi-minimal Dörfler marking. While [Ste07, Section 5] outlines the proposed strategy for the choice , we work out all details in our proof of Proposition 2.4.

Algorithm 7.  For the setting from Section 2.1 and given , perform the following steps (i)–(v):

• Compute and .

• Determine the minimal with .

• For , fill bins and define .

• This yields a permutation such that

• for all and with .

• Determine the minimal index such that .

Output:

Proposition 8.  For arbitrary , Algorithm 2.4 terminates after finitely many steps. The constructed set satisfies (3) with . Moreover, a proper implementation of Algorithm 2.4 leads to a total computational cost of with .

###### Proof.

The only non-obvious statement is the bound : For , it holds that and hence

 v+N#BK+1∑j∈BK+1xj≤vθ=∑j∈I∖BK+1xj+∑j∈BK+1xj.

Since and for all , it follows that satisfies (3). Let be the largest index such that . If no such index exists, i.e., , define . Clearly, it holds that and . Further, there exists such that satisfies (3) with minimal cardinality .

To show , it suffices to show that satisfies . Consider . Then, , , and with , it holds that

 νk0+2M(#R−1)<∑j∈R∖{π(n)}xj

It immediately follows, that . Altogether, satisfies (3) with . ∎

## 3. Minimal Dörfler marking with linear complexity

This section constitutes the main contribution of this work.    Theorem 9.  Dörfler marking with minimal cardinality is a linear complexity problem. More precisely, a call of Algorithm 3.1 below with a vector leads after operations to a set with (3) and .     We prove this main theorem explicitly by introducing the QuickMark algorithm in Section 3.1. The correctness of the QuickMark algorithm is proved in Section 3.2 and the linear complexity of QuickMark is shown in Section 3.3. Section 3.4 concludes with some remarks on the implementation of the algorithm.

### 3.1. The QuickMark algorithm

Adapting the divide-and-conquer strategy of efficient selection algorithms [Hoa61], we propose a new strategy to determine, at linear costs, a subset with (3) and . The proposed algorithm consists of an initial call (Algorithm 3.1) and the function QuickMark (Algorithm 3.1), which steers the divide-and-conquer strategy based on the subroutines Pivot (Algorithm 3.1) and Partition (Algorithm 3.1).

To improve readability throughout this chapter, whenever a permutation on would be altered by a function, that function instead is written to take the permutation as input and returns as output the new permutation . If a permutation is not changed by a function, it is simply denoted by . Moreover, let represent the identity permutation on , i.e., for all . For an index set define .

Algorithm 10 (Initial call of QuickMark).  For the setting from Section 2.1, we perform the following steps (i)–(iv):

• Initialize the identity permutation .

• Define lower index and upper index .

• Compute the goal value .

• Call  QuickMark

Output:

Analogously to selection algorithms [Hoa61], the QuickMark algorithm is based on the subroutine Partition, where elements are essentially separated into two classes: Those elements with smaller value than the pivot element, and those with greater value than the pivot element. Then, the algorithm decides, which of the two classes is not to be inspected further.

Algorithm 11 ( QuickMark).  Input: Vector , permutation on , goal value , lower and upper indices .

• Determine a pivot index Pivot.

• Determine a new permutation via Partition.

• Compute the sum of the greatest elements .

• If , then return QuickMark

• Else, if , then return

• Else return QuickMark

Output: Permutation of and index .

The Pivot subroutine should determine a feasible pivot element of a given (sub-) array. While the concrete choice of the pivot strategy is irrelevant for the correctness of the procedure, it is the decisive factor for the computational complexity of the divide-and-conquer strategy. For now, we consider an arbitrarily (e.g., randomly) chosen . While in Section 3.2 correctness of the algorithm is proved independently of the concrete pivot strategy, in Section 3.3 we propose a pivot strategy that leads — even in the worst case — to linear complexity of Algorithm 3.1.

Algorithm 12 ( Pivot).  Input: Vector , permutation on , lower and upper indices .

• Use to determine a pivot index .

Output: Pivot index .

For a given pivot element, the Partition subroutine reorganizes the elements of an (sub-) array depending on whether they are greater than, smaller than, or equal to the pivot.

Algorithm 13 ( = Partition).  Input: Vector , permutation on , lower and upper indices , pivot index .

• Compute a permutation on together with the unique indices and such that the following three implications hold true for all :

• If , then .

• If , then .

• If , then .

• Define

Output: Permutation of together with indices and .

The following remark collects some important observations (4)–(5) about the state of and in Algorithm 3.1. The validity of (4) will be shown in Proposition 3.2.1 in Section 3.2. The properties (5) follow directly from Algorithm 3.1.    Remark 14. When Partition (Algorithm 3.1) is called in step (ii) of QuickMark (Algorithm 3.1), the permutation and the indices satisfy

 xπold(j) >xπold(k) for all 1≤j<ℓ≤k≤N, (4a) xπold(j) >xπold(k) for all 1≤j≤u

This is illustrated in Figure 1.

The permutation defined in step (ii) of Algorithm 3.1 differs from only at the indices . Consequently, (4a)–(4b) are preserved by . With the indices returned by Algorithm 3.1 and the pivot index, it additionally holds that

 xπnew(j) >xπold(p) for all ℓ≤j≤g, (5a) xπnew(j) =xπold(p) for all g

This is illustrated in Figure 2.

### 3.2. Correctness of the QuickMark algorithm

We consider , permutations on , indices with , and a value . Proving the correctness of QuickMark (Algorithm 3.1) is organized into three steps: In Section 3.2.1 we verify some essential properties satisfied by the input parameters of calls to Algorithm 3.1. Section 3.2.2 introduces auxiliary subproblems generated and solved by Algorithm 3.1 and gives insight on the idea behind the QuickMark strategy. Termination of Algorithm 3.1 is investigated in Section 3.2.3, where the correctness is proved.

#### 3.2.1. Admissible calls to QuickMark

We consider the following crucial properties, which will be shown to be always satisfied in Proposition 3.2.1.    Definition 15.  A call QuickMark to Algorithm 3.1 is called admissible, if the inputs satisfy the following conditions (a)(b):

• It holds that

 xπold(j) >xπold(k) for all 1≤j<ℓ≤k≤N, (6a) xπold(j) >xπold(k) for all 1≤j≤u
• It holds that

 0

In fact, the following proposition shows that recursive calls of QuickMark preserve the admissibility conditions.    Proposition 16.  If QuickMark is initially called by Algorithm 3.1(iv), then each subsequent recursive call QuickMark from step (iv) or (vi) of Algorithm 3.1 is admissible.

###### Proof.

The statement follows directly by induction. First, we show that the initial call QuickMark of Algorithm 3.1 initiated by Algorithm 3.1(iv) with the inputs , , , , and is admissible: Since and , Definition 3.2.1(a) contains only statements about indices in the empty set and is therefore satisfied. Definition 3.2.1(b) follows from , , and the definition of .

For the induction step, consider an admissible call QuickMark of Algorithm 3.1. We show that a potential subsequent call QuickMark initiated by either Algorithm 3.1(iv) (i.e., , , ), or by Algorithm 3.1(vi) (i.e., , , ), is also admissible: By (a), (b) we refer to the assumption, i.e., the admissibility conditions of Definition 3.2.1 satisfied by QuickMark. We aim to show the corresponding admissibility conditions of Definition 3.2.1 for the call QuickMark, which will be denoted by , .

Recall, that in either case (step (iv) or step (vi) in Algorithm 3.1), differs from only on the index set . Therefore, in both cases follows from (5a)–(5c) and (a). If recursion relies on Algorithm 3.1(iv), then , , and . Hence,

 0

proves . If recursion relies on Algorithm 3.1(vi), then , , and

 v>σg+(s−g−1)xπold(p)s−1∑j=ℓxπnew(j). (8)

Combining (b) and the last estimate yields for that

 0v′(b)=θN∑j=1xj−ℓ−1∑j=1xπold(j)−s−1∑j=ℓxπnew(j)=θN∑j=1xj−ℓ′−1∑j=1xπnew(j)(b)≤u′∑j=ℓ′xπnew(j).

This shows . ∎

#### 3.2.2. Subproblems generated by QuickMark

To analyze Algorithm 3.1, we introduce some auxiliary notation. In particular, the symbol will be used differently than in Section 2.1. The connection between the two notations is clarified in Remark 3.2.2.

By , we denote the power set of . For any admissible call QuickMark to Algorithm 3.1, let consist of all such that

 xπ(j) ≥xπ(k) for all j∈M and all k∈{ℓ,…,u}∖M, (9a) ∑j∈Mxπ(j) ≥v>∑j∈M∖{k}xπ(j) for all k∈M. (9b)

The following remark follows immediately from (9a)–(9b) and connects the introduced notation to the Dörfler marking criterion (3) from Section 2.1.    Remark 17.  For arbitrary , the set satisfies (3) with minimal cardinality .

Later in Section 3.2.3, we will prove that QuickMark called by Algorithm 3.1 determines a set . The core idea behind the proof is the observation that for an admissible call QuickMark, the set can be written as

 {π({1,…,ℓ−1})∪π(M′):M′∈M(x,π,ℓ,u,v)}.

Hence, an admissible call QuickMark to Algorithm 3.1 either determines a set and terminates in step (v), or it initiates another admissible recursive call denoted by QuickMark in step (iv) or step (vi), where , i.e., the problem is reduced to a strict subproblem.

First, we will show, that all occurring subproblems of finding are well-posed. In fact, for an admissible call QuickMark the set is always nonempty and all attain the same minimum in .    Lemma 18.  Let QuickMark be an admissible call to Algorithm 3.1. Then, . Moreover, the definition

 x∗(x,π,ℓ,u,v):=minj∈Mxπ(