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

« back to all changes in this revision

Viewing changes to nfem/pform_element/lumped_mass.cc

  • Committer: Package Import Robot
  • Author(s): Pierre Saramito
  • Date: 2012-04-06 09:12:21 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120406091221-m58me99p1nxqui49
Tags: 6.0-1
* New upstream release 6.0 (major changes):
  - massively distributed and parallel support
  - full FEM characteristic method (Lagrange-Gakerkin method) support
  - enhanced users documentation 
  - source code supports g++-4.7 (closes: #667356)
* debian/control: dependencies for MPI distributed solvers added
* debian/rules: build commands simplified
* debian/librheolef-dev.install: man1/* to man9/* added
* debian/changelog: package description rewritted (closes: #661689)

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
#include "rheolef/lumped_mass.h"
 
22
 
 
23
namespace rheolef {
 
24
using namespace std;
 
25
using namespace ublas;
 
26
 
 
27
// TODO : force trapeze quadrature formulae when using non-constant weight
 
28
// because quadrature formulae degree is automatically computed
 
29
// for an exact approximation !!
 
30
// Actually, the lumped weighted matrix does not coincide with
 
31
// the local mass matrix with trapeze quadrature formulae
 
32
 
 
33
template<class T, class M>
 
34
void 
 
35
lumped_mass<T,M>::operator() (const geo_element& K, ublas::matrix<T>& lumped_m) const
 
36
{
 
37
  build_general_mass (K, lumped_m);
 
38
  check_macro (lumped_m.size1() == lumped_m.size2(),
 
39
        "lumped_mass: incompatible `" << base::get_first_basis().name()
 
40
        << "' and `" << base::get_second_basis().name() << "' basis");
 
41
  size_type n = lumped_m.size1();
 
42
  for (size_type i = 0; i < n; i++) {
 
43
    Float s = 0;
 
44
    for (size_type j = 0; j < n; j++) {
 
45
      if (i != j) {
 
46
        s += lumped_m(i,j);
 
47
        lumped_m(i,j) = 0;
 
48
      }
 
49
    }
 
50
    lumped_m (i,i) += s;
 
51
  }
 
52
}
 
53
template<class T, class M>
 
54
void
 
55
lumped_mass<T,M>::initialize () const
 
56
{
 
57
  check_macro (base::get_first_space().size() == base::get_second_space().size(),
 
58
    "incompatible spaces for the `lumped_mass' form.");
 
59
  check_macro (base::get_first_basis().name() == base::get_second_basis().name(),
 
60
    "incompatible approximations for the `lumped_mass' form.");
 
61
  std::string approx = base::get_first_basis().name();
 
62
  check_macro ("P0" == approx || "P1" == approx || "P1d" == approx,
 
63
        "unsupported `"<<approx<<"' approximation space for `lumped_mass' form");
 
64
  if (base::is_weighted()) {
 
65
      space_constant::valued_type weight_valued = base::_wh.valued_tag();
 
66
      check_macro (weight_valued == space_constant::scalar,
 
67
        "unsupported non-scalar weight for `lumped_mass' form");
 
68
  }
 
69
  base::set_n_derivative(0);
 
70
}
 
71
// ----------------------------------------------------------------------------
 
72
// instanciation in library
 
73
// ----------------------------------------------------------------------------
 
74
template class lumped_mass<Float,sequential>;
 
75
#ifdef _RHEOLEF_HAVE_MPI
 
76
template class lumped_mass<Float,distributed>;
 
77
#endif // _RHEOLEF_HAVE_MPI
 
78
 
 
79
} // namespace rheolef