annotate src/DirichletBC.cc @ 151:5fe2a157f4eb

Update GPL to v3
author gedeone-octave <marcovass89@hotmail.it>
date Wed, 11 Sep 2013 08:50:35 +0200
parents 9486cbdc0a2e
children 67944f307560
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
1 /*
151
5fe2a157f4eb Update GPL to v3
gedeone-octave <marcovass89@hotmail.it>
parents: 143
diff changeset
2 Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net>
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
3
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify it under
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
5 the terms of the GNU General Public License as published by the Free Software
151
5fe2a157f4eb Update GPL to v3
gedeone-octave <marcovass89@hotmail.it>
parents: 143
diff changeset
6 Foundation; either version 3 of the License, or (at your option) any later
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
7 version.
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
8
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful, but WITHOUT
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
12 details.
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
13
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License along with
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
15 this program; if not, see <http://www.gnu.org/licenses/>.
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
16 */
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
17
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
18 #include "boundarycondition.h"
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
19 #include "functionspace.h"
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
20 #include "expression.h"
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
21
78
670a5d91c397 Rename the function visible from the user accordingly to dolfin interface.
gedeone-octave <marcovass89@hotmail.it>
parents: 75
diff changeset
22 DEFUN_DLD (DirichletBC, args, , "-*- texinfo -*-\n\
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
23 @deftypefn {Function File} {[@var{bc}]} = \
135
547763139e1a Fix minor bug
gedeone-octave <marcovass89@hotmail.it>
parents: 131
diff changeset
24 DirichletBC (@var{Functional Space}, @var{Boundary Label}, @var{Function handle}) \n\
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
25 The input parameters are\n\
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
26 @itemize @bullet \n\
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
27 @item @var{Functional Space} is a fem-fenics functional space where\
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
28 we want to apply the BC\n\
117
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
29 @item @var{Function handle} is a function handle which contains the expression\
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
30 that we want to apply as BC. If we have a Vector field, we can just use a\n\
125
a80ac536c78a Fix bug in the texinfo code
gedeone-octave <marcovass89@hotmail.it>
parents: 117
diff changeset
31 vector of function handle: @var{Function handle} = ['@'(x, y) f1, '@'(x, y) f2, ...]\n\
117
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
32 @item @var{Boundary} is an Array which contains the labels of the \
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
33 sides where the BC is applied\n\
50
fcfecdd3a9b5 Maint: improve the documentation
gedeone-octave <marco.vassallo@outlook.com>
parents: 44
diff changeset
34 @end itemize\n\
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
35 The output @var{BC} is an object which contains the boundary conditions\n\
143
9486cbdc0a2e Maint: update the documentation
gedeone-octave <marcovass89@hotmail.it>
parents: 137
diff changeset
36 @seealso{Mesh, FunctionSpace}\n\
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
37 @end deftypefn")
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
38 {
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
39 int nargin = args.length ();
75
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
40 octave_value retval;
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
41
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
42 if (nargin < 3 || nargin > 3)
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
43 print_usage ();
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
44 else
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
45 {
44
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
46
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
47 if (! functionspace_type_loaded)
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
48 {
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
49 functionspace::register_type ();
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
50 functionspace_type_loaded = true;
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
51 mlock ();
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
52 }
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
53
117
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
54 if (! boundarycondition_type_loaded)
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
55 {
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
56 boundarycondition::register_type ();
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
57 boundarycondition_type_loaded = true;
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
58 mlock ();
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
59 }
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
60
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
61 if (args(0).type_id () == functionspace::static_type_id ())
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
62 {
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
63 const functionspace & fspo = static_cast<const functionspace&> (args(0).get_rep ());
137
3a0f952a79ec Avois useless output.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
64 octave_fcn_handle * fh = args(1).fcn_handle_value ();
3a0f952a79ec Avois useless output.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
65 Array<octave_idx_type> side = args(2).array_value ();
3a0f952a79ec Avois useless output.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
66
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
67
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
68 if (!error_state)
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
69 {
117
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
70 std::cout <<"Building essential boundary condition..."<< std::endl;
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
71 const boost::shared_ptr <const dolfin::FunctionSpace> & V (fspo.get_pfsp ());
75
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
72
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
73 octave_value_list b (3, 1);
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
74 octave_value_list tmp = feval (fh->function_value (), b);
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
75 Array<double> res = tmp(0).array_value ();
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
76 std::size_t l = res.length ();
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
77
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
78 expression * pf;
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
79 if (l > 1)
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
80 pf = new expression (*fh, l);
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
81 else
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
82 pf = new expression (*fh);
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
83
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
84 boost::shared_ptr<const expression> f (pf);
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
85 boundarycondition * pbc = new boundarycondition ();
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
86
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
87 for (octave_idx_type i = 0; i < side.length (); ++i)
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
88 pbc->add_bc (V, f, side(i));
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
89 retval = octave_value (pbc);
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
90 }
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
91 }
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
92 }
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
93 return retval;
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
94 }