1 Introduction

The COVID-19 pandemic has caused widespread damage worldwide, in terms of human lives and international economic weakening. As a new highly contagious disease, governments have taken unprecedented measures to slow the spread of the virus, including quarantines, curfews, lockdowns, and national and international travel suspension. These measures, considered essential by many experts, are partly motivated by the lack of reliable data on this disease’s transmission and lethality, which justifies cautious responses from the authorities and population. These events demonstrate more than ever the need for reliable tools designed to model the spatio-temporal spread of infectious diseases.

The study of infectious disease proliferation is a well-established field and has given rise to the area of science called mathematical epidemiology [51]. Mathematical epidemiology proposes models that help the understanding of epidemics and to outline policies to control infectious diseases. In Brazil, studies of this type have been carried out for years for diseases such as Dengue [20] and Zika [17], and, in a global context, diseases such as HIV [41], SARS [19], Malaria [40], Ebola [38], among others. The COVID-19 pandemic brought the need for more research in this area. Several models for this pandemic outbreak have been presented in recent months [3, 13, 25, 47, 48].

Disease transmission may be modeled as compartmental models, in which the population under study is divided into compartments and has assumptions about the nature and time rate of transfer from one compartment to another [9]. These models have been used extensively in biological, ecological, and chemical applications [8, 30, 32]. They allow for an understanding of the processes at work and for predicting the dynamics of the epidemic.

One of the simplest compartmental models is the SIR model proposed by Kermack and McKendrick [34], where the population is divided into susceptible, infected, and recovered compartments. This basic SIR model can be extended in several ways by enriching the number of compartments, as the susceptible-infectious-susceptible (SIS) model for the common cold, in which infectious people become susceptible again once recovered; the susceptible-infected-recovered-deceased (SIRD), which distinguishes recovered from dead; the susceptible-exposed-infectious-recovered (SEIR) model, where infected carriers experience an exposed period before they become infectious; among others. Several features may be included such as maternal immunity, vaccinations, effects of age, variable contact rates, quarantine measures [49], etc. The SIR based models also may be used along with other approaches as a mobility network model [15] or an agent-based computational framework [54].

The large majority of the compartmental models are composed of a system of ordinary differential equations (ODE’s) in time. Though compartmentalized models are simple to formulate, analyze, and solve numerically, these models do not always account for the movement of individuals from one region to another. Different approaches have been used to introduce spatial variation into such ODE models [23, 25, 28, 31]. The strategies consist of defining regional compartments corresponding to different geographic units and adding coupling terms to the model equations to account for species’ movement from unit to unit.

In this work, we use a partial differential equation (PDE) model to capture the continuous spatio-temporal dynamics of COVID-19. PDE models incorporate spatial information more naturally and allow for capturing the dynamics across several scales of interest. They have a significant advantage over ODE models, whose ability to describe spatial information is limited by the number of geographic compartments. Indeed, recent research indicates that COVID-19 spreading presents multi-scale features that go from the virus and individual immune system scale to the collective behavior of a whole population [7]. For the scale of virus transmission among individuals, there are studies such as the potential infection zone produced by a cough [55] or the viral propagation in a built environment [39]. On a smaller scale, it is possible even to study the effects of the viral decontamination efficacy with UV irradiation [56]. On the other hand, it is also possible to simulate a global planetary scale pandemic as in [54]. Here, we are interested in study the dynamics of the virus spread in specific geographic regions.

We study a compartmental SEIRD model (susceptible-exposed-infected-recovered-deceased) that incorporates spatial spread through diffusion terms [12, 32, 35, 47, 48]. Adaptive mesh refinement and coarsening [14] can resolve population dynamics from local (street, city) to regional (district, state), providing an accurate spatio-temporal description of the infection spreading. Moreover, diffusion may be properly tuned to account for local natural or social inhomogeneities (e.g., mountains, lakes, highways) describing populations’ movements.

However, the main limitation of the diffusion–reaction PDE approach is the definition of the diffusion operator and transmission coefficients, which depend on the population’s behavior. Another issue is that the virus spread is not only through diffusion, since people, who may be infected, travel long distances in a short period. Some models relate the mobile geolocation data with the spread of the disease [37, 42]. These issues make the model a highly complex system, which may completely change as the population’s behavior changes. Therefore, this work contributes to improving the knowledge of compartmental diffusion–reaction PDE models.

All implementations are done using the libMesh library. As other freely available open-source libraries (deal.II [5], FEniCS [2], GRINS [6], MOOSE [22], etc), libmesh provides a finite element framework that can be used for numerical simulation of partial differential equations in various applied fields in science and engineering. It has already been used in more than 1000 publications with applications in many different areas. See, for example, recent applications in sediment transport [27] and bubble dynamics [26]. This library is an excellent tool for programming the finite element method and can be used for one-, two-, and three-dimensional steady and transient simulations on serial and parallel platforms. The libmesh library provides native support for adaptive mesh refinement and coarsening, thus providing a natural environment for the present study. The main advantage of this library is the possibility of focusing on implementing the specifics features of the modeling without worrying about adaptivity and code parallelization. Consequently, the effort to build a high performance computing code tends to be minimized.

The remainder of this work is organized as follows: In Sect. 2, we present the governing equations that describe the dynamics of a virus infection. First, we present a generic spatio-temporal SEIRD model, based on the EPIDEMIC software [16], used to verify our implementation. We then present a model that better represents the dynamics of COVID-19 infection spread, based on [47, 48]. In Sect. 3, we introduce the Galerkin finite element formulation, the time discretization, and the libMesh implementation. Then, we present the numerical verification of the generic spatio-temporal SEIRD model implementation. We verify our algorithm’s capacity to represent a compartmental model [16] and show how the diffusion influences the dynamics. Section 5 presents the numerical results of the spatio-temporal model of COVID-19 infection spread. We perform simulations similar to the ones presented in [48] and show tests to highlight the new modeling capabilities introduced in this work. Finally, the paper ends with a summary of our main findings and the perspectives for the next steps of this research.

2 Governing equations

