Mercurial > fem-fenics-eugenio
changeset 85:8084ecfaa2b7
Maint: old test are moved in the obsolete folder
author | gedeone-octave <marcovass89@hotmail.it> |
---|---|
date | Sat, 03 Aug 2013 14:49:56 +0200 |
parents | 98297c182dfa |
children | 66e4aa87c9a1 |
files | obsolete/test/Laplace.ufl obsolete/test/Makefile obsolete/test/laplace.m obsolete/test/mesh_test.m obsolete/test/test_all.m obsolete/test/test_bc.cpp obsolete/test/test_bc.m obsolete/test/test_coeff.cpp obsolete/test/test_coeff.m obsolete/test/test_expr.cpp obsolete/test/test_expr.m obsolete/test/test_rlhs.cc obsolete/test/test_rlhs.m test/Laplace.ufl test/Makefile test/laplace.m test/mesh_test.m test/test_all.m test/test_bc.cpp test/test_bc.m test/test_coeff.cpp test/test_coeff.m test/test_expr.cpp test/test_expr.m test/test_rlhs.cc test/test_rlhs.m |
diffstat | 26 files changed, 656 insertions(+), 656 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/Laplace.ufl Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,36 @@ +# Copyright (C) 2005-2009 Anders Logg +# +# This file is part of DOLFIN. +# +# DOLFIN is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# DOLFIN is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. +# +# First added: 2005 +# Last changed: 2011-03-08 +# +# The bilinear form a(u, v) and linear form L(v) for +# Poisson's equation. +# +# Compile this form with FFC: ffc -l dolfin Poisson.ufl. + + +element = FiniteElement("Lagrange", triangle, 1) +# element = FiniteElement("Lagrange", tetrahedron, 2) + +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/obsolete/test/Makefile Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,38 @@ +MKOCTFILE ?= mkoctfile + +OCTFILES=test_expr.oct test_bc.oct test_coeff.oct test_rlhs.oct + +LIBS += -ldolfin + +all: $(OCTFILES) + +test_expr.oct: test_expr.o + $(MKOCTFILE) -s ../src/fem_init_env.o test_expr.o -o $@ $(LDFLAGS) $(LIBS) + +test_expr.o: test_expr.cpp Laplace.h + $(MKOCTFILE) -c test_expr.cpp $(LDFLAGS) -o $@ -I../src/ + +test_bc.oct: test_bc.o + $(MKOCTFILE) -s ../src/fem_init_env.o test_bc.o -o $@ $(LDFLAGS) $(LIBS) + +test_bc.o: test_bc.cpp Laplace.h + $(MKOCTFILE) -c test_bc.cpp $(LDFLAGS) -o $@ -I../src/ + +test_coeff.oct: test_coeff.o + $(MKOCTFILE) -s ../src/fem_init_env.o test_coeff.o -o $@ $(LDFLAGS) $(LIBS) + +test_coeff.o: test_coeff.cpp Laplace.h + $(MKOCTFILE) -c test_coeff.cpp $(LDFLAGS) -o $@ -I../src/ + +test_rlhs.oct: test_rlhs.o + $(MKOCTFILE) -s ../src/fem_init_env.o test_rlhs.o -o $@ $(LDFLAGS) $(LIBS) + +test_rlhs.o: test_rlhs.cc Laplace.h + $(MKOCTFILE) -c test_rlhs.cc $(LDFLAGS) -o $@ -I../src/ + + +Laplace.h: Laplace.ufl + ffc -l dolfin Laplace.ufl + +clean: + -rm -f *.o core octave-core *.oct *~ *.xml *.pvd *.vtu Laplace.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/laplace.m Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,35 @@ +#Example of how we expect the Octave interface to look like +#This file is our test for the TDD + +# Create mesh +fem_init_env (); +pkg load msh; + +msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); +mshd = fem_init_mesh (msho); + +#Compile the problem defined in the .ufl file +#fem_ffc ("Laplace.ufl"); + +# #Import the problem inside Octave +V = fem_fs (mshd); +#Set BC equal to zero on sides with label 2 and 4 +bc = fem_bc (V, @(x, y) 0.0, [2,4]); + +##Set the coefficient for the rhs +fv = @(x,y) 10*exp(-((x - 0.5).^2 + (y - 0.5).^2) / 0.02); +f = fem_coeff ('f', fv); + +gv = @(x,y) sin (5.0 * x); +g = fem_coeff ('g', gv); + +# #Get the matrices +# A = BilinearForm (V, V, bc); +# L = LinearForm (V, bc, f, g); + +# #Solve it +# u = A\L; + +# #Plot +# uf = Function (V, u); +# dolfin_plot (uf, "Solution")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/mesh_test.m Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,32 @@ +#Example of how we expect the Octave interface to look like +#This file is our test for the TDD about mesh + +# Create mesh +fem_init_env (); + +msh1 = msh2m_structured_mesh(1:6,1:4,0,3:6); +msh2 = fem_init_mesh (msh1); +msh3 = fem_get_mesh (msh2); + +# assert (msh1, msh3) doesn't work because the order of column inside "e" and "t" +# depends on the algorithm used for visiting the mesh + +assert (msh1.p, msh3.p); + +e= [1 5 9 13 21 17 22 23 1 2 4 3 8 12 16 20 + 5 9 13 17 22 21 23 24 2 3 8 4 12 16 20 24 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 3 3 3 3 4 3 4 4 6 6 5 6 5 5 5 5 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; + +assert (msh3.e, e); + +t= [1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 + 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 2 3 4 6 7 8 10 11 12 14 15 16 18 19 20 + 6 7 8 10 11 12 14 15 16 18 19 20 22 23 24 6 7 8 10 11 12 14 15 16 18 19 20 22 23 24 + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; + +assert (msh3.t, t); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_all.m Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,59 @@ +# 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) +# we check if: +# 1) the classes created within fem-fenics +# like "mesh" and "functionspace" hold correctly the dolfin data +# 2) the class "expression", which we derived from dolfin::Expression +# correctly sets up the value for the bc using a function_handle +# 3) the class "boundarycondition", which handle a vecotr of pointer +# to dolfin::DirichletBC correctly stores the value for the bc + + +pkg load msh +addpath ("../src/") +fem_init_env (); + +# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4 +# we can use only 2D mesh for the moment +# if you want to try with a 3D mesh, you need to use tetrahedron instead of +# triangle inside Laplace.ufl and recompile fem_fs.cpp +msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); +mshd = fem_init_mesh (msho); + +V = fem_fs (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 Poisson problem with +# the velues specified inside f and g; +A = fem_rhs (V, bc); + +b = fem_lhs (V, f, g, bc); + +u = A \ b; + +func = fem_func (V, u) + +fem_plot (func); + +fem_save (func, 'solution');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_bc.cpp Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,83 @@ +#include <dolfin.h> +#include "Laplace.h" +#include "functionspace.h" +#include "boundarycondition.h" + + +class Source : public dolfin::Expression +{ + public: + Source() : dolfin::Expression() {} + + void eval(dolfin::Array<double>& values, const dolfin::Array<double>& x) const + { + double dx = x[0] - 0.5; + double dy = x[1] - 0.5; + values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02); + } +}; + +class dUdN : public dolfin::Expression +{ + public: + dUdN() : dolfin::Expression() {} + + void eval(dolfin::Array<double>& values, const dolfin::Array<double>& x) const + { + values[0] = sin(5*x[0]); + } +}; + + +DEFUN_DLD (test_bc, args, , "test_bc: functionspace V, boundarycondition bc") +{ + + int nargin = args.length (); + octave_value retval=0; + + if (nargin < 2 || nargin > 2) + print_usage (); + else + { + if (args(0).type_id () == functionspace::static_type_id () && + args(1).type_id () == boundarycondition::static_type_id ()) + { + const functionspace & fspo = + static_cast<const functionspace&> (args(0).get_rep ()); + const boundarycondition & bc = + static_cast<const boundarycondition&> (args(1).get_rep ()); + + if (!error_state) + { + const dolfin::FunctionSpace V = fspo.get_fsp (); + dolfin::Mesh mesh = *(V.mesh()); + + const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & + pbc = bc.get_bc (); + std::vector<const dolfin::BoundaryCondition*> bcu; + + for (octave_idx_type i = 0; i < pbc.size (); ++i) + bcu.push_back (& (* (pbc[i]))); + + //We use dolfin now, fem-fenics not yet available + Source f; + dUdN g; + Laplace::BilinearForm a (V, V); + Laplace::LinearForm L (V); + L.f = f; + L.g = g; + + dolfin::Function u (V); + dolfin::solve (a == L, u, bcu); + + dolfin::File file ("fem-fenics-bc.pvd"); + file << u; + + dolfin::plot (u); + dolfin::interactive (); + } + } + } + return retval; + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_bc.m Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,40 @@ +# 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) +# we check if: +# 1) the classes created within fem-fenics +# like "mesh" and "functionspace" hold correctly the dolfin data +# 2) the class "expression", which we derived from dolfin::Expression +# correctly sets up the value for the bc using a function_handle +# 3) the class "boundarycondition", which handle a vecotr of pointer +# to dolfin::DirichletBC correctly stores the value for the bc + + +pkg load msh +addpath ("../src/") + +# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4 +# we can use only 2D mesh for the moment +# if you want to try with a 3D mesh, you need to use tetrahedron instead of +# triangle inside Laplace.ufl and recompile fem_fs.cpp +msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); + +mshd = fem_init_mesh (msho); +V = fem_fs (mshd); + +f = @(x,y) 0; + +# fem_bc take 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 = sin(5*x) +bc = fem_bc (V, f, [2, 4]); + +# test_bc take as input the functionspace V, and the +# boundarycondition bc and solve the Poisson problem with +# f = 10*exp(-(dx*dx + dy*dy) / 0.02); +test_bc (V, bc);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_coeff.cpp Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,80 @@ +#include "Laplace.h" +using namespace Laplace; + +#include <dolfin.h> +#include "functionspace.h" +#include "boundarycondition.h" +#include "coefficient.h" + +DEFUN_DLD (test_coeff, args, , "test_bc: functionspace V, boundarycondition bc") +{ + + int nargin = args.length (); + octave_value retval=0; + + if (nargin < 2) + print_usage (); + else + { + if (args(0).type_id () == functionspace::static_type_id () && + args(1).type_id () == boundarycondition::static_type_id ()) + { + const functionspace & fspo = + static_cast<const functionspace&> (args(0).get_rep ()); + const boundarycondition & bc = + static_cast<const boundarycondition&> (args(1).get_rep ()); + + if (!error_state) + { + const dolfin::FunctionSpace V = fspo.get_fsp (); + LinearForm L (V); + std::size_t ncoef = L.num_coefficients (); + if (nargin < 2 + ncoef || nargin > 2 + ncoef) + error ("Wrong number of coefficient"); + else + { + for (octave_idx_type i = 0; i < ncoef; ++i) + { + const coefficient & cf =static_cast<const coefficient&> (args(i+2).get_rep ()); + std::size_t n = L.coefficient_number (cf.get_str ()); + const boost::shared_ptr<const expression> & pexp = cf.get_expr (); + L.set_coefficient (n, pexp); + } + + const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & + pbc = bc.get_bc (); + std::vector<const dolfin::BoundaryCondition*> bcu; + + for (octave_idx_type i = 0; i < pbc.size (); ++i) + bcu.push_back (& (* (pbc[i]))); + + //Now use dolfin, fem-fenics not yet available + dolfin::Vector b; + dolfin::assemble (b, L); + + for (std::size_t i = 0; i < bcu.size(); i++) + bcu[i]->apply(b); + + BilinearForm a (V, V); + dolfin::Matrix A; + dolfin::assemble (A, a); + + for (std::size_t i = 0; i < bcu.size(); i++) + bcu[i]->apply(A); + + dolfin::Function u(V); + dolfin::solve(A, *u.vector(), b, "gmres", "default"); + + dolfin::File file ("fem-fenics-bc.pvd"); + file << u; + + dolfin::plot (u); + dolfin::interactive (); + + } + } + } + } + return retval; + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_coeff.m Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,49 @@ +# 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) +# we check if: +# 1) the classes created within fem-fenics +# like "mesh" and "functionspace" hold correctly the dolfin data +# 2) the class "expression", which we derived from dolfin::Expression +# correctly sets up the value for the bc using a function_handle +# 3) the class "boundarycondition", which handle a vecotr of pointer +# to dolfin::DirichletBC correctly stores the value for the bc + + +pkg load msh +addpath ("../src/") + +# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4 +# we can use only 2D mesh for the moment +# if you want to try with a 3D mesh, you need to use tetrahedron instead of +# triangle inside Laplace.ufl and recompile fem_fs.cpp +msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); + +mshd = fem_init_mesh (msho); +V = fem_fs (mshd); + +f = @(x,y) 0; + +# 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 +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); + +# test_coeff takes as input the functionspace V, and the +# boundarycondition bc and solve the Poisson problem with +# the velues specified inside f and g; +test_coeff (V, bc, f, g);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_expr.cpp Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,76 @@ +#include <dolfin.h> +#include "Laplace.h" +#include "expression.h" +#include "functionspace.h" + + +class Source : public dolfin::Expression +{ + void eval(dolfin::Array<double>& values, const dolfin::Array<double>& x) const + { + double dx = x[0] - 0.5; + double dy = x[1] - 0.5; + values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02); + } +}; + +class dUdN : public dolfin::Expression +{ + void eval(dolfin::Array<double>& values, const dolfin::Array<double>& x) const + { + values[0] = sin(5*x[0]); + } +}; + + +DEFUN_DLD (test_expr, args, , "test_expr: functionspace V, fcn_handle f, mesh_label label") +{ + + int nargin = args.length (); + octave_value retval=0; + + if (nargin < 3 || nargin > 3) + print_usage (); + else + { + if (args(0).type_id () == functionspace::static_type_id ()) + { + const functionspace & fspo = static_cast<const functionspace&> (args(0).get_rep ()); + octave_fcn_handle * fh = args(1).fcn_handle_value (); + Array<int> side = args(2).array_value (); + + if (!error_state) + { + const dolfin::FunctionSpace V = fspo.get_fsp (); + dolfin::Mesh mesh = *(V.mesh()); + expression ff (*fh); + + //We use dolfin now, fem-fenics not yet available + + std::vector<const dolfin::BoundaryCondition*> bcu; + Source f; + dUdN g; + + for (octave_idx_type i = 0; i < side.length (); ++i) + bcu.push_back (new dolfin::DirichletBC (V, ff, side(i))); + + + Laplace::BilinearForm a (V, V); + Laplace::LinearForm L (V); + L.f = f; + L.g = g; + + dolfin::Function u(V); + dolfin::solve(a == L, u, bcu); + + dolfin::File file("fem-fenics.pvd"); + file << u; + + dolfin::plot(u); + dolfin::interactive(); + } + } + } + return retval; + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_expr.m Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,27 @@ + +# We follow the dolfin example for the Poisson problem +# (http://fenicsproject.org/documentation/dolfin/1.2.0/cpp/demo/pde/poisson/cpp/documentation.html#index-0) +# to check if: +# 1) the classes created within fem-fenics +# like "mesh" and "functionspace" hold correctly the dolfin data +# 2) the class "expression", which we derived from dolfin::Expression +# correctly sets up the value for the bc using a function_handle + + +pkg load msh +addpath("../src/") + +# 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 (mshd); + +f = @(x,y) 0; + +# test_expr take 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 + +test_expr (V, f, [2,4])
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_rlhs.cc Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,46 @@ +#include "Laplace.h" +using namespace Laplace; + +#include <dolfin.h> +#include "functionspace.h" +#include "boundarycondition.h" +#include "coefficient.h" + +DEFUN_DLD (test_rlhs, args, , "test_bc: functionspace V, boundarycondition bc") +{ + + int nargin = args.length (); + octave_value retval=0; + + if (nargin < 2) + print_usage (); + else + { + if (args(0).type_id () == functionspace::static_type_id ()) + { + const functionspace & fspo = + static_cast<const functionspace&> (args(0).get_rep ()); + Array <double> myu = args(1).array_value (); + + if (!error_state) + { + const boost::shared_ptr<const dolfin::FunctionSpace> & V = fspo.get_pfsp (); + + dolfin::Vector du(myu.length ()); + for (std::size_t i = 0; i < myu.length (); ++i) + du.setitem (i, myu(i)); + + boost::shared_ptr<dolfin::Vector> uu (new dolfin::Vector(du)); + dolfin::Function u(V, uu); + + dolfin::File file ("fem-fenics-rlhs.pvd"); + file << u; + + dolfin::plot (u); + dolfin::interactive (); + + } + } + } + return retval; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/test/test_rlhs.m Sat Aug 03 14:49:56 2013 +0200 @@ -0,0 +1,55 @@ +# 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) +# we check if: +# 1) the classes created within fem-fenics +# like "mesh" and "functionspace" hold correctly the dolfin data +# 2) the class "expression", which we derived from dolfin::Expression +# correctly sets up the value for the bc using a function_handle +# 3) the class "boundarycondition", which handle a vecotr of pointer +# to dolfin::DirichletBC correctly stores the value for the bc + + +pkg load msh +addpath ("../src/") +fem_init_env (); + +# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4 +# we can use only 2D mesh for the moment +# if you want to try with a 3D mesh, you need to use tetrahedron instead of +# triangle inside Laplace.ufl and recompile fem_fs.cpp +msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); +mshd = fem_init_mesh (msho); + +V = fem_fs (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 Poisson problem with +# the velues specified inside f and g; +A = fem_rhs (V, bc); + +b = fem_lhs (V, f, g, bc); + +u = A \ b; + +test_rlhs (V, u);
--- a/test/Laplace.ufl Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -# Copyright (C) 2005-2009 Anders Logg -# -# This file is part of DOLFIN. -# -# DOLFIN is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# DOLFIN is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. -# -# First added: 2005 -# Last changed: 2011-03-08 -# -# The bilinear form a(u, v) and linear form L(v) for -# Poisson's equation. -# -# Compile this form with FFC: ffc -l dolfin Poisson.ufl. - - -element = FiniteElement("Lagrange", triangle, 1) -# element = FiniteElement("Lagrange", tetrahedron, 2) - -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/test/Makefile Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -MKOCTFILE ?= mkoctfile - -OCTFILES=test_expr.oct test_bc.oct test_coeff.oct test_rlhs.oct - -LIBS += -ldolfin - -all: $(OCTFILES) - -test_expr.oct: test_expr.o - $(MKOCTFILE) -s ../src/fem_init_env.o test_expr.o -o $@ $(LDFLAGS) $(LIBS) - -test_expr.o: test_expr.cpp Laplace.h - $(MKOCTFILE) -c test_expr.cpp $(LDFLAGS) -o $@ -I../src/ - -test_bc.oct: test_bc.o - $(MKOCTFILE) -s ../src/fem_init_env.o test_bc.o -o $@ $(LDFLAGS) $(LIBS) - -test_bc.o: test_bc.cpp Laplace.h - $(MKOCTFILE) -c test_bc.cpp $(LDFLAGS) -o $@ -I../src/ - -test_coeff.oct: test_coeff.o - $(MKOCTFILE) -s ../src/fem_init_env.o test_coeff.o -o $@ $(LDFLAGS) $(LIBS) - -test_coeff.o: test_coeff.cpp Laplace.h - $(MKOCTFILE) -c test_coeff.cpp $(LDFLAGS) -o $@ -I../src/ - -test_rlhs.oct: test_rlhs.o - $(MKOCTFILE) -s ../src/fem_init_env.o test_rlhs.o -o $@ $(LDFLAGS) $(LIBS) - -test_rlhs.o: test_rlhs.cc Laplace.h - $(MKOCTFILE) -c test_rlhs.cc $(LDFLAGS) -o $@ -I../src/ - - -Laplace.h: Laplace.ufl - ffc -l dolfin Laplace.ufl - -clean: - -rm -f *.o core octave-core *.oct *~ *.xml *.pvd *.vtu Laplace.h
--- a/test/laplace.m Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#Example of how we expect the Octave interface to look like -#This file is our test for the TDD - -# Create mesh -fem_init_env (); -pkg load msh; - -msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); -mshd = fem_init_mesh (msho); - -#Compile the problem defined in the .ufl file -#fem_ffc ("Laplace.ufl"); - -# #Import the problem inside Octave -V = fem_fs (mshd); -#Set BC equal to zero on sides with label 2 and 4 -bc = fem_bc (V, @(x, y) 0.0, [2,4]); - -##Set the coefficient for the rhs -fv = @(x,y) 10*exp(-((x - 0.5).^2 + (y - 0.5).^2) / 0.02); -f = fem_coeff ('f', fv); - -gv = @(x,y) sin (5.0 * x); -g = fem_coeff ('g', gv); - -# #Get the matrices -# A = BilinearForm (V, V, bc); -# L = LinearForm (V, bc, f, g); - -# #Solve it -# u = A\L; - -# #Plot -# uf = Function (V, u); -# dolfin_plot (uf, "Solution")
--- a/test/mesh_test.m Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -#Example of how we expect the Octave interface to look like -#This file is our test for the TDD about mesh - -# Create mesh -fem_init_env (); - -msh1 = msh2m_structured_mesh(1:6,1:4,0,3:6); -msh2 = fem_init_mesh (msh1); -msh3 = fem_get_mesh (msh2); - -# assert (msh1, msh3) doesn't work because the order of column inside "e" and "t" -# depends on the algorithm used for visiting the mesh - -assert (msh1.p, msh3.p); - -e= [1 5 9 13 21 17 22 23 1 2 4 3 8 12 16 20 - 5 9 13 17 22 21 23 24 2 3 8 4 12 16 20 24 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 3 3 3 3 4 3 4 4 6 6 5 6 5 5 5 5 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; - -assert (msh3.e, e); - -t= [1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 - 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 2 3 4 6 7 8 10 11 12 14 15 16 18 19 20 - 6 7 8 10 11 12 14 15 16 18 19 20 22 23 24 6 7 8 10 11 12 14 15 16 18 19 20 22 23 24 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; - -assert (msh3.t, t); -
--- a/test/test_all.m Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +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) -# we check if: -# 1) the classes created within fem-fenics -# like "mesh" and "functionspace" hold correctly the dolfin data -# 2) the class "expression", which we derived from dolfin::Expression -# correctly sets up the value for the bc using a function_handle -# 3) the class "boundarycondition", which handle a vecotr of pointer -# to dolfin::DirichletBC correctly stores the value for the bc - - -pkg load msh -addpath ("../src/") -fem_init_env (); - -# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4 -# we can use only 2D mesh for the moment -# if you want to try with a 3D mesh, you need to use tetrahedron instead of -# triangle inside Laplace.ufl and recompile fem_fs.cpp -msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); -mshd = fem_init_mesh (msho); - -V = fem_fs (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 Poisson problem with -# the velues specified inside f and g; -A = fem_rhs (V, bc); - -b = fem_lhs (V, f, g, bc); - -u = A \ b; - -func = fem_func (V, u) - -fem_plot (func); - -fem_save (func, 'solution');
--- a/test/test_bc.cpp Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -#include <dolfin.h> -#include "Laplace.h" -#include "functionspace.h" -#include "boundarycondition.h" - - -class Source : public dolfin::Expression -{ - public: - Source() : dolfin::Expression() {} - - void eval(dolfin::Array<double>& values, const dolfin::Array<double>& x) const - { - double dx = x[0] - 0.5; - double dy = x[1] - 0.5; - values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02); - } -}; - -class dUdN : public dolfin::Expression -{ - public: - dUdN() : dolfin::Expression() {} - - void eval(dolfin::Array<double>& values, const dolfin::Array<double>& x) const - { - values[0] = sin(5*x[0]); - } -}; - - -DEFUN_DLD (test_bc, args, , "test_bc: functionspace V, boundarycondition bc") -{ - - int nargin = args.length (); - octave_value retval=0; - - if (nargin < 2 || nargin > 2) - print_usage (); - else - { - if (args(0).type_id () == functionspace::static_type_id () && - args(1).type_id () == boundarycondition::static_type_id ()) - { - const functionspace & fspo = - static_cast<const functionspace&> (args(0).get_rep ()); - const boundarycondition & bc = - static_cast<const boundarycondition&> (args(1).get_rep ()); - - if (!error_state) - { - const dolfin::FunctionSpace V = fspo.get_fsp (); - dolfin::Mesh mesh = *(V.mesh()); - - const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & - pbc = bc.get_bc (); - std::vector<const dolfin::BoundaryCondition*> bcu; - - for (octave_idx_type i = 0; i < pbc.size (); ++i) - bcu.push_back (& (* (pbc[i]))); - - //We use dolfin now, fem-fenics not yet available - Source f; - dUdN g; - Laplace::BilinearForm a (V, V); - Laplace::LinearForm L (V); - L.f = f; - L.g = g; - - dolfin::Function u (V); - dolfin::solve (a == L, u, bcu); - - dolfin::File file ("fem-fenics-bc.pvd"); - file << u; - - dolfin::plot (u); - dolfin::interactive (); - } - } - } - return retval; - -}
--- a/test/test_bc.m Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +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) -# we check if: -# 1) the classes created within fem-fenics -# like "mesh" and "functionspace" hold correctly the dolfin data -# 2) the class "expression", which we derived from dolfin::Expression -# correctly sets up the value for the bc using a function_handle -# 3) the class "boundarycondition", which handle a vecotr of pointer -# to dolfin::DirichletBC correctly stores the value for the bc - - -pkg load msh -addpath ("../src/") - -# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4 -# we can use only 2D mesh for the moment -# if you want to try with a 3D mesh, you need to use tetrahedron instead of -# triangle inside Laplace.ufl and recompile fem_fs.cpp -msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); - -mshd = fem_init_mesh (msho); -V = fem_fs (mshd); - -f = @(x,y) 0; - -# fem_bc take 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 = sin(5*x) -bc = fem_bc (V, f, [2, 4]); - -# test_bc take as input the functionspace V, and the -# boundarycondition bc and solve the Poisson problem with -# f = 10*exp(-(dx*dx + dy*dy) / 0.02); -test_bc (V, bc);
--- a/test/test_coeff.cpp Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -#include "Laplace.h" -using namespace Laplace; - -#include <dolfin.h> -#include "functionspace.h" -#include "boundarycondition.h" -#include "coefficient.h" - -DEFUN_DLD (test_coeff, args, , "test_bc: functionspace V, boundarycondition bc") -{ - - int nargin = args.length (); - octave_value retval=0; - - if (nargin < 2) - print_usage (); - else - { - if (args(0).type_id () == functionspace::static_type_id () && - args(1).type_id () == boundarycondition::static_type_id ()) - { - const functionspace & fspo = - static_cast<const functionspace&> (args(0).get_rep ()); - const boundarycondition & bc = - static_cast<const boundarycondition&> (args(1).get_rep ()); - - if (!error_state) - { - const dolfin::FunctionSpace V = fspo.get_fsp (); - LinearForm L (V); - std::size_t ncoef = L.num_coefficients (); - if (nargin < 2 + ncoef || nargin > 2 + ncoef) - error ("Wrong number of coefficient"); - else - { - for (octave_idx_type i = 0; i < ncoef; ++i) - { - const coefficient & cf =static_cast<const coefficient&> (args(i+2).get_rep ()); - std::size_t n = L.coefficient_number (cf.get_str ()); - const boost::shared_ptr<const expression> & pexp = cf.get_expr (); - L.set_coefficient (n, pexp); - } - - const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & - pbc = bc.get_bc (); - std::vector<const dolfin::BoundaryCondition*> bcu; - - for (octave_idx_type i = 0; i < pbc.size (); ++i) - bcu.push_back (& (* (pbc[i]))); - - //Now use dolfin, fem-fenics not yet available - dolfin::Vector b; - dolfin::assemble (b, L); - - for (std::size_t i = 0; i < bcu.size(); i++) - bcu[i]->apply(b); - - BilinearForm a (V, V); - dolfin::Matrix A; - dolfin::assemble (A, a); - - for (std::size_t i = 0; i < bcu.size(); i++) - bcu[i]->apply(A); - - dolfin::Function u(V); - dolfin::solve(A, *u.vector(), b, "gmres", "default"); - - dolfin::File file ("fem-fenics-bc.pvd"); - file << u; - - dolfin::plot (u); - dolfin::interactive (); - - } - } - } - } - return retval; - -}
--- a/test/test_coeff.m Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +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) -# we check if: -# 1) the classes created within fem-fenics -# like "mesh" and "functionspace" hold correctly the dolfin data -# 2) the class "expression", which we derived from dolfin::Expression -# correctly sets up the value for the bc using a function_handle -# 3) the class "boundarycondition", which handle a vecotr of pointer -# to dolfin::DirichletBC correctly stores the value for the bc - - -pkg load msh -addpath ("../src/") - -# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4 -# we can use only 2D mesh for the moment -# if you want to try with a 3D mesh, you need to use tetrahedron instead of -# triangle inside Laplace.ufl and recompile fem_fs.cpp -msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); - -mshd = fem_init_mesh (msho); -V = fem_fs (mshd); - -f = @(x,y) 0; - -# 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 -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); - -# test_coeff takes as input the functionspace V, and the -# boundarycondition bc and solve the Poisson problem with -# the velues specified inside f and g; -test_coeff (V, bc, f, g);
--- a/test/test_expr.cpp Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -#include <dolfin.h> -#include "Laplace.h" -#include "expression.h" -#include "functionspace.h" - - -class Source : public dolfin::Expression -{ - void eval(dolfin::Array<double>& values, const dolfin::Array<double>& x) const - { - double dx = x[0] - 0.5; - double dy = x[1] - 0.5; - values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02); - } -}; - -class dUdN : public dolfin::Expression -{ - void eval(dolfin::Array<double>& values, const dolfin::Array<double>& x) const - { - values[0] = sin(5*x[0]); - } -}; - - -DEFUN_DLD (test_expr, args, , "test_expr: functionspace V, fcn_handle f, mesh_label label") -{ - - int nargin = args.length (); - octave_value retval=0; - - if (nargin < 3 || nargin > 3) - print_usage (); - else - { - if (args(0).type_id () == functionspace::static_type_id ()) - { - const functionspace & fspo = static_cast<const functionspace&> (args(0).get_rep ()); - octave_fcn_handle * fh = args(1).fcn_handle_value (); - Array<int> side = args(2).array_value (); - - if (!error_state) - { - const dolfin::FunctionSpace V = fspo.get_fsp (); - dolfin::Mesh mesh = *(V.mesh()); - expression ff (*fh); - - //We use dolfin now, fem-fenics not yet available - - std::vector<const dolfin::BoundaryCondition*> bcu; - Source f; - dUdN g; - - for (octave_idx_type i = 0; i < side.length (); ++i) - bcu.push_back (new dolfin::DirichletBC (V, ff, side(i))); - - - Laplace::BilinearForm a (V, V); - Laplace::LinearForm L (V); - L.f = f; - L.g = g; - - dolfin::Function u(V); - dolfin::solve(a == L, u, bcu); - - dolfin::File file("fem-fenics.pvd"); - file << u; - - dolfin::plot(u); - dolfin::interactive(); - } - } - } - return retval; - -}
--- a/test/test_expr.m Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ - -# We follow the dolfin example for the Poisson problem -# (http://fenicsproject.org/documentation/dolfin/1.2.0/cpp/demo/pde/poisson/cpp/documentation.html#index-0) -# to check if: -# 1) the classes created within fem-fenics -# like "mesh" and "functionspace" hold correctly the dolfin data -# 2) the class "expression", which we derived from dolfin::Expression -# correctly sets up the value for the bc using a function_handle - - -pkg load msh -addpath("../src/") - -# 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 (mshd); - -f = @(x,y) 0; - -# test_expr take 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 - -test_expr (V, f, [2,4])
--- a/test/test_rlhs.cc Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#include "Laplace.h" -using namespace Laplace; - -#include <dolfin.h> -#include "functionspace.h" -#include "boundarycondition.h" -#include "coefficient.h" - -DEFUN_DLD (test_rlhs, args, , "test_bc: functionspace V, boundarycondition bc") -{ - - int nargin = args.length (); - octave_value retval=0; - - if (nargin < 2) - print_usage (); - else - { - if (args(0).type_id () == functionspace::static_type_id ()) - { - const functionspace & fspo = - static_cast<const functionspace&> (args(0).get_rep ()); - Array <double> myu = args(1).array_value (); - - if (!error_state) - { - const boost::shared_ptr<const dolfin::FunctionSpace> & V = fspo.get_pfsp (); - - dolfin::Vector du(myu.length ()); - for (std::size_t i = 0; i < myu.length (); ++i) - du.setitem (i, myu(i)); - - boost::shared_ptr<dolfin::Vector> uu (new dolfin::Vector(du)); - dolfin::Function u(V, uu); - - dolfin::File file ("fem-fenics-rlhs.pvd"); - file << u; - - dolfin::plot (u); - dolfin::interactive (); - - } - } - } - return retval; -}
--- a/test/test_rlhs.m Sat Aug 03 14:48:23 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +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) -# we check if: -# 1) the classes created within fem-fenics -# like "mesh" and "functionspace" hold correctly the dolfin data -# 2) the class "expression", which we derived from dolfin::Expression -# correctly sets up the value for the bc using a function_handle -# 3) the class "boundarycondition", which handle a vecotr of pointer -# to dolfin::DirichletBC correctly stores the value for the bc - - -pkg load msh -addpath ("../src/") -fem_init_env (); - -# create a unit square mesh using msh: labels for the boundary sides are 1,2,3,4 -# we can use only 2D mesh for the moment -# if you want to try with a 3D mesh, you need to use tetrahedron instead of -# triangle inside Laplace.ufl and recompile fem_fs.cpp -msho = msh2m_structured_mesh (0:0.05:1, 0:0.05:1, 1, 1:4); -mshd = fem_init_mesh (msho); - -V = fem_fs (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 Poisson problem with -# the velues specified inside f and g; -A = fem_rhs (V, bc); - -b = fem_lhs (V, f, g, bc); - -u = A \ b; - -test_rlhs (V, u);