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

Commit

Permalink
fem complete
Browse files Browse the repository at this point in the history
  • Loading branch information
yuehhua committed Nov 25, 2021
1 parent ad6b55e commit 9918df6
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
17 changes: 17 additions & 0 deletions example/Burgers_FEM/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name = "Burgers_FEM"
uuid = "e5170f7b-8a26-429b-971b-688deff48327"
authors = ["Yueh-Hua Tu"]
version = "0.1.0"

[deps]
FEniCS = "186dfeec-b415-5c13-8e76-5fbf19f56f9b"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"

[compat]
julia = "1.6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
6 changes: 6 additions & 0 deletions example/Burgers_FEM/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Burgers_FEM

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://yuehhua.github.io/Burgers_FEM.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://yuehhua.github.io/Burgers_FEM.jl/dev)
[![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)
[![Coverage](https://codecov.io/gh/yuehhua/Burgers_FEM.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/yuehhua/Burgers_FEM.jl)
46 changes: 46 additions & 0 deletions example/Burgers_FEM/src/Burgers_FEM.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module Burgers_FEM

using FEniCS

function run_fem=1/1000)
# parameters
s = 1024 # x
steps = 200 # t

DT = Constant(1/steps)
dt = 1/steps

mesh = UnitIntervalMesh(s)
V = FunctionSpace(mesh, "CG", 1)

bc = DirichletBC(V, 0., "on_boundary")

u_init = Expression("x[0]", degree=1)
u = TrialFunction(V)
u_old = FeFunction(V)
v = TestFunction(V)

u = interpolate(u_init, V)
assign(u_old, u)

f = Expression("0.0", degree=0)

F = (dot(u - u_old, v) / DT
+ ν*inner(grad(u), grad(v))
+ inner(u*directional_derivative(u, 0), v)
- dot(f, v)
)*dx

us = Vector{Float64}[]
t = 0.0
for n in 1:steps
t = t + dt
nlvsolve(F, u, bc)
push!(us, get_array(u))
assign(u_old, u)
end

return us
end

end
6 changes: 6 additions & 0 deletions example/Burgers_FEM/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Burgers_FEM
using Test

@testset "Burgers_FEM.jl" begin
# Write your tests here.
end

0 comments on commit 9918df6

Please sign in to comment.