1
#ifndef _RHEO_GEO_ELEMENT_V1_H
2
#define _RHEO_GEO_ELEMENT_V1_H
4
/// This file is part of Rheolef.
6
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
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.
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.
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
22
/// =========================================================================
25
NAME: @code{geo_element} - element of a mesh
26
@cindex geometrical element
27
@clindex reference element
29
@clindex reference_element
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
41
This is the test of geo_element:
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++)
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;
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;
66
AUTHOR: Pierre.Saramito@imag.fr
72
#include "rheolef/reference_element.h"
76
class geo_element : public reference_element {
79
// allocators/deallocators:
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&);
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;
97
size_type edge (size_type i_edge) const;
98
size_type face (size_type i_face) const;
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;
109
void set_type (enum_type t);
110
void set_type (size_type sz, size_type dim);
111
void set_name (char name);
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);
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,
121
void set_subgeo(const geo_element& S, size_type idx);
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;
134
// memory management:
141
geo_element::geo_element(enum_type t)
142
: reference_element(t), _heap(0)
147
geo_element::~geo_element()
153
geo_element::set_type (enum_type t)
155
reference_element::set_type(t);
160
geo_element::set_name (char name)
162
reference_element::set_name(name);
167
geo_element::set_type (size_type n_vertex, size_type dim)
169
reference_element::set_type(n_vertex,dim);
173
geo_element::size_type
174
geo_element::index() const
180
geo_element::set_index(size_type idx)
185
geo_element::size_type
186
geo_element::operator [] (size_type i) const
188
return *(_heap + heap_offset(0) + i);
191
geo_element::size_type&
192
geo_element::operator [] (size_type i)
194
return *(_heap + heap_offset(0) + i);
197
geo_element::size_type
198
geo_element::subgeo (size_type subgeo_dim, size_type i_subgeo) const
200
return *(_heap + heap_offset(subgeo_dim) + i_subgeo);
204
geo_element::set_subgeo (size_type subgeo_dim, size_type i_subgeo,
207
*(_heap + heap_offset(subgeo_dim) + i_subgeo) = idx;
210
geo_element::size_type
211
geo_element::edge (size_type i_edge) const
213
return subgeo (1, i_edge);
216
geo_element::size_type
217
geo_element::face (size_type i_edge) const
219
return subgeo (2, i_edge);
222
geo_element::size_type
223
geo_element::side (size_type i_side) const
225
return subgeo (dimension()-1, i_side);
229
geo_element::set_edge (size_type i_edge, size_type idx)
231
set_subgeo(1,i_edge,idx);
235
geo_element::set_face (size_type i_face, size_type idx)
237
set_subgeo(1,i_face,idx);
241
geo_element::set_side (size_type i_side, size_type idx)
243
set_subgeo(dimension()-1,i_side,idx);
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
250
size_type local_vertex = subgeo_local_vertex(subgeo_dim, i_subgeo, i_subgeo_vertex);
251
return operator[] (local_vertex);
255
geo_element::build_side(size_type i_side, geo_element& S) const
257
build_subgeo(dimension()-1, i_side, S);
259
}// namespace rheolef
260
#endif // _RHEO_GEO_ELEMENT_V1_H