Mercurial > fem-fenics-eugenio
changeset 177:dae73b9eab87
Remove obsolete files.
author | gedeone-octave <marcovass89@hotmail.it> |
---|---|
date | Wed, 06 Nov 2013 23:34:54 +0000 |
parents | 32a023fc678a |
children | 097026c0acb5 |
files | obsolete/Laplace.ufl obsolete/Plot_2d.cc obsolete/Plot_3d.cc obsolete/bin/codeCreator.py obsolete/bin/codeMantainer.py obsolete/bin/create_fs.py obsolete/bin/create_lhs.py obsolete/bin/create_rhs.py obsolete/fem_fs.cc obsolete/fem_func_space.m obsolete/fem_get_mesh.cc obsolete/fem_init_env.cc obsolete/fem_lhs.cc obsolete/fem_rhs.cc obsolete/plot.cc 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 |
diffstat | 28 files changed, 0 insertions(+), 2076 deletions(-) [+] |
line wrap: on
line diff
--- a/obsolete/Laplace.ufl Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/Plot_2d.cc Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - Copyright (C) 2013 Marco Vassallo - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program 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 General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, see <http://www.gnu.org/licenses/>. -*/ -#include "mesh.h" -#include "Plot_2d.h" - -DEFUN_DLD (Plot_2d, args, , "-*- texinfo -*-\n\ -@deftypefn {Function File} \ -Plot_2d (@var{msh}, @var{nodal_value})\n\ -The input parameters are a Mesh and a vector which specify the values of the \ -function that you want to plot at each node\n\ -@seealso{fem_func, fem_save}\n\ -@end deftypefn") -{ - - int nargin = args.length (); - octave_value retval; - - if (nargin < 2 || nargin > 2) - print_usage (); - else - { - if (! mesh_type_loaded) - { - mesh::register_type (); - mesh_type_loaded = true; - mlock (); - } - if (args(0).type_id () == mesh::static_type_id ()) - { - const mesh & msh = - static_cast<const mesh&> (args(0).get_rep ()); - Array <double> myu = args(1).array_value (); - - if (!error_state) - { - const dolfin::Mesh & mshd = msh.get_msh (); - boost::shared_ptr <const dolfin::FunctionSpace> V (new Plot_2d::FunctionSpace (mshd)); - - if (V->dim () != myu.length ()) - error ("Plot_2D: The size of the functional space and of the vector must agree"); - else - { - 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)); - boost::shared_ptr <const dolfin::Function> u (new dolfin::Function(V, uu)); - dolfin::plot (*u); - dolfin::interactive (); - retval = 0; - } - } - } - } - return retval; -}
--- a/obsolete/Plot_3d.cc Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - Copyright (C) 2013 Marco Vassallo - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program 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 General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, see <http://www.gnu.org/licenses/>. -*/ -#include "mesh.h" -#include "Plot_3d.h" - -DEFUN_DLD (Plot_3d, args, , "-*- texinfo -*-\n\ -@deftypefn {Function File} \ -Plot_3d (@var{msh}, @var{nodal_value})\n\ -The input parameters are a Mesh and a vector which specify the values of the \ -function that you want to plot at each node\n\ -@seealso{fem_func, fem_save}\n\ -@end deftypefn") -{ - - int nargin = args.length (); - octave_value retval; - - if (nargin < 2 || nargin > 2) - print_usage (); - else - { - if (! mesh_type_loaded) - { - mesh::register_type (); - mesh_type_loaded = true; - mlock (); - } - if (args(0).type_id () == mesh::static_type_id ()) - { - const mesh & msh = - static_cast<const mesh&> (args(0).get_rep ()); - Array <double> myu = args(1).array_value (); - - if (!error_state) - { - const dolfin::Mesh & mshd = msh.get_msh (); - boost::shared_ptr <const dolfin::FunctionSpace> V (new Plot_3d::FunctionSpace (mshd)); - - if (V->dim () != myu.length ()) - error ("The size of the functional space and of the vector must agree"); - else - { - 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)); - boost::shared_ptr <const dolfin::Function> u (new dolfin::Function(V, uu)); - dolfin::plot (*u); - dolfin::interactive (); - retval = 0; - } - } - } - } - return retval; -}
--- a/obsolete/bin/codeCreator.py Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,431 +0,0 @@ -''' - Copyright (C) 2013 - Juan Pablo Carbajal - Copyright (C) 2013 - Marco Vassallo - - This progrm is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -''' - -# Author: Juan Pablo Carbajal <ajuanpi+dev@gmail.com> -# Modified by: Marco Vassallo - -from io import open -from string import Template - -class Makefile (): - - def __init__(self,**kwargs): - """ Creates a makefile with the names of the files to be compiled. - - Inuts must be all strings. - """ - if map(type,kwargs.values()) != [str]*len(kwargs): - raise ValueError("Makefile accepts only str arguments.") - - self.name = "Makefile_"+kwargs["name"] - self.body = Template (""" -DIR = $path -CPPFLAGS= -LIBS= -ldolfin -MKOCTFILE = mkoctfile -FFC = ffc - -OCTFILES = fem_fs_$name.oct - -all : $(OCTFILES) -fs : fem_fs_$name.oct -rhs : fem_rhs_$name.oct -lhs : fem_lhs_$name.oct - -fem_fs_$name.o: fem_fs_$name.cc - $(MKOCTFILE) -I$(DIR) -I. $(CPPFLAGS) $(LDFLAGS) $< -c $@ - -fem_fs_$name.oct: $name.h fem_fs_$name.o - $(MKOCTFILE) -s fem_fs_$name.o $(DIR)fem_init_env.o $(LDFLAGS) $(LIBS) -o $@ - -fem_rhs_$name.o: fem_rhs_$name.cc - $(MKOCTFILE) -I$(DIR) -I. $(LDFLAGS) $(CPPFLAGS) $< -c $@ - -fem_rhs_$name.oct: $name.h fem_rhs_$name.o - $(MKOCTFILE) -s fem_rhs_$name.o $(DIR)fem_init_env.o $(LDFLAGS) $(LIBS) -o $@ - -fem_lhs_$name.o: fem_lhs_$name.cc - $(MKOCTFILE) -I$(DIR) -I. $(LDFLAGS) $(CPPFLAGS) $< -c $@ - -fem_lhs_$name.oct: $name.h fem_lhs_$name.o - $(MKOCTFILE) -s fem_lhs_$name.o $(DIR)fem_init_env.o $(LDFLAGS) $(LIBS) -o $@ - -$name.h: $name.ufl - $(FFC) -l dolfin $name.ufl - -.PHONY: clean - -clean: - rm -f fem_fs_$name.o fem_fs_$name.cc $name.h - rm -f fem_rhs_$name.o fem_rhs_$name.cc - rm -f fem_lhs_$name.o fem_lhs_$name.cc - rm -f $makefile - -""").safe_substitute(name=kwargs["name"], - makefile=self.name, - path=kwargs["path"]) - - def writeout (self): - mfile = open (self.name, 'w') - mfile.write(unicode(self.body)) - mfile.close() - -class Functionspace (): - - def __init__(self,**kwargs): - """ Creates a file fem_fs_$name with the name of the Variational problem to. - - Inuts must be all strings. - """ - if map(type,kwargs.values()) != [str]*len(kwargs): - raise ValueError("Functionspace accepts only str arguments.") - - self.name = "fem_fs_"+kwargs["name"]+".cc" - self.body = Template (""" -#include "functionspace.h" -#include "mesh.h" -#include "$name.h" - -DEFUN_DLD (fem_fs_$name, args, , "initialize a fs from a mesh declared with fem_init_mesh") -{ - int nargin = args.length (); - octave_value retval; - - if (nargin < 1 || nargin > 1) - print_usage (); - else - { - - if (! mesh_type_loaded) - { - mesh::register_type (); - mesh_type_loaded = true; - mlock (); - } - - if (args(0).type_id () == mesh::static_type_id ()) - { - const mesh & msho = static_cast<const mesh&> (args(0).get_rep ()); - const dolfin::Mesh & mshd = msho.get_msh (); - boost::shared_ptr <const dolfin::FunctionSpace> g (new $name::FunctionSpace (mshd)); - - if (! functionspace_type_loaded) - { - functionspace::register_type (); - functionspace_type_loaded = true; - mlock (); - } - - retval = new functionspace(g); - } - } - return retval; -} -""").safe_substitute(name=kwargs["name"]) - - def writeout (self): - mfile = open (self.name, 'w') - mfile.write(unicode(self.body)) - mfile.close() - -class RHS (): - - def __init__(self,**kwargs): - """ Creates a file fem_rhs_$name with the name of the Variational problem to. - - Inuts must be all strings. - """ - if map(type,kwargs.values()) != [str]*len(kwargs): - raise ValueError("RHS accepts only str arguments.") - - self.name = "fem_rhs_"+kwargs["name"]+".cc" - self.body = Template (""" -#include "$name.h" -#include "functionspace.h" -#include "boundarycondition.h" -#include "coefficient.h" -#include "function.h" - -DEFUN_DLD (fem_rhs_$name, args, , "A = fem_rhs_$name (FUNCTIONAL SPACE, COEFF, BC)") -{ - - int nargin = args.length (); - octave_value retval; - - if (nargin < 1) - print_usage (); - else - { - if (! functionspace_type_loaded) - { - functionspace::register_type (); - functionspace_type_loaded = true; - mlock (); - } - if (args(0).type_id () == functionspace::static_type_id ()) - { - const functionspace & fspo - = static_cast<const functionspace&> (args(0).get_rep ()); - - if (! error_state) - { - const dolfin::FunctionSpace V = fspo.get_fsp (); - $name::BilinearForm a (V, V); - std::size_t ncoef = a.num_coefficients (), nc = 0; - - if (! coefficient_type_loaded) - { - coefficient::register_type (); - coefficient_type_loaded = true; - mlock (); - } - - if (! function_type_loaded) - { - function::register_type (); - function_type_loaded = true; - mlock (); - } - - for (std::size_t i = 1; i < nargin; ++i) - { - if (args(i).type_id () == coefficient::static_type_id ()) - { - const coefficient & cf - = static_cast <const coefficient&> (args(i).get_rep ()); - - std::size_t n = a.coefficient_number (cf.get_str ()); - const boost::shared_ptr<const expression> & pexp = cf.get_expr (); - a.set_coefficient (n, pexp); - ++nc; - } - - if (args(i).type_id () == function::static_type_id ()) - { - const function & fun - = static_cast <const function&> (args(i).get_rep ()); - - std::size_t n = a.coefficient_number (fun.get_str ()); - const boost::shared_ptr<const dolfin::Function> & pfun = fun.get_pfun (); - a.set_coefficient (n, pfun); - ++nc; - } - } - - if (nc != ncoef) - error ("Wrong number of coefficient"); - else - { - - dolfin::Matrix A; - dolfin::assemble (A, a); - - if (! boundarycondition_type_loaded) - { - boundarycondition::register_type (); - boundarycondition_type_loaded = true; - mlock (); - } - - for (std::size_t i = 1; i < nargin; ++i) - { - if (args(i).type_id () == boundarycondition::static_type_id ()) - { - const boundarycondition & bc - = static_cast<const boundarycondition&> (args(i).get_rep ()); - - const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & pbc - = bc.get_bc (); - for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(A); - } - } - - int nr = A.size (0), nc = A.size (1); - // nz shoud be estimated in a better way - int nz = nr * nc; - SparseMatrix sm (nr, nc, nz); - - int ii = 0; - sm.cidx (0) = 0; - for (int j = 0; j < nc; ++j) - { - for (int i = 0; i < nr; i++) - { - double tmp = A(i, j); - if (tmp != 0.) - { - sm.data(ii) = tmp; - sm.ridx(ii) = i; - ii++; - } - } - sm.cidx(j+1) = ii; - } - sm.maybe_compress (); - - retval = sm; - - } - } - } - } - return retval; -} -""").safe_substitute(name=kwargs["name"]) - - def writeout (self): - mfile = open (self.name, 'w') - mfile.write(unicode(self.body)) - mfile.close() - -class LHS (): - - def __init__(self,**kwargs): - """ Creates a file fem_lhs_$name with the name of the Variational problem to. - - Inuts must be all strings. - """ - if map(type,kwargs.values()) != [str]*len(kwargs): - raise ValueError("lhs accepts only str arguments.") - - self.name = "fem_lhs_"+kwargs["name"]+".cc" - self.body = Template (""" -#include "$name.h" -#include "functionspace.h" -#include "boundarycondition.h" -#include "coefficient.h" -#include "function.h" - -DEFUN_DLD (fem_lhs_$name, args, , " b = fem_lhs_$name (FUNCTIONAL SPACE, COEFF, BC)") -{ - - int nargin = args.length (); - octave_value retval; - - if (nargin < 1) - print_usage (); - else - { - - if (! functionspace_type_loaded) - { - functionspace::register_type (); - functionspace_type_loaded = true; - mlock (); - } - if (args(0).type_id () == functionspace::static_type_id ()) - { - const functionspace & fspo - = static_cast<const functionspace&> (args(0).get_rep ()); - - if (! error_state) - { - const dolfin::FunctionSpace V = fspo.get_fsp (); - $name::LinearForm L (V); - std::size_t ncoef = L.num_coefficients (), nc = 0; - - if (! coefficient_type_loaded) - { - coefficient::register_type (); - coefficient_type_loaded = true; - mlock (); - } - - if (! function_type_loaded) - { - function::register_type (); - function_type_loaded = true; - mlock (); - } - - for (std::size_t i = 1; i < nargin; ++i) - { - if (args(i).type_id () == coefficient::static_type_id ()) - { - const coefficient & cf - = static_cast <const coefficient&> (args(i).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); - ++nc; - } - - if (args(i).type_id () == function::static_type_id ()) - { - const function & fun - = static_cast <const function&> (args(i).get_rep ()); - - std::size_t n = L.coefficient_number (fun.get_str ()); - const boost::shared_ptr<const dolfin::Function> & pfun = fun.get_pfun (); - L.set_coefficient (n, pfun); - ++nc; - } - } - - if (nc != ncoef) - error ("Wrong number of coefficient"); - else - { - - dolfin::Vector b; - dolfin::assemble (b, L); - - if (! boundarycondition_type_loaded) - { - boundarycondition::register_type (); - boundarycondition_type_loaded = true; - mlock (); - } - for (std::size_t i = 1; i < nargin; ++i) - { - if (args(i).type_id () == boundarycondition::static_type_id ()) - { - const boundarycondition & bc - = static_cast<const boundarycondition&> (args(i).get_rep ()); - - const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & pbc - = bc.get_bc (); - for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(b); - } - } - - dim_vector dims; - dims.resize (2); - dims(0) = b.size (); - dims(1) = 1; - Array<double> myb (dims); - - for (std::size_t i = 0; i < b.size (); ++i) - myb(i) = b[i]; - - retval = myb; - } - } - } - } - return retval; -} -""").safe_substitute(name=kwargs["name"]) - - def writeout (self): - mfile = open (self.name, 'w') - mfile.write(unicode(self.body)) - mfile.close()
--- a/obsolete/bin/codeMantainer.py Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -''' - Copyright (C) 2013 - Juan Pablo Carbajal - Copyright (C) 2013 - Marco Vassallo - - This progrm is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -''' - -# Author: Juan Pablo Carbajal <ajuanpi+dev@gmail.com> -# Modified by: Marco Vassallo - -from subprocess import check_call -from subprocess import CalledProcessError -from os import devnull - -import codeCreator as cc - -class codeMantainer (): - - def __init__ (self,name, path = "./include/"): - self.path= path - p = dict (path=self.path) - - self.name = dict (name = name) - - self.mk = [] # placeholder for makefile - - self.make = "make" - self.mk_options = [r'--file=Makefile_{name}'.format (**self.name)] - - def runFs (self): - with open (devnull, "w") as f: - check_call ([self.make] + self.mk_options + ["fs"], stdout=f) - return 0 - - def runRHS (self): - with open (devnull, "w") as f: - check_call ([self.make] + self.mk_options + ["rhs"], stdout=f) - return 0 - - def runLHS (self): - with open (devnull, "w") as f: - check_call ([self.make] + self.mk_options + ["lhs"], stdout=f) - return 0 - - def clean (self): - with open (devnull, "w") as f: - check_call ([self.make] + self.mk_options + ["clean"], stdout=f) - return 0 - - def updateMakefile(self): - self.mk = cc.Makefile(path = self.path, **self.name) - self.mk.writeout () - - def updateFs(self): - self.fs = cc.Functionspace (path = self.path, **self.name) - self.fs.writeout () - - def updateRHS(self): - self.rhs = cc. RHS (path = self.path, **self.name) - self.rhs.writeout () - - def updateLHS(self): - self.lhs = cc. LHS (path = self.path, **self.name) - self.lhs.writeout ()
--- a/obsolete/bin/create_fs.py Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#! usr/bin/python - -import argparse -from codeMantainer import * - -parser = argparse.ArgumentParser() -parser.add_argument('name') -parser.add_argument('path') -args= parser.parse_args() - -myobj = codeMantainer (args.name, args.path) -myobj.updateMakefile () -myobj.updateFs () -myobj.runFs () -myobj.clean () - -quit()
--- a/obsolete/bin/create_lhs.py Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#! usr/bin/python - -import argparse -from codeMantainer import * - -parser = argparse.ArgumentParser() -parser.add_argument('name') -parser.add_argument('path') -args= parser.parse_args() - -myobj = codeMantainer (args.name, args.path) -myobj.updateMakefile () -myobj.updateLHS () -myobj.runLHS () -myobj.clean () - -quit()
--- a/obsolete/bin/create_rhs.py Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#! usr/bin/python - -import argparse -from codeMantainer import * - -parser = argparse.ArgumentParser() -parser.add_argument('name') -parser.add_argument('path') -args= parser.parse_args() - -myobj = codeMantainer (args.name, args.path) -myobj.updateMakefile () -myobj.updateRHS () -myobj.runRHS () -myobj.clean () - -quit()
--- a/obsolete/fem_fs.cc Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - Copyright (C) 2013 Marco Vassallo - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program 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 General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, see <http://www.gnu.org/licenses/>. -*/ - - -#include "functionspace.h" -#include "mesh.h" -#include "Laplace.h" - -DEFUN_DLD (fem_fs, args, , "initialize a fs from a mesh declared with fem_init_mesh") -{ - int nargin = args.length (); - octave_value retval; - - if (nargin < 1 || nargin > 1) - print_usage (); - else - { - - if (! mesh_type_loaded) - { - mesh::register_type (); - mesh_type_loaded = true; - mlock (); - } - - if (args(0).type_id () == mesh::static_type_id ()) - { - const mesh & msho = static_cast<const mesh&> (args(0).get_rep ()); - const dolfin::Mesh & mshd = msho.get_msh (); - boost::shared_ptr <const dolfin::FunctionSpace> g (new Laplace::FunctionSpace (mshd)); - - if (! functionspace_type_loaded) - { - functionspace::register_type (); - functionspace_type_loaded = true; - mlock (); - } - - retval = new functionspace(g); - } - } - return retval; -}
--- a/obsolete/fem_func_space.m Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -## Copyright (C) 2013 Marco Vassallo - -## This program is free software; you can redistribute it and/or modify it under -## the terms of the GNU General Public License as published by the Free Software -## Foundation; either version 2 of the License, or (at your option) any later -## version. - -## This program 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 General Public License for more -## details. - -## You should have received a copy of the GNU General Public License along with -## this program; if not, see <http://www.gnu.org/licenses/>. - - -## -*- texinfo -*- -## @deftypefn {Function File} {} = fem_ffc (myproblem.ufl) -## This function take as input a .ufl file with a Variationa Problem -## @example -## -## @end example -## @seealso{} -## @end deftypefn - -function res = fem_func_space (mesh, name) - - if nargin != 2 - error ("fem_ffc: wrong number of input parameters."); - elseif ! isstr (name) - error ("fem_ffc: first argument is not a valid string"); - endif - - # fem_fs.cc is the file where I should include name.h - # I use name.h at line 35, where I call - # "new FunctionSpace (mshd);" - # because FunctionSpace is defined inside of name.h - # (correct call would be "name::FunctionSpace (mshd)" but - # I'm using the namespace "name") - command = "cp ../src/fem_fs.cc fem_fs.cc"; - [output, text] = system (command); - if output != 0 - display (text); - error ("Compilation failed"); - endif - - # add line to fem_fs.cc - filename = "fem_fs.cc"; - fid = fopen (filename, "r+"); - fseek (fid, 671, SEEK_SET ()); - fprintf (fid, "%c%s.h%c", 34, name, 34); - fseek (fid, 721, SEEK_SET ()); - fprintf (fid, "%s%c", name, 59); - fclose (fid); - - #now compile the program - command = "mkoctfile -c fem_fs.cc $(LDFLAGS) -o fem_fs.o -I../src/"; - [output, text] = system (command); - if output != 0 - display (text); - error ("Compilation failed"); - endif - - command = "mkoctfile -s ../src/mesh.o ../src/fem_init_env.o fem_fs.o -o fem_fs.oct $(LDFLAGS) -ldolfin"; - [output, text] = system (command); - if output != 0 - display (text); - error ("Compilation failed"); - endif - - #run the program and get the result - res = fem_fs (mesh); - -endfunction -
--- a/obsolete/fem_get_mesh.cc Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* - Copyright (C) 2013 Marco Vassallo - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program 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 General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -#include "mesh.h" - -DEFUN_DLD (fem_get_mesh, args, ,"-*- texinfo -*-\n\ -@deftypefn {Function File} {[@var{mesh}]} = \ -fem_get_mesh (@var{fem_mesh}) \n\ -Return a (p, e, t) representation of @var{fem_mesh}\n\ -The @var{mesh_to_read} should be an object created with \ -fem_init_mesh().\n\ -The output @var{mesh} is a PDE-tool like structure\n\ -with matrix fields (p,e,t).\n\ -@seealso{fem_init_mesh}\n\ -@end deftypefn") -{ - int nargin = args.length (); - octave_value retval; - - if (nargin < 1 || nargin > 1) - print_usage (); - else - { - - if (! mesh_type_loaded) - { - mesh::register_type (); - mesh_type_loaded = true; - mlock (); - } - - if (args(0).type_id () == mesh::static_type_id ()) - { - const mesh & msh = static_cast<const mesh&> (args(0).get_rep ()); - retval = octave_value (msh.get_pet ()); - } - else - error ("fem_get_mesh: the argument is not a mesh type"); - } - return retval; -} - -octave_scalar_map -mesh::get_pet () const -{ - const dolfin::Mesh & msh (*pmsh); - //p matrix - uint D = msh.topology ().dim (); - std::size_t num_v = msh.num_vertices (); - Matrix p (D, num_v); - std::copy (msh.coordinates ().begin (), - msh.coordinates ().end (), - p.fortran_vec ()); - - // e has 7 rows in 2d, 10 rows in 3d - msh.init (D - 1, D); - std::size_t num_f = msh.num_facets (); - dim_vector dims; - dims.resize (2); - dims(0) = D == 2 ? 7 : 10; - dims(1) = num_f; - Array<octave_idx_type> e (dims, 0); - octave_idx_type *evec = e.fortran_vec (); - uint D2 = D * D; - octave_idx_type l = 0, m = 0; - - dolfin::MeshFunction <std::size_t> facet_domains; - if (! msh.domains ().is_empty ()) - if (msh.domains ().num_marked (D-1) != 0) - facet_domains = * (msh.domains ().facet_domains ()); - - for (dolfin::FacetIterator f (msh); ! f.end (); ++f) - { - if ((*f).exterior () == true) - { - l = 0; - for (dolfin::VertexIterator v (*f); ! v.end (); ++v, ++l) - e.xelem (l, m) = (*v).index () + 1; - - if (! facet_domains.empty ()) - e.xelem (D2, m) = facet_domains[*f]; - - ++m; - } - } - - dims(1) = m; - e.resize (dims); - - for (octave_idx_type j = e.rows () - 2; - j < e.numel () - 2; j += e.rows ()) - evec[j] = 1; - - // t matrix - dims(0) = D + 2; - dims(1) = msh.num_cells (); - Array<octave_idx_type> t (dims, 1); - std::vector<unsigned int> my_cells = msh.cells (); - std::size_t n = 0; - - dolfin::MeshFunction<std::size_t> cell_domains; - if (! msh.domains ().is_empty ()) - if (msh.domains ().num_marked (D) != 0) - cell_domains = * (msh.domains ().cell_domains ()); - - for (octave_idx_type j = 0; j < t.cols (); ++j) - { - for (octave_idx_type i = 0; i < D + 1; ++i, ++n) - t.xelem (i, j) += my_cells[n]; - - if (! cell_domains.empty ()) - t.xelem (D + 1, j) = cell_domains[j]; - } - - octave_scalar_map a; - a.setfield ("p", p); - a.setfield ("e", e); - a.setfield ("t", t); - return a; - -}
--- a/obsolete/fem_init_env.cc Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - Copyright (C) 2013 Marco Vassallo - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program 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 General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, see <http://www.gnu.org/licenses/>. -*/ - - -#include "mesh.h" -#include "functionspace.h" -#include "boundarycondition.h" -#include "coefficient.h" -#include "function.h" - -DEFUN_DLD (fem_init_env, args, , "-*- texinfo -*-\n\ -@deftypefn {Function File} {[]} = \ -fem_init_env ( ) \n\ -Initialize the environment for fem-fenics\n\ -@end deftypefn") -{ - int nargin = args.length (); - octave_value retval; - - if (nargin < 0 || nargin > 0) - print_usage (); - else - { - mesh::register_type (); - mesh_type_loaded = true; - std::cout << "mesh_type_loaded" << std::endl; - functionspace::register_type (); - functionspace_type_loaded = true; - std::cout << "functionspace_type_loaded" << std::endl; - boundarycondition::register_type (); - boundarycondition_type_loaded = true; - std::cout << "boundarycondition_type_loaded" << std::endl; - coefficient::register_type (); - coefficient_type_loaded = true; - std::cout << "coefficient_type_loaded" << std::endl; - function::register_type (); - function_type_loaded = true; - std::cout << "function_type_loaded" << std::endl; - mlock (); - } - return retval; -}
--- a/obsolete/fem_lhs.cc Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* - Copyright (C) 2013 Marco Vassallo - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program 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 General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -#include "Laplace.h" -#include <dolfin.h> -#include "functionspace.h" -#include "boundarycondition.h" -#include "coefficient.h" - -DEFUN_DLD (fem_lhs, args, , "-*- texinfo -*-\n\ -@deftypefn {Function File} {[@var{bc}]} = \ -fem_rhs (@var{Functional Space}, @var{Coefficient}, \ -@var{Boundary Condition}) \n\ -The input parameters are\n\ -@itemize @bullet \n\ -@item @var{Functional Space} is the fem-fenics functional space where\ -the bilinear form is defined\n\ -@item @var{Boundary Condition} contains the value of the essential bc that\ -we want to apply to the Bilinear Form\n\ -@item @var{Coefficient} is a variable of type coefficient which contains\ -the value of the coefficient for the bilinear form\n\ -@end itemize\n\ -The output @var{A} is a sparse matrix which represents the bilinear form\n\ -@seealso{fem_init_mesh, fem_fs}\n\ -@end deftypefn") -{ - - int nargin = args.length (); - octave_value retval; - - if (nargin < 1) - print_usage (); - else - { - - if (! functionspace_type_loaded) - { - functionspace::register_type (); - functionspace_type_loaded = true; - mlock (); - } - if (args(0).type_id () == functionspace::static_type_id ()) - { - const functionspace & fspo - = static_cast<const functionspace&> (args(0).get_rep ()); - - if (! error_state) - { - const dolfin::FunctionSpace V = fspo.get_fsp (); - Laplace::LinearForm L (V); - std::size_t ncoef = L.num_coefficients (), nc = 0; - - if (! coefficient_type_loaded) - { - coefficient::register_type (); - coefficient_type_loaded = true; - mlock (); - } - for (std::size_t i = 1; i < nargin; ++i) - { - if (args(i).type_id () == coefficient::static_type_id ()) - { - const coefficient & cf - = static_cast <const coefficient&> (args(i).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); - ++nc; - } - } - - if (nc != ncoef) - error ("Wrong number of coefficient"); - else - { - - dolfin::Vector b; - dolfin::assemble (b, L); - - if (! boundarycondition_type_loaded) - { - boundarycondition::register_type (); - boundarycondition_type_loaded = true; - mlock (); - } - for (std::size_t i = 1; i < nargin; ++i) - { - if (args(i).type_id () == boundarycondition::static_type_id ()) - { - const boundarycondition & bc - = static_cast<const boundarycondition&> (args(i).get_rep ()); - - const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & pbc - = bc.get_bc (); - for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(b); - } - } - - dim_vector dims; - dims.resize (2); - dims(0) = b.size (); - dims(1) = 1; - Array<double> myb (dims); - - for (std::size_t i = 0; i < b.size (); ++i) - myb(i) = b[i]; - - retval = myb; - } - } - } - } - return retval; -}
--- a/obsolete/fem_rhs.cc Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - Copyright (C) 2013 Marco Vassallo - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program 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 General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -#include "Laplace.h" -#include <dolfin.h> -#include "functionspace.h" -#include "boundarycondition.h" -#include "coefficient.h" - -DEFUN_DLD (fem_rhs, args, , "-*- texinfo -*-\n\ -@deftypefn {Function File} {[@var{bc}]} = \ -fem_rhs (@var{Functional Space}, @var{Coefficient}, \ -@var{Boundary Condition}) \n\ -The input parameters are\n\ -@itemize @bullet \n\ -@item @var{Functional Space} is the fem-fenics functional space where\ -the bilinear form is defined\n\ -@item @var{Boundary Condition} contains the value of the essential bc that\ -we want to apply to the Bilinear Form\n\ -@item @var{Coefficient} is a variable of type coefficient which contains\ -the value of the coefficient for the bilinear form\n\ -@end itemize\n\ -The output @var{A} is a sparse matrix which represents the bilinear form\n\ -@seealso{fem_init_mesh, fem_fs}\n\ -@end deftypefn") -{ - - int nargin = args.length (); - octave_value retval; - - if (nargin < 1) - print_usage (); - else - { - if (! functionspace_type_loaded) - { - functionspace::register_type (); - functionspace_type_loaded = true; - mlock (); - } - if (args(0).type_id () == functionspace::static_type_id ()) - { - const functionspace & fspo - = static_cast<const functionspace&> (args(0).get_rep ()); - - if (! error_state) - { - const dolfin::FunctionSpace V = fspo.get_fsp (); - Laplace::BilinearForm a (V, V); - std::size_t ncoef = a.num_coefficients (), nc = 0; - - if (! coefficient_type_loaded) - { - coefficient::register_type (); - coefficient_type_loaded = true; - mlock (); - } - - for (std::size_t i = 1; i < nargin; ++i) - { - if (args(i).type_id () == coefficient::static_type_id ()) - { - const coefficient & cf - = static_cast <const coefficient&> (args(i).get_rep ()); - - std::size_t n = a.coefficient_number (cf.get_str ()); - const boost::shared_ptr<const expression> & pexp = cf.get_expr (); - a.set_coefficient (n, pexp); - ++nc; - } - } - - if (nc != ncoef) - error ("Wrong number of coefficient"); - else - { - - dolfin::Matrix A; - dolfin::assemble (A, a); - - if (! boundarycondition_type_loaded) - { - boundarycondition::register_type (); - boundarycondition_type_loaded = true; - mlock (); - } - - for (std::size_t i = 1; i < nargin; ++i) - { - if (args(i).type_id () == boundarycondition::static_type_id ()) - { - const boundarycondition & bc - = static_cast<const boundarycondition&> (args(i).get_rep ()); - - const std::vector<boost::shared_ptr <const dolfin::DirichletBC> > & pbc - = bc.get_bc (); - for (std::size_t j = 0; j < pbc.size (); ++j) - pbc[j]->apply(A); - } - } - - int nr = A.size (0), nc = A.size (1); - // nz shoud be estimated in a better way - int nz = nr * nc; - SparseMatrix sm (nr, nc, nz); - - int ii = 0; - sm.cidx (0) = 0; - for (int j = 0; j < nc; ++j) - { - for (int i = 0; i < nr; i++) - { - double tmp = A(i, j); - if (tmp != 0.) - { - sm.data(ii) = tmp; - sm.ridx(ii) = i; - ii++; - } - } - sm.cidx(j+1) = ii; - } - sm.maybe_compress (); - - retval = sm; - - } - } - } - } - return retval; -}
--- a/obsolete/plot.cc Wed Nov 06 05:37:11 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - Copyright (C) 2013 Marco Vassallo - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your option) any later - version. - - This program 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 General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -#include "function.h" -#include "mesh.h" -#include "Plot_2d.h" -#include "Plot_3d.h" - -DEFUN_DLD (plot, args, , "-*- texinfo -*-\n\ -@deftypefn {Function File} \ -fem_func (@var{Function})\n\ -The input parameter is the object that you want to plot\n\ -It can be either a Function or a Mesh \n\ -@seealso{fem_func, fem_save}\n\ -@end deftypefn") -{ - - int nargin = args.length (); - octave_value retval; - - if (nargin < 1 || nargin > 2) - print_usage (); - else - { - if (! function_type_loaded) - { - function::register_type (); - function_type_loaded = true; - mlock (); - } - - if (! mesh_type_loaded) - { - mesh::register_type (); - mesh_type_loaded = true; - mlock (); - } - - if (args(0).type_id () == function::static_type_id ()) - { - const function & uo = - static_cast<const function&> (args(0).get_rep ()); - - if (!error_state) - { - const boost::shared_ptr<const dolfin::Function> & u = uo.get_pfun (); - dolfin::plot (*u); - dolfin::interactive (); - retval = 0; - } - } - - else if (args(0).type_id () == mesh::static_type_id ()) - { - const mesh & msho = static_cast<const mesh&> (args(0).get_rep ()); - if (nargin == 1) - { - if (!error_state) - { - const boost::shared_ptr<const dolfin::Mesh> & mshd = msho.get_pmsh (); - dolfin::plot (*mshd); - dolfin::interactive (); - retval = 0; - } - } - else if (nargin == 2) - - } - - } - return retval; -}
--- a/obsolete/test/Laplace.ufl Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/Makefile Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/laplace.m Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/mesh_test.m Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_all.m Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_bc.cpp Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_bc.m Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_coeff.cpp Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_coeff.m Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_expr.cpp Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_expr.m Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_rlhs.cc Wed Nov 06 05:37:11 2013 +0000 +++ /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/obsolete/test/test_rlhs.m Wed Nov 06 05:37:11 2013 +0000 +++ /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);