/usr/include/dolfin/function/FunctionSpace.h is in libdolfin-dev 2016.2.0-2.
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 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | // 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: 2014-06-11
#ifndef __FUNCTION_SPACE_H
#define __FUNCTION_SPACE_H
#include <cstddef>
#include <map>
#include <vector>
#include <memory>
#include <unordered_map>
#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;
/// Inequality 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::size_t)
/// Index of the subspace.
/// *Returns*
/// _FunctionSpace_
/// The subspace.
std::shared_ptr<FunctionSpace> sub(std::size_t component) const
{ return extract_sub_space({component}); }
/// Extract subspace for component
///
/// *Arguments*
/// component (std::vector<std::size_t>)
/// The component.
/// *Returns*
/// _FunctionSpace_
/// The subspace.
std::shared_ptr<FunctionSpace>
sub(const std::vector<std::size_t>& component) const
{ return extract_sub_space(component); }
/// 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;
/// Check whether V is subspace of this, or this itself
///
/// *Arguments*
/// V (_FunctionSpace_)
/// The space to be tested for inclusion.
///
/// *Returns*
/// bool
/// True if V is contained or equal to this.
bool contains(const FunctionSpace& V) 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 (std::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(std::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 w.r.t. to root superspace, i.e.
/// W.sub(1).sub(0) == [1, 0].
///
/// *Returns*
/// std::vector<std::size_t>
/// The component (w.r.t to root superspace).
std::vector<std::size_t> component() const;
/// Tabulate the coordinates of all dofs on this process. This
/// function is typically used by preconditioners that require the
/// spatial coordinates of dofs, for example for re-partitioning or
/// nullspace computations.
///
/// *Arguments*
/// mesh (_Mesh_)
/// The mesh.
///
/// *Returns*
/// std::vector<double>
/// The dof coordinates (x0, y0, x1, y1, . . .)
std::vector<double> tabulate_dof_coordinates() const;
/// Set dof entries in vector to value*x[i], where [x][i] is the
/// coordinate of the dof spatial coordinate. Parallel layout of
/// vector must be consistent with dof map range This function is
/// typically used to construct the null space of a matrix
/// operator, e.g. rigid body rotations.
///
/// *Arguments*
/// vector (_GenericVector_)
/// The vector to set.
/// value (double)
/// The value to multiply to coordinate by.
/// component (std::size_t)
/// The coordinate index.
/// mesh (_Mesh_)
/// The mesh.
void set_x(GenericVector& x, double value, 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:
// General interpolation from any GenericFunction on any mesh
void interpolate_from_any(GenericVector& expansion_coefficients,
const GenericFunction& v) const;
// Specialised interpolate routine when functions are related by a
// parent mesh
void interpolate_from_parent(GenericVector& expansion_coefficients,
const GenericFunction& v) const;
// 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 w.r.t. to root space
std::vector<std::size_t> _component;
// The identifier of root space
std::size_t _root_space_id;
// Cache of subspaces
mutable std::map<std::vector<std::size_t>,
std::shared_ptr<FunctionSpace> > _subspaces;
};
}
#endif
|