This repository was archived by the owner on Sep 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
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" ]
Original file line number Diff line number Diff line change
1
+ # Burgers_FEM
2
+
3
+ [ ![ Stable] ( https://img.shields.io/badge/docs-stable-blue.svg )] ( https://yuehhua.github.io/Burgers_FEM.jl/stable )
4
+ [ ![ Dev] ( https://img.shields.io/badge/docs-dev-blue.svg )] ( https://yuehhua.github.io/Burgers_FEM.jl/dev )
5
+ [ ![ Build Status] ( https://github.com/yuehhua/Burgers_FEM.jl/actions/workflows/CI.yml/badge.svg?branch=main )] ( https://github.com/yuehhua/Burgers_FEM.jl/actions/workflows/CI.yml?query=branch%3Amain )
6
+ [ ![ Coverage] ( https://codecov.io/gh/yuehhua/Burgers_FEM.jl/branch/main/graph/badge.svg )] ( https://codecov.io/gh/yuehhua/Burgers_FEM.jl )
Original file line number Diff line number Diff line change
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. , " 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
+ - dot (f, v)
32
+ )* 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
Original file line number Diff line number Diff line change
1
+ using Burgers_FEM
2
+ using Test
3
+
4
+ @testset " Burgers_FEM.jl" begin
5
+ # Write your tests here.
6
+ end
You can’t perform that action at this time.
0 commit comments