/usr/include/dolfin/function/FunctionSpace.h is in libdolfin-dev 1.4.0+dfsg-4.
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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | // Copyright (C) 2008-2011 Anders Logg
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can 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 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Garth N. Wells 2008-2011
// Modified by Kent-Andre Mardal 2009
// Modified by Ola Skavhaug 2009
//
// First added: 2008-09-11
// Last changed: 2013-09-19
#ifndef __FUNCTION_SPACE_H
#define __FUNCTION_SPACE_H
#include <cstddef>
#include <map>
#include <vector>
#include <memory>
#include <boost/unordered_map.hpp>
#include <dolfin/common/Array.h>
#include <dolfin/common/Variable.h>
#include <dolfin/common/Hierarchical.h>
#include <dolfin/fem/FiniteElement.h>
#include <dolfin/mesh/Cell.h>
namespace dolfin
{
class Function;
class GenericDofMap;
class GenericFunction;
class GenericVector;
class Mesh;
/// This class represents a finite element function space defined by
/// a mesh, a finite element, and a local-to-global mapping of the
/// degrees of freedom (dofmap).
class FunctionSpace : public Variable, public Hierarchical<FunctionSpace>
{
public:
/// Create function space for given mesh, element and dofmap
/// (shared data)
///
/// *Arguments*
/// mesh (_Mesh_)
/// The mesh.
/// element (_FiniteElement_)
/// The element.
/// dofmap (_GenericDofMap_)
/// The dofmap.
FunctionSpace(std::shared_ptr<const Mesh> mesh,
std::shared_ptr<const FiniteElement> element,
std::shared_ptr<const GenericDofMap> dofmap);
protected:
/// Create empty function space for later initialization. This
/// constructor is intended for use by any sub-classes which need
/// to construct objects before the initialisation of the base
/// class. Data can be attached to the base class using
/// FunctionSpace::attach(...).
///
/// *Arguments*
/// mesh (_Mesh_)
/// The mesh.
explicit FunctionSpace(std::shared_ptr<const Mesh> mesh);
public:
/// Copy constructor
///
/// *Arguments*
/// V (_FunctionSpace_)
/// The object to be copied.
FunctionSpace(const FunctionSpace& V);
/// Destructor
virtual ~FunctionSpace();
protected:
/// Attach data to an empty function space
///
/// *Arguments*
/// element (_FiniteElement_)
/// The element.
/// dofmap (_GenericDofMap_)
/// The dofmap.
void attach(std::shared_ptr<const FiniteElement> element,
std::shared_ptr<const GenericDofMap> dofmap);
public:
/// Assignment operator
///
/// *Arguments*
/// V (_FunctionSpace_)
/// Another function space.
const FunctionSpace& operator= (const FunctionSpace& V);
/// Equality operator
///
/// *Arguments*
/// V (_FunctionSpace_)
/// Another function space.
bool operator== (const FunctionSpace& V) const;
/// Unequality operator
///
/// *Arguments*
/// V (_FunctionSpace_)
/// Another function space.
bool operator!= (const FunctionSpace& V) const;
/// Return mesh
///
/// *Returns*
/// _Mesh_
/// The mesh.
std::shared_ptr<const Mesh> mesh() const;
/// Return finite element
///
/// *Returns*
/// _FiniteElement_
/// The finite element.
std::shared_ptr<const FiniteElement> element() const;
/// Return dofmap
///
/// *Returns*
/// _GenericDofMap_
/// The dofmap.
std::shared_ptr<const GenericDofMap> dofmap() const;
/// Return dimension of function space
///
/// *Returns*
/// std::size_t
/// The dimension of the function space.
std::size_t dim() const;
/// Interpolate function v into function space, returning the
/// vector of expansion coefficients
///
/// *Arguments*
/// expansion_coefficients (_GenericVector_)
/// The expansion coefficients.
/// v (_GenericFunction_)
/// The function to be interpolated.
void interpolate(GenericVector& expansion_coefficients,
const GenericFunction& v) const;
/// Extract subspace for component
///
/// *Arguments*
/// i (std::size_t)
/// Index of the subspace.
/// *Returns*
/// _FunctionSpace_
/// The subspace.
std::shared_ptr<FunctionSpace> operator[] (std::size_t i) const;
/// Extract subspace for component
///
/// *Arguments*
/// component (std::vector<std::size_t>)
/// The component.
///
/// *Returns*
/// _FunctionSpace_
/// The subspace.
std::shared_ptr<FunctionSpace>
extract_sub_space(const std::vector<std::size_t>& component) const;
/// Collapse a subspace and return a new function space
///
/// *Returns*
/// _FunctionSpace_
/// The new function space.
std::shared_ptr<FunctionSpace> collapse() const;
/// Collapse a subspace and return a new function space and a map
/// from new to old dofs
///
/// *Arguments*
/// collapsed_dofs (boost::unordered_map<std::size_t, std::size_t>)
/// The map from new to old dofs.
///
/// *Returns*
/// _FunctionSpace_
/// The new function space.
std::shared_ptr<FunctionSpace>
collapse(boost::unordered_map<std::size_t, std::size_t>& collapsed_dofs) const;
/// Check if function space has given cell
///
/// *Arguments*
/// cell (_Cell_)
/// The cell.
///
/// *Returns*
/// bool
/// True if the function space has the given cell.
bool has_cell(const Cell& cell) const
{ return &cell.mesh() == &(*_mesh); }
/// Check if function space has given element
///
/// *Arguments*
/// element (_FiniteElement_)
/// The finite element.
///
/// *Returns*
/// bool
/// True if the function space has the given element.
bool has_element(const FiniteElement& element) const
{ return element.hash() == _element->hash(); }
/// Return component
///
/// *Returns*
/// std::vector<std::size_t>
/// The component (relative to superspace).
std::vector<std::size_t> component() const;
/// Return informal string representation (pretty-print)
///
/// *Arguments*
/// verbose (bool)
/// Flag to turn on additional output.
///
/// *Returns*
/// std::string
/// An informal representation of the function space.
std::string str(bool verbose) const;
/// Print dofmap (useful for debugging)
void print_dofmap() const;
private:
// The mesh
std::shared_ptr<const Mesh> _mesh;
// The finite element
std::shared_ptr<const FiniteElement> _element;
// The dofmap
std::shared_ptr<const GenericDofMap> _dofmap;
// The component (for sub spaces)
std::vector<std::size_t> _component;
// Cache of sub spaces
mutable std::map<std::vector<std::size_t>,
std::shared_ptr<FunctionSpace> > subspaces;
};
}
#endif
|