Mercurial > fem-fenics-eugenio
annotate src/fem_bc.cc @ 50:fcfecdd3a9b5
Maint: improve the documentation
author | gedeone-octave <marco.vassallo@outlook.com> |
---|---|
date | Thu, 25 Jul 2013 09:04:36 +0200 |
parents | fca8c3d75036 |
children | d6df5cc8ef53 |
rev | line source |
---|---|
31
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
1 /* |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
2 Copyright (C) 2013 Marco Vassallo |
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 |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
6 Foundation; either version 2 of the License, or (at your option) any later |
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 |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
22 DEFUN_DLD (fem_bc, args, , "-*- texinfo -*-\n\ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
23 @deftypefn {Function File} {[@var{bc}]} = \ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
24 fem_get_mesh (@var{Functional Space}, @var{Functio handle}, \ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
25 @var{Boundary}) \n\ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
26 The input parameters are\n\ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
27 @itemize @bullet \n\ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
28 @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
|
29 we want to apply the BC\n\ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
30 @item @var{Functio handle} is a function handle which contains the expression\ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
31 that we want to apply on the BC\n\ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
32 @item @var{Boundary} is an Array which specify the label of the \ |
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\ |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
36 @seealso{fem_init_mesh, fem_fs}\n\ |
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 (); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
40 octave_value retval=0; |
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 |
31
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
54 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
|
55 { |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
56 const functionspace & fspo = static_cast<const functionspace&> (args(0).get_rep ()); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
57 octave_fcn_handle * fh = args(1).fcn_handle_value (); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
58 Array<octave_idx_type> side = args(2).array_value (); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
59 |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
60 if (!error_state) |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
61 { |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
62 const boost::shared_ptr <const dolfin::FunctionSpace> & V (fspo.get_pfsp ()); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
63 const expression * pf = new expression (*fh); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
64 boost::shared_ptr<const expression> f (pf); |
44
fca8c3d75036
register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents:
31
diff
changeset
|
65 |
fca8c3d75036
register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents:
31
diff
changeset
|
66 if (! boundarycondition_type_loaded) |
fca8c3d75036
register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents:
31
diff
changeset
|
67 { |
fca8c3d75036
register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents:
31
diff
changeset
|
68 boundarycondition::register_type (); |
fca8c3d75036
register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents:
31
diff
changeset
|
69 boundarycondition_type_loaded = true; |
fca8c3d75036
register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents:
31
diff
changeset
|
70 mlock (); |
fca8c3d75036
register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents:
31
diff
changeset
|
71 } |
fca8c3d75036
register_type is called before every type is used.
gedeone-octave <marco.vassallo@outlook.com>
parents:
31
diff
changeset
|
72 |
31
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
73 boundarycondition * pbc = new boundarycondition (); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
74 |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
75 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
|
76 pbc->add_bc (V, f, side(i)); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
77 |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
78 retval = octave_value (pbc); |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
79 } |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
80 } |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
81 } |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
82 return retval; |
74cbe97f55af
New class for treatment of BC
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
83 } |