The presentation of the governing equations follows the continuum mechanics framework in [48] instead of the more traditional approach found in mathematical and biological references. Consider a system which may be decomposed into N distinct populations: \(u_1(\mathbf {x}, t)\), \(u_2(\mathbf {x}, t)\), ..., \(u_N (\mathbf {x}, t)\). Let \(\varOmega \in R^2\) be a simply connected domain of interest with boundary \(\partial \varOmega = \varGamma _D \cap \varGamma _N\), and [0, T] a generic time interval. The vector compact representation of the governing equations as a transient nonlinear diffusion–reaction system of equations reads,

$$\begin{aligned}&\frac{\partial \mathbf {u}}{\partial t} + \left( \mathbf {A} + \mathbf {B(u)}\right) \mathbf {u} - \nabla \cdot (\varvec{\nu } \nabla \mathbf {u}) - \mathbf {f}=0 \text { in }\varOmega \times [0,T] \end{aligned}$$
(1)
$$\begin{aligned}&\mathbf {u}=\mathbf {u_D} \text { in }\varGamma _D \times [0,T] \end{aligned}$$
(2)
$$\begin{aligned}&(\varvec{\nu } \nabla \mathbf {u}) \cdot \mathbf {n}=\mathbf {h} \text { in }\varGamma _N \times [0,T] \end{aligned}$$
(3)

We denote the densities of the susceptible, exposed, infected, recovered and deceased populations as \(s(\mathbf {x}, t)\), \(e(\mathbf {x}, t)\), \(i(\mathbf {x}, t)\), \(r(\mathbf {x}, t)\), and \(d(\mathbf {x}, t)\). Also, let \(c(\mathbf {x}, t)\) denote the cumulative number of infected and \(n(\mathbf {x}, t)\) the sum of the living population; i.e., \(n(\mathbf {x}, t) = s(\mathbf {x}, t) + e(\mathbf {x}, t) + i(\mathbf {x}, t) + r(\mathbf {x}, t)\). We consider \(\mathbf {u} = [s,e,i,r,d]^T\). The matrices \(\mathbf {A}\), \(\mathbf {B}\) and \(\varvec{\nu }\), and the vector \(\mathbf {f}\) depend on a particular form of the system dynamics. Furthermore, in general, \(\varvec{\nu }=\varvec{\nu }(\mathbf {x})\), that is, diffusion is heterogeneous and anisotropic. Besides the boundary conditions (2), (3), we specify the initial condition \(\mathbf {u}(\mathbf {x},0)=\mathbf {u}_0\). The total population \(U_i(t)\) of each compartment \(u_i(\mathbf {x}, t)\) is,

$$\begin{aligned} U_i(t) = \int _\varOmega u_i(\mathbf {x}, t) d\varOmega \end{aligned}$$
(4)

for \(i=1,2, \ldots , N\).

2.1 Generic spatio-temporal SEIRD model

We first consider a SEIRD model based on [16], in which we add diffusion operators based on [47], given by the following system of coupled PDEs over \(\varOmega \times [0, T]\):

$$\begin{aligned}&\frac{\partial s}{\partial t} + \frac{\beta }{n} si - \nabla \cdot (n\nu _s\nabla s) = 0 \end{aligned}$$
(5)
$$\begin{aligned}&\frac{\partial e}{\partial t} - \frac{\beta }{n} si + \alpha e - \nabla \cdot (n\nu _e \nabla e) = 0 \end{aligned}$$
(6)
$$\begin{aligned}&\frac{\partial i}{\partial t} - \alpha e + (\gamma + \delta ) i - \nabla \cdot (n\nu _i \nabla i) = 0 \end{aligned}$$
(7)
$$\begin{aligned}&\frac{\partial r}{\partial t} - \gamma i -\nabla \cdot (n \nu _r \nabla r) = 0 \end{aligned}$$
(8)
$$\begin{aligned}&\frac{\partial d}{\partial t} - \delta i = 0 \end{aligned}$$
(9)

where \(\beta \) is transmission rate (days\(^{-1})\), \(\alpha \) the latent rate (days\(^{-1})\), \(\gamma \) the recovery rate (days\(^{-1})\), \(\delta \) the death rate (days\(^{-1})\), and \(\nu _s\), \(\nu _e\), \(\nu _i\), \(\nu _r\) are diffusion parameters respectively corresponding to the different population groups (km\(^2\) persons\(^{-1}\) days\(^{-1}\)). We append to the system of equations homogeneous Neumann boundary conditions, that is, \((\varvec{\nu } \cdot \nabla \mathbf {u}) \cdot \mathbf {n} = 0\).

We can reframe this model in the general form given by Eq. (1). Thus, the matrices \(\mathbf {A}\), \(\mathbf {B}\), \(\varvec{\nu }\) and the vector \(\mathbf {f}\) reads,

$$\begin{aligned} \mathbf {A}= & {} \begin{bmatrix} 0 &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} \alpha &{} 0 &{} 0 &{} 0\\ 0 &{} -\alpha &{} \gamma +\delta &{} 0 &{} 0\\ 0 &{} 0 &{} -\gamma &{} 0 &{} 0\\ 0 &{} 0 &{} -\delta &{} 0 &{} 0\\ \end{bmatrix} \end{aligned}$$
(10)
$$\begin{aligned} \mathbf {B}= & {} \begin{bmatrix} 0 &{} 0 &{} \frac{\beta }{n}s &{} 0 &{} 0\\ 0 &{} 0 &{} -\frac{\beta }{n}s &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0\\ \end{bmatrix} \end{aligned}$$
(11)
$$\begin{aligned} \varvec{\nu }= & {} \begin{bmatrix} \varvec{\nu _s} &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} \varvec{\nu _e} &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} \varvec{\nu _i} &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} \varvec{\nu _r} &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0\\ \end{bmatrix} \end{aligned}$$
(12)
$$\begin{aligned} \varvec{\nu _k}= & {} \begin{bmatrix} \nu ^k_{xx} &{} \nu ^k_{xy}\\ \nu ^k_{yx} &{} \nu ^k_{yy} \end{bmatrix} \text { with } k=s,e,i,r \end{aligned}$$
(13)
$$\begin{aligned} \mathbf {f}= & {} \mathbf {0} \end{aligned}$$
(14)

