Loading...
Searching...
No Matches
FunctionSpace.h
// 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;
class FunctionSpace : public Variable, public Hierarchical<FunctionSpace>
{
public:
FunctionSpace(std::shared_ptr<const Mesh> mesh,
std::shared_ptr<const FiniteElement> element,
std::shared_ptr<const GenericDofMap> dofmap);
protected:
explicit FunctionSpace(std::shared_ptr<const Mesh> mesh);
public:
FunctionSpace(const FunctionSpace& V);
virtual ~FunctionSpace();
protected:
void attach(std::shared_ptr<const FiniteElement> element,
std::shared_ptr<const GenericDofMap> dofmap);
public:
const FunctionSpace& operator= (const FunctionSpace& V);
bool operator== (const FunctionSpace& V) const;
bool operator!= (const FunctionSpace& V) const;
std::shared_ptr<const Mesh> mesh() const;
std::shared_ptr<const FiniteElement> element() const;
std::shared_ptr<const GenericDofMap> dofmap() const;
std::size_t dim() const;
void interpolate(GenericVector& expansion_coefficients,
const GenericFunction& v) const;
std::shared_ptr<FunctionSpace> operator[] (std::size_t i) const;
std::shared_ptr<FunctionSpace> sub(std::size_t component) const
{ return extract_sub_space({component}); }
std::shared_ptr<FunctionSpace>
sub(const std::vector<std::size_t>& component) const
{ return extract_sub_space(component); }
std::shared_ptr<FunctionSpace>
extract_sub_space(const std::vector<std::size_t>& component) const;
bool contains(const FunctionSpace& V) const;
std::shared_ptr<FunctionSpace> collapse() const;
std::shared_ptr<FunctionSpace>
collapse(std::unordered_map<std::size_t, std::size_t>& collapsed_dofs) const;
bool has_cell(const Cell& cell) const
{ return &cell.mesh() == &(*_mesh); }
bool has_element(const FiniteElement& element) const
{ return element.hash() == _element->hash(); }
std::vector<std::size_t> component() const;
std::vector<double> tabulate_dof_coordinates() const;
void set_x(GenericVector& x, double value, std::size_t component) const;
std::string str(bool verbose) const;
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
dolfin::Cell
A Cell is a MeshEntity of topological codimension 0.
Definition Cell.h:43
dolfin::FiniteElement
This is a wrapper for a UFC finite element (ufc::finite_element).
Definition FiniteElement.h:36
dolfin::FunctionSpace
Definition FunctionSpace.h:54
dolfin::FunctionSpace::operator=
const FunctionSpace & operator=(const FunctionSpace &V)
Definition FunctionSpace.cpp:75
dolfin::FunctionSpace::has_element
bool has_element(const FiniteElement &element) const
Definition FunctionSpace.h:268
dolfin::FunctionSpace::element
std::shared_ptr< const FiniteElement > element() const
Definition FunctionSpace.cpp:109
dolfin::FunctionSpace::operator[]
std::shared_ptr< FunctionSpace > operator[](std::size_t i) const
Definition FunctionSpace.cpp:259
dolfin::FunctionSpace::collapse
std::shared_ptr< FunctionSpace > collapse() const
Definition FunctionSpace.cpp:309
dolfin::FunctionSpace::mesh
std::shared_ptr< const Mesh > mesh() const
Definition FunctionSpace.cpp:104
dolfin::FunctionSpace::print_dofmap
void print_dofmap() const
Print dofmap (useful for debugging).
Definition FunctionSpace.cpp:447
dolfin::FunctionSpace::attach
void attach(std::shared_ptr< const FiniteElement > element, std::shared_ptr< const GenericDofMap > dofmap)
Definition FunctionSpace.cpp:68
dolfin::FunctionSpace::~FunctionSpace
virtual ~FunctionSpace()
Destructor.
Definition FunctionSpace.cpp:63
dolfin::FunctionSpace::contains
bool contains(const FunctionSpace &V) const
Definition FunctionSpace.cpp:462
dolfin::FunctionSpace::str
std::string str(bool verbose) const
Definition FunctionSpace.cpp:431
dolfin::FunctionSpace::FunctionSpace
FunctionSpace(std::shared_ptr< const Mesh > mesh, std::shared_ptr< const FiniteElement > element, std::shared_ptr< const GenericDofMap > dofmap)
Definition FunctionSpace.cpp:41
dolfin::FunctionSpace::tabulate_dof_coordinates
std::vector< double > tabulate_dof_coordinates() const
Definition FunctionSpace.cpp:342
dolfin::FunctionSpace::extract_sub_space
std::shared_ptr< FunctionSpace > extract_sub_space(const std::vector< std::size_t > &component) const
Definition FunctionSpace.cpp:267
dolfin::FunctionSpace::sub
std::shared_ptr< FunctionSpace > sub(std::size_t component) const
Definition FunctionSpace.h:189
dolfin::FunctionSpace::dofmap
std::shared_ptr< const GenericDofMap > dofmap() const
Definition FunctionSpace.cpp:114
dolfin::FunctionSpace::has_cell
bool has_cell(const Cell &cell) const
Definition FunctionSpace.h:256
dolfin::FunctionSpace::component
std::vector< std::size_t > component() const
Definition FunctionSpace.cpp:337
dolfin::FunctionSpace::set_x
void set_x(GenericVector &x, double value, std::size_t component) const
Definition FunctionSpace.cpp:398
dolfin::FunctionSpace::operator!=
bool operator!=(const FunctionSpace &V) const
Definition FunctionSpace.cpp:98
dolfin::FunctionSpace::dim
std::size_t dim() const
Definition FunctionSpace.cpp:119
dolfin::FunctionSpace::interpolate
void interpolate(GenericVector &expansion_coefficients, const GenericFunction &v) const
Definition FunctionSpace.cpp:205
dolfin::FunctionSpace::operator==
bool operator==(const FunctionSpace &V) const
Definition FunctionSpace.cpp:90
dolfin::FunctionSpace::sub
std::shared_ptr< FunctionSpace > sub(const std::vector< std::size_t > &component) const
Definition FunctionSpace.h:201
dolfin::Function
Definition Function.h:66
dolfin::GenericDofMap
This class provides a generic interface for dof maps.
Definition GenericDofMap.h:50
dolfin::GenericFunction
Definition GenericFunction.h:54
dolfin::GenericVector
This class defines a common interface for vectors.
Definition GenericVector.h:48
dolfin::Hierarchical< FunctionSpace >::Hierarchical
Hierarchical(FunctionSpace &self)
Definition Hierarchical.h:48
dolfin::MeshEntity::mesh
const Mesh & mesh() const
Definition MeshEntity.h:99
dolfin::Mesh
Definition Mesh.h:84
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin
Definition adapt.h:30