Skip to content

Commit c2584aa

Browse files
authored
Update transient_heat_equation.jl
1 parent 5e24185 commit c2584aa

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

docs/src/literate-tutorials/transient_heat_equation.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@
5454
# In this example we apply the boundary conditions to the assembled discrete operators (mass matrix $\mathbf{M}$ and stiffnes matrix $\mathbf{K}$)
5555
# only once. We utilize the fact that in finite element computations Dirichlet conditions can be applied by
5656
# zero out rows and columns that correspond
57-
# to a prescribed dof in the system matrix ($\mathbf{A} = Δt \mathbf{K} + \mathbf{M}$) and setting the value of the right-hand side vector to the value
58-
# of the Dirichlet condition. Thus, we only need to apply in every time step the Dirichlet condition to the right-hand side of the problem. For more details
59-
# on the derivation and discretisation, see the [Introduction to FEM](@ref fe-intro).
57+
# to a prescribed dof in the system matrix ($\mathbf{A} = Δt \mathbf{K} + \mathbf{M}$) and setting the value of the
58+
# right-hand side vector to the value of the Dirichlet condition. Thus, we only need to apply in every time step the
59+
# Dirichlet condition to the right-hand side of the problem. For more details
60+
# on the derivation and discretisation, see [Introduction to FEM](@ref fe-intro).
6061
#-
6162
# ## Commented program
6263
#
@@ -108,7 +109,8 @@ close!(ch)
108109
update!(ch, 0.0);
109110

110111
# ### Assembling the linear system
111-
# As in the [heat equation example](@ref heat_equation.jl) we define a `doassemble!` function that assembles the diffusion and diffusive parts of the equation:
112+
# As in the [heat equation example](@ref heat_equation.jl) we define a `doassemble!` function that assembles the
113+
# diffusion and diffusive parts of the equation:
112114
function doassemble!(K::SparseMatrixCSC, M::SparseMatrixCSC, f::Vector, cellvalues::CellValues, dh::DofHandler)
113115

114116
n_basefuncs = getnbasefunctions(cellvalues)
@@ -118,15 +120,15 @@ function doassemble!(K::SparseMatrixCSC, M::SparseMatrixCSC, f::Vector, cellvalu
118120

119121
assembler = start_assemble(K, f)
120122
assembler_M = start_assemble(M)
121-
123+
122124
for cell in CellIterator(dh)
123125

124126
fill!(Ke, 0)
125127
fill!(Me, 0)
126128
fill!(fe, 0)
127129

128130
reinit!(cellvalues, cell)
129-
131+
# assemble local contributions
130132
for q_point in 1:getnquadpoints(cellvalues)
131133
= getdetJdV(cellvalues, q_point)
132134

@@ -142,13 +144,14 @@ function doassemble!(K::SparseMatrixCSC, M::SparseMatrixCSC, f::Vector, cellvalu
142144
end
143145
end
144146
end
145-
147+
# update global matrices
146148
assemble!(assembler, celldofs(cell), Ke, fe)
147149
assemble!(assembler_M, celldofs(cell), Me)
148150
end
149151
return K, M, f
150152
end
151153
#md nothing # hide
154+
152155
# ### Solution of the system
153156
# We first assemble all parts in the prior allocated `SparseMatrixCSC`.
154157
K, M, f = doassemble!(K, M, f, cellvalues, dh)

0 commit comments

Comments
 (0)