Skip to content
Snippets Groups Projects
Commit cfcf27f4 authored by Stephan Hilb's avatar Stephan Hilb
Browse files

add poisson-source example

parent 0f92c00b
No related branches found
No related tags found
No related merge requests found
using LinearAlgebra: dot, norm
using SemiSmoothNewton
using SemiSmoothNewton: vtk_mesh, vtk_append!, vtk_save
# simple 2d unit square triangulation
mesh = init_grid(32, 32)
# scalar piecewise linear continuous elements
space = FeSpace(mesh, P1(), (1,))
u = FeFunction(space, name = "u")
# inhomogenity
const p = (0.25, 0.5)
f(x) = 5 * exp(-5 * norm(x .- p)^2)
# parameter
const lambda = 19.7
# weak formulation
a(x, u, d_u, phi, d_phi) =
dot(d_u, d_phi) + lambda^2 * dot(u, phi)
l(x, phi, d_phi) =
dot(f(x), phi)
# solve u
A, b = assemble(space, a, l)
u.data .= A \ b
# vtk output
vtk = vtk_mesh("output.vtu", mesh)
vtk_append!(vtk, u)
vtk_save(vtk)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment