Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sub_grid.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016: 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_sub_grid
34#define __H__UG_sub_grid
35
36namespace ug{
37
39
44class ISubGrid {
45public:
46 virtual ~ISubGrid() {}
47
48 virtual const GridObjectCollection& goc () const = 0;
49 virtual bool is_contained(Vertex*) const = 0;
50 virtual bool is_contained(Edge*) const = 0;
51 virtual bool is_contained(Face*) const = 0;
52 virtual bool is_contained(Volume*) const = 0;
53};
54
55
57
64template <class TCallbackCls>
65class SubGrid : public ISubGrid{
66public:
67 SubGrid(GridObjectCollection goc, const TCallbackCls& cb) :
68 m_goc (goc),
69 m_callbacks (cb)
70 {
71 }
72
73 virtual const GridObjectCollection& goc () const {return m_goc;}
74 virtual bool is_contained (Vertex* e) const {return m_callbacks(e);}
75 virtual bool is_contained (Edge* e) const {return m_callbacks(e);}
76 virtual bool is_contained (Face* e) const {return m_callbacks(e);}
77 virtual bool is_contained (Volume* e) const {return m_callbacks(e);}
78
79private:
81 TCallbackCls m_callbacks;
82};
83
84
86
89{
90 public:
91 IsInSubGrid(const ISubGrid& subGrid) :
92 m_subGrid(subGrid) {}
93
94 bool operator() (Vertex* v) {return callback(v);}
95 bool operator() (Edge* e) {return callback(e);}
96 bool operator() (Face* f) {return callback(f);}
97 bool operator() (Volume* v) {return callback(v);}
98
99 private:
100 template <class TElem>
101 bool callback(TElem* e) {return m_subGrid.is_contained(e);}
102
103 private:
105};
106
107
109
112{
113 public:
114 IsNotInSubGrid(const ISubGrid& subGrid) :
115 m_subGrid(subGrid) {}
116
117 bool operator() (Vertex* v) {return callback(v);}
118 bool operator() (Edge* e) {return callback(e);}
119 bool operator() (Face* f) {return callback(f);}
120 bool operator() (Volume* v) {return callback(v);}
121
122 private:
123 template <class TElem>
124 bool callback(TElem* e) {return !m_subGrid.is_contained(e);}
125
126 private:
128};
129
130}// end of namespace
131
132#endif //__H__UG_sub_grid
Base-class for edges.
Definition grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition grid_base_objects.h:510
a helper class that holds a collection of possibly unconnected geometric-objects.
Definition grid_object_collection.h:96
Instances represent a part of a grid.
Definition sub_grid.h:44
virtual bool is_contained(Volume *) const =0
virtual const GridObjectCollection & goc() const =0
virtual ~ISubGrid()
Definition sub_grid.h:46
virtual bool is_contained(Vertex *) const =0
virtual bool is_contained(Face *) const =0
virtual bool is_contained(Edge *) const =0
Callbacks that return true if an element is contained in a sub-grid.
Definition sub_grid.h:89
IsInSubGrid(const ISubGrid &subGrid)
Definition sub_grid.h:91
const ISubGrid & m_subGrid
Definition sub_grid.h:104
bool operator()(Vertex *v)
Definition sub_grid.h:94
bool callback(TElem *e)
Definition sub_grid.h:101
Callbacks that return true if an element is not contained in a sub-grid.
Definition sub_grid.h:112
const ISubGrid & m_subGrid
Definition sub_grid.h:127
IsNotInSubGrid(const ISubGrid &subGrid)
Definition sub_grid.h:114
bool callback(TElem *e)
Definition sub_grid.h:124
bool operator()(Vertex *v)
Definition sub_grid.h:117
specializes ISubGrid for general callback classes.
Definition sub_grid.h:65
virtual bool is_contained(Edge *e) const
Definition sub_grid.h:75
virtual bool is_contained(Vertex *e) const
Definition sub_grid.h:74
TCallbackCls m_callbacks
Definition sub_grid.h:81
virtual const GridObjectCollection & goc() const
Definition sub_grid.h:73
SubGrid(GridObjectCollection goc, const TCallbackCls &cb)
Definition sub_grid.h:67
GridObjectCollection m_goc
Definition sub_grid.h:80
virtual bool is_contained(Volume *e) const
Definition sub_grid.h:77
virtual bool is_contained(Face *e) const
Definition sub_grid.h:76
Base-class for all vertex-types.
Definition grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition grid_base_objects.h:754
the ug namespace