19 #include "libmesh/face_c0polygon.h" 21 #include "libmesh/edge_edge2.h" 22 #include "libmesh/enum_order.h" 23 #include "libmesh/tensor_value.h" 33 Polygon(num_sides, num_sides, p)
42 const unsigned int side_in)
const 44 const auto ns = this->
n_sides();
48 libmesh_assert_less (node_in, ns);
49 libmesh_assert_less (node_in, this->
n_nodes());
50 libmesh_assert_less (side_in, this->
n_sides());
53 if (node_in == side_in)
54 return (node_in + ns/2 + 1) % ns;
57 return (node_in + ns/2 - 1) % ns;
87 const unsigned int s)
const 89 const auto ns = this->
n_sides();
90 libmesh_assert_less (s, ns);
91 libmesh_assert_less (n, this->
n_nodes());
93 return ((n % ns) == s) ||
94 ((n < ns) && ((s+1)%ns) == n);
97 std::vector<unsigned int>
100 const auto ns = this->
n_sides();
102 libmesh_assert_less(s, ns);
104 std::vector<unsigned int> returnval(2);
106 returnval[1] = (s+1)%ns;
111 std::vector<unsigned int>
119 const unsigned int ns = this->
n_sides();
122 Real perimeter_l1 = 0;
133 const Real costheta = cos(theta);
134 const Real sintheta = sin(theta);
140 map(0, 1) = (vec12(0) - veci(0)*costheta)/sintheta;
141 map(1, 1) = (vec12(1) - veci(1)*costheta)/sintheta;
142 map(2, 1) = (vec12(2) - veci(2)*costheta)/sintheta;
171 const auto ns = this->
n_sides();
172 libmesh_assert_less (i, ns);
174 std::unique_ptr<Elem> sidep = std::make_unique<Edge2>();
175 sidep->set_node(0, this->
node_ptr(i));
176 sidep->set_node(1, this->
node_ptr((i+1)%ns));
178 sidep->set_interior_parent(
this);
179 sidep->inherit_data_from(*
this);
187 const unsigned int i)
189 const auto ns = this->
n_sides();
190 libmesh_assert_less (i, ns);
192 if (!side.get() || side->type() !=
EDGE2)
198 side->inherit_data_from(*
this);
200 side->set_node(0, this->
node_ptr(i));
201 side->set_node(1, this->
node_ptr((i+1)%ns));
209 std::vector<dof_id_type> & )
const 211 libmesh_not_implemented();
227 Real double_area = 0;
231 this->
point(triangle[0]);
233 this->
point(triangle[0]);
237 return double_area/2;
253 Real double_area = 0;
254 Point double_area_weighted_centroid;
258 this->
point(triangle[0]);
260 this->
point(triangle[0]);
263 const Point tri_centroid = (this->
point(triangle[0]) +
264 this->
point(triangle[1]) +
265 this->
point(triangle[2]))/3;
267 double_area += double_tri_area;
269 double_area_weighted_centroid += double_tri_area * tri_centroid;
272 return double_area_weighted_centroid / double_area;
277 std::pair<unsigned short int, unsigned short int>
280 libmesh_not_implemented();
281 return std::pair<unsigned short int, unsigned short int> (0, 0);
287 const auto ns = this->
n_sides();
288 libmesh_assert_less (perm_num, ns);
309 triangle[i] = (triangle[i]+1)%ns;
318 const auto ns = this->
n_sides();
334 libmesh_assert_less (s, this->
n_sides());
345 std::vector<int> remaining_nodes(this->
n_nodes());
346 std::iota(remaining_nodes.begin(), remaining_nodes.end(), 0);
348 const auto ns = this->
n_sides();
358 const Point viplus = this->
point((i+1)%ns) - vavg;
359 plane_normal += vi.
cross(viplus);
361 plane_normal = plane_normal.
unit();
366 while (remaining_nodes.size() > 2)
368 Real min_cos_angle = 1;
369 int best_vertex = -1;
372 const Point & pn = this->
point(remaining_nodes[n]);
373 const Point & pnext = this->
point(remaining_nodes[(n+1)%ns]);
374 const Point & pprev = this->
point(remaining_nodes[(n+ns-1)%ns]);
375 const Point vprev = (pn - pprev).unit();
376 const Point vnext = (pnext - pn).unit();
378 const Real sign_check = (vprev.
cross(vnext)) * plane_normal;
382 const Real cos_angle = vprev * vnext;
383 if (cos_angle < min_cos_angle)
385 min_cos_angle = cos_angle;
392 this->
_triangulation.push_back({remaining_nodes[(best_vertex+ns-1)%ns],
393 remaining_nodes[best_vertex],
394 remaining_nodes[(best_vertex+1)%ns]});
395 remaining_nodes.erase(remaining_nodes.begin()+best_vertex);
virtual Point true_centroid() const
virtual Real volume() const override
An optimized method for calculating the area of a C0Polygon.
virtual unsigned int n_nodes() const override
ElemType
Defines an enum for geometric element types.
void swap2boundaryedges(unsigned short e1, unsigned short e2, BoundaryInfo *boundary_info) const
Swaps two edges in boundary_info, if it is non-null.
virtual std::pair< unsigned short int, unsigned short int > second_order_child_vertex(const unsigned int n) const override
Element refinement is not implemented for polygons.
virtual void permute(unsigned int perm_num) override final
Permutes the element (by swapping node and neighbor pointers) according to the specified index...
Order
defines an enum for polynomial orders.
virtual Node *& set_node(const unsigned int i)
A Node is like a Point, but with more information.
virtual Order default_order() const override
virtual bool is_edge(const unsigned int i) const override
IOPackage
libMesh interfaces with several different software packages for the purposes of creating, reading, and writing mesh files.
std::vector< std::array< int, 3 > > _triangulation
Data for a triangulation of the polygon.
virtual Point master_point(const unsigned int i) const override
This is the base class from which all geometric element types are derived.
virtual std::vector< unsigned int > nodes_on_edge(const unsigned int e) const override
void swap2boundarysides(unsigned short s1, unsigned short s2, BoundaryInfo *boundary_info) const
Swaps two sides in boundary_info, if it is non-null.
The libMesh namespace provides an interface to certain functionality in the library.
ElemType side_type(const unsigned int s) const override final
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
T cross_norm_sq(const TypeVector< T > &b, const TypeVector< T > &c)
Compute |b x c|^2 without creating the extra temporary produced by calling b.cross(c).norm_sq().
virtual bool is_vertex(const unsigned int i) const override
TypeVector< T > unit() const
void libmesh_ignore(const Args &...)
virtual unsigned int opposite_node(const unsigned int n, const unsigned int s) const override final
virtual bool has_affine_map() const override
ElemMappingType mapping_type() const
void swap2nodes(unsigned int n1, unsigned int n2)
Swaps two node_ptrs.
auto l1_norm(const NumericVector< T > &vec)
The Polygon is an element in 2D with an arbitrary (but fixed) number of sides.
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const override
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
virtual bool is_face(const unsigned int i) const override
virtual void connectivity(const unsigned int sf, const IOPackage iop, std::vector< dof_id_type > &conn) const override
TypeVector< typename CompareTypes< T, T2 >::supertype > cross(const TypeVector< T2 > &v) const
static constexpr Real affine_tol
Default tolerance to use in has_affine_map().
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
void swap2neighbors(unsigned int n1, unsigned int n2)
Swaps two neighbor_ptrs.
const Elem * neighbor_ptr(unsigned int i) const
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i) override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Node * node_ptr(const unsigned int i) const
virtual std::vector< unsigned int > nodes_on_side(const unsigned int s) const override
virtual Real volume() const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
virtual unsigned int n_sides() const override final
C0Polygon(const unsigned int num_sides, Elem *p=nullptr)
Constructor.
A Point defines a location in LIBMESH_DIM dimensional Real space.
const Point & point(const unsigned int i) const
virtual void retriangulate() override final
Create a triangulation from the current node locations.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
virtual void flip(BoundaryInfo *) override final
Flips the element (by swapping node and neighbor pointers) to have a mapping Jacobian of opposite sig...
Point vertex_average() const
virtual Point true_centroid() const override
An optimized method for calculating the centroid of a C0Polygon.
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.