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

« back to all changes in this revision

Viewing changes to nfem/plib/element.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/element.h"
22
 
#include "rheolef/basis_on_lattice.h"
23
 
 
24
 
namespace rheolef {
25
 
 
26
 
template<class T>
27
 
element_rep<T>::element_rep (std::string name, std::string numb) 
28
 
 : _name((numb != "") ? numb : name),
29
 
   _b(name),
30
 
   _numb( ((numb != "") ? numb : name) + "_numbering"),
31
 
   _tr_p1("P1"),
32
 
   _tr_p1_value()
33
 
{
34
 
   _tr_p1_value.set (_b, _tr_p1);
35
 
}
36
 
// ----------------------------------------------------------------------------
37
 
// node associated to a dof: local (K,loc_idof) argument
38
 
// ----------------------------------------------------------------------------
39
 
template<class T>
40
 
template<class M>
41
 
basic_point<T>
42
 
element_rep<T>::x_dof (const geo_element& K, size_type loc_idof, const geo_basic<T,M>& omega) const
43
 
{
44
 
    // TODO: only P1 transformation supported : isoparametric not yet !
45
 
    warning_macro ("x_dof("<<name()<<") on K"<< K.dis_ie());
46
 
    basis_on_nodal_basis::const_iterator first = _tr_p1_value.begin(K,loc_idof);
47
 
    basis_on_nodal_basis::const_iterator last  = _tr_p1_value.end  (K,loc_idof);
48
 
    point x;
49
 
    size_type dim = omega.dimension();
50
 
    for (size_type k = 0; first != last; first++, k++) {
51
 
        const point& ak = omega.vertex (K[k]);
52
 
        Float ck = (*first);
53
 
        warning_macro ("coef["<<k<<"]="<<ck);
54
 
        for (size_type i = 0; i < dim; i++) {
55
 
          x[i] += ck * ak[i];
56
 
        }
57
 
    }
58
 
    return x;
59
 
}
60
 
// ----------------------------------------------------------------------------
61
 
// node associated to a dof: "idof" argument
62
 
// ----------------------------------------------------------------------------
63
 
template<class T>
64
 
template<class M>
65
 
basic_point<T>
66
 
element_rep<T>::x_dof (size_type idof, const geo_basic<T,M>& omega) const
67
 
{
68
 
    if (name() == "P1") {
69
 
        return omega.vertex (idof);
70
 
    } else if (name() == "P0") {
71
 
        const geo_element& K = omega[idof];
72
 
        basic_point<T> x;
73
 
        for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
74
 
          x += omega.dis_vertex (K[iloc]);
75
 
        }
76
 
        x /= K.size();
77
 
        warning_macro ("x_dof = " << x);
78
 
        return x;
79
 
    } else if (name() == "P1d") {
80
 
        size_type nvert_per_elt;
81
 
        switch (omega.map_dimension()) {
82
 
          case 0: {
83
 
            nvert_per_elt = 1;
84
 
            break;
85
 
          }
86
 
          case 1: {
87
 
            nvert_per_elt = 2;
88
 
            break;
89
 
          }
90
 
          case 2: {
91
 
            if (omega.dis_size_by_variant()[reference_element::t] != 0) {
92
 
              nvert_per_elt = 3;
93
 
            } else {
94
 
              nvert_per_elt = 4;
95
 
            }
96
 
            break;
97
 
          }
98
 
          case 3:
99
 
          default: {
100
 
            if (omega.dis_size_by_variant()[reference_element::T] != 0) {
101
 
              nvert_per_elt = 4;
102
 
            } else if (omega.dis_size_by_variant()[reference_element::P] != 0) {
103
 
              nvert_per_elt = 6;
104
 
            } else {
105
 
              nvert_per_elt = 8;
106
 
            }
107
 
          }
108
 
        }
109
 
        // TODO: extend P1d mixed (t,q) or (T,P,H) meshes: nvert_per_elt is no more constant
110
 
        size_type ie   = idof/nvert_per_elt;
111
 
        size_type iloc = idof - ie*nvert_per_elt;
112
 
        const geo_element& K = omega[ie];
113
 
        size_type dis_iv = K[iloc];
114
 
        const basic_point<T>& x = omega.dis_vertex(dis_iv);
115
 
        return x;
116
 
    } else {
117
 
        // TODO: extend P2
118
 
        error_macro ("unsupported x_dof for \""<<name()<<"\" element");
119
 
        return basic_point<T>();
120
 
    }
121
 
}
122
 
// ----------------------------------------------------------------------------
123
 
// instanciation in library
124
 
// ----------------------------------------------------------------------------
125
 
template class element<Float>;
126
 
template class element_rep<Float>;
127
 
template class lagrange<Float>;
128
 
 
129
 
template
130
 
basic_point<Float> element_rep<Float>::x_dof (const geo_element& K, size_type loc_idof, const geo_basic<Float,sequential>& omeqa) const;
131
 
template
132
 
basic_point<Float> element_rep<Float>::x_dof (size_type idof, const geo_basic<Float,sequential>& omeqa) const;
133
 
 
134
 
#ifdef _RHEOLEF_HAVE_MPI
135
 
template
136
 
basic_point<Float> element_rep<Float>::x_dof (const geo_element& K, size_type loc_idof, const geo_basic<Float,distributed>& omeqa) const;
137
 
template
138
 
basic_point<Float> element_rep<Float>::x_dof (size_type idof, const geo_basic<Float,distributed>& omeqa) const;
139
 
#endif // _RHEOLEF_HAVE_MPI
140
 
 
141
 
} // namespace rheolef