15#ifndef dealii_mg_level_object_h
16#define dealii_mg_level_object_h
47template <
class Object>
72 template <
class... Args>
74 const unsigned int maxlevel,
82 const unsigned int maxlevel = 0);
118 template <
class... Args>
121 const unsigned int new_maxlevel,
179 template <
typename ActionFunctionObjectType>
181 apply(ActionFunctionObjectType action);
205template <
class Object>
206template <
class... Args>
208 const unsigned int max,
212 resize(min, max, std::forward<Args>(args)...);
216template <
class Object>
218 const unsigned int max)
225template <
class Object>
229 Assert((i >= minlevel) && (i < minlevel + objects.size()),
231 return *objects[i - minlevel];
235template <
class Object>
239 Assert((i >= minlevel) && (i < minlevel + objects.size()),
241 return *objects[i - minlevel];
245template <
class Object>
249 return this->operator[](this->max_level());
253template <
class Object>
254template <
class... Args>
257 const unsigned int new_maxlevel,
267 minlevel = new_minlevel;
268 for (
unsigned int i = 0; i < new_maxlevel - new_minlevel + 1; ++i)
269 objects.push_back(std::make_shared<Object>(std::forward<Args>(args)...));
273template <
class Object>
277 typename std::vector<std::shared_ptr<Object>>::iterator v;
278 for (v = objects.begin(); v != objects.end(); ++v)
284template <
class Object>
293template <
class Object>
297 typename std::vector<std::shared_ptr<Object>>::iterator v;
298 for (v = objects.begin(); v != objects.end(); ++v)
303template <
class Object>
311template <
class Object>
315 return minlevel + objects.size() - 1;
319template <
class Object>
323 return objects.size();
326template <
class Object>
327template <
typename ActionFunctionObjectType>
331 for (
unsigned int lvl = min_level(); lvl <= max_level(); ++lvl)
333 action(lvl, (*
this)[lvl]);
338template <
class Object>
342 std::size_t result =
sizeof(*this);
343 using Iter =
typename std::vector<std::shared_ptr<Object>>::const_iterator;
344 const Iter end = objects.end();
345 for (Iter o = objects.begin(); o != end; ++o)
346 result += (*o)->memory_consumption();
std::vector< std::shared_ptr< Object > > objects
Object & operator[](const unsigned int level)
MGLevelObject< Object > & operator=(const double d)
MGLevelObject(const unsigned int minlevel, const unsigned int maxlevel, Args &&...args)
MGLevelObject(const unsigned int minlevel=0, const unsigned int maxlevel=0)
const Object & operator[](const unsigned int level) const
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel, Args &&...args)
std::size_t memory_consumption() const
unsigned int max_level() const
unsigned int min_level() const
const Object & back() const
unsigned int n_levels() const
void apply(ActionFunctionObjectType action)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)