diff --git a/joss.07359/paper.jats/10.21105.joss.07359.jats b/joss.07359/paper.jats/10.21105.joss.07359.jats new file mode 100644 index 000000000..20299fbed --- /dev/null +++ b/joss.07359/paper.jats/10.21105.joss.07359.jats @@ -0,0 +1,922 @@ + + +
+ + + + +Journal of Open Source Software +JOSS + +2475-9066 + +Open Journals + + + +7359 +10.21105/joss.07359 + +ngsPETSc: A coupling between NETGEN/NGSolve and +PETSc + + + +https://orcid.org/0000-0002-3919-8603 + +Betteridge +Jack + + + + +https://orcid.org/0000-0002-1241-7060 + +Farrell +Patrick E. + + + + +https://orcid.org/0009-0001-8842-3221 + +Hochsteger +Matthias + + + + +https://orcid.org/0009-0000-3448-3002 + +Lackner +Christopher + + + + +https://orcid.org/0000-0002-1250-5087 + +Schöberl +Joachim + + + + +https://orcid.org/0000-0002-0435-0433 + +Zampini +Stefano + + + + +https://orcid.org/0000-0002-2577-1106 + +Zerbinati +Umberto + + +* + + + +Imperial College London, United Kingdom + + + + +CERBSim GmbH, Austria + + + + +University of Oxford, United Kingdom + + + + +TU Wien, Austria + + + + +King Abdullah University of Science and Technology, Saudi +Arabia + + + + +* E-mail: + + +1 +7 +2024 + +9 +104 +7359 + +Authors of papers retain copyright and release the +work under a Creative Commons Attribution 4.0 International License (CC +BY 4.0) +2024 +The article authors + +Authors of papers retain copyright and release the work under +a Creative Commons Attribution 4.0 International License (CC BY +4.0) + + + +PETSc +FEM +Meshing + + + + + + Summary +

Combining advanced meshing techniques with robust solver + capabilities is essential for solving difficult problems in + computational science and engineering. In recent years, various + software packages have been developed to support the integration of + meshing tools with finite element solvers. To mention a few, FreeFEM + (Hecht + et al., 2005) includes built-in support for mesh generation, + allowing users to create and manipulate meshes directly within the + software. Similarly, deal.II + (Arndt + et al., 2023) provides a GridGenerator class for generating + standard mesh geometries like grids and cylinders. Furthermore, + deal.II can interface with OpenCASCADE + (OpenCASCADE + Technology, 2023) to refine existing grids while conforming to + the geometry provided. Other finite element libraries, such as + Firedrake + (Ham + et al., 2023), DUNE-FEM + (Dedner + et al., 2010), and FEniCSx + (Baratta + et al., 2023), rely on external tools like Gmsh + (Geuzaine + & Remacle, 2020) and Tetgen + (Si, + 2015) for mesh generation. This paper introduces ngsPETSc, + software built with petsc4py + (Dalcin + et al., 2011) that seamlessly integrates the NETGEN mesher + (Schöberl, + 1997), the NGSolve finite element library + (Schöberl, + 2014), and the PETSc toolkit + (Balay + et al., 2023). ngsPETSc enables the use of NETGEN meshes and + geometries in solvers that use PETSc’s DMPLEX + (Lange + et al., 2015), and provides NGSolve users access to the wide + array of linear, nonlinear solvers, and time-steppers available in + PETSc.

+
+ + Statement of Need +

Efficiently solving large-scale partial differential equations + (PDEs) on complex geometries is vital in scientific computing. PETSc, + NETGEN, and NGSolve offer distinct functionalities: PETSc handles + linear and nonlinear problems in a discretisation agnostic manner, + NETGEN constructs meshes from constructive solid geometry (CSG) + described with OpenCASCADE + (OpenCASCADE + Technology, 2023), and NGSolve offers a wide range of finite + element discretisations. Integrating these tools with ngsPETSc + promises to streamline simulation workflows and to enhance large-scale + computing capabilities for challenging problems. This integration also + facilitates seamless mesh exports from NETGEN to PETSc DMPlex, + enabling simulations of complex geometries and supporting advanced + meshing techniques in other PETSc-based solvers that employ DMPLEX. We + illustrate this with the Firedrake finite element system + (Ham + et al., 2023).

+

In particular, by combining PETSc, NETGEN, and NGSolve within + ngsPETSc the following new features are available:

+ + +

PETSc Krylov solvers, including flexible and pipelined + variants, are available in NGSolve. They can be used both with + NGSolve matrix-free operators and NGSolve block matrices;

+
+ +

