Skip to content

Commit 1b0ae15

Browse files
committed
minor changes in transient driver
1 parent 1908e8a commit 1b0ae15

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/poisson_transient.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# ## Introduction
22

3-
# In this tutorial we will learn how to use [`GridapODEs.jl`](https://github.com/gridap/GridapODEs.jl) to solve the transient PDEs by solving the *heat equation*, equivalent to the transient Poisson equation.
3+
# In this tutorial we will learn how to use [`GridapODEs.jl`](https://github.com/gridap/GridapODEs.jl) for approximating transient PDEs by using time marching schemes (method of lines). We consider the *heat equation*, a.k.a. the transient Poisson equation.
44

5-
# We will focus on the time discretization on the equations, assuming that the reader is familiar with the spatial Finite Element discretization given in [tutorial 1](https://gridap.github.io/Tutorials/stable/pages/t001_poisson/).
5+
# We will focus on the time discretization on the equations, assuming that the reader is familiar with the `Gridap` API for spatial finite element discretizations. See, e.g., [tutorial 1](https://gridap.github.io/Tutorials/stable/pages/t001_poisson/) for more details.
66

77
# ## Problem statement
88

9-
# We solve the heat equation in a 2-dimensional domain defined by a square with Homogenous Dirichlet boundaries, $\Gamma_D$. We consider a time-dependent conductivity $\kappa(t)=1.0 + 0.95\sin(2\pi t)$, a time-dependent volumetric forcing term $f(t) = \sin(\pi t)$ and a constant Homogenous boundary condition $g = 0.0$. The initial solution is $u(x,0) = u_0 = 0$. With these definitions, the strong form of the problem reads:
9+
# We solve the heat equation in a 2-dimensional domain $\Omega$, the unit square, with Homogenous Dirichlet boundaries on the whole boundary $\partial \Omega$. We consider a time-dependent conductivity $\kappa(t)=1.0 + 0.95\sin(2\pi t)$, a time-dependent volumetric forcing term $f(t) = \sin(\pi t)$ and a constant Homogenous boundary condition $g = 0.0$. The initial solution is $u(x,0) = u_0 = 0$. With these definitions, the strong form of the problem reads:
1010

1111
# ```math
1212
# \left\lbrace
@@ -18,13 +18,13 @@
1818
# \right.
1919
# ```
2020

21-
# The weak form of the problem will read: find $u(t)\in U_g(t)$ such that
21+
# The weak form of the problem reads: find $u(t)\in U_g(t)$ such that
2222

2323
# ```math
2424
# m(t,u,v) + a(t,u,v) = b(t,v)\quad \forall v\in \ V
2525
# ```
2626

27-
# Note that $U_g(t)$ is a transient FE space, in the sense that Dirichlet boundary value of functions in $U_g$ can change in time. The definition of $m(u,v)$, $a(u,v)$ and $b(v)$ is as follows:
27+
# Note that $U_g(t)$ is a transient FE space, in the sense that Dirichlet boundary value of functions in $U_g$ _can_ change in time (even though this is not the case in this tutorial). The definition of $m(u,v)$, $a(u,v)$ and $b(v)$ is as follows:
2828

2929
# ```math
3030
# \begin{aligned}
@@ -42,7 +42,7 @@ using GridapODEs
4242
using GridapODEs.ODETools
4343
using GridapODEs.TransientFETools
4444

45-
# Without going into the details we define the `DiscreteModel` and the `Triangulation`, as it is detailed in [tutorial 2](https://gridap.github.io/Tutorials/stable/pages/t002_validation/).
45+
# First, we define the `DiscreteModel` and the `Triangulation`. More details on this can be found in [tutorial 2](https://gridap.github.io/Tutorials/stable/pages/t002_validation/).
4646

4747

4848
𝒯 = CartesianDiscreteModel((0,1,0,1),(20,20))
@@ -64,7 +64,7 @@ U = TransientTrialFESpace(V,g)
6464

