~ubuntu-branches/ubuntu/raring/rheolef/raring-proposed

« back to all changes in this revision

Viewing changes to nfem/geo_element/geo_element_v1.h

  • 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
#ifndef _RHEO_GEO_ELEMENT_V1_H
 
2
#define _RHEO_GEO_ELEMENT_V1_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
 
 
24
/*Class:geo_element
 
25
NAME:  @code{geo_element} - element of a mesh
 
26
@cindex  geometrical element
 
27
@clindex reference element
 
28
@clindex geo_element
 
29
@clindex reference_element
 
30
@clindex geo
 
31
DESCRIPTION:
 
32
  Defines geometrical elements and sides
 
33
  as a set of vertice and edge indexes.
 
34
  This element is obtained after a Piola transformation
 
35
  from a reference element (@pxref{reference_element iclass}).
 
36
  Indexes are related to arrays of edges and vertices.
 
37
  These arrays are included in the description of the mesh.
 
38
  Thus, this class is related of a given mesh instance
 
39
  (@pxref{geo class}).
 
40
EXAMPLE:
 
41
  This is the test of geo_element:
 
42
  @example
 
43
    geo_element K;
 
44
    K.set_name('t') ;
 
45
    cout << "n_vertices: " << K.size()      << endl
 
46
         << "n_edges   : " << K.n_edges()   << endl
 
47
         << "dimension : " << K.dimension() << endl << endl;
 
48
    for(geo_element::size_type i = 0; i < K.size(); i++) 
 
49
        K[i] = i*10 ;
 
50
    for(geo_element::size_type i = 0; i < K.n_edges(); i++)
 
51
        K.set_edge(i, i*10+5) ;
 
52
    cout << "vertices: local -> global" << endl;
 
53
    for (geo_element::size_type vloc = 0; vloc < K.size(); vloc++)
 
54
        cout << vloc << "-> " << K[vloc] << endl;
 
55
    cout << endl 
 
56
         << "edges: local -> global" << endl;
 
57
    for (geo_element::size_type eloc = 0; eloc < K.n_edges(); eloc++) @{
 
58
        geo_element::size_type vloc1 = subgeo_local_vertex(1, eloc, 0);
 
59
        geo_element::size_type vloc2 = subgeo_local_vertex(1, eloc, 1);
 
60
        cout << eloc << "-> " << K.edge(eloc) << endl
 
61
             << "local_vertex_from_edge(" << eloc 
 
62
             << ") -> (" << vloc1 << ", " << vloc2 << ")" << endl;
 
63
    @}
 
64
  @end example
 
65
SEE ALSO: "geo"(3)
 
66
AUTHOR: Pierre.Saramito@imag.fr
 
67
DATE:   18 jan 1998
 
68
METHODS: @geo_element
 
69
End:
 
70
*/
 
71
 
 
72
#include "rheolef/reference_element.h"
 
73
#include "rheolef/tiny_element.h"
 
74
 
 
75
namespace rheolef { 
 
76
//<geo_element:
 
77
class geo_element : public reference_element {
 
78
public:
 
79
    static const size_type not_set;
 
80
 
 
81
// allocators/deallocators:
 
82
 
 
83
    geo_element(variant_type t = max_variant);
 
84
    geo_element(const geo_element&);
 
85
    void copy (const geo_element&);
 
86
    geo_element& operator = (const geo_element&);
 
87
    explicit geo_element (const class tiny_element&);
 
88
    void copy (const class tiny_element&);
 
89
    ~geo_element();
 
90
 
 
91
// accessors:
 
92
 
 
93
    size_type index() const;
 
94
    size_type operator [] (size_type i) const;
 
95
    size_type side(size_type i_side) const;
 
96
    void build_side(size_type i_side, geo_element& S) const;
 
97
 
 
98
 
 
99
    size_type edge (size_type i_edge) const;
 
100
    size_type face (size_type i_face) const;
 
101
 
 
102
    size_type subgeo(const geo_element& S) const;
 
103
    size_type subgeo (size_type subgeo_dim, size_type i_subgeo) const;
 
104
    size_type subgeo_vertex (size_type subgeo_dim, size_type i_subgeo,
 
105
                           size_type i_subgeo_vertex) const;
 
106
    void build_subgeo(size_type subgeo_dim, size_type i_subgeo, geo_element& S) const;
 
107
    size_type subgeo_local_index(const geo_element& S) const;
 
108
 
 
109
// modifiers:
 
110
 
 
111
    void set_variant (variant_type t);
 
112
    void set_variant (size_type sz, size_type dim);
 
113
    void set_name (char      name);
 
114
 
 
115
    void set_index(size_type idx);
 
116
    size_type& operator [] (size_type i);
 
117
    void set_side (size_type i_side, size_type idx);
 
118
 
 
119
    void set_edge (size_type i_edge, size_type idx);
 
120
    void set_face (size_type i_face, size_type idx);
 
121
    void set_subgeo (size_type subgeo_dim, size_type i_subgeo, 
 
122
                           size_type idx);
 
123
    void set_subgeo(const geo_element& S, size_type idx);
 
124
 
 
125
// inputs/outputs:
 
126
 
 
127
    friend std::istream& operator >> (std::istream&, geo_element&);
 
128
    friend std::ostream& operator << (std::ostream&, const geo_element&);
 
129
    std::ostream& dump(std::ostream& s = std::cerr) const;
 
130
    void check() const;
 
131
 
 
132
// data:
 
133
protected:
 
134
    size_type *_heap;
 
135
 
 
136
// internal: memory management:
 
137
    static const size_type max_subgeo_vertex = 8;
 
138
    static const size_type _heap_size   [reference_element::max_variant];
 
139
    static const size_type _heap_offset [reference_element::max_variant][4];
 
140
    void _heap_init();
 
141
    void _heap_close();
 
142
    size_type heap_offset(size_type subgeo_dim) const { return _heap_offset [_x][subgeo_dim]; }
 
143
    size_type heap_size() const { return _heap_size [_x]; }
 
144
 
 
145
};
 
146
//>geo_element:
 
147
 
 
148
inline
 
149
geo_element::geo_element(variant_type t)
 
150
 : reference_element(t), _heap(0) 
 
151
{
 
152
    _heap_init();
 
153
}
 
154
inline
 
155
geo_element::~geo_element()
 
156
{
 
157
    _heap_close();
 
158
}
 
159
inline
 
160
void
 
161
geo_element::set_variant (variant_type t)
 
162
{
 
163
    reference_element::set_variant(t);
 
164
    _heap_init();
 
165
}
 
166
inline
 
167
void
 
168
geo_element::set_name (char name)
 
169
{
 
170
    reference_element::set_name(name);
 
171
    _heap_init();
 
172
}
 
173
inline
 
174
void 
 
175
geo_element::set_variant (size_type n_vertex, size_type dim)
 
176
{
 
177
    reference_element::set_variant(n_vertex,dim);
 
178
    _heap_init();
 
179
}
 
180
inline
 
181
geo_element::size_type
 
182
geo_element::index() const
 
183
{
 
184
    return *_heap;
 
185
}
 
186
inline
 
187
void
 
188
geo_element::set_index(size_type idx)
 
189
{
 
190
    *_heap = idx;
 
191
}
 
192
inline
 
193
geo_element::size_type
 
194
geo_element::operator [] (size_type i) const
 
195
{
 
196
    return *(_heap + heap_offset(0) + i);
 
197
}
 
198
inline
 
199
geo_element::size_type&
 
200
geo_element::operator [] (size_type i)
 
201
{
 
202
    return *(_heap + heap_offset(0) + i);
 
203
}
 
204
inline
 
205
geo_element::size_type
 
206
geo_element::subgeo (size_type subgeo_dim, size_type i_subgeo) const
 
207
{
 
208
    return *(_heap + heap_offset(subgeo_dim) + i_subgeo);
 
209
}
 
210
inline
 
211
void
 
212
geo_element::set_subgeo (size_type subgeo_dim, size_type i_subgeo,
 
213
        size_type idx)
 
214
{
 
215
    *(_heap + heap_offset(subgeo_dim) + i_subgeo) = idx;
 
216
}
 
217
inline
 
218
geo_element::size_type
 
219
geo_element::edge (size_type i_edge) const
 
220
{
 
221
    return subgeo (1, i_edge);
 
222
}
 
223
inline
 
224
geo_element::size_type
 
225
geo_element::face (size_type i_edge) const
 
226
{
 
227
    return subgeo (2, i_edge);
 
228
}
 
229
inline
 
230
geo_element::size_type
 
231
geo_element::side (size_type i_side) const
 
232
{
 
233
    return subgeo (dimension()-1, i_side);
 
234
}
 
235
inline
 
236
void
 
237
geo_element::set_edge (size_type i_edge, size_type idx)
 
238
{
 
239
    set_subgeo(1,i_edge,idx);
 
240
}
 
241
inline
 
242
void
 
243
geo_element::set_face (size_type i_face, size_type idx)
 
244
{
 
245
    set_subgeo(1,i_face,idx);
 
246
}
 
247
inline
 
248
void
 
249
geo_element::set_side (size_type i_side, size_type idx)
 
250
{
 
251
    set_subgeo(dimension()-1,i_side,idx);
 
252
}
 
253
inline
 
254
geo_element::size_type
 
255
geo_element::subgeo_vertex (size_type subgeo_dim, size_type i_subgeo,
 
256
                           size_type i_subgeo_vertex) const
 
257
{
 
258
    size_type local_vertex = subgeo_local_vertex(subgeo_dim, i_subgeo, i_subgeo_vertex);
 
259
    return operator[] (local_vertex);
 
260
}
 
261
inline
 
262
void
 
263
geo_element::build_side(size_type i_side, geo_element& S) const
 
264
{
 
265
    build_subgeo(dimension()-1, i_side, S);
 
266
}
 
267
}// namespace rheolef
 
268
#endif // _RHEO_GEO_ELEMENT_V1_H