PETSc preconditioners can be used as components within the + NGSolve preconditioning infrastructure;

+
+ +

PETSc nonlinear solvers are available in NGSolve, including + advanced line search and trust region Newton-based methods;

+
+ +

high order meshes constructed in NETGEN are now available in + Firedrake + (Ham + et al., 2023), enabling adaptive mesh refinement and + geometric multigrid on hierarchies of curved meshes.

+
+
+

In conclusion, ngsPETSc is a lightweight, user-friendly interface + that bridges the gap between NETGEN, NGSolve, and PETSc, building on + top of petsc4py. ngsPETsc aims to assist with the solution of + challenging PDEs on complex geometries, enriching the already powerful + capabilities of NETGEN, NGSolve, PETSc, and Firedrake.

+
+ + Examples +

In this section we provide a few examples of results that can be + obtained using ngsPETSc. We begin by considering a simple primal + Poisson problem on a unit square domain discretised with conforming + + + P2 + finite elements and compare the performance of different solvers newly + available in NGSolve via ngsPETSc. In particular, we consider PETSc’s + algebraic multigrid algorithm GAMG + (“Parallel + Multigrid Smoothing,” 2003), PETSc’s domain decomposition BDDC + algorithm + (Zampini, + 2016), NGSolve’s own implementation of element-wise BDDC, the + Hypre algebraic multigrid algorithm + (Falgout + & Yang, 2002) and the ML algebraic multigrid algorithm + (Sala et + al., 2004), each combined with the conjugate gradient method. + Other than the elementwise BDDC preconditioner, these preconditioners + were not previously available in NGSolve. The results are shown in + Table 1 and the full example, with more details, can be found in the + ngsPETSc + documentation. All the preconditioners considered exhibit + robust conjugate gradient iteration counts as we refine the mesh for a + + + P1 + discretisation, but out-of-the-box only BDDC type preconditioners are + robust as we refine the mesh for a + + P2 + discretisation. A possible remedy for this issue is discussed in the + ngsPETSc + documentation.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
# DoFsPETSc GAMGHYPREMLPETSc BDDC*Element-wise BDDC**
116716353631910
46485869746389
1855428142148127910
+
+

Table 1: The number of degrees of freedom (DoFs) and the number of + iterations required to solve the Poisson problem with different + solvers. Each row corresponds to a level of uniform refinement. The + conjugate gradient solve was terminated when the residual norm + decreased by six orders of magnitude. *We choose to use PETSc BDDC + with six subdomains. **Element-wise BDDC is a custom implementation of + BDDC in NGSolve.

+

We next consider the Oseen problem, i.e. + We discretise this problem using + high-order Hood-Taylor elements ( + + P4- + + P3) + on a unit square domain + (Boffi, + 1994; + Taylor + & Hood, 1973). We employ an augmented Lagrangian + formulation to better enforce the incompressibility constraint. We + present the performance of GMRES + (Saad + & Schultz, 1986) preconditioned with a two level additive + Schwarz preconditioner with vertex-patch smoothing as fine level + correction + (Benzi + & Olshanskii, 2006; + Farrell + et al., 2021). This preconditioner was built using ngsPETSc. + The result for different viscosities + + ν + are shown in Table 2, exhibiting reasonable robustness as the + viscosity (and hence Reynolds number) changes. The full example, with + more details, can be found in the + ngsPETSc + documentation.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
# refinements (# DoFs) + + ν=102 + + ν=103 + + ν=104
1 (83842)346
2 (334082)346
3 (1333762)346
+
+

Table 2: The number of iterations required to solve the Oseen + problem with different viscosities and different refinement levels. In + parentheses we report the number of degrees of freedom (DoFs) on the + finest level. The GMRES iteration was terminated when the residual + norm decreased by eight orders of magnitude.

+

Figure 1 shows a simulation of a hyperelastic beam, solved with + PETSc nonlinear solvers; the line search algorithms in PETSc solve + this straightforwardly, but an undamped Newton iteration does not + converge. Figures 2 and 3 show simulations in Firedrake that were not + previously possible. Figure 2 shows a high-order NETGEN mesh employed + for the simulation of a Navier-Stokes flow past a cylinder, while + Figure 3 shows adaptive mesh refinement for a Poisson problem on an + L-shaped domain. The adaptive procedure achieves the optimal + complexity of error with degree of freedom count, as expected + (Stevenson, + 2006).

+ +

A hyperelastic beam deformed by fixing one end and + applying a twist at the other end. The colouring corresponds to the + deviatoric von Mises stress experienced by the beam. The beam is + discretised with + + P3 + finite elements and the nonlinear problem is solved using PETSc + SNES. The full example, with more details, can be found in the + ngsPETSc + documentation.

