Mercurial > fem-fenics-eugenio
comparison src/assemble_system.cc @ 268:61830a4f9ab9
Improve formatting
author | Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> |
---|---|
date | Thu, 14 Aug 2014 12:26:55 +0200 |
parents | 5e9b5bbdc56b |
children | f4d6ae912a08 |
comparison
equal
deleted
inserted
replaced
267:53039ac90368 | 268:61830a4f9ab9 |
---|---|
1 /* | 1 /* |
2 Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net> | 2 Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net> |
3 | 3 |
4 This program is free software; you can redistribute it and/or modify it under | 4 This program is free software; you can redistribute it and/or modify it under |
5 the terms of the GNU General Public License as published by the Free Software | 5 the terms of the GNU General Public License as published by the Free Software |
6 Foundation; either version 3 of the License, or (at your option) any later | 6 Foundation; either version 3 of the License, or (at your option) any later |
7 version. | 7 version. |
58 } | 58 } |
59 | 59 |
60 if (nargout == 2) | 60 if (nargout == 2) |
61 { | 61 { |
62 if (nargin < 2) | 62 if (nargin < 2) |
63 print_usage (); | 63 { print_usage (); } |
64 else | 64 else |
65 { | 65 { |
66 | 66 |
67 if (args(0).type_id () == form::static_type_id () | 67 if (args(0).type_id () == form::static_type_id () |
68 && args(1).type_id () == form::static_type_id ()) | 68 && args(1).type_id () == form::static_type_id ()) |
69 { | 69 { |
70 const form & frm1 = | 70 const form & frm1 = |
71 static_cast<const form&> (args(0).get_rep ()); | 71 static_cast<const form &> (args(0).get_rep ()); |
72 const form & frm2 = | 72 const form & frm2 = |
73 static_cast<const form&> (args(1).get_rep ()); | 73 static_cast<const form &> (args(1).get_rep ()); |
74 | 74 |
75 if (! error_state) | 75 if (! error_state) |
76 { | 76 { |
77 const dolfin::Form & a = frm1.get_form (); | 77 const dolfin::Form & a = frm1.get_form (); |
78 const dolfin::Form & b = frm2.get_form (); | 78 const dolfin::Form & b = frm2.get_form (); |
92 { | 92 { |
93 if (args(i).type_id () == | 93 if (args(i).type_id () == |
94 boundarycondition::static_type_id ()) | 94 boundarycondition::static_type_id ()) |
95 { | 95 { |
96 const boundarycondition & bc | 96 const boundarycondition & bc |
97 = static_cast<const boundarycondition&> | 97 = static_cast<const boundarycondition &> |
98 (args(i).get_rep ()); | 98 (args(i).get_rep ()); |
99 | 99 |
100 const std::vector<SHARED_PTR | 100 const std::vector<SHARED_PTR |
101 <const dolfin::DirichletBC> > | 101 <const dolfin::DirichletBC> > |
102 & pbc = bc.get_bc (); | 102 & pbc = bc.get_bc (); |
103 | 103 |
104 for (std::size_t j = 0; j < pbc.size (); ++j) | 104 for (std::size_t j = 0; j < pbc.size (); ++j) |
105 pbc[j]->apply(A, B); | 105 { pbc[j]->apply (A, B); } |
106 } | 106 } |
107 else | 107 else |
108 error ("assemble_system: unknown argument type"); | 108 { error ("assemble_system: unknown argument type"); } |
109 } | 109 } |
110 | 110 |
111 retval(0) = factory.matrix (A); | 111 retval(0) = factory.matrix (A); |
112 retval(1) = factory.vector (B); | 112 retval(1) = factory.vector (B); |
113 } | 113 } |
114 } | 114 } |
115 else | 115 else |
116 error ("assemble_system: unknown size"); | 116 { error ("assemble_system: unknown size"); } |
117 } | 117 } |
118 } | 118 } |
119 } | 119 } |
120 else if (nargout == 3) | 120 else if (nargout == 3) |
121 { | 121 { |
122 if (nargin < 3) | 122 if (nargin < 3) |
123 print_usage (); | 123 { print_usage (); } |
124 else | 124 else |
125 { | 125 { |
126 if (args(0).type_id () == form::static_type_id () | 126 if (args(0).type_id () == form::static_type_id () |
127 && args(1).type_id () == form::static_type_id ()) | 127 && args(1).type_id () == form::static_type_id ()) |
128 { | 128 { |
129 const form & frm1 = | 129 const form & frm1 = |
130 static_cast<const form&> (args(0).get_rep ()); | 130 static_cast<const form &> (args(0).get_rep ()); |
131 const form & frm2 = | 131 const form & frm2 = |
132 static_cast<const form&> (args(1).get_rep ()); | 132 static_cast<const form &> (args(1).get_rep ()); |
133 const Array<double> myx = args(2).array_value (); | 133 const Array<double> myx = args(2).array_value (); |
134 | 134 |
135 if (! error_state) | 135 if (! error_state) |
136 { | 136 { |
137 const dolfin::Form & a = frm1.get_form (); | 137 const dolfin::Form & a = frm1.get_form (); |
152 #else | 152 #else |
153 dolfin::Vector x (myx.length ()); | 153 dolfin::Vector x (myx.length ()); |
154 #endif | 154 #endif |
155 | 155 |
156 for (std::size_t i = 0; i < myx.length (); ++i) | 156 for (std::size_t i = 0; i < myx.length (); ++i) |
157 x.setitem (i, myx.xelem (i)); | 157 { x.setitem (i, myx.xelem (i)); } |
158 | 158 |
159 for (std::size_t i = 3; i < nargin; ++i) | 159 for (std::size_t i = 3; i < nargin; ++i) |
160 { | 160 { |
161 if (args(i).type_id () == | 161 if (args(i).type_id () == |
162 boundarycondition::static_type_id ()) | 162 boundarycondition::static_type_id ()) |
163 { | 163 { |
164 const boundarycondition & bc | 164 const boundarycondition & bc |
165 = static_cast<const boundarycondition&> | 165 = static_cast<const boundarycondition &> |
166 (args(i).get_rep ()); | 166 (args(i).get_rep ()); |
167 | 167 |
168 const std::vector<SHARED_PTR | 168 const std::vector<SHARED_PTR |
169 <const dolfin::DirichletBC> > | 169 <const dolfin::DirichletBC> > |
170 & pbc = bc.get_bc (); | 170 & pbc = bc.get_bc (); |
171 | 171 |
172 for (std::size_t j = 0; | 172 for (std::size_t j = 0; |
173 j < pbc.size (); ++j) | 173 j < pbc.size (); ++j) |
174 pbc[j]->apply(A, B, x); | 174 { pbc[j]->apply (A, B, x); } |
175 | 175 |
176 } | 176 } |
177 else | 177 else |
178 error ("assemble_system: unknown argument type"); | 178 { error ("assemble_system: unknown argument type"); } |
179 } | 179 } |
180 | 180 |
181 retval(0) = factory.matrix (A); | 181 retval(0) = factory.matrix (A); |
182 retval(1) = factory.vector (B); | 182 retval(1) = factory.vector (B); |
183 retval(2) = factory.vector (x); | 183 retval(2) = factory.vector (x); |
184 } | 184 } |
185 } | 185 } |
186 else | 186 else |
187 error ("assemble_system: unknown size"); | 187 { error ("assemble_system: unknown size"); } |
188 } | 188 } |
189 } | 189 } |
190 } | 190 } |
191 return retval; | 191 return retval; |
192 } | 192 } |