Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
subset_group.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3 * Author: Andreas Vogel
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__LIB_GRID__SUBSET_GROUP__
34#define __H__UG__LIB_GRID__SUBSET_GROUP__
35
36#include <vector>
37#include <string>
39
40namespace ug{
41
43
51{
52 public:
55
58
60 SubsetGroup(ConstSmartPtr<ISubsetHandler> sh, const char* names);
61
63 SubsetGroup(ConstSmartPtr<ISubsetHandler> sh, const std::string& names);
64
66 SubsetGroup(ConstSmartPtr<ISubsetHandler> sh, const std::vector<std::string>& vName);
67
70
73
75 void add(int si);
76
78 void add(const char* name);
79
81 void add(const std::string& name);
82
84
88 void add(const std::vector<std::string>& vName);
89
91 void add(const SubsetGroup& ssGroup);
92
94 void add_all();
95
97 void remove(int si);
98
100 void remove(const char* name);
101
103 void remove(const std::string& name);
104
106
110 void remove(const std::vector<std::string>& vName);
111
113 void remove(const SubsetGroup& ssGroup);
114
116 void clear() {m_vSubset.clear();}
117
119 bool empty() const {return m_vSubset.empty();}
120
122 inline size_t size() const
123 {
124 if (!m_pSH.valid()) return 0;
125 return m_vSubset.size();
126 }
127
129 inline int operator[](size_t i) const
130 {
131 UG_ASSERT(is_init(), "No SubsetHandler set.");
132 UG_ASSERT(i < size(), "requested subset does not exist.");
133 return m_vSubset[i];
134 }
135
137 inline const std::vector<int>& index_vector() const
138 {
139 return m_vSubset;
140 }
141
143 const char* name(size_t i) const;
144
146 bool regular_grid(size_t i) const;
147
149
154 int dim(size_t i) const;
155
157
167
169 bool contains(int si) const;
170
172 bool contains(const char* name) const;
173
174 protected:
175 // returns if SubsetGroup is ready for use
176 bool is_init() const {return m_pSH.valid();}
177
178 protected:
180 std::vector<int> m_vSubset;
181};
182
188bool SameDimensionsInAllSubsets(const SubsetGroup& subsetGroup);
189
195void RemoveLowerDimSubsets(SubsetGroup& subsetGroup);
196
197} // end namespace ug
198
199#endif /*__H__UG__LIB_GRID__SUBSET_GROUP__ */
location name
Definition checkpoint_util.lua:128
Definition smart_pointer.h:296
Group of subsets.
Definition subset_group.h:51
bool regular_grid(size_t i) const
returns if a subset is a regular grid
Definition subset_group.cpp:224
void add(const std::string &name)
adds subset with a name to this group
void clear()
clear all subsets
Definition subset_group.h:116
bool empty() const
returns if function group is empty
Definition subset_group.h:119
bool is_init() const
Definition subset_group.h:176
ConstSmartPtr< ISubsetHandler > m_pSH
underlying SubsetHandler
Definition subset_group.h:179
void add(const std::vector< std::string > &vName)
adds all subset with by name to this group
int operator[](size_t i) const
index of the subset # i in this group
Definition subset_group.h:129
ConstSmartPtr< ISubsetHandler > subset_handler() const
get underlying subset handler
Definition subset_group.h:72
const std::vector< int > & index_vector() const
vector of the subset indices in the group
Definition subset_group.h:137
SubsetGroup()
Default Constructor.
Definition subset_group.cpp:45
size_t size() const
number of subsets in this group
Definition subset_group.h:122
void remove(const std::string &name)
removes subset with a given name from this group
void set_subset_handler(ConstSmartPtr< ISubsetHandler > sh)
set an underlying subset handler
Definition subset_group.h:69
void add_all()
select all subsets of underlying subset handler
Definition subset_group.cpp:133
void remove(const std::vector< std::string > &vName)
removes subsets with given names from this group
std::vector< int > m_vSubset
selected Subset Indices
Definition subset_group.h:180
int dim(size_t i) const
dimension of subset
Definition subset_group.cpp:237
void add(int si)
adds a subset by number to this group
Definition subset_group.cpp:64
void remove(int si)
removes a subset from this group
Definition subset_group.cpp:142
int get_highest_subset_dimension() const
highest dimension of all subset
Definition subset_group.cpp:249
bool contains(int si) const
returns true if subset is contained in this group
Definition subset_group.cpp:272
#define UG_ASSERT(expr, msg)
Definition assert.h:70
the ug namespace
bool SameDimensionsInAllSubsets(const SubsetGroup &subsetGroup)
Definition subset_group.cpp:299
void RemoveLowerDimSubsets(SubsetGroup &subsetGroup)
Definition subset_group.cpp:315