+ +
+ +

Flow past a cylinder. The Navier-Stokes equations are + discretised on a NETGEN high-order mesh with Firedrake. We use + high-order Taylor-Hood elements ( + + P4- + + P3) + and a vertex-patch smoother as fine level correction in a two-level + additive Schwarz preconditioner, + (Benzi + & Olshanskii, 2006; + Farrell + et al., 2021). The full example, with more details, can be + found in + ngsPETSc + documentation. On the right a zoom near the cylinder + shows the curvature of the mesh.

+ +
+ +

An adaptive scheme applied to the Poisson problem on an + L-shaped domain. The domain is discretised using + + + P1 + finite elements and the adaptive mesh refinement is driven by a + Babuška-Rheinboldt error estimator + (Babuška + & Rheinboldt, 1978). The adaptive procedure delivers + optimal scaling of the energy norm of the error in terms of the + number of degrees of freedom. The full example, with more details, + can be found in the + ngsPETSc + documentation.

+ +
+

More examples can be found in the documentation of ngsPETSc manual + (Zerbinati, + 2024).

+
+ + Acknowledgement +

This work was funded by the Engineering and Physical Sciences + Research Council [grant numbers EP/R029423/1 and EP/W026163/1]. For + the purpose of open access, the author has applied a CC BY public + copyright licence to any Author Accepted Manuscript (AAM) version + arising from this submission.

