-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add advection equation * format * don't save gif * format * adjust tolerance for CI * add test with vector advection velocity
- Loading branch information
1 parent
231f03c
commit a0c9d6b
Showing
11 changed files
with
183 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using KernelInterpolation | ||
using OrdinaryDiffEq | ||
using Plots | ||
|
||
# source term of advection equation | ||
f(t, x, equations) = 0.0 | ||
pde = AdvectionEquation((0.5,), f) | ||
|
||
# initial condition | ||
u(t, x, equations) = exp(-100.0 * (x[1] - equations.advection_velocity[1] * t - 0.3)^2) | ||
|
||
n = 20 | ||
nodeset_inner = homogeneous_hypercube(n, 0.01, 1.0) | ||
# only provide boundary condition at left boundary | ||
nodeset_boundary = NodeSet([0.0]) | ||
g(t, x) = u(t, x, pde) | ||
|
||
kernel = WendlandKernel{1}(3, shape_parameter = 1.0) | ||
sd = Semidiscretization(pde, nodeset_inner, g, nodeset_boundary, u, kernel) | ||
tspan = (0.0, 1.0) | ||
ode = semidiscretize(sd, tspan) | ||
|
||
sol = solve(ode, Rosenbrock23(), saveat = 0.01) | ||
titp = TemporalInterpolation(sol) | ||
|
||
many_nodes = homogeneous_hypercube(200; dim = 1) | ||
|
||
plot() | ||
for t in 0.0:0.2:1.0 | ||
plot!(many_nodes, titp(t), training_nodes = false, linewidth = 2, color = :blue, | ||
label = t == 0.0 ? "numerical" : "") | ||
scatter!(many_nodes, u.(Ref(t), many_nodes, Ref(pde)), linewidth = 2, | ||
linestyle = :dot, color = :red, markersize = 2, | ||
label = t == 0.0 ? "analytical" : "") | ||
end | ||
plot!() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using KernelInterpolation | ||
using OrdinaryDiffEq | ||
using LinearAlgebra: norm | ||
using WriteVTK: WriteVTK, paraview_collection | ||
|
||
# source term of advection equation | ||
f(t, x, equations) = 0.0 | ||
pde = AdvectionEquation((0.5, 0.5, 0.5), f) | ||
|
||
# initial condition | ||
function u(t, x, equations) | ||
exp(-20.0 * norm(x .- equations.advection_velocity .* t .- [0.3, 0.3, 0.3])^2) | ||
end | ||
|
||
n = 10 | ||
nodeset_inner = homogeneous_hypercube(n, 0.01, 1.0; dim = 3) | ||
# don't provide any boundary condition | ||
nodeset_boundary = empty_nodeset(3, Float64) | ||
g(t, x) = 0.0 | ||
|
||
kernel = WendlandKernel{3}(3, shape_parameter = 1.0) | ||
sd = Semidiscretization(pde, nodeset_inner, g, nodeset_boundary, u, kernel) | ||
tspan = (0.0, 1.0) | ||
ode = semidiscretize(sd, tspan) | ||
|
||
sol = solve(ode, Rosenbrock23(), saveat = 0.01) | ||
titp = TemporalInterpolation(sol) | ||
|
||
many_nodes = homogeneous_hypercube(15; dim = 3) | ||
OUT = "out" | ||
ispath(OUT) || mkpath(OUT) | ||
pvd = paraview_collection(joinpath(OUT, "solution")) | ||
for t in sol.t | ||
KernelInterpolation.add_to_pvd(joinpath(OUT, | ||
"advection_3d_basic_$(lpad(round(Int, t * 100), 4, '0'))"), | ||
pvd, t, many_nodes, | ||
titp(t).(many_nodes), u.(Ref(t), many_nodes, Ref(pde)), | ||
keys = ["numerical", "analytical"]) | ||
end | ||
WriteVTK.vtk_save(pvd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters