2
/// This file is part of Rheolef.
4
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
6
/// Rheolef is free software; you can redistribute it and/or modify
7
/// it under the terms of the GNU General Public License as published by
8
/// the Free Software Foundation; either version 2 of the License, or
9
/// (at your option) any later version.
11
/// Rheolef is distributed in the hope that it will be useful,
12
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
/// GNU General Public License for more details.
16
/// You should have received a copy of the GNU General Public License
17
/// along with Rheolef; if not, write to the Free Software
18
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
/// =========================================================================
22
// diagonal form(X,Y,"A") : L2 scalar product, ect...
24
// authors: Pierre.Saramito@imag.fr
28
# include "rheolef/form_diag.h"
29
# include "rheolef/field.h"
30
# include "rheolef/skit.h"
32
# include "form_diag_assembly.h"
36
// symbol to function handler
37
// for elementary matrix funtions
44
const string& coord_sys)
46
string symbol = "lumped_" + name;
49
// shared with form.c:
50
string get_form_approx_name (const space& X);
52
form_diag::form_diag (const space& X, const char* name)
56
string x_approx_name = get_form_approx_name(X);
57
string coord_sys = X.coordinate_system();
59
form_e (form_diag_symbol(name, x_approx_name, coord_sys));
61
form_diag_assembly (*this, form_e);
63
form_diag::form_diag (const field& dh)
64
: X_(dh.get_space()), uu(dh.u), bb(dh.b)
69
operator << (ostream& s, const form_diag& m)
71
s << "M_U\n" << vec<Float>(m.uu);
72
s << "M_B\n" << vec<Float>(m.bb);
77
operator * (const form_diag& m, const field& x)
79
field y(m.get_space());
86
operator / (const Float& lambda, const form_diag& m)
88
form_diag m0(m.get_space()) ;
89
m0.uu = Float(1)/m.uu ;
90
m0.bb = Float(1)/m.bb ;
94
operator * (const form_diag& m1, const form_diag& m2)
96
form_diag m(m1.get_space());
97
m.uu = basic_diag<Float>(m1.uu * m2.uu);
98
m.bb = basic_diag<Float>(m1.bb * m2.bb);
104
operator - (const form_diag& m)
106
form_diag g(m.get_space());
107
g.uu = basic_diag<Float>(-1*m.uu) ;
108
g.bb = basic_diag<Float>(-1*m.bb) ;
112
operator - (const form_diag& m1, const form_diag& m2)
114
form_diag m(m1.get_space());
115
m.uu = basic_diag<Float>(m1.uu - m2.uu);
116
m.bb = basic_diag<Float>(m1.bb - m2.bb);
120
operator + (const form_diag& m1, const form_diag& m2)
122
form_diag m(m1.get_space());
123
m.uu = basic_diag<Float>(m1.uu + m2.uu);
124
m.bb = basic_diag<Float>(m1.bb + m2.bb);
128
operator * (const Float& lambda, const form_diag& m)
130
form_diag g(m.get_space());
131
g.uu = basic_diag<Float>(lambda*m.uu) ;
132
g.bb = basic_diag<Float>(lambda*m.bb) ;