BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
grid_segment.hpp
1 // Copyright (C) 2011-2013 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef bempp_grid_segment_hpp
22 #define bempp_grid_segment_hpp
23 
24 #include "../common/common.hpp"
25 #include "../common/shared_ptr.hpp"
26 
27 #include <boost/array.hpp>
28 #include <set>
29 #include <vector>
30 
31 namespace Bempp
32 {
33 
34 class Grid;
35 
47 {
48 public:
51  static GridSegment wholeGrid(const Grid& grid, int level = 0);
52 
58  static GridSegment openDomain(const Grid& grid, int domain, int level = 0);
59 
65  static GridSegment closedDomain(const Grid& grid, int domain, int level = 0);
66 
77  GridSegment(const Grid& grid,
78  const std::set<int>& excludedEntitiesCodim0,
79  const std::set<int>& excludedEntitiesCodim1,
80  const std::set<int>& excludedEntitiesCodim2,
81  const std::set<int>& excludedEntitiesCodim3,
82  int level = 0);
83 
94  GridSegment(int entityCountCodim0,
95  int entityCountCodim1,
96  int entityCountCodim2,
97  int entityCountCodim3,
98  const std::set<int>& excludedEntitiesCodim0,
99  const std::set<int>& excludedEntitiesCodim1,
100  const std::set<int>& excludedEntitiesCodim2,
101  const std::set<int>& excludedEntitiesCodim3);
102 
105  bool contains(int codim, int index) const;
106 
116  void markExcludedEntities(int codim, std::vector<int>& marks,
117  int mark = -1) const;
118 
123  GridSegment complement() const;
124 
130  GridSegment union_(const GridSegment& other) const;
131 
138  GridSegment difference(const GridSegment& other) const;
139 
145  GridSegment intersection(const GridSegment& other) const;
146 
147 private:
148  boost::array<int, 4> m_entityCounts;
149  boost::array<std::set<int>, 4> m_excludedEntities;
150 };
151 
152 GridSegment gridSegmentWithPositiveX(const Grid& grid, int level = 0);
153 
154 } // namespace Bempp
155 
156 #endif
GridSegment(const Grid &grid, const std::set< int > &excludedEntitiesCodim0, const std::set< int > &excludedEntitiesCodim1, const std::set< int > &excludedEntitiesCodim2, const std::set< int > &excludedEntitiesCodim3, int level=0)
Constructor.
Definition: grid_segment.cpp:59
GridSegment difference(const GridSegment &other) const
Return the difference of this GridSegment and the GridSegment other.
Definition: grid_segment.cpp:249
GridSegment intersection(const GridSegment &other) const
Return the intersection of this GridSegment and the GridSegment other.
Definition: grid_segment.cpp:255
Abstract wrapper of a grid.
Definition: grid.hpp:50
void markExcludedEntities(int codim, std::vector< int > &marks, int mark=-1) const
Mark array elements corresponding to entities that do not belong to this GridSegment.
Definition: grid_segment.cpp:202
bool contains(int codim, int index) const
Return true if the segment contains the entity of codimension codim and index index, false otherwise.
Definition: grid_segment.cpp:192
static GridSegment closedDomain(const Grid &grid, int domain, int level=0)
Return a GridSegment representing a closed domain of a grid.
Definition: grid_segment.cpp:148
GridSegment union_(const GridSegment &other) const
Return the union of this GridSegment and the GridSegment other.
Definition: grid_segment.cpp:233
Segment of a grid.
Definition: grid_segment.hpp:46
GridSegment complement() const
Return the complement of this grid segment.
Definition: grid_segment.cpp:215
static GridSegment openDomain(const Grid &grid, int domain, int level=0)
Return a GridSegment representing an open domain of a grid.
Definition: grid_segment.cpp:105
static GridSegment wholeGrid(const Grid &grid, int level=0)
Return a GridSegment representing the whole grid grid at a given level (level = -1 for leafView)...
Definition: grid_segment.cpp:99