LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
point.h
1
10#ifndef __818709b0104548a7b5e6f47bdba89f69
11#define __818709b0104548a7b5e6f47bdba89f69
12
13#include <lf/mesh/mesh.h>
14
15#include <iostream>
16
17namespace lf::mesh::hybrid2d {
18
28class Point : public mesh::Entity {
30
31 public:
33 Point() = default;
34
37 Point(const Point&) = delete;
38 Point(Point&&) noexcept = default;
39 Point& operator=(const Point&) = delete;
40 Point& operator=(Point&&) noexcept = default;
54 std::unique_ptr<geometry::Geometry>&& geometry)
55 : index_(index), geometry_(std::move(geometry)), this_(this) {
56 // DIAGNOSTICS
57 // std::cout << "hybrid2d::Point(" << index_ << ") " << std::endl;
58 LF_VERIFY_MSG(geometry_, "Point must be supplied with a geometry");
59 LF_VERIFY_MSG(geometry_->DimLocal() == 0,
60 "Geometry must be that of a point");
61 LF_VERIFY_MSG(geometry_->RefEl() == base::RefEl::kPoint(),
62 "Geometry must fit point");
63 }
64
65 [[nodiscard]] unsigned Codim() const override { return 2; }
66
69 unsigned rel_codim) const override {
70 LF_ASSERT_MSG(rel_codim == 0, "A point has only codim = 0 sub-entities");
71 return {&this_, 1};
72 }
73
76 const override {
77 LF_ASSERT_MSG(false, "A point has not sub-entities");
79 }
80
82 [[nodiscard]] const geometry::Geometry* Geometry() const override {
83 return geometry_.get();
84 }
85
87 [[nodiscard]] size_type index() const { return index_; }
88
89 [[nodiscard]] base::RefEl RefEl() const override {
90 return base::RefEl::kPoint();
91 }
92
93 [[nodiscard]] bool operator==(const mesh::Entity& rhs) const override {
94 return this == &rhs;
95 }
96
97 ~Point() override = default;
98
99 private:
100 size_type index_ = -1; // zero-based index of this entity.
101 std::unique_ptr<geometry::Geometry> geometry_ = nullptr; // shape information
102 static constexpr std::array<lf::mesh::Orientation, 1> dummy_or_{
104 Entity* this_ = nullptr; // needed for SubEntity()
105};
106
107} // namespace lf::mesh::hybrid2d
108
109#endif // __818709b0104548a7b5e6f47bdba89f69
Represents a reference element with all its properties.
Definition: ref_el.h:106
static constexpr RefEl kPoint()
Returns the (0-dimensional) reference point.
Definition: ref_el.h:141
Interface class for shape information on a mesh cell in the spirit of parametric finite element metho...
Interface class representing a topological entity in a cellular complex
Definition: entity.h:39
lf::base::size_type size_type
A node object for a 2D hybrid mesh.
Definition: point.h:28
bool operator==(const mesh::Entity &rhs) const override
Check if two entities are the same.
Definition: point.h:93
Point(const Point &)=delete
const geometry::Geometry * Geometry() const override
return pointer to associated geometry object
Definition: point.h:82
Point(Point &&) noexcept=default
std::unique_ptr< geometry::Geometry > geometry_
Definition: point.h:101
nonstd::span< const lf::mesh::Orientation > RelativeOrientations() const override
Definition: point.h:75
nonstd::span< const Entity *const > SubEntities(unsigned rel_codim) const override
Return all sub entities of this entity that have the given codimension (w.r.t. this entity!...
Definition: point.h:68
mesh::Mesh::size_type size_type
Definition: point.h:29
unsigned Codim() const override
The codimension of this entity w.r.t. the Mesh.dimMesh() of the owning mesh manager.
Definition: point.h:65
base::RefEl RefEl() const override
Describes the reference element type of this entity.
Definition: point.h:89
size_type index() const
access to index of an entity
Definition: point.h:87
Point()=default
default constructors, needed by std::vector
~Point() override=default
static constexpr std::array< lf::mesh::Orientation, 1 > dummy_or_
Definition: point.h:102
An alternative implementation of a hybrid2d mesh manager that uses Pointers to store sub-entity relat...
Definition: hybrid2d.h:13