This model is based on the EPIDEMIC software,Footnote 1 and it is employed to verify our implementation. The system of equations represents that the susceptible population decreases as the exposed population increases. This variation depends on the transmission rate between infected and susceptible. The number of exposed increases because of the transmission rate and decreases when the exposed individuals become infected (after the incubation period). The number of infected increases after the incubation period and decreases depending on the recovery and death rate. The number of deaths depends only on the death rate as the number of recovered depends only on the recovery rate. Finally, the cumulative number of infected depends only on the exposed and the incubation period. The diffusion parameters are included in the model to spread the disease spatially.

Summarizing, this model assumes:

  • Movement is proportional to population size; i.e., more movement occurs within heavily populated regions;

  • No movement occurs among the deceased population;

  • There is a latency period between exposure and the development of symptoms;

  • The probability of contagion is inversely proportional to the population size;

  • The exposed persons will ever develop symptoms;

  • Only infected persons are capable of spreading the disease;

  • The non-virus mortality rate is not considered in this model;

  • New births are not considered in this model.

Note that the EPIDEMIC model’s dynamics does not represent the actual COVID19 dynamics since, in the case of COVID19, the exposed population may be asymptomatic and recover without becoming infected and still spread the virus. Thus, a better model would be the one based on [47, 48].

2.2 Spatio-temporal model of COVID-19 infection spread

We begin by making several model assumptions to represent the COVID-19 infection spread adequately [48]:

  • Only mortality due the COVID-19 is considered;

  • New births are not considered in this model.

  • Some portion of exposed persons never develop symptoms, and move directly from the exposed compartment to the recovered compartment (asymptomatic cases);

  • Both asymptomatic (exposed) and symptomatic (infected) patients are capable of spreading the disease;

  • There is a latency period between exposure and the development of symptoms;

  • It is possible that new cases of exposed people appear randomly in the system (exposed people who return from a travel);

  • The probability of contagion increases with population size (Allee effect [47]);

  • Movement is proportional to population size; i.e., more movement occurs within heavily populated regions;

  • No movement occurs among the deceased population;

Then, the system of equations becomes:

$$\begin{aligned}&\begin{aligned}&\frac{\partial s}{\partial t} + \beta _i \left( 1-\frac{A}{n}\right) si + \beta _e \left( 1-\frac{A}{n}\right) se + f\\&\quad - \nabla \cdot (n\nu _s\nabla s) = 0 \end{aligned} \end{aligned}$$
(15)
$$\begin{aligned}&\begin{aligned}&\frac{\partial e}{\partial t} - \beta _i \left( 1-\frac{A}{n}\right) si - \beta _e \left( 1-\frac{A}{n}\right) se + (\alpha + \gamma _e) e -f \\&\quad - \nabla \cdot (n\nu _e \nabla e) = 0 \end{aligned} \end{aligned}$$
(16)
$$\begin{aligned}&\frac{\partial i}{\partial t} - \alpha e + (\gamma _i + \delta ) i - \nabla \cdot (n\nu _i \nabla i) = 0 \end{aligned}$$
(17)
$$\begin{aligned}&\frac{\partial r}{\partial t} -\gamma _e e- \gamma _i i -\nabla \cdot (n \nu _r \nabla r) = 0 \end{aligned}$$
(18)
$$\begin{aligned}&\frac{\partial d}{\partial t} - \delta i = 0 \end{aligned}$$
(19)

where A characterizes the Allee effect (persons), that takes into account the tendency of outbreaks to cluster around large populations, \(\beta _i\) is the transmission rate between symptomatic and susceptible (persons\(^{-1}\) days\(^{-1})\), \(\beta _e\) is the transmission rate between asymptomatic and susceptible (persons\(^{-1}\) days\(^{-1})\), f is a source function that depends on space and time (persons), \(\alpha \) is the latent rate (days\(^{-1})\), \(\gamma _e\) is the recovery rate of the asymptomatic (days\(^{-1})\), \(\gamma _i\) is the recovery rate of the symptomatic (days\(^{-1})\), \(\delta \) is the death rate (days\(^{-1})\), and \(\nu _s\), \(\nu _e\), \(\nu _i\), \(\nu _r\) are the diffusion parameters respectively corresponding to the different population groups (km\(^2\) persons\(^{-1}\) \(days^{-1}\)).

Now, we call exposed who has contact with the virus but remains asymptomatic. However, since the virus is highly transmissible, the exposed population also may transmit the virus. The exposed may recover without any symptoms or may become infected. The infected follow the same logic as the previous SEIRD system (they may recover or die). The main difference in the new SEIRD system is in the exposed population and with whom it interacts. The source function f may be defined to represent exposed people who return from travel. Note that \(\beta \) has units (days\(^{-1}\)) while \(\beta _i\) and \(\beta _e\) have units (person\(^{-1}\) days\(^{-1}\)). This difference arrives from the formulation choice. While in Eqs. (5) and (6), the contact terms are normalized by the living population, this normalization does not occur in Eqs. (15) and (16). The first approach is called frequency-dependent formulation, in which the contagion is independent of population density. On the other hand, in the density-dependent formulation, the contagion depends on population density, as the name suggests. Both models may be valid and deliver accurate results, depending on the physical situation.

To better represent what happens in real situations, where the epidemiology changes as the public health guidelines, lockdowns, and health response evolve, it is relevant to consider time and spatially varying parameters. The policies may be different in different cities, as well as it may change with time. Therefore, it is possible to adjust the contact rate and diffusion parameters for each period and location. Connecting the COVID-19 available data to emerging technologies, like physics informed neural networks [44], data-driven inference techniques [50], or Bayesian calibration [29] can help to get insight into the relevant parameters and their spatio-temporal characteristics.

