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

« back to all changes in this revision

Viewing changes to nfem/basis/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 internal}).
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
 
 
74
 
namespace rheolef { 
75
 
//<geo_element:
76
 
class geo_element : public reference_element {
77
 
public:
78
 
 
79
 
// allocators/deallocators:
80
 
 
81
 
    geo_element(enum_type t = max_size);
82
 
    geo_element(const geo_element&);
83
 
    explicit geo_element (const class tiny_element&);
84
 
    void copy (const geo_element&);
85
 
    void copy (const class tiny_element&);
86
 
    geo_element& operator = (const geo_element&);
87
 
    ~geo_element();
88
 
 
89
 
// accessors:
90
 
 
91
 
    size_type index() const;
92
 
    size_type operator [] (size_type i) const;
93
 
    size_type side(size_type i_side) const;
94
 
    void build_side(size_type i_side, geo_element& S) const;
95
 
 
96
 
 
97
 
    size_type edge (size_type i_edge) const;
98
 
    size_type face (size_type i_face) const;
99
 
 
100
 
    size_type subgeo(const geo_element& S) const;
101
 
    size_type subgeo (size_type subgeo_dim, size_type i_subgeo) const;
102
 
    size_type subgeo_vertex (size_type subgeo_dim, size_type i_subgeo,
103
 
                           size_type i_subgeo_vertex) const;
104
 
    void build_subgeo(size_type subgeo_dim, size_type i_subgeo, geo_element& S) const;
105
 
    size_type subgeo_local_index(const geo_element& S) const;
106
 
 
107
 
// modifiers:
108
 
 
109
 
    void set_type (enum_type t);
110
 
    void set_type (size_type sz, size_type dim);
111
 
    void set_name (char      name);
112
 
 
113
 
    void set_index(size_type idx);
114
 
    size_type& operator [] (size_type i);
115
 
    void set_side (size_type i_side, size_type idx);
116
 
 
117
 
    void set_edge (size_type i_edge, size_type idx);
118
 
    void set_face (size_type i_face, size_type idx);
119
 
    void set_subgeo (size_type subgeo_dim, size_type i_subgeo, 
120
 
                           size_type idx);
121
 
    void set_subgeo(const geo_element& S, size_type idx);
122
 
 
123
 
// inputs/outputs:
124
 
 
125
 
    friend std::istream& operator >> (std::istream&, geo_element&);
126
 
    friend std::ostream& operator << (std::ostream&, const geo_element&);
127
 
    std::ostream& dump(std::ostream& s = std::cerr) const;
128
 
    void check() const;
129
 
 
130
 
// data:
131
 
protected:
132
 
    size_type *_heap;
133
 
 
134
 
// memory management:
135
 
    void _heap_init();
136
 
    void _heap_close();
137
 
};
138
 
//>geo_element:
139
 
 
140
 
inline
141
 
geo_element::geo_element(enum_type t)
142
 
 : reference_element(t), _heap(0) 
143
 
{
144
 
    _heap_init();
145
 
}
146
 
inline
147
 
geo_element::~geo_element()
148
 
{
149
 
    _heap_close();
150
 
}
151
 
inline
152
 
void
153
 
geo_element::set_type (enum_type t)
154
 
{
155
 
    reference_element::set_type(t);
156
 
    _heap_init();
157
 
}
158
 
inline
159
 
void
160
 
geo_element::set_name (char name)
161
 
{
162
 
    reference_element::set_name(name);
163
 
    _heap_init();
164
 
}
165
 
inline
166
 
void 
167
 
geo_element::set_type (size_type n_vertex, size_type dim)
168
 
{
169
 
    reference_element::set_type(n_vertex,dim);
170
 
    _heap_init();
171
 
}
172
 
inline
173
 
geo_element::size_type
174
 
geo_element::index() const
175
 
{
176
 
    return *_heap;
177
 
}
178
 
inline
179
 
void
180
 
geo_element::set_index(size_type idx)
181
 
{
182
 
    *_heap = idx;
183
 
}
184
 
inline
185
 
geo_element::size_type
186
 
geo_element::operator [] (size_type i) const
187
 
{
188
 
    return *(_heap + heap_offset(0) + i);
189
 
}
190
 
inline
191
 
geo_element::size_type&
192
 
geo_element::operator [] (size_type i)
193
 
{
194
 
    return *(_heap + heap_offset(0) + i);
195
 
}
196
 
inline
197
 
geo_element::size_type
198
 
geo_element::subgeo (size_type subgeo_dim, size_type i_subgeo) const
199
 
{
200
 
    return *(_heap + heap_offset(subgeo_dim) + i_subgeo);
201
 
}
202
 
inline
203
 
void
204
 
geo_element::set_subgeo (size_type subgeo_dim, size_type i_subgeo,
205
 
        size_type idx)
206
 
{
207
 
    *(_heap + heap_offset(subgeo_dim) + i_subgeo) = idx;
208
 
}
209
 
inline
210
 
geo_element::size_type
211
 
geo_element::edge (size_type i_edge) const
212
 
{
213
 
    return subgeo (1, i_edge);
214
 
}
215
 
inline
216
 
geo_element::size_type
217
 
geo_element::face (size_type i_edge) const
218
 
{
219
 
    return subgeo (2, i_edge);
220
 
}
221
 
inline
222
 
geo_element::size_type
223
 
geo_element::side (size_type i_side) const
224
 
{
225
 
    return subgeo (dimension()-1, i_side);
226
 
}
227
 
inline
228
 
void
229
 
geo_element::set_edge (size_type i_edge, size_type idx)
230
 
{
231
 
    set_subgeo(1,i_edge,idx);
232
 
}
233
 
inline
234
 
void
235
 
geo_element::set_face (size_type i_face, size_type idx)
236
 
{
237
 
    set_subgeo(1,i_face,idx);
238
 
}
239
 
inline
240
 
void
241
 
geo_element::set_side (size_type i_side, size_type idx)
242
 
{
243
 
    set_subgeo(dimension()-1,i_side,idx);
244
 
}
245
 
inline
246
 
geo_element::size_type
247
 
geo_element::subgeo_vertex (size_type subgeo_dim, size_type i_subgeo,
248
 
                           size_type i_subgeo_vertex) const
249
 
{
250
 
    size_type local_vertex = subgeo_local_vertex(subgeo_dim, i_subgeo, i_subgeo_vertex);
251
 
    return operator[] (local_vertex);
252
 
}
253
 
inline
254
 
void
255
 
geo_element::build_side(size_type i_side, geo_element& S) const
256
 
{
257
 
    build_subgeo(dimension()-1, i_side, S);
258
 
}
259
 
}// namespace rheolef
260
 
#endif // _RHEO_GEO_ELEMENT_V1_H