Skip to content
This repository was archived by the owner on Sep 28, 2024. It is now read-only.

Commit 5e289dd

Browse files
committed
fem complete
update README and format
1 parent 63f0c58 commit 5e289dd

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

example/Burgers_FEM/Project.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name = "Burgers_FEM"
2+
uuid = "e5170f7b-8a26-429b-971b-688deff48327"
3+
authors = ["Yueh-Hua Tu"]
4+
version = "0.1.0"
5+
6+
[deps]
7+
FEniCS = "186dfeec-b415-5c13-8e76-5fbf19f56f9b"
8+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
9+
10+
[compat]
11+
julia = "1.6"
12+
13+
[extras]
14+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
15+
16+
[targets]
17+
test = ["Test"]

example/Burgers_FEM/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Burgers' equation resolved by finite element method
2+
3+
This example exhibits PDE problem for Burgers' equation resolved by finite element method. Change directory to `example/Burgers_FEM` and use following commend to solve the problem:
4+
5+
```julia
6+
$ julia --proj
7+
8+
julia> using Burgers_FEM; Burgers_FEM.run_fem()
9+
```
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module Burgers_FEM
2+
3+
using FEniCS
4+
5+
function run_fem= 1 / 1000)
6+
# parameters
7+
s = 1024 # x
8+
steps = 200 # t
9+
10+
DT = Constant(1 / steps)
11+
dt = 1 / steps
12+
13+
mesh = UnitIntervalMesh(s)
14+
V = FunctionSpace(mesh, "CG", 1)
15+
16+
bc = DirichletBC(V, 0.0, "on_boundary")
17+
18+
u_init = Expression("x[0]", degree = 1)
19+
u = TrialFunction(V)
20+
u_old = FeFunction(V)
21+
v = TestFunction(V)
22+
23+
u = interpolate(u_init, V)
24+
assign(u_old, u)
25+
26+
f = Expression("0.0", degree = 0)
27+
28+
F = (dot(u - u_old, v) / DT
29+
+ ν * inner(grad(u), grad(v))
30+
+ inner(u * directional_derivative(u, 0), v)
31+
-
32+
dot(f, v)) * dx
33+
34+
us = Vector{Float64}[]
35+
t = 0.0
36+
for n in 1:steps
37+
t = t + dt
38+
nlvsolve(F, u, bc)
39+
push!(us, get_array(u))
40+
assign(u_old, u)
41+
end
42+
43+
return us
44+
end
45+
46+
end

example/Burgers_FEM/test/runtests.jl

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Burgers_FEM
2+
using Test
3+
4+
@testset "Burgers_FEM.jl" begin
5+
# Write your tests here.
6+
end

test/runtests.jl

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ end
2727
 l、゙ ~ヽ
2828
 じしf_, )ノ
2929
=#
30+
# Want some fish?

0 commit comments

Comments
 (0)