LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
ref_el.cc
1#include "ref_el.h"
2
3namespace lf::base {
4
5const Eigen::MatrixXd RefEl::ncoords_point_dynamic_ = Eigen::VectorXd(0);
6
7const Eigen::MatrixXd RefEl::ncoords_segment_dynamic_ =
8 Eigen::Vector2d(0, 1).transpose();
9
10const Eigen::MatrixXd RefEl::ncoords_tria_dynamic_ =
11 (Eigen::MatrixXd{2, 3} << 0, 1, 0, 0, 0, 1).finished();
12
13const Eigen::MatrixXd RefEl::ncoords_quad_dynamic_ =
14 (Eigen::MatrixXd{2, 4} << 0, 1, 1, 0, 0, 0, 1, 1).finished();
15
16// Print function
17void PrintInfo(std::ostream &o, const RefEl &ref_el, int output_ctrl) {
18 int dim_ref_el = ref_el.Dimension();
19 int no_nodes = ref_el.NumNodes();
20 o << "Type of reference element: " << ref_el.ToString() << std::endl;
21 o << "Dimension: " << dim_ref_el << std::endl;
22 o << "Number of nodes: " << no_nodes << std::endl;
23
24 if (output_ctrl > 0) {
25 // Loop over dimensions
26 for (int co_dim = dim_ref_el; co_dim > 0; co_dim--) {
27 int num_sub_ent = ref_el.NumSubEntities(co_dim);
28 o << "Codimension " << co_dim << " has " << num_sub_ent
29 << " entities of type " << ref_el.SubType(co_dim, 0).ToString()
30 << std::endl;
31
32 if (output_ctrl > 10) {
33 for (; num_sub_ent > 0; num_sub_ent--) {
34 int sub_ent = num_sub_ent - 1;
35 o << " Subentity " << sub_ent << " is of type "
36 << ref_el.SubType(co_dim, 0).ToString();
37
38 if (ref_el.SubType(co_dim, 0) == RefEl::kPoint() &&
39 output_ctrl > 20) {
40 o << " and has coordinates [" << ref_el.NodeCoords().col(sub_ent)[0]
41 << " " << ref_el.NodeCoords().col(sub_ent)[1] << "]" << std::endl;
42 }
43 o << std::endl;
44 }
45 }
46 }
47 }
48} // end void PrintInfo
49
50} // namespace lf::base
Represents a reference element with all its properties.
Definition: ref_el.h:106
static const Eigen::MatrixXd ncoords_quad_dynamic_
Definition: ref_el.h:111
static const Eigen::MatrixXd ncoords_segment_dynamic_
Definition: ref_el.h:109
const Eigen::MatrixXd & NodeCoords() const
Get the coordinates of the nodes of this reference element.
Definition: ref_el.h:238
constexpr size_type NumSubEntities(dim_t sub_codim) const
Get the number of sub-entities of this RefEl with the given codimension.
Definition: ref_el.h:305
constexpr dim_t Dimension() const
Return the dimension of this reference element.
Definition: ref_el.h:201
static const Eigen::MatrixXd ncoords_tria_dynamic_
Definition: ref_el.h:110
static constexpr RefEl kPoint()
Returns the (0-dimensional) reference point.
Definition: ref_el.h:141
static const Eigen::MatrixXd ncoords_point_dynamic_
Definition: ref_el.h:108
constexpr size_type NumNodes() const
The number of nodes of this reference element.
Definition: ref_el.h:210
std::string ToString() const
Return a string representation of this Reference element.
Definition: ref_el.h:455
constexpr RefEl SubType(dim_t sub_codim, dim_t sub_index) const
Return the RefEl of the sub-entity with codim sub_codim and index sub_index.
Definition: ref_el.h:348
Contains basic functionality that is used by other parts of LehrFEM++.
Definition: base.h:15
void PrintInfo(std::ostream &o, const RefEl &ref_el, int output_ctrl)
Definition: ref_el.cc:17