1 Introduction

Nonlocal models such as nonlocal diffusion and peridynamics provide a description of governing laws in terms of integral operators rather than classical differential operators [2,3,4,5,6,7,8]. They can describe phenomena not well represented by classical partial differential equations (PDEs), especially on problems characterized by long-range interactions and discontinuities [2, 9, 10]. As a result, applications of nonlocal models span a large spectrum of scientific and engineering problems, including subsurface transport [11,12,13,14,15], phase transitions [16,17,18], image processing [19,20,21,22], multiscale and homogenized systems [23,24,25,26,27,28,29], turbulence [30, 31], stochastic processes [32,33,34], and fracture mechanics [7, 35, 36].

In this work, we consider nonlocal models that are characterized by a general heterogeneous nonlocal operator of the form:

$$\begin{aligned} \mathcal {L}_{\delta }[u](\boldsymbol{x},t):=\int _{B_\delta (\boldsymbol{x})}K(\boldsymbol{x},\boldsymbol{y})(u(\boldsymbol{y},t)-u(\boldsymbol{x},t))d\boldsymbol{y}, \quad \text {with }K(\boldsymbol{x},\boldsymbol{y}):=\varpi (\boldsymbol{x},\boldsymbol{y})C(\boldsymbol{x},\boldsymbol{y})\gamma (\boldsymbol{x},\boldsymbol{y}). \end{aligned}$$

where u is the solution we seek, \(\gamma (\boldsymbol{x},\boldsymbol{y}):=\gamma _\delta ({\left| \boldsymbol{x}-\boldsymbol{y} \right| })\) is a (possibly singular) radial kernel which for fixed \(\boldsymbol{x}\) is supported on the ball of radius \(\delta\), \(B_\delta (\boldsymbol{x})\), and the two-point functions \(\varpi (\boldsymbol{x},\boldsymbol{y})\) and \(C(\boldsymbol{x},\boldsymbol{y})\) allow for the description of material heterogeneity while preserving the physical consistency. \(\delta\) defines the extent of nonlocal interactions, which is also referred to as a horizon. This integral form allows for the description of long-range interactions and reduces the regularity requirements on problem solutions, and hence enhances the accuracy of their modeling representations by generalizing the space of admissible solutions, which can feature discontinuities. Another important feature of such models is that when the classical continuum models still apply and with proper definitions of \(\varpi (\boldsymbol{x},\boldsymbol{y})\) and \(C(\boldsymbol{x},\boldsymbol{y})\), these nonlocal models can revert back to classical continuum models with heterogeneous material properties, as \(\delta \rightarrow 0\).

When discretizing the nonlocal models, it is desired to preserve the corresponding local limit under refinement grid size \(h \rightarrow 0\), since analyzing consistency in the limit to the local solution provides a mathematically unambiguous means to understand accuracy and physical compatibility. Such a property is termed asymptotically compatible (AC) [37].Footnote 1 In recent years, there has been significant work toward establishing such discretizations [37,38,39,40,41,42,43,44,45,46,47]. Broadly, strategies either involve adopting traditional finite element shape functions and carefully performing geometric calculations to integrate over relevant horizon/element subdomains, or adopt a strong-form meshfree discretization where particles are associated with abstract measure. The former is more amenable to mathematical analysis due to a better variational setting, while the latter is simple to implement and generally faster [48, 49].

In this paper we focus on the meshfree approach and approximate the heterogeneous nonlocal operator as:

$$\begin{aligned} \mathcal {L}_{\delta }[u](\boldsymbol{x}_i,t)\approx \mathcal {L}_{\delta ,h}[u](\boldsymbol{x}_i,t):=\sum _{{j\ne i}} K(\boldsymbol{x}_i,\boldsymbol{x}_j)(u(\boldsymbol{x}_j,t)-u(\boldsymbol{x}_i,t))\omega _{ij}, \end{aligned}$$

where the quadrature weights \(\omega _{ij}\) are associated with a local neighborhood of particles for each discretization point \(\boldsymbol{x}_i\), generated by local optimizations to make the approximation rule exact for certain classes of functions. By defining the averaged material property field \(K(\boldsymbol{x},\boldsymbol{y})\) as an analog of a series of two springs connecting the two points, our recent work [45, 50,51,52,53,54] has provided theoretical analysis and numerical verifications on the AC property on this optimization-based quadrature rule for heterogeneous materials [51, 52]. In this paper, we will provide an open-source meshfree solver and demonstrations of its convergence properties on various examples. To achieve a convergent simulation, the AC property to the local limit is only one important ingredient. Besides the consistency to the local limit, two additional features are desired in our nonlocal problem solver. Firstly, in peridynamics problems, one of its main appeals is to handle fracture problems, where free surfaces are associated with the evolution of a fracture surface. To achieve numerical consistency for problems involving fracture, one must also consider the interplay between consistency of quadrature for discrete operators and the imposition of traction loads as fracture surfaces open up and evolve [55]. Second, in applications such as the particle systems with long-range interactions, the horizon size \(\delta\) should be seen as a physical value and there is possibly no corresponding local limit. To preserve the physical consistency in such a scenario, the numerical convergence to the correct nonlocal limit when \(h\rightarrow 0\) would be desired in the nonlocal problem solver.

Our goal is to demonstrate a comprehensive treatment of nonlocal quadrature rule, material heterogeneity, and evolving free surfaces, which is able to achieve numerical consistency to both local and nonlocal limits and capture material fracture. In particular, when no fracture occurs and the analytical solution is sufficiently smooth, the formulation should preserve the AC limit under \(\delta\)-convergence and the consistency to the nonlocal limit as \(h\rightarrow 0\). Moreover, when fracture occurs, the formulation should be able to capture the material damage and the evolving fracture surfaces via bond breaking. This practically means that one is able to incorporate all of the necessary ingredients to perform non-trivial simulations of fracture mechanics while maintaining a scalable implementation and guaranteeing convergence. To achieve these properties, our development has two steps. First, to handle material heterogeneity and free surfaces in such a way that one preserves a limit to the relevant local problem, a unified mathematical formulation is introduced. Then, to preserving the AC limit under \(\delta\)-convergence and the consistency to the nonlocal limit as \(h\rightarrow 0\), an optimization-based quadrature rule is employed. As a result, our method provides an efficient discretization with rigorous underpinnings for a class of nonlocal models featuring material heterogeneity and evolving fractures.

We remark that the paper is organized to first establish the mathematical formulations and provide a brief summary of theoretical underpinnings of the approach, while the second half focuses on a user manual for the code [1] together with demonstrations on several exemplar applications. Practitioner with more applied interests may skip the first part without issue. The paper is organized as follows.

We firstly recall the heterogeneous nonlocal diffusion and bond-based peridynamics problems in Sect. 2, and provide a unified mathematical formulation for handling material heterogeneity and fracture. In Sect. 3, the optimization-based quadrature rule is elaborated as a unified numerical approach for heterogeneous nonlocal diffusion and bond-based peridynamics, together with the treatment of material fracture. We also provide a summary of the rigorous convergence analysis for the optimization-based quadrature rule, verifying its consistency to the local limit when \(h,\delta \rightarrow 0\), and to the nonlocal limit when \(h\rightarrow 0\). Then, in Sect. 4 the main structure of OBMeshfree code is shown and each code component is discussed in detail. In Sect. 5, we demonstrate four examples as verifications and validations of the code, including three problems with manufactured solutions and one example on reproducing high-velocity impact results from the Kalthoff-Winkler experiment as an engineering-oriented problem. Section 6 summarizes our results and discusses future research.

2 Nonlocal Theory

In this section, we introduce the notation and describe the nonlocal models that will be useful throughout the following sections.

Let \({\Omega }\in \mathbb {R}^d\), \(d=1,2,3\), be a bounded open domain. We are interested in solving for functions \(u:{\Omega }\rightarrow \mathbb {R}\) and \(\boldsymbol{u}:{\Omega }\rightarrow \mathbb {R}^d\), solutions of nonlocal diffusion and nonlocal mechanics problems, respectively. Herein, \(u(\boldsymbol{x})\) represents the concentration of a diffusive quantity in the nonlocal diffusion problem, and \(\boldsymbol{u}(\boldsymbol{x})\) represents the displacement field of an object in mechanics. In nonlocal settings, every point in a domain interacts with a neighborhood of points. In this work, we further assume that such neighborhood is an Euclidean ball surrounding points in the domain, i.e., \(B_\delta (\boldsymbol{x}):=\{\boldsymbol{y}\in \mathbb {R}^d:|\boldsymbol{y}-\boldsymbol{x}|\le \delta \}\), where \(\delta\) is the horizon. This assumption has implications on the concept of boundary conditions. In particular, unless otherwise stated, the boundary conditions should no longer be prescribed on the sharp interface, \(\partial {\Omega }\), but on a collar of thickness of at least \(\delta\) surrounding the domain \({\Omega }\), that we refer to as the nonlocal volumetric boundary domain (or simply nonlocal boundary),

$$\begin{aligned} \mathcal {B}\Omega :=\left\{ \boldsymbol{x}\notin {\Omega }|\text {dist}(\boldsymbol{x}, \partial {\Omega }) <\delta \right\} . \end{aligned}$$

This set consists of all points outside the domain that interact with points inside the domain. To define the nonlocal problems with general mixed boundary conditions, we further decompose the sharp interface \(\partial \Omega\) into two parts: \(\partial \Omega =\partial \Omega _D\bigcup \partial \Omega _N\), where \((\partial \Omega _D)^o\bigcap (\partial \Omega _N)^o=\emptyset\). To apply the nonlocal Dirichlet-type boundary condition, we assume that \(\boldsymbol{u}(\boldsymbol{x})=\boldsymbol{u}_D(\boldsymbol{x})\) are provided in a layer with non-zero volume outside \(\Omega\), while the free surface boundary condition is applied on the sharp interface \(\partial \Omega _N\). To define a Dirichlet-type constraint, we denote

$$\begin{aligned} \mathcal {B}\Omega _D:=\{\boldsymbol{x}\notin \Omega |\text {dist}(\boldsymbol{x},\partial \Omega _D)<\delta \},\, \end{aligned}$$

and assume that the value of \(\boldsymbol{u}\) is given on \(\mathcal {B}\Omega _D\). For notation simplicity, we denote \({\Omega }_D:={\Omega }\bigcup \mathcal {B}\Omega _D\).

