Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.1.0/v0.9.0/cpp
DOLFINx  0.1.0
DOLFINx C++ interface
FunctionSpace.h
1 // Copyright (C) 2008-2019 Anders Logg and Garth N. Wells
2 //
3 // This file is part of DOLFINx (https://www.fenicsproject.org)
4 //
5 // SPDX-License-Identifier: LGPL-3.0-or-later
6 
7 #pragma once
8 
9 #include <cstddef>
10 #include <functional>
11 #include <map>
12 #include <memory>
13 #include <vector>
14 #include <xtensor/xtensor.hpp>
15 
16 namespace dolfinx
17 {
18 
19 namespace mesh
20 {
21 class Mesh;
22 }
23 
24 namespace fem
25 {
26 class DofMap;
27 class FiniteElement;
28 
32 
34 {
35 public:
40  FunctionSpace(std::shared_ptr<const mesh::Mesh> mesh,
41  std::shared_ptr<const fem::FiniteElement> element,
42  std::shared_ptr<const fem::DofMap> dofmap);
43 
44  // Copy constructor (deleted)
45  FunctionSpace(const FunctionSpace& V) = delete;
46 
48  FunctionSpace(FunctionSpace&& V) = default;
49 
51  virtual ~FunctionSpace() = default;
52 
53  // Assignment operator (delete)
54  FunctionSpace& operator=(const FunctionSpace& V) = delete;
55 
57  FunctionSpace& operator=(FunctionSpace&& V) = default;
58 
61  bool operator==(const FunctionSpace& V) const;
62 
65  bool operator!=(const FunctionSpace& V) const;
66 
70  std::shared_ptr<FunctionSpace> sub(const std::vector<int>& component) const;
71 
75  bool contains(const FunctionSpace& V) const;
76 
80  std::pair<std::shared_ptr<FunctionSpace>, std::vector<std::int32_t>>
81  collapse() const;
82 
86  std::vector<int> component() const;
87 
96  xt::xtensor<double, 2> tabulate_dof_coordinates(bool transpose) const;
97 
99  std::size_t id() const;
100 
102  std::shared_ptr<const mesh::Mesh> mesh() const;
103 
105  std::shared_ptr<const fem::FiniteElement> element() const;
106 
108  std::shared_ptr<const fem::DofMap> dofmap() const;
109 
110 private:
111  // The mesh
112  std::shared_ptr<const mesh::Mesh> _mesh;
113 
114  // The finite element
115  std::shared_ptr<const fem::FiniteElement> _element;
116 
117  // The dofmap
118  std::shared_ptr<const fem::DofMap> _dofmap;
119 
120  // The component w.r.t. to root space
121  std::vector<int> _component;
122 
123  // Unique identifier
124  std::size_t _id;
125 
126  // The identifier of root space
127  std::size_t _root_space_id;
128 
129  // Cache of subspaces
130  mutable std::map<std::vector<int>, std::weak_ptr<FunctionSpace>> _subspaces;
131 };
132 
142 std::array<std::vector<std::shared_ptr<const FunctionSpace>>, 2>
144  const std::vector<
145  std::vector<std::array<std::shared_ptr<const FunctionSpace>, 2>>>& V);
146 } // namespace fem
147 } // namespace dolfinx
dolfinx::fem::FunctionSpace::id
std::size_t id() const
Unique identifier.
Definition: FunctionSpace.cpp:209
dolfinx::fem::FunctionSpace
This class represents a finite element function space defined by a mesh, a finite element,...
Definition: FunctionSpace.h:33
dolfinx::fem::FunctionSpace::tabulate_dof_coordinates
xt::xtensor< double, 2 > tabulate_dof_coordinates(bool transpose) const
Definition: FunctionSpace.cpp:104
dolfinx::fem::common_function_spaces
std::array< std::vector< std::shared_ptr< const FunctionSpace > >, 2 > common_function_spaces(const std::vector< std::vector< std::array< std::shared_ptr< const FunctionSpace >, 2 >>> &V)
Extract FunctionSpaces for (0) rows blocks and (1) columns blocks from a rectangular array of (test,...
Definition: FunctionSpace.cpp:242
dolfinx::fem::FunctionSpace::mesh
std::shared_ptr< const mesh::Mesh > mesh() const
The mesh.
Definition: FunctionSpace.cpp:211
dolfinx::fem::FunctionSpace::dofmap
std::shared_ptr< const fem::DofMap > dofmap() const
The dofmap.
Definition: FunctionSpace.cpp:218
dolfinx::fem::FunctionSpace::collapse
std::pair< std::shared_ptr< FunctionSpace >, std::vector< std::int32_t > > collapse() const
Collapse a subspace and return a new function space and a map from new to old dofs.
Definition: FunctionSpace.cpp:83
dolfinx::fem::FunctionSpace::contains
bool contains(const FunctionSpace &V) const
Check whether V is subspace of this, or this itself.
Definition: FunctionSpace.cpp:223
dolfinx::fem::FunctionSpace::~FunctionSpace
virtual ~FunctionSpace()=default
Destructor.
dolfinx::fem::FunctionSpace::component
std::vector< int > component() const
Get the component with respect to the root superspace.
Definition: FunctionSpace.cpp:101
dolfinx::fem::FunctionSpace::element
std::shared_ptr< const fem::FiniteElement > element() const
The finite element.
Definition: FunctionSpace.cpp:213
dolfinx::fem::FunctionSpace::sub
std::shared_ptr< FunctionSpace > sub(const std::vector< int > &component) const
Extract subspace for component.
Definition: FunctionSpace.cpp:46
dolfinx::fem::FunctionSpace::operator!=
bool operator!=(const FunctionSpace &V) const
Inequality operator.
Definition: FunctionSpace.cpp:40
dolfinx::fem::FunctionSpace::operator==
bool operator==(const FunctionSpace &V) const
Equality operator.
Definition: FunctionSpace.cpp:35
dolfinx::fem::FunctionSpace::FunctionSpace
FunctionSpace(std::shared_ptr< const mesh::Mesh > mesh, std::shared_ptr< const fem::FiniteElement > element, std::shared_ptr< const fem::DofMap > dofmap)
Create function space for given mesh, element and dofmap.
Definition: FunctionSpace.cpp:26