~ubuntu-branches/ubuntu/trusty/rheolef/trusty-proposed

« back to all changes in this revision

Viewing changes to nfem/lib/form_diag.cc

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2010-06-12 09:08:59 UTC
  • Revision ID: james.westby@ubuntu.com-20100612090859-8gpm2gc7j3ab43et
Tags: upstream-5.89
ImportĀ upstreamĀ versionĀ 5.89

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
///
 
2
/// This file is part of Rheolef.
 
3
///
 
4
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
 
5
///
 
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.
 
10
///
 
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.
 
15
///
 
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
 
19
///
 
20
/// =========================================================================
 
21
//
 
22
// diagonal form(X,Y,"A") : L2 scalar product, ect...
 
23
//
 
24
// authors: Pierre.Saramito@imag.fr
 
25
//
 
26
// date: 15 july 1997
 
27
//
 
28
# include "rheolef/form_diag.h"
 
29
# include "rheolef/field.h"
 
30
# include "rheolef/skit.h"
 
31
 
 
32
# include "form_diag_assembly.h"
 
33
using namespace std;
 
34
 
 
35
//
 
36
// symbol to function handler
 
37
// for elementary matrix funtions
 
38
//
 
39
static 
 
40
string
 
41
form_diag_symbol (
 
42
    const string& name, 
 
43
    const string& approx,
 
44
    const string& coord_sys)
 
45
{
 
46
    string symbol = "lumped_" + name;
 
47
    return symbol;
 
48
}
 
49
// shared with form.c:
 
50
string get_form_approx_name (const space&  X);
 
51
 
 
52
form_diag::form_diag (const space& X, const char* name)
 
53
: X_(X), uu(), bb()
 
54
{
 
55
  X_.freeze();
 
56
  string x_approx_name = get_form_approx_name(X);
 
57
  string coord_sys = X.coordinate_system();
 
58
  form_element
 
59
   form_e (form_diag_symbol(name, x_approx_name, coord_sys));
 
60
 
 
61
  form_diag_assembly (*this, form_e);
 
62
}
 
63
form_diag::form_diag (const field& dh)
 
64
: X_(dh.get_space()), uu(dh.u), bb(dh.b)
 
65
{
 
66
}
 
67
 
 
68
ostream& 
 
69
operator << (ostream& s, const form_diag& m)
 
70
{
 
71
    s << "M_U\n" << vec<Float>(m.uu);
 
72
    s << "M_B\n" << vec<Float>(m.bb);
 
73
    return s;
 
74
}
 
75
 
 
76
field
 
77
operator * (const form_diag& m, const field& x)
 
78
{
 
79
    field y(m.get_space());
 
80
    y.u = m.uu*x.u;
 
81
    y.b = m.bb*x.b;
 
82
    return y;
 
83
}
 
84
 
 
85
form_diag 
 
86
operator / (const Float& lambda, const form_diag& m)
 
87
{
 
88
  form_diag m0(m.get_space()) ;
 
89
  m0.uu = Float(1)/m.uu ;
 
90
  m0.bb = Float(1)/m.bb ;
 
91
  return m0 ;
 
92
}
 
93
form_diag
 
94
operator * (const form_diag& m1, const form_diag& m2)
 
95
{
 
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);
 
99
  return m;
 
100
}
 
101
 
 
102
//new
 
103
form_diag
 
104
operator - (const form_diag& m)
 
105
{
 
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) ;
 
109
  return g ;
 
110
}
 
111
form_diag
 
112
operator - (const form_diag& m1, const form_diag& m2)
 
113
{
 
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);
 
117
  return m;
 
118
}
 
119
form_diag
 
120
operator + (const form_diag& m1, const form_diag& m2)
 
121
{
 
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);
 
125
  return m;
 
126
}
 
127
form_diag
 
128
operator * (const Float& lambda, const form_diag& m)
 
129
{
 
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) ;
 
133
  return g ;
 
134
 
135
//wen