~ubuntu-branches/ubuntu/saucy/rheolef/saucy-proposed

« back to all changes in this revision

Viewing changes to nfem/plib/geo_connectivity.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 _RHEOLEF_GEO_CONNECTIVITY_H
2
 
#define _RHEOLEF_GEO_CONNECTIVITY_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
 
// ============================================================================
25
 
//  connectivity manipulations
26
 
// ============================================================================
27
 
 
28
 
#include "rheolef/config.h"
29
 
 
30
 
namespace rheolef { 
31
 
 
32
 
// a := a inter b
33
 
// NOTE: could be in O(a.size + b.size) since a and b are sorted
34
 
template<class Set>
35
 
static
36
 
void
37
 
in_place_set_intersection (Set& a, const Set& b)
38
 
{
39
 
    // c := a inter b
40
 
    Set c;
41
 
    set_intersection (a.begin(), a.end(), b.begin(), b.end(), 
42
 
        inserter(c, c.end()));
43
 
 
44
 
    // a := c
45
 
    a.erase (a.begin(), a.end());
46
 
    copy (c.begin(), c.end(), inserter(a, a.end()));
47
 
}
48
 
// a := a union b
49
 
// NOTE: could be in O(a.size + b.size) since a and b are sorted
50
 
template<class Set>
51
 
static
52
 
void
53
 
in_place_set_union (Set& a, const Set& b)
54
 
{
55
 
    // c := a inter b
56
 
    Set c;
57
 
    set_union (a.begin(), a.end(), b.begin(), b.end(), 
58
 
        inserter(c, c.end()));
59
 
 
60
 
    // a := c
61
 
    a.erase(a.begin(), a.end());
62
 
    copy (c.begin(), c.end(), inserter(a, a.end()));
63
 
}
64
 
template<class Iterator, class SetRandomIterator>
65
 
static 
66
 
void
67
 
build_point_to_element_sets (
68
 
  // input
69
 
        Iterator           iter,        // elements
70
 
        Iterator           last,
71
 
  // output
72
 
        SetRandomIterator  ball)        // point-to-element-set
73
 
{
74
 
    typedef typename geo_element::size_type size_type;
75
 
 
76
 
    for (size_type idx = 0; iter != last; iter++, idx++) {
77
 
        const geo_element& E = *iter;
78
 
        for (size_type i = 0; i < E.size(); i++) {
79
 
            ball [E[i]].insert (ball [E[i]].end(), idx);
80
 
        }
81
 
    }
82
 
}
83
 
/// @brief builds a set of elements that all contain S.
84
 
template<class Element, class SetRandomIterator, class Set>
85
 
void
86
 
build_set_that_contains_S (
87
 
        const Element&       S,
88
 
        SetRandomIterator    ball,
89
 
        Set&                 contains_S)
90
 
{
91
 
    typedef geo_element::size_type size_type;
92
 
 
93
 
    contains_S.erase (contains_S.begin(), contains_S.end());
94
 
    if (S.size() == 0) {
95
 
        return;
96
 
    }
97
 
    copy (ball[S[0]].begin(), ball[S[0]].end(),
98
 
        inserter (contains_S, contains_S.end()));
99
 
 
100
 
    for (size_type i = 1; i < S.size(); i++) {
101
 
        in_place_set_intersection (contains_S, ball[S[i]]);
102
 
    }
103
 
}
104
 
 
105
 
}// namespace rheolef
106
 
#endif // _RHEOLEF_GEO_CONNECTIVITY_H