6565
# ## Weak form
6666

67-
# The weak form of the problem follows the same structure as other `Gridap` tutorials, where we define the bilinear and linear forms to define the `FEOperator`. In this case we need to deal with time-dependent quantities and with the presence of time derivatives. The former is handled by passing the time, $t$, as an additional argument to the form, i.e. $a(t,u,v)$. The later is defined using the time derivative operator `∂t`.
67+
# The weak form of the problem follows the same structure as other `Gridap` tutorials, where we define the bilinear and linear forms to define the `FEOperator`. In this case we need to deal with time-dependent quantities and with the presence of time derivatives. The former is handled by passing the time, $t$, as an additional argument to the form, i.e. $a(t,u,v)$. The latter is defined using the time derivative operator `∂t`.
6868

6969
# The most general way of constructing a transient FE operator is by using the `TransientFEOperator` function, which receives a residual, a jacobian with respect to the unknown and a jacobian with respect to the time derivative.
7070
κ(t) = 1.0 + 0.95*sin(2π*t)
@@ -74,7 +74,7 @@ jac(t,u,du,v) = ∫( κ(t)*(∇(du)⋅∇(v)) )dΩ
7474
jac_t(t,u,duₜ,v) = ( duₜ*v )dΩ
7575
op = TransientFEOperator(res,jac,jac_t,U,V)
7676

77-
# We can also take advantage of automatic differentitation techniques and use the `TransientFEOperator` function sending only the residual.
77+
# We can also take advantage of automatic differentiation techniques to compute both Jacobians and use the `TransientFEOperator` function sending just the residual.
7878
op_AD = TransientFEOperator(res,U,V)
7979

8080
# Alternatively, we can exploit the fact that the problem is linear and use the transient Affine FE operator signature `TransientAffineFEOperator`. In that case, we send a form for the mass contribution, $m$, a form for the stiffness contribution, $a$, and the forcing term, $b$.
@@ -96,7 +96,7 @@ op_C = TransientConstantFEOperator(m,a,b,U,V)
9696

9797
# ## Transient solver
9898

99-
# Once we have the FE operator defined, we proceed with the definition of the transient solver. First, we define a linear solver to be used at each time step. Here we use the `LUSolver`, but other choices could be made.
99+
# Once we have the FE operator defined, we proceed with the definition of the transient solver. First, we define a linear solver to be used at each time step. Here we use the `LUSolver`, but other choices are possible.
100100
linear_solver = LUSolver()
101101

102102
# Then, we define the ODE solver. That is, the scheme that will be used for the time integration. In this tutorial we use the `ThetaMethod` with $\theta = 0.5$, resulting in a 2nd order scheme. The `ThetaMethod` function receives the linear solver, the time step size $\Delta t$ (constant) and the value of $\theta $.
@@ -112,7 +112,7 @@ uₕₜ = solve(ode_solver,op,u₀,t₀,T)
112112

113113
# ## Postprocessing
114114

115-
# We should highlight that `uₕₜ` is just an iterable function and the results at each time steps are only computed when iterating over it. We can post-process the results and generate the corresponding `vtk` files using the `createpvd` and `createvtk` functions. The former will create a `.pvd` file with the collection of `.vtu` files saved at each time step by `createvtk`. This can be done as follows:
115+
# We should highlight that `uₕₜ` is just an _iterable_ function and the results at each time steps are only computed when iterating over it, i.e., lazily. We can post-process the results and generate the corresponding `vtk` files using the `createpvd` and `createvtk` functions. The former will create a `.pvd` file with the collection of `.vtu` files saved at each time step by `createvtk`. The computation of the problem solutions will be triggered in the following loop:
116116
createpvd("poisson_transient_solution") do pvd
117117
for (uₕ,t) in uₕₜ
118118
pvd[t] = createvtk(Ω,"poisson_transient_solution_$t"*".vtu",cellfields=["u"=>uₕ])

0 commit comments

Comments
 (0)