To express this model in the general form given by equation (1), the matrices \(\mathbf {A}\), \(\mathbf {B}\), \(\varvec{\nu }\) and the vector \(\mathbf {f}\) reads,

$$\begin{aligned} \mathbf {A}= & {} \begin{bmatrix} 0 &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} \alpha +\gamma _e &{} 0 &{} 0 &{} 0\\ 0 &{} -\alpha &{} \gamma _i+\delta &{} 0 &{} 0\\ 0 &{} -\gamma _e &{} -\gamma _i &{} 0 &{} 0\\ 0 &{} 0 &{} -\delta &{} 0 &{} 0\\ \end{bmatrix} \end{aligned}$$
(20)
$$\begin{aligned} \mathbf {B}= & {} \begin{bmatrix} 0 &{} \beta _e\left( 1-\frac{A}{n}\right) s &{} \beta _i\left( 1-\frac{A}{n}\right) s &{} 0 &{} 0\\ 0 &{} -\beta _e\left( 1-\frac{A}{n}\right) s &{} -\beta _i\left( 1-\frac{A}{n}\right) s &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0\\ \end{bmatrix} \end{aligned}$$
(21)
$$\begin{aligned} \varvec{\nu }= & {} \begin{bmatrix} \varvec{\nu _s} &{} 0 &{} 0 &{} 0 &{} 0\\ 0 &{} \varvec{\nu _e} &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} \varvec{\nu _i} &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} \varvec{\nu _r} &{} 0\\ 0 &{} 0 &{} 0 &{} 0 &{} 0\\ \end{bmatrix} \end{aligned}$$
(22)
$$\begin{aligned} \varvec{\nu _k}= & {} \begin{bmatrix} \nu ^k_{xx} &{} \nu ^k_{xy}\\ \nu ^k_{yx} &{} \nu ^k_{yy} \end{bmatrix} \text { with } k=s,e,i,r \end{aligned}$$
(23)
$$\begin{aligned} \mathbf {f}= & {} \begin{bmatrix} -f\\ f \\ 0 \\ 0 \\ 0 \\ \end{bmatrix} \end{aligned}$$
(24)

If we assume that the region of interest is isolated, we prescribe the following homogeneous Neumann boundary conditions,

$$\begin{aligned}&\nabla s \cdot \mathbf {n} = 0 \end{aligned}$$
(25)
$$\begin{aligned}&\nabla e \cdot \mathbf {n} = 0 \end{aligned}$$
(26)
$$\begin{aligned}&\nabla i \cdot \mathbf {n} = 0 \end{aligned}$$
(27)
$$\begin{aligned}&\nabla r \cdot \mathbf {n} = 0 \end{aligned}$$
(28)

or simply \((\varvec{\nu } \cdot \nabla \mathbf {u}) \cdot \mathbf {n} = 0\).

2.3 Determination of \(R_0\)

The basic reproduction number, \(R_0\), is defined as the average number of additional infections produced by an infected individual in a wholly susceptible population over the full course of the disease outbreak. In an epidemic situation, the threshold \(R_0 = 1\) is the dividing line between the infection dying out and the onset of an epidemic. \(R_0 > 1\) implies growth of the epidemic, whereas \(R_0 < 1\) implies decay in infectious spread [9].

The concept of \(R_0\) is well-defined for ODE models. However, its extension to a PDE model is unclear, owing to the influence of diffusion. Viguerie et al. [48] found that a \(R_0\) derived for the ODE version of the PDE model is not consistently reliable to represent the epidemic’s dynamic growth adequately. If we do not consider the diffusion, \(R_0\) may be calculated as:

$$\begin{aligned} R_0 = \frac{\beta _es + f}{\alpha + \gamma _e} + \frac{\beta _i\alpha s}{(\alpha +\gamma _e)(\delta +\gamma _i)} \end{aligned}$$
(29)

For further details about the \(R_0\) calculation, refer to [18, 48].

Fig. 1
figure 1

Statistical refinement strategy: elements in hatched areas are flagged to AMR/C process

Fig. 2
figure 2

Adaptive mesh refinement: hierarchy of refined meshes with hanging nodes, where the solution is constrained to enforce continuity

Fig. 3
figure 3

Test 1: Reproducing a compartmental model

Fig. 4
figure 4

Test 1: Values over a centralized horizontal line at t = 365 days

Fig. 5
figure 5

Test 2: Infected initial condition

Fig. 6
figure 6

Test 2: Values over a centralized horizontal line at t = 365 days

Fig. 7
figure 7

Test 2: Infected people at different time-steps (top) and adapted meshes (bottom)

3 Finite element formulation

In this section we briefly introduce the Galerkin finite element formulation, the time discretization, and the the libMesh implementation, supporting adaptive mesh refinement and coarsening. Appendices A and B give respectively the resulting finite element matrices for the generic spatio-temporal SEIRD and COVID-19 models.

Fig. 8
figure 8

Test 3: Susceptible initial condition

Fig. 9
figure 9

Test 3: Infected people at different time-steps (top) and adapted meshes (bottom)

3.1 Space discretization

We introduce a Galerkin finite element variational formulation for space discretization. Without loss of generality, we consider the case of homogeneous Dirichlet and Neumann boundary conditions. Let \(\mathbf {V_u}^h\) be a finite dimensional space such that,

$$\begin{aligned} \begin{aligned}&\mathbf {V_u}^h=\{\mathbf {u}^h(\cdot ,t), \mathbf {w}^h(\cdot ) \in H^1(\varOmega ) |\mathbf {u}^h=0, \\&\mathbf {w}^h=0 \text { on } \varGamma _D\} \end{aligned} \end{aligned}$$
(30)

in which \(\mathbf {u}^h(\cdot ,t)\) is the discrete counterpart of \(\mathbf {u}\) and \(\mathbf {w}^h\) the weight function. The weak formulation is then: find \(\mathbf {u}^h \in \mathbf {V_u}^h\) such that \(\forall \mathbf {w}^h \in \mathbf {V_u}^h\),

