Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.3.0/v0.9.0/cpp
DOLFINx  0.3.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::mesh
17 {
18 class Mesh;
19 }
20 
21 namespace dolfinx::fem
22 {
23 class DofMap;
24 class FiniteElement;
25 
29 
31 {
32 public:
37  FunctionSpace(std::shared_ptr<const mesh::Mesh> mesh,
38  std::shared_ptr<const fem::FiniteElement> element,
39  std::shared_ptr<const fem::DofMap> dofmap);
40 
41  // Copy constructor (deleted)
42  FunctionSpace(const FunctionSpace& V) = delete;
43 
45  FunctionSpace(FunctionSpace&& V) = default;
46 
48  virtual ~FunctionSpace() = default;
49 
50  // Assignment operator (delete)
51  FunctionSpace& operator=(const FunctionSpace& V) = delete;
52 
55 
58  bool operator==(const FunctionSpace& V) const;
59 
62  bool operator!=(const FunctionSpace& V) const;
63 
67  std::shared_ptr<FunctionSpace> sub(const std::vector<int>& component) const;
68 
72  bool contains(const FunctionSpace& V) const;
73 
77  std::pair<std::shared_ptr<FunctionSpace>, std::vector<std::int32_t>>
78  collapse() const;
79 
83  std::vector<int> component() const;
84 
93  xt::xtensor<double, 2> tabulate_dof_coordinates(bool transpose) const;
94 
96  std::size_t id() const;
97 
99  std::shared_ptr<const mesh::Mesh> mesh() const;
100 
102  std::shared_ptr<const fem::FiniteElement> element() const;
103 
105  std::shared_ptr<const fem::DofMap> dofmap() const;
106 
107 private:
108  // The mesh
109  std::shared_ptr<const mesh::Mesh> _mesh;
110 
111  // The finite element
112  std::shared_ptr<const fem::FiniteElement> _element;
113 
114  // The dofmap
115  std::shared_ptr<const fem::DofMap> _dofmap;
116 
117  // The component w.r.t. to root space
118  std::vector<int> _component;
119 
120  // Unique identifier
121  std::size_t _id;
122 
123  // The identifier of root space
124  std::size_t _root_space_id;
125 
126  // Cache of subspaces
127  mutable std::map<std::vector<int>, std::weak_ptr<FunctionSpace>> _subspaces;
128 };
129 
139 std::array<std::vector<std::shared_ptr<const FunctionSpace>>, 2>
141  const std::vector<
142  std::vector<std::array<std::shared_ptr<const FunctionSpace>, 2>>>& V);
143 } // namespace dolfinx::fem
This class represents a finite element function space defined by a mesh, a finite element,...
Definition: FunctionSpace.h:31
virtual ~FunctionSpace()=default
Destructor.
std::vector< int > component() const
Get the component with respect to the root superspace.
Definition: FunctionSpace.cpp:101
std::shared_ptr< FunctionSpace > sub(const std::vector< int > &component) const
Extract subspace for component.
Definition: FunctionSpace.cpp:46
xt::xtensor< double, 2 > tabulate_dof_coordinates(bool transpose) const
Definition: FunctionSpace.cpp:104
bool contains(const FunctionSpace &V) const
Check whether V is subspace of this, or this itself.
Definition: FunctionSpace.cpp:230
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
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
std::shared_ptr< const fem::DofMap > dofmap() const
The dofmap.
Definition: FunctionSpace.cpp:225
std::shared_ptr< const fem::FiniteElement > element() const
The finite element.
Definition: FunctionSpace.cpp:220
bool operator!=(const FunctionSpace &V) const
Inequality operator.
Definition: FunctionSpace.cpp:40
FunctionSpace(FunctionSpace &&V)=default
Move constructor.
bool operator==(const FunctionSpace &V) const
Equality operator.
Definition: FunctionSpace.cpp:35
FunctionSpace & operator=(FunctionSpace &&V)=default
Move assignment operator.
std::shared_ptr< const mesh::Mesh > mesh() const
The mesh.
Definition: FunctionSpace.cpp:218
std::size_t id() const
Unique identifier.
Definition: FunctionSpace.cpp:216
Finite element method functionality.
Definition: assemble_matrix_impl.h:23
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:249
Mesh data structures and algorithms on meshes.
Definition: DirichletBC.h:20