view inst/example/Poisson/Poisson.m @ 164:7190852cf57f

Update the examples giving two input parameters to the BilinearForm.
author gedeone-octave <marcovass89@hotmail.it>
date Sat, 05 Oct 2013 10:40:06 +0100
parents d03d998e64af
children e85390ed620d
line wrap: on
line source

pkg load fem-fenics msh
import_ufl_Problem ('Poisson')

# Create mesh and define function space
x = y = linspace (0, 1, 33);
mesh = Mesh(msh2m_structured_mesh (x, y, 1, 1:4));

V = FunctionSpace('Poisson', mesh);

# Define boundary condition
bc = DirichletBC(V, @(x, y) 0.0, [2;4]);

f = Expression ('f', @(x,y) 10*exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02));
g = Expression ('g', @(x,y) sin (5.0 * x));

a = BilinearForm ('Poisson', V, V);
L = LinearForm ('Poisson', V, f, g);

# Compute solution
[A, b] = assemble_system (a, L, bc);
sol = A \ b;
u = Function ('u', V, sol);

# Save solution in VTK format
save (u, 'poisson')

# Plot solution
plot (u);