https://mooseframework.inl.gov
MortarSegmentHelper.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "libmesh/point.h"
13 #include "libmesh/int_range.h"
14 
15 #include <vector>
16 
17 using libMesh::Point;
18 using libMesh::Real;
19 
27 {
28 public:
29  MortarSegmentHelper(const std::vector<Point> secondary_nodes,
30  const Point & center,
31  const Point & normal);
32 
39  const Point & p1, const Point & p2, const Point & q1, const Point & q2, Real & s) const;
40 
44  bool isInsideSecondary(const Point & pt) const;
45 
49  bool isDisjoint(const std::vector<Point> & poly) const;
50 
55  std::vector<Point> clipPoly(const std::vector<Point> & primary_nodes) const;
56 
63  void triangulatePoly(std::vector<Point> & poly_nodes,
64  const unsigned int offset,
65  std::vector<std::vector<unsigned int>> & tri_map) const;
66 
73  void getMortarSegments(const std::vector<Point> & primary_nodes,
74  std::vector<Point> & nodes,
75  std::vector<std::vector<unsigned int>> & elem_to_nodes);
76 
80  Real area(const std::vector<Point> & nodes) const;
81 
85  const Point & center() const { return _center; }
86 
91 
95  Point point(unsigned int i) const
96  {
97  return (_secondary_poly[i](0) * _u) + (_secondary_poly[i](1) * _v) + _center;
98  }
99 
100 private:
105 
110 
117 
122 
127 
128  bool _debug;
129 
133  Real _tolerance = 1e-8;
134 
139 
144 
148  std::vector<Point> _secondary_poly;
149 };
Point _center
Geometric center of secondary element.
Real _area_tol
Tolerance times secondary area for dimensional consistency.
bool isInsideSecondary(const Point &pt) const
Check that a point is inside the secondary polygon (for verification only)
R poly(const C &c, const T x, const bool derivative=false)
Evaluate a polynomial with the coefficients c at x.
Definition: MathUtils.h:237
void getMortarSegments(const std::vector< Point > &primary_nodes, std::vector< Point > &nodes, std::vector< std::vector< unsigned int >> &elem_to_nodes)
Get mortar segments generated by a secondary and primary element pair.
Real _length_tol
Tolerance times secondary area for dimensional consistency.
std::vector< Point > clipPoly(const std::vector< Point > &primary_nodes) const
Clip secondary element (defined in instantiation) against given primary polygon result is a set of 2D...
Real remainder() const
Get area fraction remaining after clipping against primary elements.
std::vector< Point > _secondary_poly
List of projected points on the linearized secondary element.
Real _tolerance
Tolerance for intersection and clipping.
Point _u
Vectors orthogonal to normal that span the plane projection will be performed on. ...
Real _secondary_area
Area of projected secondary element.
Point _normal
Normal at geometric center of secondary element.
bool isDisjoint(const std::vector< Point > &poly) const
Checks whether polygons are disjoint for an easy out.
const Point & center() const
Get center point of secondary element.
Real area(const std::vector< Point > &nodes) const
Compute area of polygon.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This class supports defining mortar segment mesh elements in 3D by projecting secondary and primary e...
Point getIntersection(const Point &p1, const Point &p2, const Point &q1, const Point &q2, Real &s) const
Computes the intersection between line segments defined by point pairs (p1,p2) and (q1...
MortarSegmentHelper(const std::vector< Point > secondary_nodes, const Point &center, const Point &normal)
Real _remaining_area_fraction
Fraction of area remaining after overlapping primary polygons clipped.
void triangulatePoly(std::vector< Point > &poly_nodes, const unsigned int offset, std::vector< std::vector< unsigned int >> &tri_map) const
Triangulate a polygon (currently uses center of polygon to define triangulation)
Point point(unsigned int i) const
Get 3D position of node of linearized secondary element.