+
+ + + + + + + + SchöberlJoachim + + NETGEN An advancing front 2D/3D-mesh generator based on abstract rules + Computing and visualization in science + Springer Science; Business Media LLC + 1997 + 1 + 1 + 10.1007/s007910050004 + 41 + 52 + + + + + + SchöberlJoachim + + C++ 11 implementation of finite elements in NGSolve + Institute for analysis and scientific computing, Vienna University of Technology + 2014 + 30 + + + + + + HamDavid A + KellyPaul HJ + MitchellLawrence + CotterColin J + KirbyRobert C + SagiyamaKoki + BouzianiNacime + VorderwuelbeckeSophia + GregoryThomas J + BetteridgeJack + others + + Firedrake user manual + Imperial College London and University of Oxford and Baylor University and University of Washington, + 202305 + 10.25561/104839 + + + + + + SiHang + + TetGen, a Delaunay-based quality tetrahedral mesh generator + ACM Trans. Math. Softw. + Association for Computing Machinery + New York, NY, USA + 201502 + 41 + 2 + 0098-3500 + https://doi.org/10.1145/2629697 + 10.1145/2629697 + + + + + + BalaySatish + AbhyankarShrirang + AdamsMark F. + BensonSteven + BrownJed + BrunePeter + BuschelmanKris + ConstantinescuEmil + DalcinLisandro + DenerAlp + EijkhoutVictor + FaibussowitschJacob + GroppWilliam D. + HaplaVáclav + IsaacTobin + JolivetPierre + KarpeevDmitry + KaushikDinesh + KnepleyMatthew G. + KongFande + KrugerScott + MayDave A. + McInnesLois Curfman + MillsRichard Tran + MitchellLawrence + MunsonTodd + RomanJose E. + RuppKarl + SananPatrick + SarichJason + SmithBarry F. + ZampiniStefano + ZhangHong + ZhangHong + ZhangJunchao + + PETSc/TAO users manual + Argonne National Laboratory + 2023 + 10.2172/2205494 + + + + + + DalcinLisandro D. + PazRodrigo R. + KlerPablo A. + CosimoAlejandro + + Parallel distributed computing using python + Advances in Water Resources + 2011 + 34 + 9 + 0309-1708 + 10.1016/j.advwatres.2011.04.013 + 1124 + 1139 + + + + + + ZerbinatiUmberto + + ngsPETSc user manual + Zenodo + 202407 + 10.5281/zenodo.12650574 + + + + + + ZampiniStefano + + PCBDDC: A class of robust dual-primal methods in PETSc + SIAM Journal on Scientific Computing + 2016 + 38 + 5 + 10.1137/15M1025785 + S282 + S306 + + + + + Parallel multigrid smoothing: Polynomial versus Gauss–Seidel + Journal of Computational Physics + 2003 + 188 + 2 + 0021-9991 + 10.1016/S0021-9991(03)00194-3 + 593 + 610 + + + + + + BenziMichele + OlshanskiiMaxim A. + + An augmented lagrangian–based approach to the oseen problem + SIAM Journal on Scientific Computing + 2006 + 28 + 6 + 10.1137/050646421 + 2095 + 2113 + + + + + + BabuškaI. + RheinboldtW. C. + + A-posteriori error estimates for the finite element method + International Journal for Numerical Methods in Engineering + 1978 + 12 + 10 + 10.1002/nme.1620121010 + 1597 + 1615 + + + + + + OpenCASCADE Technology + + OpenCASCADE + 2023 + https://www.opencascade.com/ + + + + + + FarrellPatrick E. + MitchellLawrence + ScottL. Ridgway + WechsungFlorian + + A Reynolds-robust preconditioner for the Scott-Vogelius discretization of the stationary incompressible Navier-Stokes equations + The SMAI Journal of computational mathematics + Société de Mathématiques Appliquées et Industrielles + 2021 + 7 + 10.5802/smai-jcm.72 + 75 + 96 + + + + + + SalaM. + HuJ. J. + TuminaroR. S. + + ML3.1 smoothed aggregation user’s guide + Sandia National Laboratories + Albuquerque, NM (USA) + 2004 + 10.2172/974895 + + + + + + BoffiD. + + Stability of higher order triangular Hood–Taylor methods for the stationary Stokes equations + Mathematical Models and Methods in Applied Sciences + 1994 + 04 + 02 + 10.1142/S0218202594000133 + 223 + 235 + + + + + + TaylorC. + HoodP. + + A numerical solution of the Navier–Stokes equations using the finite element technique + Computers & Fluids + 1973 + 1 + 1 + 0045-7930 + 10.1016/0045-7930(73)90027-3 + 73 + 100 + + + + + + FalgoutRobert D. + YangUlrike Meier + + Hypre: A library of high performance preconditioners + Computational science — ICCS 2002 + + SlootPeter M. A. + HoekstraAlfons G. + TanC. J. Kenneth + DongarraJack J. + + Springer Berlin Heidelberg + 2002 + 978-3-540-47789-1 + 10.1007/3-540-47789-6_66 + 632 + 641 + + + + + + SaadYousef + SchultzMartin H. + + GMRES: A generalized minimal residual algorithm for solving nonsymmetric linear systems + SIAM Journal on Scientific and Statistical Computing + 1986 + 7 + 3 + 10.1137/0907058 + 856 + 869 + + + + + + StevensonR. + + Optimality of a standard adaptive finite element method + Foundations of Computational Mathematics + 2006 + 7 + 2 + 10.1007/s10208-005-0183-0 + 245 + 269 + + + + + + HechtFrédéric + PironneauOlivier + Le HyaricA + OhtsukaK + + FreeFem++ manual + Laboratoire Jacques Louis Lions + 2005 + + + + + + DednerAndreas + KlöfkornRobert + NolteMartin + OhlbergerMario + + A generic interface for parallel and adaptive discretization schemes: Abstraction principles and the dune-fem module + Computing + 20101101 + 90 + 3 + 1436-5057 + https://doi.org/10.1007/s00607-010-0110-3 + 10.1007/s00607-010-0110-3 + 165 + 196 + + + + + + ArndtDaniel + BangerthWolfgang + BergbauerMaximilian + FederMarco + FehlingMarc + HeinzJohannes + HeisterTimo + HeltaiLuca + KronbichlerMartin + MaierMatthias + MunchPeter + PelteretJean-Paul + TurcksinBruno + WellsDavid + ZampiniStefano + + The deal.II library, version 9.5 + Journal of Numerical Mathematics + 2023 + 31 + 3 + https://dealii.org/deal95-preprint.pdf + 10.1515/jnma-2023-0089 + 231 + 246 + + + + + + BarattaIgor A. + DeanJoseph P. + DokkenJørgen S. + HaberaMichal + HaleJack S. + RichardsonChris N. + RognesMarie E. + ScroggsMatthew W. + SimeNathan + WellsGarth N. + + DOLFINx: The next generation FEniCS problem solving environment + Zenodo + 202312 + https://doi.org/10.5281/zenodo.10447666 + 10.5281/zenodo.10447666 + + + + + + GeuzaineChristophe + RemacleJean-François + + A three-dimensional finite element mesh generator with built-in pre-and post-processing facilities + International Journal for Numerical Methods in Engineering + 2020 + 11 + 79 + + + + + + + LangeMichael + KnepleyMatthew G. + GormanGerard J. + + Flexible, scalable mesh and data management using PETSc DMPlex + Proceedings of the 3rd international conference on exascale applications and software + University of Edinburgh + Great Britain + 2015 + 9780992661519 + 71 + 76 + + + + +