/usr/include/deal.II/base/mg_level_object.h is in libdeal.ii-dev 8.1.0-6ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | // ---------------------------------------------------------------------
// $Id: mg_level_object.h 30036 2013-07-18 16:55:32Z maier $
//
// Copyright (C) 2003 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef __deal2__mg_level_object_h
#define __deal2__mg_level_object_h
#include <deal.II/base/subscriptor.h>
#include <vector>
#include <deal.II/base/std_cxx1x/shared_ptr.h>
DEAL_II_NAMESPACE_OPEN
/**
* An array with an object for each level. The purpose of this class
* is mostly to store objects and allow access by level number, even
* if the lower levels are not used and therefore have no object at
* all; this is done by simply shifting the given index by the minimum
* level we have stored.
*
* In most cases, the objects which are stored on each levels, are
* either matrices or vectors.
*
* @ingroup mg
* @ingroup data
* @author Wolfgang Bangerth, Guido Kanschat, 1999, 2005, 2010
*/
template<class Object>
class MGLevelObject : public Subscriptor
{
public:
/**
* Constructor allowing to
* initialize the number of
* levels. By default, the object
* is created empty.
*/
MGLevelObject (const unsigned int minlevel = 0,
const unsigned int maxlevel = 0);
/**
* Access object on level @p level.
*/
Object &operator[] (const unsigned int level);
/**
* Access object on level
* @p level. Constant version.
*/
const Object &operator[] (const unsigned int level) const;
/**
* Delete all previous contents
* of this object and reset its
* size according to the values
* of @p new_minlevel and
* @p new_maxlevel.
*/
void resize (const unsigned int new_minlevel,
const unsigned int new_maxlevel);
/**
* Call <tt>operator = (s)</tt>
* on all objects stored by this
* object. This is particularly
* useful for
* e.g. <tt>Object==Vector@<T@></tt>
*/
MGLevelObject<Object> &operator = (const double d);
/**
* Call @p clear on all objects
* stored by this object. This
* function is only implemented
* for some @p Object classes,
* e.g. the PreconditionBlockSOR
* and similar classes.
*/
void clear();
/**
* Coarsest level for multigrid.
*/
unsigned int min_level () const;
/**
* Finest level for multigrid.
*/
unsigned int max_level () const;
/**
* @deprecated Replaced by min_level()
*/
unsigned int get_minlevel () const DEAL_II_DEPRECATED;
/**
* @deprecated Replaced by max_level()
*/
unsigned int get_maxlevel () const DEAL_II_DEPRECATED;
/**
* Memory used by this object.
*/
std::size_t memory_consumption () const;
private:
/**
* Level of first component.
*/
unsigned int minlevel;
/**
* Array of the objects to be held.
*/
std::vector<std_cxx1x::shared_ptr<Object> > objects;
};
/* ------------------------------------------------------------------- */
template<class Object>
MGLevelObject<Object>::MGLevelObject(const unsigned int min,
const unsigned int max)
:
minlevel(0)
{
resize (min, max);
}
template<class Object>
Object &
MGLevelObject<Object>::operator[] (const unsigned int i)
{
Assert((i>=minlevel) && (i<minlevel+objects.size()),
ExcIndexRange (i, minlevel, minlevel+objects.size()));
return *objects[i-minlevel];
}
template<class Object>
const Object &
MGLevelObject<Object>::operator[] (const unsigned int i) const
{
Assert((i>=minlevel) && (i<minlevel+objects.size()),
ExcIndexRange (i, minlevel, minlevel+objects.size()));
return *objects[i-minlevel];
}
template<class Object>
void
MGLevelObject<Object>::resize (const unsigned int new_minlevel,
const unsigned int new_maxlevel)
{
Assert (new_minlevel <= new_maxlevel, ExcInternalError());
// note that on clear(), the
// shared_ptr class takes care of
// deleting the object it points to
// by itself
objects.clear ();
minlevel = new_minlevel;
for (unsigned int i=0; i<new_maxlevel-new_minlevel+1; ++i)
objects.push_back(std_cxx1x::shared_ptr<Object> (new Object));
}
template<class Object>
MGLevelObject<Object> &
MGLevelObject<Object>::operator = (const double d)
{
typename std::vector<std_cxx1x::shared_ptr<Object> >::iterator v;
for (v = objects.begin(); v != objects.end(); ++v)
**v=d;
return *this;
}
template<class Object>
void
MGLevelObject<Object>::clear ()
{
typename std::vector<std_cxx1x::shared_ptr<Object> >::iterator v;
for (v = objects.begin(); v != objects.end(); ++v)
(*v)->clear();
}
template<class Object>
unsigned int
MGLevelObject<Object>::get_minlevel () const
{
return minlevel;
}
template<class Object>
unsigned int
MGLevelObject<Object>::get_maxlevel () const
{
return minlevel + objects.size() - 1;
}
template<class Object>
unsigned int
MGLevelObject<Object>::min_level () const
{
return minlevel;
}
template<class Object>
unsigned int
MGLevelObject<Object>::max_level () const
{
return minlevel + objects.size() - 1;
}
template<class Object>
std::size_t
MGLevelObject<Object>::memory_consumption () const
{
std::size_t result = sizeof(*this);
typedef typename std::vector<std_cxx1x::shared_ptr<Object> >::const_iterator Iter;
const Iter end = objects.end();
for (Iter o=objects.begin(); o!=end; ++o)
result += (*o)->memory_consumption();
return result;
}
DEAL_II_NAMESPACE_CLOSE
#endif
|