Startpage >> Main >> ExampleBySilvainAuliac

Example By Silvain Auliac

One-dimensional problems with FreeFem++

You can do it by solving it on a 2D domain while, the solution would just be a constant continuation of the function with respect to \(y\). In the following piece of code, the \([0,1]\) interval is emulated by a rectangle with small size along the \(y\) direction.

It is perhaps wiser to use periodic fespace function with respect to \(x\) in case of Neumann boundary conditions, that is:

fespace Vh(Th,P1,periodic=[[1,x],[3,x]]);

than:

fespace Vh(Th,P1);

Basic mesh for the 1d problem1d Solution

download example : Lap1D.edp or return to 1d examples

int np=100;
mesh Th = square(np,1,[x,y/50]); //transformation for viewing comfort
plot(Th,wait=1,aspectratio=1);
fespace Vh(Th,P1);
Vh u,v;
func f=1.;
solve Laplace1D(u,v) = int2d(Th)(dx(u)*dx(v)) - int2d(Th)(v*f) + on(2,4,u=0.);
plot(u,wait=1,dim=3,fill=1);

return to 1d examples

Page last modified on June 27, 2018, at 03:47 PM