9#include "check_child_geometry.h"
11#include <gtest/gtest.h>
20 "This refinement pattern is not made for a " << geom.
RefEl());
23 for (
auto codim = 0; codim <= geom.
RefEl().Dimension(); ++codim) {
27 EXPECT_EQ(children.size(), ref_pat.
NumChildren(codim));
29 for (
int i = 0; i < children.size(); ++i) {
30 auto &child = children[i];
31 EXPECT_EQ(child->RefEl().Dimension(), geom.
DimLocal() - codim);
32 EXPECT_EQ(child->DimGlobal(), geom.
DimGlobal());
33 EXPECT_EQ(child->DimLocal(), geom.
DimLocal() - codim);
37 EXPECT_EQ(child_polygons[i].rows(), geom.
DimLocal());
38 EXPECT_EQ(child_polygons[i].cols(), 1);
39 auto child_coord = geom.
Global(child_polygons[i].cast<double>() * h);
41 auto zero = Eigen::Matrix<double, 0, 1>::Zero();
42 EXPECT_TRUE(child_coord.isApprox(child->Global(zero)));
46 auto qr = qr_provider(child->RefEl());
47 auto a = child->Global(qr.Points());
49 std::unique_ptr<lf::geometry::Geometry> ref_pat_geo =
nullptr;
51 switch (child->RefEl()) {
53 ref_pat_geo = std::make_unique<lf::geometry::SegmentO1>(
54 child_polygons[i].cast<double>() * h);
57 ref_pat_geo = std::make_unique<lf::geometry::TriaO1>(
58 child_polygons[i].cast<double>() * h);
61 ref_pat_geo = std::make_unique<lf::geometry::QuadO1>(
62 child_polygons[i].cast<double>() * h);
67 "This reference element is not yet supported by the test.");
70 auto b = geom.
Global(ref_pat_geo->Global(qr.Points()));
72 EXPECT_TRUE(a.isApprox(b)) << std::endl
73 << a <<
"\n is not \n"
87 const auto &points = qr.Points();
88 const auto &weights = qr.Weights();
93 for (
size_t j = 0; j < points.cols(); ++j) {
94 vol += weights(j) * integrationElements(j);
100 const double volume = computeVolume(geom);
101 double refinedVolume = 0.;
106 for (
auto &childGeom : children) {
107 refinedVolume += computeVolume(*childGeom);
112 EXPECT_EQ(refinedVolume, 0.)
113 << refPat <<
" should not produce any children";
116 EXPECT_FLOAT_EQ(volume, refinedVolume)
117 <<
"Parent and children volumes differ for " << refPat;
Represents a reference element with all its properties.
static constexpr RefEl kSegment()
Returns the (1-dimensional) reference segment.
static constexpr RefEl kPoint()
Returns the (0-dimensional) reference point.
static constexpr RefEl kTria()
Returns the reference triangle.
static constexpr RefEl kQuad()
Returns the reference quadrilateral.
Interface class for shape information on a mesh cell in the spirit of parametric finite element metho...
virtual base::RefEl RefEl() const =0
The Reference element that defines the domain of this mapping.
virtual std::vector< std::unique_ptr< Geometry > > ChildGeometry(const RefinementPattern &ref_pat, lf::base::dim_t codim) const =0
Generate geometry objects for child entities created in the course of refinement.
virtual Eigen::MatrixXd Global(const Eigen::MatrixXd &local) const =0
Map a number of points in local coordinates into the global coordinate system.
virtual dim_t DimLocal() const =0
Dimension of the domain of this mapping.
virtual dim_t DimGlobal() const =0
Dimension of the image of this mapping.
virtual Eigen::VectorXd IntegrationElement(const Eigen::MatrixXd &local) const =0
The integration element (factor appearing in integral transformation formula, see below) at number of...
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.
Represents a Quadrature Rule over one of the Reference Elements.
Class containing information about the refinement of a cell.
unsigned int sub_idx_t
type for local indices of sub-entities
Defines the Geometry::test_utils module and provides a number of test functions to check geometry obj...
void checkChildGeometry(const lf::geometry::Geometry &geom, const lf::geometry::RefinementPattern &ref_pat, const std::function< lf::quad::QuadRule(lf::base::RefEl)> &qr_provider)
Checks that the mapping geom.ChildGeometry() is the same as geom composed with the mapping imposed by...
void checkChildGeometryVolume(const lf::geometry::Geometry &geom, const lf::refinement::RefPat &refPat, const lf::base::sub_idx_t &anchor)
Checks if the total volume is conserved after call to ChildGeometry()
QuadRule make_QuadRule(base::RefEl ref_el, unsigned degree)
Returns a QuadRule object for the given Reference Element and Degree.
RefPat
(possibly incomplete) list of refinement patterns for triangles/quadrilaterals