$$\begin{aligned}&\begin{aligned}&\left( \mathbf {w}^h,\frac{\partial \mathbf {u}^h}{\partial t}\right) + \bigg (\mathbf {w}^h, \left( \mathbf {A} + \mathbf {B(u}^h)\right) \mathbf {u}^h\bigg )\\&\quad - \bigg (\mathbf {w}^h,\nabla \cdot (\varvec{\nu } \nabla \mathbf {u}^h)\bigg ) - \bigg (\mathbf {w}^h,\mathbf {f}\bigg )=0 \; \text { in }\varOmega \times [0,T] \end{aligned} \end{aligned}$$
(31)
$$\begin{aligned}&\left( \mathbf {w}^h, \mathbf {u}^h(\cdot ,0) \right) = \left( \mathbf {w}^h, \mathbf {u}_0 \right) \text { in }\varOmega \end{aligned}$$
(32)

Here we define the operation \((\cdot ,\cdot )\) as the standard scalar product in \(L^2(\varOmega )\).

3.2 Time integration

The SEIRD and COVID-19 models yield stiff systems of equations, making explicit time-marching methods unfeasible. The Backward Euler method is widely applied because of its unconditional numerical stability characteristics. However, it has the disadvantage of being only first-order accurate, which introduces a significant amount of numerical diffusion. Then, we use the second-order Backward Differentiation Formula (BDF2), which, compared to the prevailing Backward Euler method, has significantly better accuracy while retaining unconditional linear stability. The model becomes,

$$\begin{aligned} \begin{aligned}&\left( \mathbf {w}^h,\frac{1.5\mathbf {u}_{n+1}^h-2\mathbf {u}^h_n + 0.5\mathbf {u}^h_{n-1}}{\varDelta t}\right) \\&\quad + \bigg (\mathbf {w}^h, \left( \mathbf {A} + \mathbf {B(u}_{n+1}^h)\right) \mathbf {u}_{n+1}^h\bigg ) \\&\quad - \bigg (\mathbf {w}^h,\nabla \cdot (\varvec{\nu } \nabla \mathbf {u}_{n+1}^h)\bigg )\\&\quad - \bigg (\mathbf {w}^h,\mathbf {f}_{n+1}\bigg )=0 \text { in }\varOmega \times [0,T] \end{aligned} \end{aligned}$$
(33)

The subscript \({n+1}\) is associated to \(t=t_{n+1}\) and n, and \({n-1}\) to the previous time-steps.

Fig. 10
figure 10

Test 3: Total deaths at t = 365 days

Fig. 11
figure 11

COVID19 Test 1: Compartmental model

Fig. 12
figure 12

COVID19 Test 2: Initial conditions

Fig. 13
figure 13

COVID19 Test 2: Reproducing a 1D model

Fig. 14
figure 14

COVID Test 2: Populations at t = 200 days

3.3 Implementation and adaptive mesh refinement

We implement the compartmental epidemiological models in libMesh, a C++ FEM open-source software library for parallel adaptive finite element applications [36]. libMesh also interfaces with external solver packages like PETSc [4] and Trilinos [46]. Recently, libMesh was also coupled with in-situ visualization and data-analysis tools [11, 45]. It provides a finite element framework that can be used for the numerical simulation of partial differential equations on serial and parallel platforms. This library is an excellent tool for programming the finite element method and can be used for one-, two-, and three-dimensional steady and transient simulations. The libMesh library also has native support for adaptive mesh refinement and coarsening (AMR/C).

Fig. 15
figure 15

COVID19 Test 2: Mesh convergence study (total population by time)

Fig. 16
figure 16

COVID19 Test 2: Mesh convergence study (individuals at t = 90 days)

Fig. 17
figure 17

COVID19 Test 2: Time convergence study (total population by time)

Fig. 18
figure 18

COVID19 Test 2: Time convergence study (individuals at t = 90 days)

Fig. 19
figure 19

COVID Test 3: Populations at different times (top rows) and adapted meshes (bottom)

