PolyFEM
Loading...
Searching...
No Matches
FESpace.hpp
Go to the documentation of this file.
1#pragma once
2
9
10#include <Eigen/Dense>
11
12#include <algorithm>
13#include <cassert>
14#include <map>
15#include <memory>
16#include <unordered_map>
17#include <vector>
18
19namespace polyfem::varform
20{
21 class FESpace;
22
24 {
25 public:
27 int n_bases = 0;
28
30 std::shared_ptr<std::vector<basis::ElementBases>> bases;
31
33 Eigen::VectorXi disc_orders;
34
36 std::map<int, Eigen::MatrixXd> polys;
37
39 std::map<int, std::pair<Eigen::MatrixXd, Eigen::MatrixXi>> polys_3d;
40
42 std::shared_ptr<mesh::MeshNodes> mesh_nodes;
43
44 void init_from_fe_space(const FESpace &space);
45
46 void reset()
47 {
48 n_bases = 0;
49 bases = nullptr;
50 disc_orders.resize(0);
51 polys.clear();
52 polys_3d.clear();
53 mesh_nodes = nullptr;
54 }
55 };
56
58 class FESpace
59 {
60 public:
62 int value_dim = 1;
63
65 int n_bases = 0;
66
68 std::shared_ptr<std::vector<basis::ElementBases>> bases;
69
71 Eigen::VectorXi disc_orders;
72
74 Eigen::VectorXi disc_ordersq;
75
77 std::map<int, basis::InterfaceData> poly_edge_to_data;
78
80 std::map<int, Eigen::MatrixXd> polys;
81
83 std::map<int, std::pair<Eigen::MatrixXd, Eigen::MatrixXi>> polys_3d;
84
86 std::shared_ptr<mesh::MeshNodes> mesh_nodes;
87
89 std::shared_ptr<GeometryMapping> geometry;
90
91 Eigen::VectorXi space_in_node_to_node;
93
94 int ndof() const
95 {
96 return n_bases * value_dim;
97 }
98
99 bool has_bases() const
100 {
101 return bases != nullptr;
102 }
103
104 bool is_iso_parametric() const
105 {
106 return geometry && geometry->bases == bases;
107 }
108
109 const std::vector<basis::ElementBases> &basis_list() const
110 {
111 assert(bases);
112 return *bases;
113 }
114
115 const std::vector<basis::ElementBases> &geometry_basis_list() const
116 {
117 assert(geometry);
118 assert(geometry->bases);
119 return *geometry->bases;
120 }
121
122 void reset()
123 {
124 value_dim = 1;
125 n_bases = 0;
126 bases = nullptr;
127 disc_orders.resize(0);
128 disc_ordersq.resize(0);
129 poly_edge_to_data.clear();
130 polys.clear();
131 polys_3d.clear();
132 mesh_nodes = nullptr;
133 geometry = nullptr;
134
135 space_in_node_to_node.resize(0);
137 }
138 };
139
141 {
142 n_bases = space.n_bases;
143 bases = space.bases;
144 disc_orders = space.disc_orders;
145 polys = space.polys;
146 polys_3d = space.polys_3d;
147 mesh_nodes = space.mesh_nodes;
148 }
149
152 {
153 std::vector<int> boundary_nodes;
154 std::vector<mesh::LocalBoundary> total_local_boundary;
155 std::vector<mesh::LocalBoundary> local_boundary;
156 std::vector<mesh::LocalBoundary> local_neumann_boundary;
157 std::vector<mesh::LocalBoundary> local_pressure_boundary;
158 std::unordered_map<int, std::vector<mesh::LocalBoundary>> local_pressure_cavity;
159 std::vector<int> pressure_boundary_nodes;
160 std::vector<int> dirichlet_nodes;
161 std::vector<RowVectorNd> dirichlet_nodes_position;
162 std::vector<int> neumann_nodes;
163 std::vector<RowVectorNd> neumann_nodes_position;
164
166 {
167 boundary_nodes.clear();
168 local_boundary.clear();
171 local_pressure_cavity.clear();
173 dirichlet_nodes.clear();
175 neumann_nodes.clear();
177 }
178
180 {
181 std::sort(boundary_nodes.begin(), boundary_nodes.end());
182 boundary_nodes.erase(std::unique(boundary_nodes.begin(), boundary_nodes.end()), boundary_nodes.end());
183 }
184
185 void reset()
186 {
187 total_local_boundary.clear();
189 }
190 };
191} // namespace polyfem::varform
A finite-element space for one scalar- or vector-valued field.
Definition FESpace.hpp:59
const std::vector< basis::ElementBases > & geometry_basis_list() const
Definition FESpace.hpp:115
std::shared_ptr< std::vector< basis::ElementBases > > bases
Per-element basis data.
Definition FESpace.hpp:68
std::shared_ptr< GeometryMapping > geometry
Geometric mapping used to integrate this FE space.
Definition FESpace.hpp:89
int value_dim
Number of field components per scalar basis function.
Definition FESpace.hpp:62
Eigen::VectorXi disc_orders
Primary polynomial degree for each mesh element.
Definition FESpace.hpp:71
Eigen::VectorXi disc_ordersq
Secondary polynomial degree for anisotropic bases, e.g. prisms.
Definition FESpace.hpp:74
int n_bases
Number of globally indexed scalar basis functions in the space.
Definition FESpace.hpp:65
Eigen::VectorXi space_in_node_to_node
Definition FESpace.hpp:91
std::map< int, std::pair< Eigen::MatrixXd, Eigen::MatrixXi > > polys_3d
Physical vertices and face connectivity for 3D polyhedral elements.
Definition FESpace.hpp:83
std::map< int, Eigen::MatrixXd > polys
Physical boundary samples for 2D polygonal elements.
Definition FESpace.hpp:80
std::map< int, basis::InterfaceData > poly_edge_to_data
Polygonal-basis construction data, indexed by element ID.
Definition FESpace.hpp:77
const std::vector< basis::ElementBases > & basis_list() const
Definition FESpace.hpp:109
Eigen::VectorXi space_in_primitive_to_primitive
Definition FESpace.hpp:92
bool is_iso_parametric() const
Definition FESpace.hpp:104
std::shared_ptr< mesh::MeshNodes > mesh_nodes
Optional primitive-to-node mapping for this FE space.
Definition FESpace.hpp:86
Eigen::VectorXi disc_orders
Polynomial degree of the geometry mapping on each mesh element.
Definition FESpace.hpp:33
std::map< int, std::pair< Eigen::MatrixXd, Eigen::MatrixXi > > polys_3d
Physical vertices and face connectivity for 3D polyhedral elements.
Definition FESpace.hpp:39
void init_from_fe_space(const FESpace &space)
Definition FESpace.hpp:140
std::shared_ptr< std::vector< basis::ElementBases > > bases
Per-element scalar bases used to interpolate physical coordinates.
Definition FESpace.hpp:30
int n_bases
Number of globally indexed scalar geometry basis functions.
Definition FESpace.hpp:27
std::shared_ptr< mesh::MeshNodes > mesh_nodes
Optional primitive-to-node mapping for the geometry bases.
Definition FESpace.hpp:42
std::map< int, Eigen::MatrixXd > polys
Physical boundary samples for 2D polygonal elements.
Definition FESpace.hpp:36
Temporary compatibility wrapper for boundary data belonging to one FE space.
Definition FESpace.hpp:152
std::vector< RowVectorNd > neumann_nodes_position
Definition FESpace.hpp:163
std::vector< mesh::LocalBoundary > local_boundary
Definition FESpace.hpp:155
std::vector< mesh::LocalBoundary > local_neumann_boundary
Definition FESpace.hpp:156
std::vector< mesh::LocalBoundary > total_local_boundary
Definition FESpace.hpp:154
std::vector< RowVectorNd > dirichlet_nodes_position
Definition FESpace.hpp:161
std::vector< mesh::LocalBoundary > local_pressure_boundary
Definition FESpace.hpp:157
std::unordered_map< int, std::vector< mesh::LocalBoundary > > local_pressure_cavity
Definition FESpace.hpp:158
std::vector< int > pressure_boundary_nodes
Definition FESpace.hpp:159