18 : coords_(std::move(coords)),
19 alpha_(coords_.rows()),
20 beta_(coords_.rows(), 2),
21 gamma_(coords_.rows(), 2),
22 delta_(coords_.rows()),
23 gamma_x_2_(coords_.rows(), 2) {
31 const Eigen::VectorXd& A =
coords_.col(0);
32 const Eigen::VectorXd& B =
coords_.col(1);
33 const Eigen::VectorXd& C =
coords_.col(2);
34 const Eigen::VectorXd& D =
coords_.col(3);
35 const Eigen::VectorXd& E =
coords_.col(4);
36 const Eigen::VectorXd& F =
coords_.col(5);
41 beta_ << 4. * D - 3. * A - B, 4. * F - 3. * A - C;
42 gamma_ << 2. * (A + B) - 4. * D, 2. * (A + C) - 4. * F;
43 delta_ << 4. * (A + E - D - F);
50 LF_VERIFY_MSG((0. <= local.array()).all() && (local.array() <= 1.).all(),
51 "local coordinates out of bounds for reference element");
54 return ((
beta_ * local) + (
gamma_ * local.array().square().matrix()) +
55 (
delta_ * local.row(0).cwiseProduct(local.row(1))))
64 LF_VERIFY_MSG((0. <= local.array()).all() && (local.array() <= 1.).all(),
65 "local coordinates out of bounds for reference element");
67 Eigen::MatrixXd tmp(
gamma_.rows(), 2 * local.cols());
69 for (
long i = 0; i < local.cols(); ++i) {
70 tmp.block(0, 2 * i, tmp.rows(), 2) =
71 gamma_x_2_.array().rowwise() * local.col(i).transpose().array();
74 Eigen::MatrixXd local_reversed = local.colwise().reverse();
75 local_reversed.resize(1, local.size());
77 return beta_.replicate(1, local.cols()) + tmp +
78 (local_reversed.replicate(
delta_.rows(), 1).array().colwise() *
87 const Eigen::MatrixXd& local)
const {
88 LF_VERIFY_MSG((0. <= local.array()).all() && (local.array() <= 1.).all(),
89 "local coordinates out of bounds for reference element");
91 Eigen::MatrixXd jac =
Jacobian(local);
92 Eigen::MatrixXd jacInvGram(jac.rows(), jac.cols());
95 for (
long i = 0; i < local.cols(); ++i) {
96 auto jacobian = jac.block(0, 2 * i, 2, 2);
97 jacInvGram.block(0, 2 * i, 2, 2) << jacobian(1, 1), -jacobian(1, 0),
98 -jacobian(0, 1), jacobian(0, 0);
99 jacInvGram.block(0, 2 * i, 2, 2) /= jacobian.determinant();
102 for (
long i = 0; i < local.cols(); ++i) {
103 auto jacobian = jac.block(0, 2 * i, jac.rows(), 2);
105 auto A = jacobian.col(0);
106 auto B = jacobian.col(1);
109 Eigen::MatrixXd tmp(2, 2);
110 tmp << B.dot(B), -AB, -AB, A.dot(A);
112 jacInvGram.block(0, 2 * i, jac.rows(), 2) =
113 jacobian * tmp / tmp.determinant();
123 LF_VERIFY_MSG((0. <= local.array()).all() && (local.array() <= 1.).all(),
124 "local coordinates out of bounds for reference element");
126 Eigen::MatrixXd jac =
Jacobian(local);
127 Eigen::VectorXd intElem(local.cols());
130 for (
long i = 0; i < local.cols(); ++i) {
131 intElem(i) = std::abs(jac.block(0, 2 * i, 2, 2).determinant());
134 for (
long i = 0; i < local.cols(); ++i) {
135 auto jacobian = jac.block(0, 2 * i, jac.rows(), 2);
137 auto A = jacobian.col(0);
138 auto B = jacobian.col(1);
141 intElem(i) = std::sqrt(std::abs(A.dot(A) * B.dot(B) - AB * AB));
151 LF_ASSERT_MSG(i == 0,
"i is out of bounds");
152 return std::make_unique<TriaO2>(
coords_);
155 LF_ASSERT_MSG(0 <= i && i <= 2,
"i is out of bounds");
156 return std::make_unique<SegmentO2>(
157 (Eigen::Matrix<double, Eigen::Dynamic, 3>(
DimGlobal(), 3)
163 LF_ASSERT_MSG(0 <= i && i <= 5,
"i is out of bounds");
164 return std::make_unique<Point>(
coords_.col(i));
167 LF_VERIFY_MSG(
false,
"codim is out of bounds")
176 LF_VERIFY_MSG(codim < 3,
"Illegal codim " << codim);
178 const double hLattice = 1. /
static_cast<double>(ref_pat.
LatticeConst());
179 std::vector<std::unique_ptr<Geometry>> childGeoPtrs = {};
182 std::vector<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic>> childPolygons(
185 const int noChildren = childPolygons.size();
188 "NumChildren " << noChildren <<
" <-> " << ref_pat.
NumChildren(codim));
191 for (
size_t child = 0; child < noChildren; ++child) {
197 childPolygons[child].rows() == 2,
198 "childPolygons[child].rows() = " << childPolygons[child].rows());
200 childPolygons[child].cols() == (3 - codim),
201 "childPolygons[child].cols() = " << childPolygons[child].cols());
203 const Eigen::MatrixXd locChildPolygonCoords(
204 hLattice * childPolygons[child].cast<double>());
208 Eigen::MatrixXd locChildCoords(locChildPolygonCoords.rows(), 6);
209 locChildCoords << locChildPolygonCoords,
210 (locChildPolygonCoords.col(0) + locChildPolygonCoords.col(1)) / 2.,
211 (locChildPolygonCoords.col(1) + locChildPolygonCoords.col(2)) / 2.,
212 (locChildPolygonCoords.col(2) + locChildPolygonCoords.col(0)) / 2.;
214 childGeoPtrs.push_back(
215 std::make_unique<TriaO2>(
Global(locChildCoords)));
220 Eigen::MatrixXd locChildCoords(locChildPolygonCoords.rows(), 3);
221 locChildCoords << locChildPolygonCoords,
222 (locChildPolygonCoords.col(0) + locChildPolygonCoords.col(1)) / 2.;
224 childGeoPtrs.push_back(
225 std::make_unique<SegmentO2>(
Global(locChildCoords)));
230 childGeoPtrs.push_back(
231 std::make_unique<Point>(
Global(locChildPolygonCoords)));
236 LF_VERIFY_MSG(
false,
"Illegal co-dimension");
static constexpr RefEl kTria()
Returns the reference triangle.
std::string ToString() const
Return a string representation of this Reference element.
Abstract interface class for encoding topological local refinement
lf::base::size_type LatticeConst() const
Provides information about lattice constant used.
virtual lf::base::size_type NumChildren(lf::base::dim_t codim) const =0
provide number of child entities of a given co-dimension to be created by refinement
virtual std::vector< Eigen::Matrix< int, Eigen::Dynamic, Eigen::Dynamic > > ChildPolygons(lf::base::dim_t codim) const =0
provide lattice reference coordinates of vertices of child polygons
lf::base::RefEl RefEl() const
Returns topological type of entity for which the current object is set up.
Eigen::MatrixXd Global(const Eigen::MatrixXd &local) const override
Map a number of points in local coordinates into the global coordinate system.
dim_t DimGlobal() const override
Dimension of the image of this mapping.
Eigen::Matrix< double, Eigen::Dynamic, 6 > coords_
Coordinates of the 6 vertices/midpoints, stored in matrix columns.
Eigen::Matrix< double, Eigen::Dynamic, 2 > beta_
Eigen::MatrixXd JacobianInverseGramian(const Eigen::MatrixXd &local) const override
Evaluate the Jacobian * Inverse Gramian ( ) simultaneously at numPoints.
std::unique_ptr< Geometry > SubGeometry(dim_t codim, dim_t i) const override
Construct a new Geometry() object that describes the geometry of the i-th sub-entity with codimension...
Eigen::Matrix< double, Eigen::Dynamic, 1 > alpha_
Eigen::Matrix< double, Eigen::Dynamic, 2 > gamma_
std::vector< std::unique_ptr< Geometry > > ChildGeometry(const RefinementPattern &ref_pat, lf::base::dim_t codim) const override
Generate geometry objects for child entities created in the course of refinement.
Eigen::Matrix< double, Eigen::Dynamic, 1 > delta_
Eigen::VectorXd IntegrationElement(const Eigen::MatrixXd &local) const override
The integration element (factor appearing in integral transformation formula, see below) at number of...
Eigen::Matrix< double, Eigen::Dynamic, 2 > gamma_x_2_
TriaO2(Eigen::Matrix< double, Eigen::Dynamic, 6 > coords)
Constructor building triangle from vertex/midpoint coordinates.
Eigen::MatrixXd Jacobian(const Eigen::MatrixXd &local) const override
Evaluate the jacobian of the mapping simultaneously at numPoints points.
unsigned int dim_t
type for dimensions and co-dimensions and numbers derived from them
Defines the Geometry interface and provides a number of classes that implement this interface + addit...