LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
quad_rule.h
1
8
9#ifndef INCGa7241ee797424d98ad339341b02bca70
10#define INCGa7241ee797424d98ad339341b02bca70
11
12#include <lf/base/base.h>
13
14#include <iostream>
15#include <utility>
16
17namespace lf::quad {
18
19using quadDegree_t = unsigned int;
20
58class QuadRule {
59 public:
62 QuadRule(const QuadRule&) = default;
63 QuadRule(QuadRule&&) = default;
64 QuadRule& operator=(const QuadRule&) = default;
66 ~QuadRule() = default;
76 QuadRule() : ref_el_(lf::base::RefEl::kPoint()), points_(0, 0), weights_(0) {}
77
106 explicit QuadRule(base::RefEl ref_el, Eigen::MatrixXd points,
107 Eigen::VectorXd weights, quadDegree_t degree)
108 : ref_el_(std::move(ref_el)),
109 degree_(degree),
110 points_(std::move(points)),
111 weights_(std::move(weights)) {
112 LF_ASSERT_MSG(points_.rows() == ref_el_.Dimension(), "Dimension mismatch");
113 LF_ASSERT_MSG(weights_.size() == points_.cols(), "Dimension mismatch");
114 }
115
120 [[nodiscard]] base::RefEl RefEl() const { return ref_el_; }
121
145 [[nodiscard]] quadDegree_t Degree() const { return degree_; }
146
153 [[nodiscard]] unsigned int Order() const { return Degree() + 1; }
154
161 [[nodiscard]] const Eigen::MatrixXd& Points() const { return points_; }
162
168 [[nodiscard]] const Eigen::VectorXd& Weights() const { return weights_; }
169
174 [[nodiscard]] base::size_type NumPoints() const { return points_.cols(); }
175
185 void PrintInfo(std::ostream& o, int out_ctrl = 0) const {
186 o << weights_.size() << "-point QR";
187 if (out_ctrl > 0) {
188 o << ", weights = " << weights_.transpose() << ", nodes = \n" << points_;
189 }
190 }
191
192 private:
195 Eigen::MatrixXd points_;
196 Eigen::VectorXd weights_;
197
198 public:
199};
200
210std::ostream& operator<<(std::ostream& stream,
211 const lf::quad::QuadRule& quadrule);
212
213} // namespace lf::quad
214
216
220template <>
221struct fmt::formatter<lf::quad::QuadRule> : ostream_formatter {};
223
224#endif // INCGa7241ee797424d98ad339341b02bca70
Represents a reference element with all its properties.
Definition ref_el.h:109
Represents a Quadrature Rule over one of the Reference Elements.
Definition quad_rule.h:58
QuadRule(base::RefEl ref_el, Eigen::MatrixXd points, Eigen::VectorXd weights, quadDegree_t degree)
Construct a new quadrature rule by specifying reference element, points, weights and degree of exactn...
Definition quad_rule.h:106
quadDegree_t Degree() const
Return the degree of exactness of this Quadrature Rule.
Definition quad_rule.h:145
base::RefEl ref_el_
Definition quad_rule.h:193
const Eigen::VectorXd & Weights() const
All quadrature weights as a vector.
Definition quad_rule.h:168
void PrintInfo(std::ostream &o, int out_ctrl=0) const
Output function controlled by variable out_ctrl;.
Definition quad_rule.h:185
Eigen::MatrixXd points_
Definition quad_rule.h:195
QuadRule(QuadRule &&)=default
QuadRule & operator=(const QuadRule &)=default
base::RefEl RefEl() const
The reference element over which this QuadRule integrates.
Definition quad_rule.h:120
const Eigen::MatrixXd & Points() const
All quadrature points as column vectors.
Definition quad_rule.h:161
QuadRule & operator=(QuadRule &&)=default
QuadRule()
Default constructor creating an "invalid quadrature rule".
Definition quad_rule.h:76
Eigen::VectorXd weights_
Definition quad_rule.h:196
quadDegree_t degree_
Definition quad_rule.h:194
QuadRule(const QuadRule &)=default
unsigned int Order() const
Return the order of the quadrature rule.
Definition quad_rule.h:153
base::size_type NumPoints() const
Return the total number of quadrature points (num of columns of points/weights)
Definition quad_rule.h:174
unsigned int size_type
general type for variables related to size of arrays
Definition types.h:20
Contains basic functionality that is used by other parts of LehrFEM++.
Definition base.h:15
Rules for numerical quadrature on reference entity shapes.
unsigned int quadDegree_t
Definition quad_rule.h:19
std::ostream & operator<<(std::ostream &stream, const lf::quad::QuadRule &quadrule)
Output operator for quadrature rules.
Definition quad_rule.cc:19
Definition assemble.h:34