annotate src/DirichletBC.cc @ 253:5e9b5bbdc56b

Support both DOLFIN 1.3.0 and 1.4.0 * src/dolfin_compat.h: use a macro to set the correct shared_ptr (std or boost)
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Tue, 29 Jul 2014 18:05:56 +0200
parents 2dde165e3fd5
children ab35a8b0deef
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"
253
5e9b5bbdc56b Support both DOLFIN 1.3.0 and 1.4.0
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 186
diff changeset
21 #include "dolfin_compat.h"
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
22
173
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 168
diff changeset
23 DEFUN_DLD (DirichletBC, args, ,
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 168
diff changeset
24 "-*- texinfo -*-\n\
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
25 @deftypefn {Function File} {[@var{bc}]} = \
182
b40f22aad4af Improve the documentation for the pkg release.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
26 DirichletBC (@var{FunctionSpace}, @var{Boundary_Label},\
b40f22aad4af Improve the documentation for the pkg release.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
27 @var{Function_handle}) \n\
b40f22aad4af Improve the documentation for the pkg release.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
28 Specify essential boundary condition on a specific side.\n\
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
29 The input parameters are\n\
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
30 @itemize @bullet \n\
182
b40f22aad4af Improve the documentation for the pkg release.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
31 @item @var{FunctionSpace} is the fem-fenics space where \
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
32 we want to apply the BC\n\
182
b40f22aad4af Improve the documentation for the pkg release.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
33 @item @var{Function_handle} is a function handle which contains the expression \
b40f22aad4af Improve the documentation for the pkg release.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
34 that we want to apply as a BC. If we have a Vector field, we can just use a\n\
b40f22aad4af Improve the documentation for the pkg release.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
35 vector of function handles: \
186
2dde165e3fd5 Fix error in the documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 184
diff changeset
36 @var{Function handle} = ['''@'''(x, y) f1, '''@'''(x, y) f2, ...]\n\
184
66071811eef8 Improve the documentation for the pkg releae.
gedeone-octave <marcovass89@hotmail.it>
parents: 183
diff changeset
37 @item @var{Boundary_Label} is an Array which contains the label(s) of the \
182
b40f22aad4af Improve the documentation for the pkg release.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
38 side(s) where the BC has to be applied.\n\
50
fcfecdd3a9b5 Maint: improve the documentation
gedeone-octave <marco.vassallo@outlook.com>
parents: 44
diff changeset
39 @end itemize\n\
183
536ee96a8cd0 Fix other errors in the documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 182
diff changeset
40 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
41 @seealso{Mesh, FunctionSpace}\n\
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
42 @end deftypefn")
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
43 {
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
44 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
45 octave_value retval;
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
46
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
47 if (nargin < 3 || nargin > 3)
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
48 print_usage ();
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
49 else
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
50 {
44
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
51
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
52 if (! functionspace_type_loaded)
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
53 {
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
54 functionspace::register_type ();
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
55 functionspace_type_loaded = true;
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
56 mlock ();
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
57 }
fca8c3d75036 register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents: 31
diff changeset
58
117
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
59 if (! boundarycondition_type_loaded)
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
60 {
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
61 boundarycondition::register_type ();
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
62 boundarycondition_type_loaded = true;
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
63 mlock ();
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
64 }
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 78
diff changeset
65
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
66 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
67 {
173
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 168
diff changeset
68 const functionspace & fspo =
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 168
diff changeset
69 static_cast<const functionspace&> (args(0).get_rep ());
137
3a0f952a79ec Avois useless output.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
70 octave_fcn_handle * fh = args(1).fcn_handle_value ();
3a0f952a79ec Avois useless output.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
71 Array<octave_idx_type> side = args(2).array_value ();
3a0f952a79ec Avois useless output.
gedeone-octave <marcovass89@hotmail.it>
parents: 135
diff changeset
72
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
73
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
74 if (!error_state)
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
75 {
253
5e9b5bbdc56b Support both DOLFIN 1.3.0 and 1.4.0
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 186
diff changeset
76 const SHARED_PTR <const dolfin::FunctionSpace>
173
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 168
diff changeset
77 & 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
78
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
79 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
80 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
81 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
82 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
83
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
84 expression * pf;
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
85 if (l > 1)
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
86 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
87 else
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
88 pf = new expression (*fh);
d6df5cc8ef53 Improve the expression class to deal also with vector fields.
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
89
253
5e9b5bbdc56b Support both DOLFIN 1.3.0 and 1.4.0
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 186
diff changeset
90 SHARED_PTR <const expression> f (pf);
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
91 boundarycondition * pbc = new boundarycondition ();
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
92
173
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 168
diff changeset
93 for (octave_idx_type i = 0;
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 168
diff changeset
94 i < side.length (); ++i)
31
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
95 pbc->add_bc (V, f, side(i));
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
96 retval = octave_value (pbc);
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
97 }
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
98 }
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
99 }
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
100 return retval;
74cbe97f55af New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
101 }