Multiple scales can be resolved by AMR/C. libMesh supports AMR/C by h-refinement (element subdivision), p-refinement (increasing the polynomial approximation order), and hp-refinement, that is, a combination of both [14]. In libMesh, coarsening is supported in the h, p, and hp AMR/C options. In the present work, we restrict ourselves to h-refinement with hanging nodes. The AMR/C procedure uses a local error estimator to drive the refinement and coarsening procedure, considering the error of an element relative to its neighbor elements in the mesh. This error may come from any variable of the system. As it is standard in libMesh, Kelly\('\)s error indicator is employed, which uses the \(H^1\) seminorm to estimate the error [1]. Apart from the element interior residual, the flux jumps across the inter-element edges influence the element error. The flux jump of each edge is computed and added to the element error contribution. For both the element residual and flux jump, the values of the desired variables at each node are necessary. Therefore, the error \(\left\Vert e \right\Vert ^2\) can be stated as,

$$\begin{aligned} \left\Vert e \right\Vert ^2 = \sum _{i=1}^n \left\Vert e \right\Vert ^2_i \end{aligned}$$
(34)

where \(\left\Vert e \right\Vert ^2_i\) is the error of each variable. In this study, we use all population types as variables for the error estimator.

After computing the error values, the elements are “flagged” for refining and coarsening regarding their relative error. This is done by a statistical element flagging strategy. It is assumed that the element error \(\left\Vert e \right\Vert \) is distributed approximately in a normal probability function. Here, the statistical mean \(\mu _s\) and standard deviation \(\sigma _s\) of all errors are calculated. Whether an element is flagged is depending on a refining (\(r_f\)) and a coarsening (\(c_f\)) fraction. For all errors \(\left\Vert e \right\Vert < \mu _s - \sigma _s c_f\) the elements are flagged for coarsening and for all \(\left\Vert e \right\Vert > \mu _s + \sigma _s r_f\) the elements are marked for refinement (see Fig. 1). The refinement level is limited by a maximum h-level (\(h_{max}\)), (see Fig. 2), and the coarsening is done by h-restitution of sub-elements [14, 33].

4 Numerical results: verification of the generic spatio-temporal SEIRD model

To verify the implementation of the generic spatio-temporal SEIRD model, we have done several tests. For this, we consider a square domain of 1 km \(\times \) 1 km centered at (0, 0) for all tests in this section.

4.1 Test 1: reproducing a compartmental model

In the first test, we do not consider diffusion. We consider a population of 1000 people/km\(^2\) with 1 person/km\(^2\) initially infected in all area of the domain. Then, the initial conditions are: \(s_0=999\), \(e_0 = 0\), \(i_0=1\), \(r_0=0\) and \(d_0=0\). This test aims to reproduce a compartmental simulation of the EPIDEMIC software by using the same initial parameters. The results have to be the same in each point of the domain and the same as the EPIDEMIC software. We set \(\alpha = 0.14286\) days\(^{-1}\), \(\beta = 0.25\) days\(^{-1}\), \(\delta = 0.06666\) days\(^{-1}\), \(\gamma = 0.1\) days\(^{-1}\) and \(\varDelta t =1\) day. The mesh has \(50\times 50\) bilinear quadrilateral elements. Figure 3 shows the comparison of the results, where we can see a very good agreement between both solutions.

Figure 4 shows the results over a centralized horizontal line crossing the domain at t = 365 days. It is possible to see that the results are the same in all the domain, as expected.

4.2 Test 2: initial infected only in a circle region with diffusion

Now, we consider the same parameters of the previous example, but different initial conditions. We consider a population of 1000 people/km\(^2\) in all area of the domain with 1 person/km\(^2\) initially infected only in a circle centered at (0, 0) and radius \(R=0.5\) km, We assume that \(\nu _s = \nu _e = \nu _i = \nu _r = 10^{-8}\) km\(^2\) persons\(^{-1}\) days\(^{-1}\). Then, the initial conditions are: \(s_0=999\), \(e_0 = 0\), \(i_0=1\) for \(R<=0.5\) and \(i_0=0\) for \(R>0\) with \(R=\sqrt{x^2+y^2}\), \(r_0=0\) and \(d_0=0\) (see Fig. 5). We consider adaptive mesh refinement in this example. The original mesh has \(50 \times 50\) bilinear quadrilateral elements, and after the refinement, the smallest element has size 0.005 km. We initially refine the domain in two levels. For the AMR/C procedure, we set \(h_{max}=2\), \(r_f=0.95\), \(c_f=0.05\). We apply the adaptive mesh refinement every 5 time-steps.

Figure 6 shows the results over a centralized horizontal line crossing the domain at t = 365 days. Figure 7 shows the infected people at different time-steps. Note that the infected remains actives in other parts of the domain because of the diffusion. It is possible to see the wave effect of the disease spreading. Note that the AMR/C procedure improves spatial resolution on the regions where the infected people are higher.

4.3 Test 3: varying the population

In this test, we change the initial population. Instead of a constant value in all domain, we set 1000 people/km\(^2\) at the left/top quadrant, 500 people/km\(^2\) at the right/top quadrant, 250 people/km\(^2\) at the left/bottom quadrant and 750 people/km\(^2\) at the right/bottom quadrant (Fig. 8). Then, the initial conditions are: \(s_0=999\) for \(x\le 0\) and \(y>0\), \(s_0=499\) for \(x>0\) and \(y>0\), \(s_0=249\) for \(x\le 0\) and \(y<=\), \(s_0=749\) for \(x>0\) and \(y>0\), \(e_0 = 0\), \(i_0=1\) for \(R\le 0.5\) and \(i_0=0\) for \(R>0\) with \(R=\sqrt{x^2+y^2}\), \(r_0=0\) and \(d_0=0\). The initial population infected is 1 person/km\(^2\) at the same circled region of the previous test. All other parameters are the same of the previous simulation.

Fig. 20
figure 20

COVID Test 3: Populations over a horizontal/vertical line crossing the middle of the domain

Fig. 21
figure 21

COVID Test 3: Time history of the total number of individuals

Fig. 22
figure 22

COVID Test 4: Populations at different times (top rows) and adapted meshes (bottom)

Figure 9 shows the infected people ate different time-steps. It is possible to see that the regions with denser populations (more people/km\(^2\)) are more affected by the disease. Figure 10 shows the total number of deaths after 365 days, and the regions with more people/km\(^2\) have more deaths than the less dense regions. Note also that the AMR/C procedure generates meshes following the model dynamics.

Fig. 23
figure 23

COVID Test 4: Populations over a horizontal line crossing the middle of the domain

Fig. 24
figure 24

COVID Test 4: Populations over a vertical line crossing the middle of the domain

5 Numerical results: verification of the spatio-temporal model of COVID-19 infection spread

In this section, we perform some simulations to validate the spatio-temporal model of COVID-19 infection spread.

5.1 COVID19 Test 1: compartmental model

In this test, we do not consider diffusion. We consider a square domain of 1 km \(\times \) 1 km centered at (0, 0) with a population of 1000 people/km\(^2\), with 1 person/km\(^2\) initially infected and 5 people/km\(^2\) exposed in all area of the domain. Then, the initial conditions are: \(s_0=994\), \(e_0 = 5\), \(i_0=1\), \(r_0=0\) and \(d_0=0\). The aim of this test is to reproduce a compartmental simulation presented in [48] by using the same initial parameters. The results has to be the same in each point of the domain and also the same of the ones given in [48]. We set \(\alpha = 0.125\) days\(^{-1}\), \(\beta _i = \beta _e = 0.005 \) days\(^{-1}\) persons\(^{-1}\), \(\delta = 0.0625\) days\(^{-1}\), \(\gamma _i = 0.041666667\) days\(^{-1}\) and \(\gamma _e = 0.1666667\) days\(^{-1}\). The mesh has \(50\times 50\) bilinear quadrilateral elements. Figure 11 shows the comparison of the results, where we can see an excellent agreement.

5.2 COVID19 Test 2: reproducing a 1D model

In this example, we reproduce a 1D model with quadrilateral elements being the spatial domain \(\varOmega \) given by [0, 1] and a time interval [0, T] with \(T=200\) days. To reproduce a 1D simulation with quadrilateral elements, we fix the element width to 0.0005 and vary its length to find the proper refinement for this case. Therefore, we run a mesh convergence study as well as a time-step convergence study.

For the initial conditions, we set \(s = s_0\) and \(e = e_0\) as follows,

$$\begin{aligned}&\begin{aligned} s_0&= e^{-(x+1)^4}+e^{-\frac{(x-0.35) ^2}{10^{-2}}} \\&\quad +\frac{1}{8}\left( e^{-\frac{(x-0.62)^4}{10^{-5}}}+e^{-\frac{(x-0.52)^4}{10^{-5}}} +e^{-\frac{(x-0.42)^4}{10^{-5}}}\right) \\&\quad + \frac{1}{4}e^{-\frac{(x-0.735)^4}{10^{-5}}} \end{aligned} \end{aligned}$$
(35)
$$\begin{aligned}&e_0=\frac{1}{20}e^{-\frac{(x-0.75)^4}{10^{-5}}} \end{aligned}$$
(36)

Figure 12 shows the initial conditions. We further set \(i_0 = 0\), \(r_0 = 0\), and \(d_0 = 0\). Qualitatively, the initial conditions represent a large population centered around \(x = 0.35\) with no exposed persons and a small population centered around \(x = 0.75\) with some exposed individuals. We also enforce homogeneous Neumann boundary conditions at \(x = 0\) and a zero-population Dirichlet boundary condition at \(x = 1\) for all model compartments. The latter represents a non-populated area at \(x = 1\).

We set \(\alpha = 0.09375\) days\(^{-1}\), \(\beta _i = \beta _e = 0.375\) days\(^{-1}\) persons\(^{-1}\), \(\delta = 0.0046875\) days\(^{-1}\), \(\gamma _i = 0.03125\) days\(^{-1}\) and \(\gamma _e = 0.125\) days\(^{-1}\), \(A=0\), \(\nu _s = 3.75\times 10^{-5}\), \(\nu _e = 0.75\times 10^{-3}\), \(\nu _i = 0.75\times 10^{-10}\) and \(\nu _r = 3.75\times 10^{-5}\) km\(^2\) persons\(^{-1}\) days\(^{-1}\).

Figure 13 shows the comparison of the results with a mesh size \(\varDelta x = 1/500\) and a time-step \(\varDelta t = 0.25\) days. For comparison, we multiply the total number of individuals by 2000, since our element width is 1/2000 and it has influence when integrating the domain. We can observe a very good agreement between both solutions.

5.2.1 Mesh convergence study

We compare numerical solutions computed on successively refined uniform grids with mesh size \(\varDelta x=1/50\), 1/100, 1/250, 1/500, and 1/1000. The time step is \(\varDelta t = 0.25\) days. Figure 15 shows the difference in the total population of each compartment of individuals for the different meshes.

A good resolution is found for \(\varDelta x=1/500\). It is easy to see this convergence in Fig. 16, where the number of individuals of each compartment is plotted at \(t=90\) days.

Fig. 25
figure 25

COVID Test 4: Time history of the total number of individuals

Fig. 26
figure 26

COVID Test 5: Initial susceptible population

5.2.2 Time-step convergence study

We examine the impact of time-step size \(\varDelta t\) on the numerical approximation of the model solution. We consider the time step sizes \(\varDelta t = 1\), \(\varDelta t = 0.5\), \(\varDelta t = 0.25\), \(\varDelta t = 0.125\) and \(\varDelta t = 0.0625\) days. As the results in Sect. 5.2.1 suggested \(\varDelta x =1/500\) is a sufficiently fine spatial discretization, we utilize this mesh resolution here. Figure 17 shows the difference of the total population of each compartment of individuals for the different time-steps.

A good accuracy is found for \(\varDelta t=0.25\) days. It is easy to see how the accuracy improves in Fig. 18, where the number of individuals of each compartment is plotted at \(t=90\) days.

5.3 COVID19 Test 3: reproducing a 2D model

This test is the application of the previous configuration rotated in a two dimensional square with corners at \((-1,-1), (1,-1), (1,1)\) and \((-1,1)\). The initial population is:

$$\begin{aligned}&\begin{aligned} s_0&= e^{-(R+1)^4}+e^{-\frac{(R-0.35) ^2}{10^{-2}}}\\&\quad +\frac{1}{8}\left( e^{-\frac{(R-0.62)^4}{10^{-5}}}+e^{-\frac{(R-0.52)^4}{10^{-5}}} +e^{-\frac{(R-0.42)^4}{10^{-5}}}\right) \\&\quad + \frac{1}{4}e^{-\frac{(R-0.735)^4}{10^{-5}}} \end{aligned} \end{aligned}$$
(37)
$$\begin{aligned}&e_0=\frac{1}{20}e^{-\frac{(R-0.75)^4}{10^{-5}}} \end{aligned}$$
(38)

with \(R=\sqrt{x^2+y^2}\).

The original mesh has \(50\times 50\) bilinear quadrilaterals elements and it is refined in two levels at the beginning of the simulation. For the AMR/C procedure, we set \(h_{max}=2\), \(r_f=0.95\), \(c_f=0.05\). We apply the adaptive mesh refinement every 4 time-steps. The behavior of the transmission has to be similar to the 1D model results, but in a radial configuration. In latex: Figures 19 shows the populations at different time-steps. Figure 20 shows the results over a centralized horizontal line (or vertical because the axisymmetry) crossing the domain at t=200 days. If we compare Figure 20 with Figure 14, it is possible to see that the populations follow a similar behavior.

In Fig. 21 we plot the time history of the total number of individuals. There is a small gain in the total number of individuals (less than 0.1%).

5.4 COVID19 Test 4: Anisotropic diffusion

This test considers anisotropic diffusion in the previous configuration (only in the x direction). Therefore, the populations move spatially only in the x direction. Figure 22 shows the populations at different time-steps. Figure 23 shows the results over a centralized horizontal line crossing the domain, and Fig. 24 over a centralized vertical line. By comparing these two figures, it is clear how the diffusion direction influences the behavior of the virus spread. Since there is no movement of infected or exposed people in the y direction, part of the population does not have contact with the virus because there is no chance of the virus to reach them.

In Fig. 25 we plot the time history of the total number of individuals. We can see a gain in the total number of individuals of less than 0.1%.

5.5 COVID19 Test 5: Random source

This test has a new configuration. We still work with the two dimensional square with corners at \((-1,-1), (1,-1), (1,1)\) and \((-1,1)\) and an anisotropic diffusion only in the x direction. We set \(\alpha = 0.09375\) days\(^{-1}\), \(\beta _i = \beta _e = 0.375 /n\) days\(^{-1}\) persons\(^{-1}\), \(\delta = 0.0046875\) days\(^{-1}\), \(\gamma _i = 0.03125\) days\(^{-1}\) and \(\gamma _e = 0.125\) days\(^{-1}\), \(A=0\), \(\nu _s = 3.75\times 10^{-9}\), \(\nu _e = 0.75\times 10^{-7}\), \(\nu _i = 0.75\times 10^{-14}\) and \(\nu _r = 3.75\times 10^{-9}\) km\(^2\) persons\(^{-1}\) days\(^{-1}\), and \(\varDelta t=0.25\) days.

The original mesh has \(50\times 50\) bilinear quadrilaterals elements and it is refined in two levels at the beginning of the simulation. For the AMR/C procedure, we set \(h_{max}=2\), \(r_f=0.95\), \(c_f=0.05\). We apply the adaptive mesh refinement every 4 time-steps.

The initial population is:

$$\begin{aligned} s_0= & {} max \left\{ \begin{array}{ccc} 100000e^{-\frac{R_1^4}{10^{-2}}}\\ 10000e^{-\frac{R_2^4}{10^{-4}}}\\ 10000e^{-\frac{R_3^4}{10^{-4}}}\\ 1000 \end{array}\right. \end{aligned}$$
(39)
$$\begin{aligned} e_0= & {} 0 \end{aligned}$$
(40)
$$\begin{aligned} i_0= & {} 0 \end{aligned}$$
(41)
$$\begin{aligned} R_1= & {} \sqrt{x^2+y^2} \end{aligned}$$
(42)
$$\begin{aligned} R_2= & {} \sqrt{x^2+(y-0.75)^2} \end{aligned}$$
(43)
$$\begin{aligned} R_3= & {} \sqrt{(x-0.75)^2+y^2} \end{aligned}$$
(44)
Fig. 27
figure 27

COVID Test 5: Example of the random source of exposed people

Figure 26 shows the initial susceptible population. Note there are not infected or exposed people at the initial time. We implement a random source of the exposed population that depends on the number of susceptible people. In all time-steps random nodes of the domain receive a certain number of exposed people. It tries to simulate people who travel and suddenly appear in a region carrying the virus. The random source does not add individuals to the population, but change individuals between susceptible and exposed compartments. Of course, this model is simple. Nevertheless, it demonstrates how to handle a random source term in the equations. Figure 27 shows a example of the random exposed number of people that appears in one time-step.

Fig. 28
figure 28

COVID Test 5: Populations at different times (top rows) and adapted meshes (bottom)

Fig. 29
figure 29

COVID Test 5: Populations over a horizontal line crossing the middle of the domain

Fig. 30
figure 30

COVID Test 5: Populations over a vertical line crossing the middle of the domain

Fig. 31
figure 31

COVID Test 5: Time history of the total number of individuals

Figure 28 shows the populations at different time-steps. We see oscillations in the number of individuals of the populations coming from the random source dynamic. These oscillations are smoothed in the x direction because of the diffusion. We can see this better in Figs. 29 and 30 that shows the results over a centralized horizontal and vertical line crossing the domain, respectively. The vertical plot shows unsmoothed oscillations coming from the random source in the y direction. In this example, it is possible to better seeing the effects of anisotropic diffusion. Note that in the horizontal plot, the populations spread over the x direction, while in the vertical plot, the populations change the compartments but stay in the same coordinates.

In Fig. 31, we plot the time history of the total number of individuals. There is a negligible increase in the total number of individuals (less than 0.1%).

6 Conclusions

We developed an extended continuum SEIRD model to represent the dynamics of the COVID-19 virus spread based on the framework proposed in [47]. We validate our code by comparing our results with other simulations. We introduce new test cases to highlight new modeling capabilities. Among the new features added to the base model, there is the addition of a source term, which represents exposed people who return from travel, by changing individuals from the susceptible compartment to the exposed compartment. We also add the possibility of anisotropic non-homogeneous diffusion. Our code is implemented through the libMesh library and supports adaptive mesh refinement and coarsening. Therefore, it can represent several spatial scales, adapting the resolution to the disease dynamics.

We worked with a transient nonlinear reaction-diffusion system of equations that can also be improved to include advection to represent vectors of motion of the population in specific directions in a given region [21, 24, 52, 53]. For instance, this could model movement to and from certain vacation spots or daily movement between capital and countryside.

Data is essential to define the epidemic spreading parameters, as diffusion and infection rate. We have to study how it would be the best way to represent people who return from travels, addressing questions like defining the probability of a random source appearing in the system, in which area, the population density, among others. Diffusion–reaction models, as the present one, are richer than standard compartmental models. However, they are slower, which hampers their widespread utilization in what-if scenarios, parametric studies, and time-critical situations. Therefore, the development of low-dimensional computational models will leverage the ability of continuous models to perform in real-time scenarios. Projection-based or data-driven model order reduction [10, 43] aims to lower the computational complexity of a given computational model by reducing its dimensionality (or order), can provide this leverage. They can work in conjunction with emerging machine learning methods such as physics informed neural networks [44], data-driven inference techniques to learn parameters [50] or Bayesian calibration [29]. We can foresee a tremendous impact in the mathematical epidemiology field of all these new methods and techniques, enlarging the predictive capabilities and computational efficiency of diffusion–reaction epidemiological models.