Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
form.h
Go to the documentation of this file.
1# ifndef _RHEOLEF_FORM_H
2# define _RHEOLEF_FORM_H
3//
4// This file is part of Rheolef.
5//
6// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7//
8// Rheolef is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 2 of the License, or
11// (at your option) any later version.
12//
13// Rheolef is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with Rheolef; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// =========================================================================
23// AUTHOR: Pierre.Saramito@imag.fr
24// DATE: 2 july 1997
25
26namespace rheolef {
124} // namespace rheolef
125
126#include "rheolef/csr.h"
127#include "rheolef/field.h"
128
129namespace rheolef {
130
131namespace details {
132// these classes are used for allocator from the std::initializer_list
133template <class T, class M> class form_concat_value;
134template <class T, class M> class form_concat_line;
135
136// Define traits for un-assembled forms:
137template<class Expr> struct is_form_lazy: std::false_type {};
138} // namespace details
139
140// forward declaration:
141template <class T, class M> class band_basic;
142
143
144// [verbatim_form_basic]
145template<class T, class M>
147public :
148// typedefs:
149
151 typedef T value_type;
155
156// allocator/deallocator:
157
161
162 template<class Expr, class Sfinae = typename std::enable_if<details::is_form_lazy<Expr>::value, Expr>::type>
163 form_basic (const Expr&);
164
165 template<class Expr, class Sfinae = typename std::enable_if<details::is_form_lazy<Expr>::value, Expr>::type>
166 form_basic<T,M>& operator= (const Expr&);
167
168// allocators from initializer list (c++ 2011):
169
170 form_basic (const std::initializer_list<details::form_concat_value<T,M> >& init_list);
171 form_basic (const std::initializer_list<details::form_concat_line <T,M> >& init_list);
172
173// accessors:
174
177 const geo_type& get_geo() const;
178 bool is_symmetric() const;
179 void set_symmetry (bool is_symm = true) const;
181 void set_definite_positive (bool is_dp = true) const;
184
185 const communicator& comm() const;
186
187// linear algebra:
188
195 float_type operator () (const field_basic<T,M>& uh, const field_basic<T,M>& vh) const;
196
197// io:
198
199 odiststream& put (odiststream& ops, bool show_partition = true) const;
200 void dump (std::string name) const;
201
202// accessors & modifiers to unknown & blocked parts:
203
204 const csr<T,M>& uu() const { return _uu; }
205 const csr<T,M>& ub() const { return _ub; }
206 const csr<T,M>& bu() const { return _bu; }
207 const csr<T,M>& bb() const { return _bb; }
208 csr<T,M>& set_uu() { return _uu; }
209 csr<T,M>& set_ub() { return _ub; }
210 csr<T,M>& set_bu() { return _bu; }
211 csr<T,M>& set_bb() { return _bb; }
212// [verbatim_form_basic]
213// internals:
214 int constraint_process_rank() const { return uu().constraint_process_rank(); }
215// data
216protected:
223
224// internals:
225public:
226 // assembly from an un-assembled form_lazy expr
227 template<class Expr, class Sfinae = typename std::enable_if<details::is_form_lazy<Expr>::value, Expr>::type>
228 void convert_from_form_lazy (const Expr& expr);
229
230 // with vf expression arg
231 template <class Expr>
233 const geo_basic<T,M>& dom,
234 const geo_basic<T,M>& band,
235 const band_basic<T,M>& gh,
236 const Expr& expr,
237 const integrate_option& fopt,
238 bool is_on_band);
239 template <class Expr>
240 void do_integrate (
241 const geo_basic<T,M>& domain,
242 const Expr& expr,
243 const integrate_option& fopt);
244 template <class Expr>
245 void do_integrate (
246 const band_basic<T,M>& gh,
247 const Expr& expr,
248 const integrate_option& fopt);
249
250 // backward compat: named forms
251 form_basic (const space_type& X, const space_type& Y,
252 const std::string& name = "",
253 const quadrature_option& qopt = quadrature_option());
254
255 form_basic (const space_type& X, const space_type& Y,
256 const std::string& name,
257 const field_basic<T,M>& weight,
258 const quadrature_option& qopt = quadrature_option());
259
260 template<class Function>
261 form_basic (const space_type& X, const space_type& Y,
262 const std::string& name,
263 Function weight,
264 const quadrature_option& qopt = quadrature_option());
265
266 form_basic (const space_type& X, const space_type& Y,
267 const std::string& name,
268 const geo_basic<T,M>& gamma,
269 const quadrature_option& qopt = quadrature_option());
270
271 form_basic (const space_type& X, const space_type& Y,
272 const std::string& name,
273 const geo_basic<T,M>& gamma,
274 const field_basic<T,M>& weight,
275 const quadrature_option& qopt = quadrature_option());
276
277 template<class Function>
278 form_basic (
279 const space_type& X,
280 const space_type& Y,
281 const std::string& name,
282 const geo_basic<T,M>& gamma,
283 Function weight,
284 const quadrature_option& qopt = quadrature_option());
285protected:
286 // backward compat: named forms (cont.)
287 template<class WeightFunction>
288 void form_init (
289 const std::string& name,
290 bool has_weight,
291 WeightFunction weight,
292 const quadrature_option& qopt);
293 template<class WeightFunction>
295 const std::string& name,
296 const geo_basic<T,M>& gamma,
297 bool has_weight,
298 WeightFunction weight,
299 const geo_basic<T,M>& w_omega, // the domain where the fct weight is defined
300 const quadrature_option& qopt);
301// [verbatim_form_basic_cont]
302};
303template<class T, class M> form_basic<T,M> trans (const form_basic<T,M>& a);
304template<class T, class M> field_basic<T,M> diag (const form_basic<T,M>& a);
305template<class T, class M> form_basic<T,M> diag (const field_basic<T,M>& dh);
306// [verbatim_form_basic_cont]
307
308// [verbatim_form]
310// [verbatim_form]
311
312// ------------ inline'd -----------------------------------
313
314template<class T, class M>
315inline
317: _X(), _Y(), _uu(), _ub(), _bu(), _bb()
318{
319}
320template<class T, class M>
321inline
323: _X(a._X), _Y(a._Y), _uu(a._uu), _ub(a._ub), _bu(a._bu), _bb(a._bb)
324{
325}
326template<class T, class M>
327inline
330{
331 _X.operator= (a._X);
332 _Y.operator= (a._Y);
333 _uu.operator= (a._uu);
334 _ub.operator= (a._ub);
335 _bu.operator= (a._bu);
336 _bb.operator= (a._bb);
337 return *this;
338}
339template<class T, class M>
340inline
341const typename form_basic<T,M>::space_type&
343{
344 return _X;
345}
346template<class T, class M>
347inline
348const typename form_basic<T,M>::space_type&
350{
351 return _Y;
352}
353template<class T, class M>
354inline
355const typename form_basic<T,M>::geo_type&
357{
358 return _X.get_geo();
359}
360template<class T, class M>
361inline
362const communicator&
364{
365 return get_geo().comm();
366}
367// ----------------
368// linear albebra
369// ----------------
370template<class T, class M>
371inline
374{
375 form_basic<T,M> c (get_first_space(), get_second_space());
376 c._uu = _uu + b._uu;
377 c._ub = _ub + b._ub;
378 c._bu = _bu + b._bu;
379 c._bb = _bb + b._bb;
380 return c;
381}
382template<class T, class M>
383inline
386{
387 form_basic<T,M> c (get_first_space(), get_second_space());
388 c._uu = _uu - b._uu;
389 c._ub = _ub - b._ub;
390 c._bu = _bu - b._bu;
391 c._bb = _bb - b._bb;
392 return c;
393}
394template<class T, class M>
395inline
398{
399 form_basic<T,M> c (b.get_first_space(), get_second_space());
400 c._uu = _uu*b._uu + _ub*b._bu;
401 c._ub = _uu*b._ub + _ub*b._bb;
402 c._bu = _bu*b._uu + _bb*b._bu;
403 c._bb = _bu*b._ub + _bb*b._bb;
404 return c;
405}
406template<class T, class M>
407inline
410{
411 _uu *= lambda;
412 _ub *= lambda;
413 _bu *= lambda;
414 _bb *= lambda;
415 return *this;
416}
417template<class T, class M>
418inline
421{
422 form_basic<T,M> b = a;
423 b *= lambda;
424 return b;
425}
426template<class T, class M>
427inline
428form_basic<T,M>
430{
431 return T(-1)*a;
432}
433template<class T, class M>
434inline
435bool
437{
438 return _uu.is_symmetric() && _bb.is_symmetric();
439}
440template<class T, class M>
441inline
442void
444{
445 _uu.set_symmetry(is_symm);
446 _bb.set_symmetry(is_symm);
447}
448template<class T, class M>
449inline
450bool
452{
453 return _uu.is_definite_positive() && _bb.is_definite_positive();
454}
455template<class T, class M>
456inline
457void
459{
460 _uu.set_definite_positive(is_dp);
461 _bb.set_definite_positive(is_dp);
462}
463template<class T, class M>
464inline
465bool
467{
468 return is_symmetric() && is_definite_positive();
469}
470template<class T, class M>
471inline
472void
474{
475 set_symmetry();
476 set_definite_positive();
477}
478
479}// namespace rheolef
480# endif /* _RHEOLEF_FORM_H */
field gh(Float epsilon, Float t, const field &uh, const test &v)
see the band page for the full documentation
see the csr page for the full documentation
Definition csr.h:317
form_basic< T, M > operator-(const form_basic< T, M > &b) const
Definition form.h:385
csr< T, M > & set_ub()
Definition form.h:209
scalar_traits< T >::type float_type
Definition form.h:152
const csr< T, M > & bb() const
Definition form.h:207
const csr< T, M > & ub() const
Definition form.h:205
form_basic< T, M > operator*(const form_basic< T, M > &b) const
Definition form.h:397
odiststream & put(odiststream &ops, bool show_partition=true) const
Definition form.cc:235
void convert_from_form_lazy(const Expr &expr)
csr< T, M > & set_bu()
Definition form.h:210
space_basic< float_type, M > space_type
Definition form.h:154
csr< T, M > _uu
Definition form.h:219
bool is_definite_positive() const
Definition form.h:451
float_type operator()(const field_basic< T, M > &uh, const field_basic< T, M > &vh) const
Definition form.cc:143
void set_definite_positive(bool is_dp=true) const
Definition form.h:458
space_type _X
Definition form.h:217
form_basic< T, M > & operator=(const form_basic< T, M > &)
Definition form.h:329
csr< T, M > _bb
Definition form.h:222
form_basic< T, M > & operator*=(const T &lambda)
Definition form.h:409
void do_integrate_internal(const geo_basic< T, M > &dom, const geo_basic< T, M > &band, const band_basic< T, M > &gh, const Expr &expr, const integrate_option &fopt, bool is_on_band)
csr< T, M > _ub
Definition form.h:220
csr< T, M > & set_uu()
Definition form.h:208
csr< T, M > & set_bb()
Definition form.h:211
const csr< T, M > & uu() const
Definition form.h:204
bool is_symmetric() const
Definition form.h:436
csr< T, M >::size_type size_type
Definition form.h:150
bool is_symmetric_definite_positive() const
Definition form.h:466
void form_init_on_domain(const std::string &name, const geo_basic< T, M > &gamma, bool has_weight, WeightFunction weight, const geo_basic< T, M > &w_omega, const quadrature_option &qopt)
void set_symmetry(bool is_symm=true) const
Definition form.h:443
void do_integrate(const geo_basic< T, M > &domain, const Expr &expr, const integrate_option &fopt)
const space_type & get_first_space() const
Definition form.h:342
field_basic< T, M > trans_mult(const field_basic< T, M > &yh) const
Definition form.cc:134
form_basic(const form_basic< T, M > &)
Definition form.h:322
int constraint_process_rank() const
Definition form.h:214
const csr< T, M > & bu() const
Definition form.h:206
geo_basic< float_type, M > geo_type
Definition form.h:153
csr< T, M > _bu
Definition form.h:221
const space_type & get_second_space() const
Definition form.h:349
void form_init(const std::string &name, bool has_weight, WeightFunction weight, const quadrature_option &qopt)
space_type _Y
Definition form.h:218
form_basic< T, M > operator+(const form_basic< T, M > &b) const
Definition form.h:373
const geo_type & get_geo() const
Definition form.h:356
void set_symmetric_definite_positive() const
Definition form.h:473
const communicator & comm() const
Definition form.h:363
generic mesh with rerefence counting
Definition geo.h:1089
see the integrate_option page for the full documentation
odiststream: see the diststream page for the full documentation
Definition diststream.h:137
the finite element space
Definition space.h:382
form_basic< Float, rheo_default_memory_model > form
Definition form.h:309
void get_geo(istream &in, my_geo &omega)
Expr1::float_type T
Definition field_expr.h:230
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format format format dump
This file is part of Rheolef.
csr< T, sequential > operator-(const csr< T, sequential > &a)
Definition csr.h:447
csr< T, M > diag(const vec< T, M > &d)
Definition csr.cc:56
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
Definition csr.h:455
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition csr.h:437