In this paper and the code [1], we focus on 2D problems (\(d = 2\)) and provide demonstrations with both static and dynamic examples, although the method is also applicable to 3D problems.

2.1 Nonlocal Diffusion Models

Nonlocal diffusion models have been employed in many applications [30, 56], and they are capable to describe the underlying phenomena when the classical Fick’s first law or standard Brownian motion fails [57,58,59,60]. Specifically, given a loading field f, the time-dependent nonlocal diffusion equation can be given as:

$$\begin{aligned} \dfrac{\partial u}{\partial t}(\boldsymbol{x},t)-\mathcal {L}_{D\delta }[u](\boldsymbol{x},t) =f(\boldsymbol{x},t), \end{aligned}$$
(1)

where the diffusion operator on scalar function \(u:\mathbb {R}^d\rightarrow \mathbb {R}\) is defined as

$$\begin{aligned} \mathcal {L}_{D\delta }[u](\boldsymbol{x},t):=2\int _{B_\delta (\boldsymbol{x})}A(\boldsymbol{x},\boldsymbol{y})\gamma (\boldsymbol{x},\boldsymbol{y})(u(\boldsymbol{y},t)-u(\boldsymbol{x},t))d\boldsymbol{y}=f(\boldsymbol{x},t), \quad \boldsymbol{x}\in {\Omega }. \end{aligned}$$
(2)

Here, \(A(\boldsymbol{x},\boldsymbol{y})\in [r,R]\), \(r,R>0\), is a uniformly bounded and continuous two-point function, describing the heterogeneous diffusion property. \(\gamma\) denotes a properly scaled kernel function which is assumed to satisfy:

$$\begin{aligned} \gamma (\boldsymbol{x},\boldsymbol{y})=\gamma _\delta (|\boldsymbol{x}-\boldsymbol{y}|)=\frac{1}{\delta ^{d+2}}\gamma _1\left( \frac{|\boldsymbol{x}-\boldsymbol{y}|}{\delta }\right) =\frac{D_0}{\delta ^{d+2-s}|\boldsymbol{x}-\boldsymbol{y}|^s}, \end{aligned}$$
(3)

where \(\gamma _1\) is a nonnegative and nonincreasing function, s is the order of the kernel singularity in \(\gamma\), and there exists a positive constant \(\zeta <1\) satisfying \(B_\zeta (\mathbf{0})\subset \text {supp}(\gamma _1)\subset B_1(\boldsymbol{0})\) and \(\int _{B_1(\boldsymbol{0})}\gamma _1(|\textbf{z}|)|\textbf{z}|^2d\textbf{z}=d\). Then, (1) can be seen as a nonlocal analog to the local diffusion equation.Footnote 2 In particular, when taking the local diffusion parameter field \(a(\boldsymbol{x}):=A(\boldsymbol{x},\boldsymbol{x})\) and consistent Dirichlet-type boundary conditions, it was shown in [51] that (1) is well-posed and converges to the classical diffusion equation

$$\begin{aligned} \dfrac{\partial u}{\partial t}(\boldsymbol{x},t)-\mathcal {L}_{D}[u](\boldsymbol{x},t) =f(\boldsymbol{x},t),\quad \mathcal {L}_{D}[u](\boldsymbol{x},t):=\nabla \cdot (a(\boldsymbol{x})\nabla u(\boldsymbol{x},t)), \end{aligned}$$
(4)

as \(\delta \rightarrow 0\). Therefore, in examples where only the local diffusion coefficient field \(a(\boldsymbol{x})\) is provided, one can take the nonlocal diffusion coefficient as the harmonic mean of the local diffusion coefficient:

$$\begin{aligned} A(\boldsymbol{x},\boldsymbol{y})=2\left( \dfrac{1}{a(\boldsymbol{x})}+\dfrac{1}{a(\boldsymbol{y})}\right) ^{-1}. \end{aligned}$$
(5)

For further details, we refer interested readers to [51].

Here, we consider nonlocal diffusion problems with Dirichlet-type boundary conditions without loss of generality.Footnote 3 That means, \(\mathcal {B}\Omega =\mathcal {B}\Omega _D\) and a volume constraint \(u_D:\mathcal {B}\Omega \times [0,T]\rightarrow \mathbb {R}\) is provided. Then, the nonlocal counterpart of a Dirichlet boundary condition for PDEs is applied as a volume constraint: \(u(\boldsymbol{x},t)=u_D(\boldsymbol{x},t)\) for \((\boldsymbol{x},t)\in \mathcal {B}\Omega \times [0,T]\). Although in Sect. 5 we only provide numerical verification for the convergence of numerical solutions in static cases, sample codes for both static and time-dependent nonlocal diffusion problems are provided in [1].

2.2 Peridynamics Models

The peridynamic theory provides a nonlocal mechanics model, which has been applied for material failure and damage simulation [2, 7, 61,62,63,64] and provided robust modeling capabilities for analysis of complex crack propagation phenomena, such as crack branching [35, 54, 65, 66], bridging, deflection and trapping [52, 67].

Consider a body occupying the domain \({\Omega }\), the general peridynamic equation of motion for a point \(\boldsymbol{x}\in {\Omega }\) and time \(t\in [0,T]\) is

$$\begin{aligned} \rho \dfrac{\partial ^2\boldsymbol{u}}{\partial t^2}(\boldsymbol{x},t)-\mathcal {L}_{P\delta }[\boldsymbol{u}](\boldsymbol{x},t)=\boldsymbol{f}(\boldsymbol{x},t), \end{aligned}$$

where \(\mathcal {L}_{P\delta }\) is a nonlocal operator representing the peridynamic internal force density, \(\rho\) is the mass density, and \(\boldsymbol{f}\) is a prescribed body force density. As for the nonlocal diffusion problems, the nonlocal interactions in \(\mathcal {L}_{P\delta }\) are also restricted to the nonlocal neighborhood, \(B_\delta (\boldsymbol{x})\), characterized by the horizon size \(\delta\). In this work, we focus on the bond-based peridynamic solid model [2, 45, 68], and take the peridynamics operator as:

$$\begin{aligned} \begin{aligned} \mathcal {L}_{P\delta }[\boldsymbol{u}](\boldsymbol{x},t):=&\,c\int _{B_\delta (\boldsymbol{x})} \kappa (\boldsymbol{x},\boldsymbol{y}) \gamma (\left| \boldsymbol{y}-\boldsymbol{x}\right| )\frac{\left( \boldsymbol{y}-\boldsymbol{x}\right) \otimes \left( \boldsymbol{y}-\boldsymbol{x}\right) }{\left| \boldsymbol{y}-\boldsymbol{x}\right| ^2} \left( \boldsymbol{u}(\boldsymbol{y},t) - \boldsymbol{u}(\boldsymbol{x},t) \right) d\boldsymbol{y}. \end{aligned} \end{aligned}$$
(6)

Here, \(\gamma\) is the kernel function as defined in (3), and the two-point functions \(\kappa (\boldsymbol{x},\boldsymbol{y})\) denote the (averaged) bulk modulus property.Footnote 4. To recover parameters for linear elasticity when the nonlocal effects vanish, one should take \(c=24/5\) for \(d=2\), and \(c=6\) for \(d=3\) (see, e.g., [4, 45] for further details). Similar as in the nonlocal diffusion problems, in examples where only the local bulk modulus coefficient field \(\kappa (\boldsymbol{x})\) is provided, we take the nonlocal bulk modulus coefficient as the harmonic mean of the local coefficient [67, 69, 70]:

$$\begin{aligned} \kappa (\boldsymbol{x},\boldsymbol{y})=2\left( \dfrac{1}{\kappa (\boldsymbol{x})}+\dfrac{1}{\kappa (\boldsymbol{y})}\right) ^{-1}. \end{aligned}$$
(7)

One of the main features of peridynamics is to handle fracture problems, where damage is incorporated into the peridynamic constitutive model by allowing the bonds of solid interactions to break irreversibly. Here we employ the critical stretch criterion where breakage occurs when a bond is extended beyond some predetermined critical bond deformed length [54, 71]. Then, this criterion is implemented by multiplying the pairwise force function with a history-dependent scalar Boolean function. In particular, to model brittle fracture, we break the bond between two material points, \(\boldsymbol{x}\) and \(\boldsymbol{y}\), when the associated strain exceeds a critical strain threshold. A two-point Boolean state function \(\theta (\boldsymbol{x},\boldsymbol{y},t)\) is defined and updated to describe the bond breakage through the crack growing

