https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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 "MortarSegmentInfo.h"
13
14#include "libmesh/point.h"
15#include "libmesh/int_range.h"
16
17#include <array>
18#include <optional>
19#include <string>
20#include <vector>
21
22using libMesh::Point;
23using libMesh::Real;
24
25#ifdef MOOSE_UNIT_TEST
26class MortarSegmentHelperTest;
27#endif
28
36{
37public:
41 MortarSegmentHelper(std::vector<Point> secondary_nodes,
42 const Point & center,
43 const Point & normal,
44 const MortarSegmentTriangulationMode triangulation_mode,
45 const bool triangulate_triangles);
46
50 MortarSegmentHelper(std::vector<Point> secondary_nodes,
51 std::vector<Point> secondary_reference_points,
52 const Point & center,
53 const Point & normal,
54 const MortarSegmentTriangulationMode triangulation_mode,
55 const bool triangulate_triangles);
56
63 const Point & p1, const Point & p2, const Point & q1, const Point & q2, Real & s) const;
64
68 bool isInsideSecondary(const Point & pt) const;
69
73 bool isDisjoint(const std::vector<Point> & poly) const;
74
78 std::vector<Point> projectPrimaryPoly(const std::vector<Point> & primary_nodes) const;
79
84 std::vector<Point> clipPoly(const std::vector<Point> & primary_nodes) const;
85
96 void triangulatePoly(std::vector<Point> & poly_nodes,
97 std::vector<std::vector<unsigned int>> & tri_map) const;
98
105 void getMortarSegments(const std::vector<Point> & primary_nodes,
106 std::vector<Point> & nodes,
107 std::vector<std::vector<unsigned int>> & elem_to_nodes);
108
114 void getMortarSegments(const std::vector<Point> & primary_nodes,
115 const std::vector<Point> & primary_reference_points,
116 std::vector<Point> & nodes,
117 std::vector<std::vector<unsigned int>> & elem_to_nodes,
118 std::vector<std::array<Point, 3>> & elem_to_secondary_reference_points,
119 std::vector<std::array<Point, 3>> & elem_to_primary_reference_points,
120 Real minimum_segment_area = 0.);
121
125 Real area(const std::vector<Point> & nodes) const;
126
130 const Point & center() const { return _center; }
131
135 const Point & normal() const { return _normal; }
136
140 Real remainder() const { return _remaining_area_fraction; }
141
145 Point point(unsigned int i) const
146 {
147 return (_secondary_poly[i](0) * _u) + (_secondary_poly[i](1) * _v) + _center;
148 }
149
150private:
155 {
156 const std::vector<Point> & primary_reference_points;
157 std::vector<std::array<Point, 3>> & elem_to_secondary_reference_points;
158 std::vector<std::array<Point, 3>> & elem_to_primary_reference_points;
160 };
161
162 void getMortarSegmentsImpl(const std::vector<Point> & primary_nodes,
163 std::vector<Point> & nodes,
164 std::vector<std::vector<unsigned int>> & elem_to_nodes,
165 ReferenceMappingData * reference_mapping);
166
171 std::vector<Point> clipProjectedPoly(const std::vector<Point> & primary_poly) const;
172
177 std::optional<Point> referencePoint(const Point & point,
178 const std::vector<Point> & poly,
179 const std::vector<Point> & reference_points,
180 std::string * failure_reason = nullptr) const;
181
182#ifdef MOOSE_UNIT_TEST
184#endif
185
190
195
202
207
212
213 bool _debug;
214
218 Real _tolerance = 1e-8;
219
224
229
234
239
243 std::vector<Point> _secondary_poly;
244
246 std::vector<Point> _secondary_reference_points;
247};
MortarSegmentTriangulationMode
This class supports defining mortar segment mesh elements in 3D by projecting secondary and primary e...
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...
Point point(unsigned int i) const
Get 3D position of node of linearized secondary element.
Real _area_tol
Tolerance times secondary area for dimensional consistency.
Point _u
Vectors orthogonal to normal that span the plane projection will be performed on.
Point _center
Geometric center of secondary element.
Real _secondary_area
Area of projected secondary element.
std::vector< Point > _secondary_poly
List of projected points on the linearized secondary element.
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,...
std::vector< Point > projectPrimaryPoly(const std::vector< Point > &primary_nodes) const
Project a primary polygon into the helper plane while preserving the clipping orientation.
std::vector< Point > clipProjectedPoly(const std::vector< Point > &primary_poly) const
Clip an already projected primary polygon against the secondary polygon.
const MortarSegmentTriangulationMode _triangulation_mode
Triangulation mode used for clipped polygons.
const bool _triangulate_triangles
Whether already-triangular polygons should still be centroid-subdivided.
bool isInsideSecondary(const Point &pt) const
Check that a point is inside the secondary polygon (for verification only)
const Point & normal() const
Get the unit normal of the projection plane.
void triangulatePoly(std::vector< Point > &poly_nodes, std::vector< std::vector< unsigned int > > &tri_map) const
Triangulate a polygon according to the configured mortar-segment triangulation mode.
Point _normal
Unit normal of the plane used to project and clip the linearized secondary subpatch.
Real _remaining_area_fraction
Fraction of area remaining after overlapping primary polygons clipped.
std::optional< Point > referencePoint(const Point &point, const std::vector< Point > &poly, const std::vector< Point > &reference_points, std::string *failure_reason=nullptr) const
Recover a parent-reference point from a projected sub-element map.
Real _length_tol
Tolerance times secondary area for dimensional consistency.
const Point & center() const
Get center point of secondary element.
Real area(const std::vector< Point > &nodes) const
Compute area of polygon.
bool isDisjoint(const std::vector< Point > &poly) const
Checks whether polygons are disjoint for an easy out.
Real remainder() const
Get area fraction remaining after clipping against primary elements.
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.
void getMortarSegmentsImpl(const std::vector< Point > &primary_nodes, std::vector< Point > &nodes, std::vector< std::vector< unsigned int > > &elem_to_nodes, ReferenceMappingData *reference_mapping)
Real _tolerance
Tolerance for intersection and clipping.
friend class MortarSegmentHelperTest
std::vector< Point > _secondary_reference_points
Parent reference points corresponding to _secondary_poly.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Output containers and filtering data used while generating reference-coordinate mappings.
const std::vector< Point > & primary_reference_points
std::vector< std::array< Point, 3 > > & elem_to_secondary_reference_points
std::vector< std::array< Point, 3 > > & elem_to_primary_reference_points