Journal of Computational Science 4 (2013) 170–179 Contents lists available at SciVerse ScienceDirect Journal of Computational Science j ourna l ho me page: www.elsevier.com/locate/jocs Preventing deadlock during anisotropic 2D mesh adaptation in hp-adaptive FEM Arkadiusz Szymczak a , Anna Paszy ´ nska b , Maciej Paszy ´ nski a, , David Pardo c a AGH University of Science and Technology, Krakow, Poland b Faculty of Physics, Astronomy and Applied Computer Science, Jagiellonian University, Krakow, Poland c University of the Basque Country (UPV/EHU) and IKERBASQUE (Basque Foundation for Sciences), Bilbao, Spain a r t i c l e i n f o Article history: Received 16 March 2011 Received in revised form 8 September 2011 Accepted 18 September 2011 Available online 1 October 2011 Keywords: Anisotropic mesh adaptation Hp-adaptive finite element method Grammar Petri net Deadlock a b s t r a c t The paper presents a grammar for anisotropic two-dimensional mesh adaptation in hp-adaptive Finite Element Method with rectangular elements. Expressing mesh transformations as grammar productions is useful for concurrency analysis thanks to exhibiting the partial causality order (Lamport relationship) between atomic operations. It occurs that a straightforward approach to modeling this process via gram- mar productions leads to potential deadlock in h-adaptation of the mesh. This fact is shown on a Petri net model of an exemplary adaptation. Therefore auxiliary productions are added to the grammar in order to ensure that any sequence of productions allowed by the grammar does not lead to a dead- lock state. The fact that the enhanced grammar is deadlock-free is proven via a corresponding Petri net model. The proof has been performed by means of reachability graph construction and analysis. The paper is concluded with numerical simulations of magnetolluric measurements where the deadlock problem occurred. © 2011 Elsevier B.V. All rights reserved. 1. Introduction In this paper we present a Petri nets based approach for test- ing and preventing deadlock during mesh transformations for two dimensional hp-adaptive Finite Element Method (hp-FEM) compu- tations [1,2]. The hp-adaptation generates a sequence of meshes providing exponential convergence of the numerical error with respect to the number of degrees of freedom. It has multiple applications including material science [3–5], propagation of elec- tromagnetic waves, in particular with oil-industry applications [6–9] as well as heat transfer problems [4,5]. The paper presents a grammar for anisotropic two-dimensional mesh adaptation in hp-adaptive Finite Element Method with rect- angular elements. h-Adaptation of the mesh elements is governed by the following set of rules: element interiors and element edges are broken separately; an element edge may be subject to Nth level adaptation only when all its adjacent element interiors are at Nth level of adap- tation; an element interior may be subject to (N + 1)th level adaptation only when all its adjacent element edges are at Nth level of adap- tation; Corresponding author. E-mail address: paszynsk@agh.edu.pl (M. Paszy ´ nski). URL: http://home.agh.edu.pl/ paszynsk (M. Paszy ´ nski). an element may be broken either horizontally or vertically or in both directions as a single operation (we consider anisotropic mesh refinements). The first three rules follow from the fact that we enforce 1- irregularity rule [1] over the mesh, to prevent the presence of double constrained nodes. According to the 1-irregularity rule a finite element can be broken only once without breaking the adja- cent large elements. The rule prevents unbroken element edges from being adjacent to more than two finite elements on one side. When an unbroken edge is adjacent to one large finite ele- ment on one side and two smaller finite elements on the other side, the approximation over these two smaller elements is con- strained by the approximation over the larger element. To avoid a technical nightmare with constrained approximation over multi- ple constrained edges, the 1-irregularity rule is commonly used in the h adaptive algorithms. The next section presents a grammar governing the process of h-adaptation such that all the above rules are fulfilled. It occurs that straightforward translation of the above rules to grammar pro- ductions can lead to a deadlock in a sequence of mesh element adaptations allowed by this grammar. This fact is shown by means of a Petri net modeling the grammar-driven h-adaptation. The subsequent section presents an enhancement to the defined grammar. The new productions are added to remove the deadlock by canceling one of the anisotropic refinements and replacing it by the isotropic one. The analysis of the Petri net modeling the 1877-7503/$ see front matter © 2011 Elsevier B.V. All rights reserved. doi:10.1016/j.jocs.2011.09.001