Line data Source code
1 : /*
2 : * Copyright (c) 2015: G-CSC, Goethe University Frankfurt
3 : * Author: Sebastian Reiter
4 : *
5 : * This file is part of UG4.
6 : *
7 : * UG4 is free software: you can redistribute it and/or modify it under the
8 : * terms of the GNU Lesser General Public License version 3 (as published by the
9 : * Free Software Foundation) with the following additional attribution
10 : * requirements (according to LGPL/GPL v3 §7):
11 : *
12 : * (1) The following notice must be displayed in the Appropriate Legal Notices
13 : * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 : *
15 : * (2) The following notice must be displayed at a prominent place in the
16 : * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 : *
18 : * (3) The following bibliography is recommended for citation and must be
19 : * preserved in all covered files:
20 : * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 : * parallel geometric multigrid solver on hierarchically distributed grids.
22 : * Computing and visualization in science 16, 4 (2013), 151-164"
23 : * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 : * flexible software system for simulating pde based models on high performance
25 : * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 : *
27 : * This program is distributed in the hope that it will be useful,
28 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : * GNU Lesser General Public License for more details.
31 : */
32 :
33 : #ifndef __H__UG_topology_callbacks
34 : #define __H__UG_topology_callbacks
35 :
36 : #include "lib_grid/algorithms/geom_obj_util/vertex_util.h"
37 : #include "element_callback_interface.h"
38 :
39 : namespace ug{
40 :
41 : /** \ingroup lib_grid_element_callbacks
42 : * \{ */
43 :
44 : /// Element callback that returns true, if an element lies on the grids boundary
45 : class IsOnBoundary : public ElementCallback
46 : {
47 : public:
48 : IsOnBoundary(Grid& g) :
49 : m_grid(g) {}
50 :
51 : bool operator() (Vertex* v) const {return callback(v);}
52 : bool operator() (Edge* e) const {return callback(e);}
53 0 : bool operator() (Face* f) const {return callback(f);}
54 : bool operator() (Volume*) const {return false;}
55 :
56 : private:
57 : template <class TElem>
58 0 : bool callback(TElem* e) const {return LiesOnBoundary(m_grid, e);}
59 :
60 : private:
61 : Grid& m_grid;
62 : };
63 :
64 : /// Element callback that returns true, if an element does not lie on the grids boundary
65 : class IsNotOnBoundary : public ElementCallback
66 : {
67 : public:
68 : IsNotOnBoundary(Grid& g) :
69 : m_grid(g) {}
70 :
71 : bool operator() (Vertex* v) const {return callback(v);}
72 : bool operator() (Edge* e) const {return callback(e);}
73 0 : bool operator() (Face* f) const {return callback(f);}
74 : bool operator() (Volume*) const {return true;}
75 : private:
76 : template <class TElem>
77 0 : bool callback(TElem* e) const {return !LiesOnBoundary(m_grid, e);}
78 :
79 : private:
80 : Grid& m_grid;
81 : };
82 :
83 :
84 : class IsBoundaryOrManifodFace : public ElementCallback
85 : {
86 : public:
87 0 : IsBoundaryOrManifodFace(Grid& g) :
88 0 : m_grid(g) {}
89 :
90 0 : bool operator() (Vertex* v) const {return false;}
91 0 : bool operator() (Edge* e) const {return false;}
92 0 : bool operator() (Face* f) const {return callback(f);}
93 0 : bool operator() (Volume*) const {return true;}
94 :
95 : private:
96 : template <class TElem>
97 : bool callback(TElem* e) const
98 : {
99 : //todo: mutex?
100 : //todo: m_grid.num_associated_elements<Volume>(e)...
101 0 : const_cast<Grid&>(m_grid).associated_elements(
102 0 : const_cast<IsBoundaryOrManifodFace*>(this)->m_tmpVols, e);
103 0 : return m_tmpVols.size() < 2;
104 : }
105 :
106 : private:
107 : Grid& m_grid;
108 : Grid::volume_traits::secure_container m_tmpVols;// optimization for single-thread
109 : };
110 :
111 : class IsNotBoundaryOrManifodFace : public ElementCallback
112 : {
113 : public:
114 : IsNotBoundaryOrManifodFace(Grid& g) :
115 : m_callback(g) {}
116 :
117 0 : bool operator() (Vertex* v) const {return !m_callback(v);}
118 0 : bool operator() (Edge* e) const {return !m_callback(e);}
119 0 : bool operator() (Face* f) const {return !m_callback(f);}
120 0 : bool operator() (Volume* v) const {return !m_callback(v);}
121 :
122 : private:
123 : IsBoundaryOrManifodFace m_callback;
124 : };
125 : /** \} */ //lib_grid_element_callbacks
126 :
127 : }// end of namespace
128 :
129 : #endif //__H__UG_topology_callbacks
|