/usr/include/rheolef/geo-connectivity.h is in librheolef-dev 5.93-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | #ifndef _RHEO_GEO_CONNECTIVITY_H
#define _RHEO_GEO_CONNECTIVITY_H
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// =========================================================================
// ============================================================================
// connectivity manipulations
// ============================================================================
#include "rheolef/georep.h"
namespace rheolef {
// can be used to build explicitely edges:
void build_edge (const geo& omega, std::vector<geo_element>& edge);
void build_edge (const geo& omega, std::vector<std::pair<size_t,size_t> >& edge);
// the rest is used internaly by the class geo and error_estimator_zz
// a := a inter b
// NOTE: could be in O(a.size + b.size) since a and b are sorted
template<class Set>
static
void
in_place_set_intersection (Set& a, const Set& b)
{
// c := a inter b
Set c;
set_intersection (a.begin(), a.end(), b.begin(), b.end(),
inserter(c, c.end()));
// a := c
a.erase(a.begin(), a.end());
copy (c.begin(), c.end(), inserter(a, a.end()));
}
// a := a union b
// NOTE: could be in O(a.size + b.size) since a and b are sorted
template<class Set>
static
void
in_place_set_union (Set& a, const Set& b)
{
// c := a inter b
Set c;
set_union (a.begin(), a.end(), b.begin(), b.end(),
inserter(c, c.end()));
// a := c
a.erase(a.begin(), a.end());
copy (c.begin(), c.end(), inserter(a, a.end()));
}
template<class Iterator, class SetRandomIterator>
static
void
build_point_to_element_sets (
// input
Iterator iter, // elements
Iterator last,
// output
SetRandomIterator ball) // point-to-element-set
{
typedef typename std::iterator_traits<Iterator>::value_type element_type;
typedef typename element_type::size_type size_type;
for (size_type idx = 0; iter != last; iter++, idx++) {
const element_type& E = *iter;
for (size_type i = 0; i < E.size(); i++) {
ball [E[i]].insert(ball [E[i]].end(), idx);
}
}
}
template<class Element, class SetRandomIterator,
class Set, class RandomIterator>
void
build_set_that_contains_S (
const Element& S,
SetRandomIterator ball,
RandomIterator element,
Set& contains_S)
//! builds a set of elements that all contain S.
{
typedef geo_element::size_type size_type;
contains_S.erase(contains_S.begin(), contains_S.end());
if (S.size() == 0) {
return;
}
copy (ball[S[0]].begin(), ball[S[0]].end(),
inserter(contains_S, contains_S.end()));
for (size_type i = 1; i < S.size(); i++) {
in_place_set_intersection (contains_S, ball[S[i]]);
}
}
template<class RandomIterator,
class RandomIterator2, class RandomIterator3,
class SetRandomIterator, class Size>
Size
build_subgeo_numbering (
// input
RandomIterator iter,
RandomIterator last,
SetRandomIterator ball,
Size subgeo_dim,
RandomIterator2 count_geo,
RandomIterator3 count_element)
{
typedef typename std::iterator_traits<RandomIterator>::value_type element_type;
typedef reference_element::size_type size_type;
typedef std::set<size_type> set_type;
typedef std::set<size_type>::const_iterator const_iterator_set;
RandomIterator element = iter;
Size n_subgeo = 0;
for (;iter != last; iter++) {
const element_type& K = *iter;
size_type n = K.n_subgeo(subgeo_dim);
for (size_type j = 0; j < n; j++) {
if (K.subgeo(subgeo_dim,j) != geo_element::not_set) {
// subgeo already numbered in K
continue;
}
// found a new subgeo
element_type S;
K.build_subgeo(subgeo_dim, j, S);
count_geo [S.dimension()] ++;
count_element [S.type()] ++;
set_type contains_S;
build_set_that_contains_S (S, ball, element, contains_S);
for (const_iterator_set p = contains_S.begin();
p != contains_S.end(); p++) {
element [*p].set_subgeo(S, size_type(n_subgeo));
}
n_subgeo++;
}
}
return n_subgeo;
}
template<class RandomIterator, class SetRandomIterator,
class RandomIterator2, class RandomIterator3,
class Size1, class Size2>
std::istream&
load_subgeo_numbering (
// input
RandomIterator element,
SetRandomIterator ball,
Size1 subgeo_dim,
Size2 n_subgeo,
// in-output
std::istream& is,
RandomIterator2 count_geo,
RandomIterator3 count_element)
{
typedef typename std::iterator_traits<RandomIterator>::value_type element_type;
typedef reference_element::size_type size_type;
typedef std::set<size_type> set_type;
typedef std::set<size_type>::const_iterator const_iterator_set;
for (size_type idx = 0; idx < n_subgeo; idx++) {
element_type S;
is >> S;
count_geo [S.dimension()] ++;
count_element [S.type()] ++;
set_type contains_S;
build_set_that_contains_S (S, ball, element, contains_S);
for (const_iterator_set p = contains_S.begin();
p != contains_S.end(); p++) {
element [*p].set_subgeo(S, idx);
}
}
return is;
}
// NOTE: c'est pour les domaines
// ca pourrait etre fait au vol
// pendant la lecture
//
template<class RandomIterator, class Iterator,
class SetRandomIterator>
void
propagate_subgeo_numbering (
// input
Iterator iter,
Iterator last,
RandomIterator element,
SetRandomIterator ball)
{
typedef typename std::iterator_traits<Iterator>::value_type element_type;
typedef reference_element::size_type size_type;
typedef std::set<size_type> set_type;
typedef std::set<size_type>::const_iterator const_iterator_set;
for (; iter != last; iter++) {
element_type& S = *iter;
set_type contains_S;
build_set_that_contains_S (S, ball, element, contains_S);
if (contains_S.size() == 0) {
error_macro ("domain element not in mesh: " << S);
return;
}
// now, choose any element K containing S
const_iterator_set p = contains_S.begin();
element_type& K = element [*p];
// and propagate numbering from K into S...
for (size_type d = 1; d <= S.dimension(); d++) {
size_type nsubgeo = S.n_subgeo(d);
for (size_type i = 0; i < nsubgeo; i++) {
element_type E;
S.build_subgeo(d, i, E);
size_type idx = K.subgeo(E);
S.set_subgeo(d, i, idx);
}
}
}
}
template<class RandomIterator, class SetRandomIterator,
class Container, class Size>
void
build_boundary (
// input
RandomIterator iter,
RandomIterator last,
SetRandomIterator ball,
Size d,
// output:
Container& boundary)
{
typedef typename std::iterator_traits<RandomIterator>::value_type element_type;
typedef reference_element::size_type size_type;
typedef std::set<size_type> set_type;
typedef std::set<size_type>::const_iterator const_iterator_set;
RandomIterator element = iter;
for (;iter != last; iter++) {
const element_type& K = *iter;
size_type n = K.n_subgeo(d);
for (size_type j = 0; j < n; j++) {
element_type S;
K.build_subgeo(d, j, S);
S.set_index(K.subgeo(d,j));
set_type contains_S;
build_set_that_contains_S (S, ball, element, contains_S);
switch (contains_S.size()) {
case 1:
boundary.push_back (S);
break;
case 2:
// interior face
break;
default:
error_macro ("face " << S << " shared by " << contains_S.size() << " elements");
}
}
}
}
void build_connectivity (georep& g);
}// namespace rheolef
#endif // _RHEO_GEO_CONNECTIVITY_H
|