$$\begin{aligned} \theta (\boldsymbol{x},\boldsymbol{y},t)&= {\left\{ \begin{array}{ll} 1, \quad \text {if }{S}(\boldsymbol{x},\boldsymbol{y},\tau )\le {S}_0(\boldsymbol{x},\boldsymbol{y}),\;\forall \tau \le t, \text { and }\boldsymbol{y}\in B_\delta (\boldsymbol{x})\bigcap \Omega _D,\\ 0, \quad \text {otherwise}, \\ \end{array}\right. } \end{aligned}$$
(8)

where the associated strain S and the critical bond stretch \({S}_0\) related to material parameters are defined as [71]:

$$\begin{aligned} \begin{array}{l} {S}(\boldsymbol{x},\boldsymbol{y},t): = \frac{||\boldsymbol{u}(\boldsymbol{y},t)-\boldsymbol{u}(\boldsymbol{x},t) + \boldsymbol{y}-\boldsymbol{x}||-||\boldsymbol{y}- \boldsymbol{x}||}{||\boldsymbol{y}- \boldsymbol{x}||},\\ {S}_0(\boldsymbol{x},\boldsymbol{y}):= {\left\{ \begin{array}{ll} \sqrt{\frac{\pi G(\boldsymbol{x},\boldsymbol{y})}{3\kappa (\boldsymbol{x},\boldsymbol{y})\delta }}, \quad \text {2D},\\ \sqrt{\frac{5G(\boldsymbol{x},\boldsymbol{y})}{9\kappa (\boldsymbol{x},\boldsymbol{y})\delta }}, \quad \text {3D}, \\ \end{array}\right. } \end{array} \end{aligned}$$
(9)

where \(\kappa\) is the nonlocal bulk modulus coefficient.

In (9) \(G(\boldsymbol{x},\boldsymbol{y})\) is the averaged fracture energy defined via the arithmetic mean:

$$\begin{aligned} G(\boldsymbol{x},\boldsymbol{y})= \frac{1}{2}(G(\boldsymbol{x})+G(\boldsymbol{y})). \end{aligned}$$
(10)

Here, the averaged material properties definition in (7) and the averaged fracture energy definition in (10) are inspired by seeing the interaction between \(\boldsymbol{x}\) and \(\boldsymbol{y}\) as an analog of a series of two springs connecting the two points. Following a similar argument as in [52], one can show that when no fracture occurs and the local modulus field satisfies \(\kappa \in C(\overline{{\Omega }\bigcup \mathcal {B}\Omega })\), it is guaranteed that the nonlocal solution of (6) converges to the solution of a linear elastic model as \(\delta \rightarrow 0\), hence it preserves the correct local limit.

In summary, with proper initial conditions and Dirichlet-type boundary condition in \(\mathcal {B}\Omega _D\), we obtain a unified mathematical formulation for dynamic bond-based peridynamics for \(\boldsymbol{x}\in {\Omega }\):

$$\begin{aligned} \rho \dfrac{\partial ^2\boldsymbol{u}}{\partial t^2}(\boldsymbol{x},t) - c\int _{B_\delta (\boldsymbol{x})} \theta (\boldsymbol{x},\boldsymbol{y},t)\kappa (\boldsymbol{x},\boldsymbol{y}) \gamma (\left| \boldsymbol{y}-\boldsymbol{x}\right| )\frac{\left( \boldsymbol{y}-\boldsymbol{x}\right) \otimes \left( \boldsymbol{y}-\boldsymbol{x}\right) }{\left| \boldsymbol{y}-\boldsymbol{x}\right| ^2} \left( \boldsymbol{u}(\boldsymbol{y},t) - \boldsymbol{u}(\boldsymbol{x},t) \right) d\boldsymbol{y}= \boldsymbol{f}(\boldsymbol{x},t). \end{aligned}$$
(11)

This formulation naturally handles both material heterogeneity and evolving fracture as the free surface boundary conditions on \(\partial {\Omega }_N\). For further discussions on the free surface boundary conditions and more general Neumann-type boundary conditions in peridynamics, we refer interested readers to [52, 54].

3 Optimization-Based Quadrature Rules

In this section, we elaborate the strong-form particle discretization of the nonlocal diffusion and peridynamics models introduced above. To obtain a unified formulation for both models, we rewrite (2) and (6) as a general heterogeneous nonlocal operator of the form:

$$\begin{aligned} \mathcal {L}_{\delta }[u](\varvec{x},t):=\int _{B_\delta (\varvec{x})}K(\varvec{x},\varvec{y})(u(\varvec{y},t)-u(\varvec{x},t))d\varvec{y}, \quad \text {with }K(\varvec{x},\varvec{y}):=\varpi (\varvec{x},\varvec{y})C(\varvec{x},\varvec{y})\gamma (\varvec{x},\varvec{y}). \end{aligned}$$
(12)

Here, \(\gamma\) is the nonlocal kernel satisfying (3), \(\varpi (\varvec{x},\varvec{y})\) is a general two-point function corresponding to the (heterogeneous) material properties, and \(C(\varvec{x},\varvec{y})\) corresponds to a two-point (tensor) function which is designed to guarantee the consistency to the desired local limit. In nonlocal diffusion problems, we have \(\varpi (\varvec{x},\varvec{y}):=A(\varvec{x},\varvec{y})\) and \(C(\varvec{x},\varvec{y}):=2\), which corresponds to the diffusion property. In bond-based peridynamics, \(\varpi (\varvec{x},\varvec{y}):=\kappa (\varvec{x},\varvec{y})\) and \(C(\varvec{x},\varvec{y}):=c\dfrac{(\varvec{y}-\varvec{x})\otimes (\varvec{y}-\varvec{x})}{{\left| \varvec{y}-\varvec{x} \right| }^2}\), characterizing the average material properties and bond strengths between material points \(\varvec{x}\) and \(\varvec{y}\).

Denoting \(u_{\delta }\) and \(u_0\) as the nonlocal and local analytical solution respectively, and \(u_{\delta ,h}\) as the numerical solution, in OBMeshfree we focus on two types of convergence:

$$\begin{aligned} \underset{h\rightarrow 0}{\lim }{\left| \left| u_{\delta ,h}-u_\delta \right| \right| }_{L^2({\Omega })}=0,\quad \text { and }\quad \underset{h,\delta \rightarrow 0}{\lim }{\left| \left| u_{\delta ,h}-u_0 \right| \right| }_{L^2({\Omega })}=0. \end{aligned}$$
(13)

The first type of convergence indicates that the numerical discretization method is consistent with the nonlocal problem, while the second type shows that the nonlocal numerical solution preserves the correct local limit, or equivalently, the numerical scheme is asymptotically compatible. To maintain an easily scalable implementation, in asymptotic compatibility studies we assume \(\delta\) to be chosen such that the ratio \(\frac{\delta }{h}\) is bound by a constant as \(\delta \rightarrow 0\), restricting ourselves to the “\(\delta\)-convergence” scenario [72]. In the following sections, we will first introduce the spatial and temporal discretization methods for nonlocal diffusion and peridynamics problems with full Dirichlet-type boundary conditions. Then, we incorporate the bond breaking mechanism and the free surface formulation, to provide a fully discretized framework for bond-based peridynamics including the damage criteria and the handling of free surfaces created by evolving fracture.

3.1 Spatial Discretization

Assume that the whole interaction domain, \({\Omega }_D\), is discretized into a collection of points

$$\begin{aligned} \chi _{h} = \{\varvec{x}_i\}_{i=1}^M \subset \Omega \bigcup \mathcal {B}\Omega , \end{aligned}$$

we seek for numerical solutions such that \(u_i\approx u(\varvec{x}_i)\). Recall the definitions [73] of fill distance \(h_{\chi _h,\Omega } = \underset{\varvec{x}_i \in \Omega \bigcup {\mathcal {B}\Omega }}{\sup }\; \underset{{\varvec{x}_j \in \chi _h\backslash \{\varvec{x}_i\}}}{\min }||\varvec{x}_i - \varvec{x}_j||_2\) and separation distance \({q_{\chi _h} = \frac{1}{2} \underset{i \ne j}{\min } ||\varvec{x}_i - \varvec{x}_j||_2}\), for simplicity we drop subscripts and simply write h and q. In this work, we assume that \(\chi _h\) is quasi-uniform, namely that there exists a constant \(C_{q} > 0\), such that \(q \le h \le C_q q\).

Then, we seek to generate consistent meshfree quadrature rules of the form

$$\begin{aligned} \mathcal {L}_{\delta }[u](\varvec{x}_i,t)\approx \mathcal {L}_{\delta ,h}[u](\varvec{x}_i,t):=\sum _{{j\ne i}} K(\varvec{x}_i,\varvec{x}_j)(u(\varvec{x}_j,t)-u(\varvec{x}_i,t))\omega _{ij}. \end{aligned}$$
(14)

Here, \(\{\omega _{ij}\}_{\varvec{x}_j \in B_\delta (\varvec{x}_i)}\) is a collection of to-be-determined quadrature weights corresponding to a neighborhood of collocation point \(\varvec{x}_i\), which will be constructed through an optimization-based approach to ensure consistency guarantees. Specifically, we seek quadrature weights for integrals supported on balls of the form

$$\begin{aligned} I[q] := \int _{B_\delta (\varvec{x}_i)} q(\varvec{x}_i,\varvec{y}) d\varvec{y}\approx I_h[q] := \sum _{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\backslash \{\varvec{x}_i\}} q(\varvec{x}_i,\varvec{x}_j)\omega _{ij}, \end{aligned}$$
(15)

where the subscript i in \(\left\{ \omega _{ij}\right\}\) denote that we seek a different family of quadrature weights for different subdomains \(B_\delta (\varvec{x}_i)\). These weights are then generated from the following optimization problem

$$\begin{aligned} \underset{\left\{ \omega _{ij}\right\} }{\text {min}} \sum _{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\backslash \{\varvec{x}_i\}} \omega _{ij}^2\gamma _\delta (\varvec{x}_i,\varvec{x}_j) \quad \text {such that}, \quad I_h[q] = I[q] \quad \forall q \in \varvec{V}_{h,\varvec{x}_i}, \end{aligned}$$
(16)

where \(\varvec{V}_{h,\varvec{x}_i}=\left\{ q(\varvec{y}-\varvec{x}_i)=p(\varvec{y}-\varvec{x}_i)\gamma _\delta (\varvec{x}_i,\varvec{y})C(\varvec{x}_i,\varvec{y})\Big |p\in \mathbb {P}_n(\mathbb {R}^d) \right. \; \text{such that} \; \left. \int _{B_\delta (\varvec{x}_i)}q(\varvec{y}-\varvec{x}_i)d\varvec{y}<\infty \right\},\) denotes the space of functions which should be integrated exactly. \(\mathbb {P}_n(\mathbb {R}^d)\) is the space of n-th order polynomials, and \(C(\varvec{x},\varvec{y})\) is given as in (12).

For each material point \(\varvec{x}_i\in {\Omega }\bigcap \chi _h\), we denote the total number of to-be-determined quadrature weights \(\omega _{ij}\) as \(M_i\). To solve for the optimization problem (16), we formulate it as a saddle point problem

$$\begin{aligned} \begin{bmatrix} \varvec{W} &{} \varvec{B}^\intercal \\ \varvec{B} &{} \mathbf{0} \end{bmatrix} \begin{bmatrix} \boldsymbol{\omega } \\ \boldsymbol{\lambda } \end{bmatrix} = \begin{bmatrix} \mathbf{0} \\ \varvec{g} \end{bmatrix}, \end{aligned}$$
(17)

where \(\varvec{W}\in \mathbb {R}^{M_i\times M_i}\) is a diagonal matrix with the diagonal element determined by \(\varvec{W}_{j,j}=2\gamma _\delta (\varvec{x}_i,\varvec{x}_j)\), \(\boldsymbol{\omega } \in \mathbb {R}^{M_i}\) are the vector of quadrature weights \(\omega _{ij}\), and \(\boldsymbol{\lambda }\in \mathbb {R}^{\text {dim}(V_{h,\varvec{x}_i})}\) are a set of Lagrange multipliers. \(\varvec{B}\in \mathbb {R}^{M_i\times \text {dim}(V_{h,\varvec{x}_i})}\) consists of the reproducing function evaluated at the quadrature points, satisfying \(\varvec{B}_{\alpha ,j}=q_{\alpha }(\varvec{x}_j-\varvec{x}_i)\), for \(q_{\alpha }\in \varvec{V}_{h,\varvec{x}_i}\) and \(\varvec{x}_j\in \chi _h\bigcap B_\delta (\varvec{x}_i)\backslash \{\varvec{x}_i\}\). \(\varvec{g}\in \mathbb {R}^{\text {dim}(V_{h,\varvec{x}_i})}\) consists of the integral of the reproducing functions over the ball, satisfying \(\varvec{g}_\alpha =I[q_\alpha ]\). By eliminating the constraints, the quadrature weights can be obtained by solving

$$\begin{aligned} \boldsymbol{\omega } = \varvec{W}^{-1}\varvec{B}^\intercal (\varvec{B}\varvec{W}^{-1}\varvec{B}^\intercal )^{-1}\varvec{g}. \end{aligned}$$
(18)

We note that the application of this quadrature does not require a background grid and is therefore truly meshfree. Moreover, the quadrature weights only need to be obtained once, using a list of neighbors lying within \(B_\delta (\varvec{x})\). In fact, in OBMeshfree weights are obtained as a preprocessing step, by solving a small local optimization problem requiring only the inversion of a small linear system in (18) for each \(\varvec{x}_i\).

Substituting the quadrature rule (14), the nonlocal diffusion operator \(\mathcal {L}_{D\delta }\) and the bond-based peridynamics operator \(\mathcal {L}_{P\delta }\) can be respectively discretized as:

$$\begin{aligned} (\mathcal {L}_{D\delta ,h} u)_i:=2\sum _{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\backslash \{\varvec{x}_i\}}A(\varvec{x}_i,\varvec{x}_j)\gamma _\delta (|\varvec{x}_i-\varvec{x}_j|)(u_i-u_j)\omega _{ij}, \end{aligned}$$
(19)
$$\begin{aligned} (\mathcal {L}_{P\delta ,h} \varvec{u})_i :=c\sum _{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\backslash \{\varvec{x}_i\}} \kappa (\varvec{x}_i,\varvec{x}_j) \gamma _\delta (|\varvec{x}_i-\varvec{x}_j|)\frac{\left( \varvec{x}_j-\varvec{x}_i\right) \otimes \left( \varvec{x}_j-\varvec{x}_i\right) }{\left| \varvec{x}_j-\varvec{x}_i\right| ^2} \left( \varvec{u}_i - \varvec{u}_j \right) \omega _{ij}. \end{aligned}$$
(20)

As verified in [45, 51,52,53], the above quadrature rule is able to obtain a compatible discretization that achieves both the consistency with the nonlocal analytical solution and the asymptotic compatibility to the local limit. In the following, we briefly list the theoretical analysis results provided in [45, 51]. For analysis, we denote

$$\begin{aligned} K(\varvec{x},\varvec{y})=\dfrac{N(\varvec{x},\varvec{y})}{\delta ^{d+2-s}|\varvec{x}-\varvec{y}|^s}, \end{aligned}$$
(21)

where the numerator satisfies \(N(\varvec{x},\varvec{y})\le C_N\) for all \(\varvec{y}\in B_\delta (\varvec{x})\).

For the asymptotic compatibility to the local limit, as shown in [45], the optimization-based quadrature rule has the following truncation error estimates:

Theorem 1 (Truncation Estimates with Fixed \(h/\delta\))

Consider a fixed ratio \(h/\delta\) and assume that both \(N(\varvec{x},\varvec{y})\) and \(u(\varvec{x})\) are sufficiently smooth, i.e., \(N(\varvec{x},\varvec{y})\in C^{n+2}(\overline{({\Omega }_D)^2})\) and \(u(\varvec{x})\in C^{n+2}(\overline{{\Omega }_D})\). For any \(\varvec{x}_i\in \chi _h\bigcap {\Omega }\), the quadrature weights obtained from (16) with \(n>d+s-3\) would satisfy the following pointwise error estimate, with a constant \(C>0\) independent of \(\delta\) and \(\varvec{x}_i\):

$$\begin{aligned} \left| \int _{B_\delta (\varvec{x}_i)} K(\varvec{x}_i,\varvec{y})u(\varvec{y})d\varvec{y}-\sum _{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\backslash \{\varvec{x}_i\}} K_{ij}u_j \omega _{ij}\right| <C\delta ^{n-1}. \end{aligned}$$

For the convergence to the nonlocal analytical solution, following [51], we further require that \(s<d\). Moreover, \(\chi _h\) is assumed to be a uniform Cartesian grid:

$$\begin{aligned} \chi _h:=\{(k_{(1)}h,\cdots ,k_{(d)}h)|\varvec{k}=(k_{(i)},\cdots ,k_{(d)})\in \mathbb {Z}^d\}\bigcap {\Omega }_D, \end{aligned}$$

where h is the spatial grid size. Then, the optimization-based quadrature rule has the following truncation error estimates with fixed \(\delta\) and vanishing h:

Theorem 2 (Truncation Estimates with Fixed \(\delta\))

Consider a fixed \(\delta\) and assume that both \(N(\varvec{x},\varvec{y})\) and \(u(\varvec{x})\) are sufficiently smooth, satisfying \(N(\varvec{x},\varvec{y})\in C^{4}(\overline{({\Omega }_D)^2})\) and \(u(\varvec{x})\in C^{1}(\overline{{\Omega }_D})\). Then there exists a constant \(C_{pos}<1\), such that for \(h<C_{pos}\delta\), the quadrature weights obtained from (16) with \(n=3\) would satisfy the following pointwise error estimate, with the generic constant \(C>0\) independent of h but may dependent on \(\delta\):

$$\begin{aligned} \left| \int _{B_\delta (\varvec{x}_i)} K(\varvec{x}_i,\varvec{y})u(\varvec{y})d\varvec{y}-\sum _{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\backslash \{\varvec{x}_i\}} K_{ij}u_j \omega _{ij}\right| <Ch^{\text {min}(1,d-s)}. \end{aligned}$$

With the above truncation error estimates, the following convergence properties can be proved for static nonlocal diffusion problems, with detailed proof can be found in [51]:

Theorem 3 (Asymptotic Compatibility to the Analytical Local Diffusion Problems)

Consider uniform Cartesian grids and \(s<d\). Assume that \(A(\varvec{x},\varvec{y})\in C^{4}(\overline{({\Omega }_D)^2})\), \(a(\varvec{x})\in C^{\infty }({\Omega })\), \({\Omega }_D\in C^1\), and the analytical local diffusion solution \(u_0\in C^4({\overline{{\Omega }_D}})\). When applying the boundary condition \(u_D(\varvec{x}_i)=u_0(\varvec{x}_i)\) for \(\varvec{x}_i\in \chi _h\bigcap \mathcal {B}\Omega _D\), there exists a \(\delta _0>0\) and \(C_{pos}<1\), such that for any \(0<\delta <\delta _0\) and fixed ratio \(h/\delta <C_{pos}\), the meshfree quadrature rule with \(n=3\) is asymptotically compatible for nonlocal diffusion problems, i.e.,

$$\begin{aligned} {\left| \left| u_{\delta ,h}-u_0 \right| \right| }_{L^\infty (\chi _h)}\le C\delta ^2, \end{aligned}$$
(22)

where C is a generic constant independent of \(\delta\) and h.

Theorem 4 (Convergence to the Analytical Nonlocal Diffusion Solution)

Consider uniform Cartesian grids and \(s<d\). Assume that \(A(\varvec{x},\varvec{y})\in C^{4}(\overline{({\Omega }_D)^2})\), the analytical nonlocal diffusion solution \(u_\delta (\varvec{x}) \in C^1(\overline{{\Omega }_D})\), \(a(\varvec{x})\in C^{\infty }({\Omega })\) and \({\Omega }_D\in C^1\), then there exists a \(\delta _0>0\) and \(C_{pos}<1\), such that for a fixed \(\delta\) satisfying \(0<\delta <\delta _0\) and \(h<C_{pos}\delta\), the following convergence property holds for the meshfree quadrature rule with \(n=3\):

$$\begin{aligned} {\left| \left| u_{\delta ,h}-u_\delta \right| \right| }_{L^\infty (\chi _h)}\le C h^{\min (1,d-s)}, \end{aligned}$$
(23)

where C is a generic constant independent of h but may depends on \(\delta\).

3.2 Temporal Discretization

In this section we introduce the discretization methods in time, and demonstrate the fully discretized methods for nonlocal diffusion and peridynamics problems with Dirichlet-type boundary conditions. Although in the demonstrating examples of Sect. 5 we mostly focus on static nonlocal problems (except the validation problem of the Kalthoff-Winkler experiment), the options and codes of dynamic problems are implemented in OBMeshfree, which can be readily used following the instruction provided in Sect. 4.

For the dynamic nonlocal diffusion model (4), the backward Euler method is employed. With time step size \(\Delta t\) and the approximated solution at the m-th time step, \(u_i^{m}\), the solution at the \(m+1\)-th time step is solved via:

$$\begin{aligned} \left\{ \begin{array}{ll} \frac{\rho }{\Delta t} u_{i}^{m+1} - (\mathcal {L}_{D\delta ,h} u)_i^{m+1} = \varvec{f}(\varvec{x}_i,(m+1)\Delta t) + \frac{\rho }{\Delta t}u_{i}^m, &{} \quad \text {for }\varvec{x}_i \text { in }\Omega \bigcap \chi _h,\\ u_i^{m+1}=u_D(\varvec{x}_i,(m+1)\Delta t), &{} \quad \text {for }\varvec{x}_i \text { in }\mathcal {B}\Omega _D\bigcap \chi _h,\\ u_i^0=\phi (\varvec{x}_i), &{}\quad \text {for }\varvec{x}_i \in {\Omega }_D\bigcap \chi _h,\\ \end{array}\right. \end{aligned}$$
(24)

where \(\mathcal {L}_{D\delta ,h}\) is the discrete nonlocal diffusion operator as defined in (19), \(u_D(\varvec{x}_i)\) is the prescribed Dirichlet boundary condition, and \(\phi\) is the initial value.

For the dynamic peridynamics model, to discretize in time we also apply the backward time stepping scheme. With time step size \(\Delta t\), at the \((m+1)-\)th time step we solve for the displacement \(\varvec{u}_i^{m+1}\approx \varvec{u}(\varvec{x}_i,(m+1)\Delta t)\) following:

$$\begin{aligned} \left\{ \begin{array}{ll} \frac{\rho }{\Delta t^2} \varvec{u}_{i}^{m+1} - (\mathcal {L}_{P\delta ,h} \varvec{u})_i^{m+1} = \varvec{f}(\varvec{x}_i,(m+1)\Delta t) + \frac{\rho }{\Delta t^2}(2\varvec{u}_{i}^m - \varvec{u}_i^{m-1}), &{} \quad \text {for }\varvec{x}_i \text { in }\Omega \bigcap \chi _h,\\ \varvec{u}_i^{m+1}=\varvec{u}_D(\varvec{x}_i,(m+1)\Delta t), &{} \quad \text {for }\varvec{x}_i \text { in }\mathcal {B}\Omega _D\bigcap \chi _h,\\ \varvec{u}_i^0={\boldsymbol{\phi }}(\varvec{x}_i),\;\varvec{u}_i^1={\boldsymbol{\psi }}(\varvec{x}_i), &{}\quad \text {for }\varvec{x}_i \in {\Omega }_D\bigcap \chi _h,\\ \end{array}\right. \end{aligned}$$
(25)

where \(\mathcal {L}_{P\delta ,h}\) is the discretized nonlocal operator as defined in (20), \(\varvec{u}_D\) is the given Dirichlet-type boundary condition, and \({\boldsymbol{\phi }}\), \({\boldsymbol{\psi }}\) are the initial displacement field at the first two time steps.

3.3 Peridynamics with Free Surfaces and Evolving Fracture

In this section we extend OBMeshfree, to handle peridynamics models with free surfaces and fracture. For a given point \(\varvec{x}_i\) and the horizon \(\delta\), a bond is associated with each neighbor point \(\varvec{x}_j\in B_{\delta }(\varvec{x}_i)\), and the weight \(\omega _{ij}\) is associated with this bond. In the meshfree formulation, the fracture is captured by evolving free surfaces implicitly via the breaking of bonds. When fracture occurs, it creates new surfaces when the free surface boundary conditions are applied. These new free surfaces will also be added into the set of Neumann-type boundary, \(\partial {\Omega }_N\). That means, \(\partial {\Omega }_N\) evolves with fracture. Instead of parameterizing the \(\partial {\Omega }_N\) and evolve its formulation with time, in OBMeshfree the boundary \(\partial {\Omega }_N\) is naturally represented by breaking bonds. In particular, when the change of displacement on material point \(\varvec{x}_j\) may have an impact on the displacement at \(\varvec{x}_i\), we call their bond as “intact”, and set the corresponding state function value \(\theta (\varvec{x}_i,\varvec{x}_j,t)\) as 1. On the other hand, when the bond between \(\varvec{x}_i\) and \(\varvec{x}_j\) intersects the surface \(\partial {\Omega }_N\), and/or the bond stretch \({S}(\varvec{x}_i,\varvec{x}_j,\tau )\) has exceeded the critical bond stretch threshold \({S}_0(\varvec{x},\varvec{y})\) at some time instant \(\tau <t\), the bond is considered “broken” and we set \(\theta (\varvec{x}_i,\varvec{x}_j,t)\) as 0. In particular, at the m-th time step we set:

$$\begin{aligned} \theta ^{m}_{ij} = {\left\{ \begin{array}{ll} 1, \quad \text {if }\varvec{x}_j\in B_\delta (\varvec{x}_i)\bigcap \Omega _D \text { and }{S}(\varvec{x}_i,\varvec{x}_i,l\Delta t)\le {S}_0(\varvec{x}_i,\varvec{x}_j),\;\forall l=1,\cdots ,m,\\ 0, \quad \text {otherwise}, \\ \end{array}\right. } \end{aligned}$$
(26)

Applying the above formulation in (11), at the m-th dynamic step, we seek for solutions of the displacement \(u^m_{i}\approx \varvec{u}(\varvec{x}_i,m\Delta t)\) through the following meshfree scheme:

$$\begin{aligned} \begin{aligned} \frac{\rho }{\Delta t^2} \varvec{u}_{i}^{m+1}&- c\sum _{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\backslash \{\varvec{x}_i\}} \kappa (\varvec{x}_i,\varvec{x}_j) \gamma _\delta (|\varvec{x}_i-\varvec{x}_j|)\frac{\left( \varvec{x}_j-\varvec{x}_i\right) \otimes \left( \varvec{x}_j-\varvec{x}_i\right) }{\left| \varvec{x}_j-\varvec{x}_i\right| ^2} \left( \varvec{u}^{m+1}_i - \varvec{u}^{m+1}_j \right) \theta ^{m}_{ij}\omega _{ij}\\&=\varvec{f}(\varvec{x}_i,(m+1)\Delta t) + \frac{\rho }{\Delta t^2}(2\varvec{u}_{i}^m - \varvec{u}_i^{m-1}), \quad \text {for }\varvec{x}_i \text { in }\Omega \bigcap \chi _h, \end{aligned} \end{aligned}$$
(27)
$$\begin{aligned} \varvec{u}_i^{m+1}=\varvec{u}_D(\varvec{x}_i,(m+1)\Delta t), \quad \text {for }\varvec{x}_i \text { in }\mathcal {B}\Omega _D\bigcap \chi _h, \end{aligned}$$
(28)
$$\begin{aligned} \varvec{u}_i^0={\boldsymbol{\phi }}(\varvec{x}_i),\;\varvec{u}_i^1={\boldsymbol{\psi }}(\varvec{x}_i), \quad \text { for }\varvec{x}_i \in {\Omega }_D\bigcap \chi _h. \end{aligned}$$
(29)

Note that because the evolving fracture creates new free surfaces, so \(\partial {\Omega }_N\) and \(\theta\) alter with \(u^{m+1}\). In our implementation, we have been using the damage index, \(\theta ^{m}_{ij}\), from the last time step, and the above algorithm can therefore be seen as a semi-implicit time integration approach. However, we point out the users can also implement a fully implicit approach by employing subiterations at each time step following [54], to capture the implicit coupling between the material response and the evolving geometry due to fracture evolution. First one can assume that no new bonds have been broken at the current time step and solve for the displacement field. Second, based on the displacement field, the damage criteria is evaluated and \(\theta ^{m+1}_{ij}\) is updated following (26) for each bond. If any bond meets the criteria of breaking, the displacement field will be solved again with new free surfaces. In [54], we repeat this procedure until no new broken bonds are detected, and finally proceed to the next time step.

Finally, the solution \(\varvec{u}_i^{m+1}\) and the bond state function \(\theta ^{m+1}_{ij}\) are obtained at time step \(m+1\), we postprocess fracture evolution and identify cracks, by calculating the damage field \(d_{i}^{m+1}\approx d(\varvec{x}_i,(m+1)\Delta t)\) as

$$\begin{aligned} {d_{i}^{m+1}}=\dfrac{\underset{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\setminus \varvec{x}_i}{\sum }(1-\theta ^{m+1}_{ij})}{\underset{\varvec{x}_j \in \chi _h\bigcap B_\delta (\varvec{x}_i)\setminus \varvec{x}_i}{\sum }1}, \end{aligned}$$
(30)

which measures the weakening of material via the percentage of broken bonds in the neighborhood of \(\varvec{x}_i\).

4 Using OBMeshfree

In this section we firstly overview the usage of OBMeshfree. For quick start, we refer the readers to Sect. 4.1. In order to further customize the examples, we then introduce the overall structure of the code and explain each.cpp file in detail in Sect. 4.3. One can find the most up-to-date version of OBMeshfree at https://github.com/youhq34/meshfree_quadrature_nonlocal.

4.1 OBMeshfree Usage and Workflow

Four cases are implement in this exemplar code. After downloading and extract the codes, users can compile the code using the following command

  • ./make Nldiff for the static nonlocal diffusion problem, on a default domain \(\Omega =[0,1]^2\);

  • ./make Nldiffd for the dynamic nonlocal diffusion problem, on a default domain \(\Omega =[0,1]^2\);

  • ./make PD for the static bond-based peridymics problem, on a default domain \(\Omega =[0,1]^2\);

  • ./make KW for the dynamic bond-based peridynamics problem with evolving fracture, reproducing the Kalthoff-Winkler fracture experiment.

Then, the codes run with:

  • ./nldiff.ex <#particles> <dhratio> <poly_order> <case> for the static nonlocal diffusion problem. Inputs are:

    1. <#particles>: The number of uniform discretization points on each dimension.

    2. <dhratio>: The ratio between \(\delta\) and h.

    3. <poly_order>: The highest polynomial order, n, to be exactly reproduced by the quadrature weights.Footnote 5

    4. <case>: A switcher for different experiment settings of Sect. 5. Here, 0 corresponds to the first example and 1 corresponds to the second example.

  • ./nldiffd.ex <#particles> <dhratio> <poly_order> <dt> <timestep> for the dynamic nonlocal diffusion problem. The first three inputs are the same as in the static nonlocal diffusion problem. The last two inputs are:

    1. <dt>: The time step size.

    2. <timestep>: The total number of time steps to be simulated.

  • ./PMB2D.ex <#particles> <dhratio> <poly_order> <perturbation> for the static bond-based peridymics problem. The first three inputs are the same as in the nonlocal diffusion problem. The last input parameter is:

    1. <perturbation>: The level of perturbation from a uniform grid, so as to create quasi-uniform discretization points. In particular, the Cartesian grids with grid size h are perturbed with a uniformly distributed random vector field \((\Delta x,\Delta y)\), \(\Delta x, \Delta y \sim \mathcal {U}[-rh,rh]\). Here r controls the degree of perturbation, which is given by <perturbation>.

  • ./KW.ex <#particles> <dhratio> <poly_order> <dt> <timestep> for the dynamic bond-based peridynamics problem with evolving fracture, with the same inputs as in the dynamic nonlocal diffusion problem.

4.2 Software Components

gcc 7.5.0 or a newer version is required. The codes are built based on BLAS and LAPACK. Users might need to change the settings of BLAS and LAPACK libraries in Makefile.

4.3 Structure of the Code

The current version of OBMeshfree contains three folders, corresponding to nonlocal diffusion problems, bond-based peridynamics problems, and the Kalthoff-Winkler fracture experiment simulation, respectively.

  • Under the folder nonlocal_diffusion, there are two.cpp files. nonlocaldiff_static.cpp is the script for static nonlocal diffusion problems, and nonlocaldiff.cpp is for dynamic nonlocal diffusion problems.

  • Under the folder bond-based-pd, PMB_2Dweight.cpp provides the script for the static bond-based peridynamics model.

  • Under the folder Kalthoff-Winkler-test, KW_2Dweight_dynamic.cpp is the script for the Kalthoff-Winkler fracture experiment, serving as an exemplar script for dynamic fracture problem with peridynamics, as well as a validation of OBMeshfree to realistic engineering applications.

In each folder, vvector.h provides the definitions for basic vector operations.

4.4 Description of the Code

In addition to the grid size h, the ratio between horizon/grid size, \(\delta /h\), the reproducing polynomial order n, and the time step size \(\Delta t\), users can further customize the test examples and material properties based on their demands. In this section we will illustrate the structure of the scripts and the usage of each function.

4.4.1 Description of nonlocal_static.cpp

nonlocal_static.cpp provides numerical simulations for static nonlocal diffusion problems, and serves as a numerical verification for the consistency of numerical solutions to a user-defined analytical local/nonlocal limit. The structures are as follows.

  • User defined functions:

    1. phi defines the functions q in \(\varvec{V}_{h,\varvec{x}_i}\), the finite dimensional function space OBMeshfree seeks to exactly reproduced by the quadrature weights.

    2. Iphi defines the analytical integral of each q, which will be employed as the right hand side of the constraints in (16).

    3. inverse is the function that calculates the inverse matrix, developed based on LAPACK.

    4. u_exact defines the analytical solution at point \(\varvec{x}=(x,y)\) when it is available, for the purpose of verifying the convergence. This analytical solution will be also used as initial conditions and boundary conditions.

    5. Ffun defines the loading field \(f(\varvec{x})\) at point \(\varvec{x}=(x,y)\), with inputs \(\varvec{x}\) and \(\delta\).

    6. diff_coef defines the nonlocal diffusion coefficient at point \(\varvec{x}=(x,y)\) as the harmonic mean of the local diffusion coefficient, when studying the AC convergence. Users can also define the nonlocal diffusion coefficient field directly for a more general nonlocal model, as described below.

    7. nonlocal_diff_coef defines the nonlocal diffusion coefficient \(A(\varvec{x},\varvec{y})\), taking a pair of 2D points, \((\varvec{x},\varvec{y})=(x_1,x_2,y_1,y_2)\), as the input.

  • Preprocess performs the main steps of OBMeshfree, i.e., generating the quadrature weights. Preprocess takes coordinates of the grids, number of grids, \(\delta /h\) and the neighborhood list for each grid as inputs, and produces a list of quadrature weights \(\omega _{ij}\) corresponding to each neighborhood point for all particles in the domain.

  • Main contains the complete procedure solving a static nonlocal diffusion problem. The steps are:

    1. 1.

      Read in the number of discretization points in each direction as N and the ratio \(\delta /h\) as dhratio from inputs.

    2. 2.

      Set initial configuration, including x and y coordinates of the grids, and the analytical solution at each grid.

    3. 3.

      Set neighborhood list for every particle.

    4. 4.

      Generate quadrature weights via Preprocess.

    5. 5.

      Assemble the stiffness matrix and corresponding forcing term for the particles in the computational domain \(\Omega \bigcap \chi _h\).

    6. 6.

      Apply Dirichlet boundary condition for the particles in \(\mathcal {B}\Omega _D\bigcap \chi _h\).

    7. 7.

      Solve for the linear system using LAPACK build-in functions.

    8. 8.

      Compute the truncation error and the solution error based on the user-defined analytical solution.

4.4.2 Description of nonlocaldiff.cpp

nonlocaldiff.cpp runs dynamical simulations for nonlocal diffusion problems. It also provides the option to compare the numerical solutions with a user-defined analytical local/nonlocal limit. The structures are as follows.

  • User defined functions:

    1. phi, Iphi, diff_coef and inverse are defined the same as in Sect. 4.4.1.

    2. u_exact defines the analytical solution at point \(\varvec{x}=(x,y)\) and time instant t.

    3. F_fun defines the forcing term for the nonlocal diffusion equation at point \(\varvec{x}=(x,y)\) and time instant t.

  • Preprocess generates the quadrature weights and also assembles the stiffness matrix.

  • Backward_Euler is the function updating the solution at each time step, with the following steps:

    1. 1.

      Update the forcing term and the Dirichlet-type boundary condition for the current time instant t.

    2. 2.

      Based on the solution at the previous time instant, \(t-\Delta t\), solve the linear system via LAPACK build-in functions and update the solution at the current time instant t.

  • main contains the complete procedure solving a dynamic nonlocal diffusion problem. The steps are:

    1. 1.

      Read in the number of discretization points in each direction as N, the ratio \(\delta /h\) as dhratio, the time step size \(\Delta t\) as dt, and the total number of time steps as timestep from inputs.

    2. 2.

      Set up the x and y coordinates of the grids, the initial condition, and the analytical solution at each discretization point.

    3. 3.

      Set up the neighborhood list for every particle.

    4. 4.

      Generate quadrature weights and assemble the stiffness matrix via Preprocess.

    5. 5.

      Perform the iteration in time from step 1 to step timestep. At each time step, run Backward_Euler.

    6. 6.

      Evaluate the solution error at the last time step.

4.4.3 Description of PMB_2Dweight.cpp

PMB_2Dweight.cpp performs the numerical verification for static bond-based peridynamics problem and provides the option to compare the numerical solutions with a user-defined analytical local/nonlocal limit. The structures are as follows.

  • User defined functions:

    1. phi and Iphi are defined the same as in Sect. 4.4.1.

    2. u_exact and v_exact define the x- and y-components of the analytical displacement field at point \(\varvec{x}=(x,y)\), respectively.

    3. E defines the heterogeneous material property field, as the function of Young’s modulus E at point \(\varvec{x}=(x,y)\). Then, the nonlocal modulus coefficient is defined as the harmonic mean of the local modulus coefficient.

    4. fx_exact and fy_exact defines the body force density components of the x- and y-directions at point \(\varvec{x}=(x,y)\), respectively.

  • Preprocess generates the quadrature weights.

  • Main performs the complete procedure solving a nonlocal static bond-based peridynamics problem. The steps are:

    1. 1.

      Read in the number of discretization points in each direction as N and the ratio \(\delta /h\) as dhratio from inputs.

    2. 2.

      Set up the x and y coordinates of the grids and the analytical solution, if available, at each discretization point.

    3. 3.

      Set up the neighborhood list for every particle.

    4. 4.

      Generate quadrature weights via Preprocess.

    5. 5.

      Assemble the stiffness matrix and corresponding forcing term for the particles in the computational domain \(\Omega \bigcap \chi _h\).

    6. 6.

      Apply Dirichlet boundary condition for the particles in \(\mathcal {B}\Omega _D\bigcap \chi _h\).

    7. 7.

      Solve for the linear system using LAPACK build-in functions.

    8. 8.

      Compute the truncation error and the solution error.

4.4.4 Description of KW_2Dweight_dynamic.cpp

KW_2Dweight_dynamic.cpp performs numerical simulation to reproduce the Kalthoff-Winkler fracture experiment. It provides an exemplar simulation for dynamic bond-based peridynamics problem, and serves as a validation for the applicability of the approach to realistic problems. The structures are as follows.

  • User define functions

    1. phi, Iphi are defined the same as in Sect. 4.4.1.

    2. BoundaryID assign each particle an ID, classifies the particles in \(\chi _h\bigcap \mathcal {B}\Omega\) into different regions for further processing.

    3. Bulk defines the bulk modulus of the material.

    4. den defines the density of the material.

    5. smax defines the critical bond stretch of the material.

    6. u_bc and v_bc define the x- and y-components of the displacement field at point \(\varvec{x}=(x,y)\) for imposing the boundary conditions in the Kalthoff-Winkler fracture experiment. u_bc and v_bc take the coordinate \(\varvec{x}=(x,y)\) and the user-defined BoundaryID of the particle \(\varvec{x}\) as inputs, to impose the Dirichlet-type boundary condition on the top and the bottom of the object in the Kalthoff-Winkler fracture experiment.

    7. fx and fy define the body force density components of the x- and y-directions at point \(\varvec{x}=(x,y)\), respectively.

  • Preprocess generates the quadrature weights.

  • Backward_Euler is the function updating the solution at each time step, with the following steps:

    1. 1.

      Assemble the stiffness matrix using the new quadrature weights and the corresponding forcing term for the particles in the computational domain \(\Omega \bigcap \chi _h\).

    2. 2.

      Update the boundary condition for \(\mathcal {B}\Omega \bigcap \chi _h\) at time instance t.

    3. 3.

      Based on the solutions at the previous two time instants, \(t-\Delta t\) and \(t-2\Delta t\), solve the linear system via LAPACK build-in functions and update the solution at the current time instant t.

  • main contains the complete procedure for simulating the Kalthoff-Winkler fracture experiment. The steps are:

    1. 1.

      Read in the number of particles in y-direction as N, then set the number of particles in x-direction as 2N. Read in the ratio \(\delta /h\) as dhratio, the time step size as dt, and the total number of time steps to be simulated as timestep from input.

    2. 2.

      Set up material properties, including the bulk modulus Bulk, critical bond stretch smax, and material density den for bond-based peridynamics problems.

    3. 3.

      Set up the x and y coordinates of the grids and the initial condition at each discretization point.

    4. 4.

      Set up the neighborhood list for every particle.

    5. 5.

      Initialize the pre-notched crack by breaking any bond that intersects with the crack.

    6. 6.

      Generate quadrature weights through Preprocess.

    7. 7.

      For \(m=1:\) timestep

      1. 7a.

        Examine the breaking bonds, update the bond state function values and the quadrature weights.

      2. 7b.

        Run Backward_Euler to update the displacement field.

      3. 7c.

        Compute the damage field using the current solution

      4. 7d.

        Save the damage and displacements field for post processing.

5 Numerical Examples

In this section, we will use manufactured solutions to test the consistency of OBMeshfree, by investigating the convergence of the numerical solution to the local and nonlocal limits. Four test problems are considered: a static nonlocal diffusion problem verifying the consistency to the analytical nonlocal limit, a static nonlocal diffusion problem verifying the AC convergence, a static bond-based peridynamics problem verifying the AC convergence, and a dynamic bond-based peridynamics problem reproducing the Kalthoff-Winkler fracture experiment.

We denote \(u_{\delta }\) and \(u_0\) as the nonlocal and local analytical solution respectively, and \(u_{\delta ,h}\) the numerical solution. In example 1, we investigate the convergence of numerical solutions to the nonlocal analytical solution with vanishing h and fixed \(\delta\) by calculating \(\Vert u_{\delta ,h}- u_\delta \Vert _{l^2}\), where the root-mean-square takes the form \({\left| \left| F \right| \right| }_{l^2}:=\sqrt{\dfrac{\sum _{\varvec{x}_i \in \chi _h} |F(\varvec{x}_i)|^2}{\#(\chi _h)}}\), serving as a numerical approximation of the error in the \(L^2({\Omega })\) norm. Then in examples 2 and 3, we investigate the convergence of numerical solutions to the local analytical solution under the \(\delta\)-convergence limit. The differences between the local limit and the nonlocal numerical solution are estimated via \(\Vert u_{\delta ,h}- u_0 \Vert _{l^2}\). Last but not least, in example 4 we consider the Kalthoff-Winkler experiment, wherein the fracture dynamics driven by an impactor striking a pre-notched plate generates an experimentally reproducable crack pattern. These four cases demonstrate the ability of the discretization to resolve both static and dynamic problems.

In nonlocal diffusion examples, we set the kernel \(\gamma _\delta\) as a constant without singularity, i.e., \(s=0\). In this case, we note due to the \(O(\delta ^2)\) discrepancy between local and nonlocal diffusion operators, \(n=3\) would provide the smallest polynomial space of \(\varvec{V}_{h,\varvec{x}_i}\) to achieve the optimal convergence rate \(O(\delta ^2)\) in AC tests. Moreover, we further point out that when the grid is uniform, one can equivalently set \(n=2\), since the constraint for odd-order polynomials are automatically guaranteed thanks to the symmetric properties. Hence, we set the default reproducing polynomial order for nonlocal diffusion examples as \(n=2\). As discussed in Theorems 1 and 2, an \(O(\delta ^2)\) discrepancy to the local limit under \(\delta -\)convergence and an O(h) error to the nonlocal limit are anticipated. In peridynamics examples, we employ a singular kernel \(\gamma _\delta\) with singularity order \(s=1\), and investigate the performance of our solver when the grids are not fully uniform. In this case, we set \(n=3\) as the default reproducing polynomial order, since the grids and quadrature weights in each \(B_\delta (\varvec{x})\) are no longer symmetric.

5.1 Examples on Nonlocal Diffusion Problems

In this section we numerically investigate the convergence properties of OBMeshfree, by studying its performance on two nonlocal diffusion examples with manufactured solutions. To verify the error bounds provided in Theorems 3 and 4, besides the \(l^2\) error we further measure the discrepancy of numerical solution and analytical solution with the \(l^\infty\) error given by: \({\left| \left| F \right| \right| }_{l^\infty }:=\max _{\varvec{x}_i \in \chi _h} |F(\varvec{x}_i)|\), serving as a numerical approximation of the error in the \(L^\infty ({\Omega })\) norm.

5.1.1 Consistency to the Nonlocal Limit

Firstly, we test the consistency of numerical solutions to the nonlocal limit. Consider a static nonlocal diffusion problem on \({\Omega }=[0,1]^2\) with nonlocal diffusion coefficient field

$$\begin{aligned} A(\varvec{x},\varvec{y}):=A(x_1, x_2,y_1, y_2)=5+x_1+y_1, \end{aligned}$$

subjected to the Dirichlet-type boundary condition on \(\mathcal {B}\Omega _D\):

$$\begin{aligned} u_D(\varvec{x})=u_D(x,y):=x^6+y^6, \end{aligned}$$

and a loading field on \({\Omega }\):

$$\begin{aligned} f(\varvec{x})=f(x,y):=&\,(5+2x)(\frac{5}{32}\pi \delta ^8+\frac{15}{8}\pi \delta ^6(x^2+y^2)+\frac{15}{4}\pi \delta ^4(x^4+y^4))\\&+(\frac{5}{32}\pi \delta ^8x+\frac{15}{6}\delta ^6x^3+\frac{3}{2}\pi \delta ^4x^5). \end{aligned}$$

This problem has a manufactured analytical nonlocal solution

$$\begin{aligned} u_\delta (\varvec{x})=u_\delta (x,y)=x^6+y^6. \end{aligned}$$

Firstly, we aim to verify Theorem 1, by calculating the solution error and truncation error of the discretized nonlocal operator with a fixed \(\delta /h=3.5\) and decreasing horizon size \(\delta\) from 7/16 to 7/256. The results with reproducing polynomial orders \(n=2,3,4,5\) are illustrated in Fig. 1, where we plot the solution error \({\left| \left| u_{\delta ,h}-u_\delta \right| \right| }\) as well as the truncation error \({\left| \left| \mathcal {L}_{D\delta }[u_\delta ]-\mathcal {L}_{D\delta ,h}[u_\delta ] \right| \right| }\) as functions of \(\delta\), for each value of n. We observe \(O(\delta ^{n-1})\) convergence in the truncation error, verified the estimate in Theorem 1. For the solution error, we observe \(O(\delta ^n)\) convergence for even n and \(O(\delta ^{n-1})\) convergence for odd n. This is probably caused by the symmetry of the odd-order polynomials on the ball when uniform grids are employed. Users can generate the above results using the script nonlocaldiff_static.cpp. As an instance, for grid size \(h=1/64\), horizon size \(\delta =3.5h\), and polynomial order \(n=5\), simulations run with the command ‘./nldiff.ex 64 3.5 5 0’, where the last argument corresponds to the case index for this example.

Fig. 1
figure 1

Example 1: verifying the convergence of solution error \({\left| \left| u_\delta -u_{\delta ,h} \right| \right| }\) (left) and truncation error \({\left| \left| \mathcal {L}_{D\delta }[u_\delta ]-\mathcal {L}_{D\delta ,h}[u_\delta ] \right| \right| }\) (right) to the nonlocal limit, when taking \(\delta \rightarrow 0\)

We now proceed to verify Theorems 2 and 4, by considering a fixed horizon size \(\delta =0.4375\) and decreasing the grid size h from 1/8 to 1/128. When taking the reproducing polynomial order \(n=2\) (which is equivalent to \(n=3\) due to the symmetry in uniform grids), the results are displayed in Fig. 2, illustrating an O(h) convergence in both the truncation error and solution error. This result is consistent with the error estimates provided in Theorems 2 and 4. Users can generate these numerical results using the script nonlocaldiff_static.cpp. To keep the horizon size, \(\delta\), as a fixed value when decreasing h, the second and the third arguments should increase proportionally. For example, to fix the horizon size as \(\delta =0.4375\), for grid size \(h=1/8\) one should run the command ‘.\nldiff.ex 8 3.5 3 0’, and for grid size \(h=1/16\) one should run ‘.\nldiff.ex 16 7.0 3 0’.

Fig. 2
figure 2

Example 1: verifying the convergence of solution error \({\left| \left| u_\delta -u_{\delta ,h} \right| \right| }\) (left) and truncation error \({\left| \left| \mathcal {L}_{D\delta }[u_\delta ]-\mathcal {L}_{D\delta ,h}[u_\delta ] \right| \right| }\) (right) to the nonlocal limit, when taking a fixed \(\delta\) and setting \(h\rightarrow 0\)

5.1.2 Asymptotic Compatibility to the Local Limit

Herein, we study the AC consistency of the numerical solution, by considering a static nonlocal diffusion problem example with manufactured local limit. We study a heterogeneous nonlocal diffusion problem on \({\Omega }=[0,1]^2\), with given local diffusion coefficient field

$$\begin{aligned} a(\varvec{x})=a(x,y):=2+\sin (x)\sin (y). \end{aligned}$$

The object is subjected to Dirichlet-type boundary condition on \(\mathcal {B}\Omega _D\) as:

$$\begin{aligned} u_D(\varvec{x})=u_D(x,y):=\cos (x)\cos (y) \end{aligned}$$

and loading

$$\begin{aligned} f(\varvec{x})=f(x,y):=4\cos (x)\cos (y)+4\sin (x)\cos (x)\sin (y)\cos (y). \end{aligned}$$

When taking the nonlocal diffusion coefficient field as the harmonic mean of \(a(\varvec{x})\) following (4), the nonlocal solution should converge to the analytical local solution

$$\begin{aligned} u_0(\varvec{x})=u_0(x,y)=\cos (x)\cos (y) \end{aligned}$$

as \(\delta \rightarrow 0\).

To present the numerical results of \(\delta\)-convergence, we fix the ratio \(\delta /h=3.5\) and study the convergence of the numerical solution to the local limit with decreasing grid size h from 1/10 to 1/160. In this example we employ the reproducing polynomial order \(n=2\), which is equivalent to \(n=3\) due to the symmetry in uniform grids, and therefore is anticipated to provide the optimal convergence rate, \(O(\delta ^2)\), to the local limit. The solution error \({\left| \left| u_{\delta ,h}-u_0 \right| \right| }\) as well as the truncation error \({\left| \left| \mathcal {L}_D[u_0]-\mathcal {L}_{D\delta ,h}[u_0] \right| \right| }\) are plotted as functions of \(\delta\) in Fig. 3. In both \(l^2\) and \(l^\infty\) norms, a \(O(\delta ^2)\) convergence is observed for the solution error and the truncation error, verifying the analysis in Theorem 3. To reproduce these results, users can run the script nonlocaldiff_static.cpp. Taking the case with grid size \(h=1/160\), reproducing polynomial order \(n=2\), and \(\delta /h=3.5\) as an instance, results are obtained with the command ‘./nldiff.ex 160 3.5 2 1’. Here, the last argument corresponds to the case index for this example.

Fig. 3
figure 3

Example 2: verifying the convergence of solution error \({\left| \left| u_0-u_{\delta ,h} \right| \right| }\) (left) and truncation error \({\left| \left| \mathcal {L}_D[u_0]-\mathcal {L}_{D\delta ,h}[u_0] \right| \right| }\) (right) to the local limit, when taking \(h,\delta \rightarrow 0\)

5.2 Examples on Peridynamics

In this section we demonstrate two bond-based peridynamics examples using OBMeshfree. In the first example, we provide verification on a static example with manufactured local solution. To provide heuristic studies on the solution convergence rates, we measure discrepancy of numerical solution and analytical solution with the \(l^2\) error. Then, in the second example we use the dynamic peridynamics code to reproduce the Kalthoff-Winkler fracture experiment, demonstrating the applicability of this approach to realistic engineering applications involving dynamic fracture. For the purpose of demonstration, we consider 2D problems under plane strain setting in all examples.

5.2.1 Asymptotic Compatibility to the Local Limit

In this section we consider the static bond-based peridynamics modeling for an object occupying the region \({\Omega }=[0,1]^2\), whose material microstructure is characterized by a fixed Possion ratio \(\nu =0.25\) and a local Young’s modulus field

$$\begin{aligned} E(\varvec{x})=E(x,y):=2+\sin (x)\sin (y). \end{aligned}$$

Assume that the Dirichlet-type boundary condition

$$\begin{aligned} \varvec{u}_D(\varvec{x})=\varvec{u}_D(x,y):=\left[ \sin (x)\sin (y),-\cos (x)\cos (y)\right] \end{aligned}$$

is given for \(\varvec{x}\in \mathcal {B}\Omega _D\), and the object is subject to a body load

$$\begin{aligned} \varvec{f}(\varvec{x})=\varvec{f}(x,y):= \left[ \begin{array}{c} -12C_1\sin (x)\sin (y)+4C_1\cos (2x)\sin ^2(y))+4C_1\cos (2y)\sin ^2(x))\\ 12C_1\cos (x)\cos (y)+3C_1\sin (2x)\sin (2y) \end{array}\right] ^T, \; C_1:=1/(2(1+\nu )). \end{aligned}$$

When taking the nonlocal modulus field as the harmonic mean of the local one, the bond-based peridynamics problem converges to the Navier equations [74,75,76] for linear elasticity:

$$\begin{aligned} -\mathcal {L}_{P}[\varvec{u}](\varvec{x})=\varvec{f}(\varvec{x}) \end{aligned}$$

as \(\delta \rightarrow 0\). Here,

$$\begin{aligned} \mathcal {L}_{P} [\varvec{u}]:=\dfrac{E}{2(1+\nu )} \nabla \cdot (2\textbf{E}+\text {tr}(\textbf{E})\textbf{I}), \end{aligned}$$
(31)

where the strain tensor \(\textbf{E}:=\dfrac{1}{2}(\nabla \varvec{u}+(\nabla \varvec{u})^T)\) and \(\text {tr}(\textbf{E})\) denotes its trace. Hence, with this example we aim to investigate if the numerical solution would converge to the following analytical local solution of (31):

$$\begin{aligned} \varvec{u}_0(\varvec{x})=\varvec{u}_0(x,y):=\left[ \sin (x)\sin (y),-\cos (x)\cos (y)\right] \end{aligned}$$

under the \(\delta\)-convergence setting.

To study the AC convergence, in this example we fix \(\delta /h=3.5\) while decreasing the grid size h from 1/8 to 1/128, and calculate the discrepancy between our numerical solution and the analytical local limit. To demonstrate our meshfree approach in handling non-uniform grids, we first generate the uniform grid, then perturb the uniform grid points with \((\Delta x,\Delta y)\), where \(\Delta x, \Delta y \sim \mathcal {U}[-rh,rh]\). Here, the perturbation ratio \(r\in (0,1)\) provides a metric for the effect of anisotropy in the underlying discretization. Two examples of perturbed grids are demonstrated in Fig. 4, corresponding to \(r=0.2\) and \(r=0.5\), respectively. For each perturbation ratio \(r\in \{0.2,0.5\}\), we generate 5 realizations of grids using different random seeds. To investigate the impact of non-uniform grids, we record the solution and truncation errors for each realization, and report their means and standard errors versus the horizon size \(\delta\) in Fig. 5. \(O(\delta ^2)\) convergence is observed in the truncation error for all perturbation levels. Here we notice that the standard errors of the right plot are almost invisible, showing that the truncation errors are not sensitive to perturbations in the discretization grids, possibly because they are dominated by the discrepancy from \(\varvec{u}\) to the reproducing polynomial space instead of the interpolation error. For the solution error, we also observe \(O(\delta ^2)\) convergence to the local limit when using uniform grids, while the convergence rate slightly deteriorates as we increase the level of perturbation, possibly due to the effects of grid anisotropy on the stiffness matrix. To reproduce these results, users can run the script PMB_2Dweight.cpp. For grid size \(h=1/128\), \(\delta /h=3.5\), and perturbation level \(r=20\%\), as an instance, results are generated using the command ‘./PMB2D.ex 128 3.5 3 0.2’.

Fig. 4
figure 4

Exemplar non-uniform grids generated for \({\Omega }\bigcup \mathcal {B}\Omega\), with the perturbation ratios \(r=20\%\) (left) and \(r=50\%\) (right). The computational domain \({\Omega }=[0,1]^2\) is indicated by the blue box

Fig. 5
figure 5

Example 3: verifying the convergence of peridynamics solution error \({\left| \left| u_0-u_{\delta ,h} \right| \right| }\) (left) and truncation error \({\left| \left| \mathcal {L}_P[u_0]-\mathcal {L}_{P\delta ,h}[u_0] \right| \right| }\) (right) to the local limit, when taking \(h,\delta \rightarrow 0\) and perturbing the uniform grid with different levels of perturbation. Means and standard errors of 5 realizations are reported for each perturbation level

5.2.2 Dynamic Fracture: Reproducing the Kalthoff-Winkler Experiment

We now consider a dynamic fracture problem where a steel plate is struck by a cylindrical impactor [77], which is the so-called Kalthoff-Winkler experiment. The plate is pre-notched, and crack will grow from the pre-notch tips upon an impact. Experiments show that the fracture pattern behaves differently depending on the regimes governed by the impactor velocity. In this example, we employ parameters given in Fig. 6, which is also consistent with those investigated previously in a particle-based peridynamics model [36]. Under such a setting, experimentally it was observed that a reproducible 68\(^\circ\) angel is formed by the growing crack and the initial vertical pre-notch [77]. With this example, we aim to validate if our OBMeshfree is capable to capture the evolving fracture and reproducing the crack pattern.

Fig. 6
figure 6

Experimental setup for the Kalthoff-Winkler experiment. The figure is adapted from [36]

In this example, to model the impact, \(\varvec{u}=[0,-32t]\) is imposed between the two notches, as depicted in Fig. 6. Then, on the rest regime of the top of the plate, a homogeneous Dirichlet boundary conditions \(\varvec{u}=[0,0]\) is applied. All other boundaries are treated as free surfaces, hence any bonds across those surfaces are set as broken following Sect. 5.2.2. For the material properties, we employ the settings employed in [36]. In particular, the plate has a density 8e-3 kg/m\(^3\), an elastic modulus of 191 GPa, a yield strength of 2000 MPa, and a fracture toughness of 90 MPa m\(^{1/2}\). The above material properties yield a bond breaking criteria of \({S}_0=0.0099/\sqrt{\delta }\) following (9). In our code, the spatial unit is unified as cm, the temporal unit is unified as ms, and weight unit is unified as kg.

In Fig. 7 we illustrate the evolution of simulated displacement field at four time instances: t=2e-4 ms, t=2e-3 ms, t=4e-3 ms, and t=6e-3 ms. In this simulation a uniform grid with \(64\times 128\) particles, \(\delta =3.0h\) and time discretization size \(\Delta t=2e-4ms\) are employed. At the end of the simulation, three fragments remain due to the crack. In Fig. 8 we further illustrate the fracture pattern, whose fragment shape reproduces the experimentally observed 68\(^\circ\) crack angle at the pre-notch tip. The results in this section are generated based on the script KW_2Dweight_dynamic.cpp. Users can reproduce these results by running the command ‘./KW.ex 64 3.0 3 2e-4 500’.

Fig. 7
figure 7

The evolution of the displacement field for the Kalthoff-Winkler fracture experiment, after 1, 50, 100 and 150 time steps. The logarithmic value of displacement magnitude (\(\log _{10}{\left| \varvec{u} \right| }\)) is colored for plot

Fig. 8
figure 8

Crack pattern for Kalthoff-Winkler experiment when taking \(h=\)0.15625 cm and \(\delta =3.0h\) at time t=6e-3ms, successfully reproduced the 68\(^\circ\) crack angle as reported in [36, 77]

Remark 1

To fully resolve the transient dynamics of the problem in [78], we may define the CFL condition number \(C_{CFL}:=\dfrac{C_R \Delta t}{h}\), where \(C_R\) is the Rayleigh speed calculated following [79]. When \(C_{CFL}\le \frac{1}{2}\), we fully resolve the transient dynamics of the problem. In this example, our settings are corresponding to \(C_{CFL}\approx 0.4\). For further results with different CFL condition numbers, we refer interested readers to [45], where both fully resolved dynamics (\(C_{CFL}\le \frac{1}{2}\)) and implicit solution of wave propagation (\(C_{CFL}>1\)) were investigated.

6 Conclusion

In this work, we have developed an open-source software called OBMeshfree for meshfree analysis on nonlocal problems. The program is developed based on an optimization-based quadrature rule and consists of a set of routines for generating quadrature weights on a neighborhood of each material point, discretizing two-dimensional nonlocal diffusion and peridynamics operators, performing integrating in time, handling material heterogeneity and evolving fracture, and calculating solution and truncation errors in cases with manufactured solutions. Benchmark problems are presented to verify the convergence, efficiency, and robustness properties of the meshfree discretization method implemented in OBMeshfree, under both uniform and highly non-uniform nodal distributions. Our method features a unified mathematical workflow for handling material heterogeneity and evolving material fracture, and it is able to provably obtain high-order convergence to both local and nonlocal limits. With sufficient regularity assumptions on the solution and material property fields, the approach is able to obtain O(h) and \(O(\delta ^2)\) convergences to the nonlocal and local theory, respectively.

The open-source code can serve as an entry point for researchers who are interested in the computer implementation of the optimization-based quadrature rule employed in [45, 50,51,52,53], and the code can also be adopted as a rapid prototyping and testing tool for the simulations with nonlocal models. Although the linear diffusion and bond-based peridynamics problems are chosen as the model problem, the flexibility of the code allows the extension to solve more advanced nonlocal problems for various scientific and engineering applications. For example, since phase transformations and fracture are both nonlinear phenomena, a development of meshfree solver for nonlocal and nonlinear problems is also desired. We also point out that as a simple demonstration of our meshfree method, in the current implementation stiffness matrices are assembled in dense format and solved using LAPACK. For the purpose of further improving the efficiency in large scale problems, one might consider employing sparse matrices and high-performance linear algebra routines such as ScaLAPACK [80].