changeset 73:7c74e99fb548

Rename the files * test_Laplace.m -> Poisson.m * Laplace.ufl -> Poisson.ufl * test_biharmonic.m -> Biharmonic.m * Heat.ufl -> Evolution.ufl * test_heat.m -> Evolution.m
author gedeone-octave <marco.vassallo@outlook.com>
date Mon, 29 Jul 2013 22:55:03 +0200
parents 98fd451fc822
children d123adbe296b
files example/Biharmonic.m example/Evolution.m example/Evolution.ufl example/Heat.ufl example/Laplace.ufl example/Poisson.m example/Poisson.ufl example/test_biharmonic.m example/test_heat.m example/test_laplace.m
diffstat 10 files changed, 124 insertions(+), 194 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/Biharmonic.m	Mon Jul 29 22:55:03 2013 +0200
@@ -0,0 +1,28 @@
+pkg load msh
+pkg load fem-fenics
+
+fem_init_env ();
+problem = 'Biharmonic';
+fem_create_all (problem);
+
+x = y = linspace (0, 1, 32);
+msho = msh2m_structured_mesh (x, y, 1, 1:4);
+mshd = fem_init_mesh (msho);
+
+V  = fem_fs_Biharmonic (mshd);
+
+bc = fem_bc (V, @(x,y) 0, 1:4);
+ 
+
+f = fem_coeff ('f', @(x,y) 4.0*pi^4.*sin(pi.*x).*sin(pi.*y));
+
+g = fem_coeff ('alpha', @(x,y) 8);
+
+A = fem_rhs_Biharmonic (V, bc, g);
+b = fem_lhs_Biharmonic (V, bc, f );
+
+u = A \ b;
+
+
+func = fem_func ('u', V, u);
+fem_plot (func);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/Evolution.m	Mon Jul 29 22:55:03 2013 +0200
@@ -0,0 +1,41 @@
+pkg load msh
+pkg load fem-fenics
+
+
+fem_init_env ();
+problem = 'Evolution';
+fem_create_all (problem);
+
+msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4);
+mshd = fem_init_mesh (msho);
+
+V  = fem_fs_Evolution (mshd);
+
+bc = fem_bc (V, @(x,y) 1, 1:4);
+
+t = 0;
+dt = 0.01;
+T = 0.3;
+
+k = fem_coeff ('dt', @(x,y) dt);
+
+u0 = fem_coeff ('u0', @(x,y) 10*exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02));
+
+A = fem_rhs_Evolution (V, bc, k);
+
+# solve the problem for each time step
+# We need to update only the lhs
+while t < T
+  t += dt;
+
+  # we can pass u0 to the lhs indifferently as a fem_coeff or
+  # as a fem_func
+  b = fem_lhs_Evolution (V, k, u0, bc);
+
+  u = A \ b;
+ 
+  u0 = fem_func ('u0', V, u);
+
+  #press Q to make the plot continue
+  fem_plot (u0);
+end  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/Evolution.ufl	Mon Jul 29 22:55:03 2013 +0200
@@ -0,0 +1,12 @@
+element = FiniteElement("Lagrange", triangle, 1)
+
+u = TrialFunction(element)
+v = TestFunction(element)
+
+u0 = Coefficient(element)
+
+dt = Constant(triangle)
+
+eq = (1/dt)*(u-u0)*v*dx + inner(grad(u), grad(v))*dx
+a = rhs (eq)
+L = lhs (eq)
--- a/example/Heat.ufl	Sun Jul 28 18:28:46 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-element = FiniteElement("Lagrange", triangle, 1)
-
-u = TrialFunction(element)
-v = TestFunction(element)
-
-u0 = Coefficient(element)
-f = Coefficient(element)
-g = Coefficient(element)
-k = Constant(triangle)
-
-eq = (1/k)*(u-u0)*v*dx + inner(grad(u), grad(v))*dx -f*v*dx - g*v*ds
-a = rhs (eq)
-L = lhs (eq)
--- a/example/Laplace.ufl	Sun Jul 28 18:28:46 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-# Copyright (C) 2005-2009 Anders Logg
-element = FiniteElement("Lagrange", triangle, 1)
-
-
-u = TrialFunction(element)
-v = TestFunction(element)
-
-f = Coefficient(element)
-g = Coefficient(element)
-
-a = inner(grad(u), grad(v))*dx
-L = f*v*dx + g*v*ds
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/Poisson.m	Mon Jul 29 22:55:03 2013 +0200
@@ -0,0 +1,31 @@
+pkg load msh
+pkg load fem-fenics
+
+fem_init_env ();
+problem = 'Poisson';
+fem_create_all (problem);
+
+ 
+
+x = y = linspace (0, 1, 32);
+msho = msh2m_structured_mesh (x, y, 1, 1:4);
+mshd = fem_init_mesh (msho);
+
+V  = fem_fs_Poisson (mshd);
+
+bc = fem_bc (V, @(x,y) 0, [2, 4]);
+
+f = fem_coeff ('f', @(x,y) 10*exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02));
+g = fem_coeff ('g', @(x,y) sin (5.0 * x));
+
+A = fem_rhs_Poisson (V, bc);
+b = fem_lhs_Poisson (V, f, g, bc);
+
+u = A \ b;
+
+
+func = fem_func ('u', V, u);
+
+fem_plot (func);
+
+fem_save (func, problem);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/Poisson.ufl	Mon Jul 29 22:55:03 2013 +0200
@@ -0,0 +1,12 @@
+# Copyright (C) 2005-2009 Anders Logg
+element = FiniteElement("Lagrange", triangle, 1)
+
+
+u = TrialFunction(element)
+v = TestFunction(element)
+
+f = Coefficient(element)
+g = Coefficient(element)
+
+a = inner(grad(u), grad(v))*dx
+L = f*v*dx + g*v*ds
--- a/example/test_biharmonic.m	Sun Jul 28 18:28:46 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-# We follow the dolfin example for the Biharmonic problem
-# See (http://fenicsproject.org/documentation/dolfin/1.2.0/cpp/demo/pde/biharmonic/cpp/documentation.html#index-0)
-
-# initialize the environment and create function related to the problem
-# defined inside Biharmonic.ufl
-pkg load msh
-pkg load fem-fenics
-fem_init_env ();
-problem = 'Biharmonic';
-fem_create_fs (problem);
-fem_create_rhs (problem);
-fem_create_lhs (problem);
-
-# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4
-x = y = linspace (0, 1, 32);
-msho = msh2m_structured_mesh (x, y, 1, 1:4);
-mshd = fem_init_mesh (msho);
-
-V  = fem_fs_Biharmonic (mshd);
-
-# fem_bc takes as input the functionspace V, a function handler f,
-# and the sides where we want to apply the condition
-# The value on each point of the boundary is computed using
-# the eval method available inside expression.h
-f = @(x,y) 0;
-bc = fem_bc (V, f, 1:4);
-
-# fem_coeff takes as input a string and a function handler
-# and is used below to set the value of the coefficient of the rhs
-
-ff = @(x,y) 4.0*pi^4.*sin(pi.*x).*sin(pi.*y);
-f = fem_coeff ('f', ff);
-
-gg = @(x,y) 8;
-alpha = fem_coeff ('alpha', gg);
-
-# fem_rhs and fem_lhs takes as input the functionspace V, and the
-# boundarycondition bc and solve the Poisson problem with
-# the velues specified inside f and alpha;
-A = fem_rhs_Biharmonic (V, alpha, bc);
-
-b = fem_lhs_Biharmonic (V, f, bc);
-
-u = A \ b;
-
-func = fem_func ('u', V, u);
-
-fem_plot (func);
-
-fem_save (func, problem);
--- a/example/test_heat.m	Sun Jul 28 18:28:46 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-# We follow the evolutionary heat equation specified in the file Heat.ufl
-
-pkg load msh
-pkg load fem-fenics
-fem_init_env ();
-problem = 'Heat';
-fem_create_fs (problem);
-fem_create_rhs (problem);
-fem_create_lhs (problem);
-
-# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4
-msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4);
-mshd = fem_init_mesh (msho);
-
-V  = fem_fs_Heat (mshd);
-
-# fem_bc takes as input the functionspace V, a function handler f,
-# and the sides where we want to apply the condition
-# The value on each point of the boundary is computed using
-# the eval method available inside expression.h
-# if a side is not specified, Neumann conditions are applied
-# with g specified below
-f = @(x,y) 0;
-bc = fem_bc (V, f, 1:4);
-
-# fem_coeff takes as input a string and a function handler
-# and is used below to set the value of the coefficient of the rhs
-
-ff = @(x,y) 0;
-f = fem_coeff ('f', ff);
-
-gg = @(x,y) 0;
-g = fem_coeff ('g', gg);
-
-# fem_rhs and fem_lhs takes as input the functionspace V, and the
-# boundarycondition bc and solve the Poisson problem with
-# the velues specified inside f and g;
-t = 0;
-dt = 0.05;
-T = 3;
-
-kk = @(x,y) dt;
-k = fem_coeff ('k', kk);
-
-A = fem_rhs_Heat (V, bc, k);
-
-uu = @(x,y) 10*exp(-((x - 0.5).^2 + (y - 0.5).^2) / 0.02);
-u0 = fem_coeff ('u0', uu);
-
-# solve the problem for each time step
-# We need to update only the lhs
-while t < T
-  t += dt;
-  b = fem_lhs_Heat (V, f, g, k, u0, bc);
-
-  u = A \ b;
-
-  u0 = fem_func ('u0', V, u);
-  fem_plot (u0);
-#  fem_save (u0, num2str(t));
-end
--- a/example/test_laplace.m	Sun Jul 28 18:28:46 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-# We follow the dolfin example for the Poisson problem
-#    -div ( grad (u) ) = f      on omega
-#                    u = h      on gamma_d;
-#                du/dn = g      on gamma_n;
-# See (http://fenicsproject.org/documentation/dolfin/1.2.0/cpp/demo/pde/poisson/cpp/documentation.html#index-0)
-
-
-pkg load msh
-pkg load fem-fenics
-
-# initialize the environment and create function related to the problem
-# defined inside Laplace.ufl
-fem_init_env ();
-problem = 'Laplace';
-fem_create_fs (problem);
-fem_create_rhs (problem);
-fem_create_lhs (problem);
-
-# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4
-msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4);
-mshd = fem_init_mesh (msho);
-
-V  = fem_fs_Laplace (mshd);
-
-# fem_bc takes as input the functionspace V, a function handler f,
-# and the sides where we want to apply the condition
-# The value on each point of the boundary is computed using
-# the eval method available inside expression.h
-# if a side is not specified, Neumann conditions are applied
-# with g specified below
-f = @(x,y) 0;
-bc = fem_bc (V, f, [2, 4]);
-
-# fem_coeff takes as input a string and a function handler
-# and is used below to set the value of the coefficient of the rhs
-
-ff = @(x,y) 10*exp(-((x - 0.5).^2 + (y - 0.5).^2) / 0.02);
-f = fem_coeff ('f', ff);
-
-gg = @(x,y) sin (5.0 * x);
-g = fem_coeff ('g', gg);
-
-# fem_rhs and fem_lhs takes as input the functionspace V, and the
-# boundarycondition bc and solve the Lapalce problem with
-# the velues specified inside f and g;
-A = fem_rhs_Laplace (V, bc);
-
-b = fem_lhs_Laplace (V, f, g, bc);
-
-u = A \ b;
-
-# fem_func create a function object which can be plotted, saved or
-#  used to set the coefficient of the lhs/rhs
-func = fem_func ('u', V, u);
-
-fem_plot (func);
-
-fem_save (func, problem);