https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TriToQuadConverter.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 "MeshGenerator.h"
13#include "MooseEnum.h"
14
15#include <array>
16#include <vector>
17
24{
25public:
27
29
30 std::unique_ptr<MeshBase> generate() override;
31
33 using QuadCorners = std::array<unsigned int, 4>;
34
40 {
42 Real eta;
44 dof_id_type first_elem_id;
46 dof_id_type second_elem_id;
48 std::array<dof_id_type, 4> quad_node_ids;
49 };
50
59 static Real quadQuality(const std::array<Point, 4> & quad_points);
60
69 static std::vector<RecombineCandidate>
70 greedyMatching(std::vector<RecombineCandidate> & candidates, const Real eta_min);
71
78 static std::vector<QuadCorners> triSubdivisionTemplate();
79
86 static std::vector<QuadCorners> quadSubdivisionTemplate();
87
88protected:
90 std::unique_ptr<MeshBase> & _input;
94 const Real _eta_min;
96 const SubdomainName _tri_subdomain_name_suffix;
98 const bool _all_quad;
99
100private:
108 static RecombineCandidate
109 buildCandidate(const Elem & elem, const unsigned int side, const Elem & neighbor);
110
118 void subdivide(ReplicatedMesh & mesh) const;
119
124 void recombine(ReplicatedMesh & mesh) const;
125
133 void moveSurvivingTriangles(ReplicatedMesh & mesh,
134 const subdomain_id_type scratch_subdomain_id) const;
135};
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
MeshGenerators are objects that can modify or add to an existing mesh.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
This TriToQuadConverter object converts a mesh made of TRI3 elements into a mesh made of QUAD4 elemen...
static std::vector< RecombineCandidate > greedyMatching(std::vector< RecombineCandidate > &candidates, const Real eta_min)
Select the pairs of triangles to merge, taking the highest scoring candidates first and consuming eac...
const SubdomainName _tri_subdomain_name_suffix
Suffix appended to the name of a subdomain to name the one its surviving triangles move into.
void subdivide(ReplicatedMesh &mesh) const
Replace every element of the mesh by one quadrilateral per corner, built on its centroid and its edge...
std::unique_ptr< MeshBase > & _input
Mesh that possibly comes from another generator.
const bool _all_quad
Whether the triangles that survive recombination are eliminated.
const Real _eta_min
Score below which a pair of adjacent triangles is not recombined.
static std::vector< QuadCorners > triSubdivisionTemplate()
The three quadrilaterals that a triangle is split into, one per corner, each of them built on that co...
std::array< unsigned int, 4 > QuadCorners
The four corners of one quadrilateral, as indices into the point list of a template.
static Real quadQuality(const std::array< Point, 4 > &quad_points)
Compute the quality score of a planar quadrilateral, eta = max(0, 1 - (2 / pi) * max_k |pi / 2 - alph...
void moveSurvivingTriangles(ReplicatedMesh &mesh, const subdomain_id_type scratch_subdomain_id) const
Move the triangles that recombination did not consume out of the subdomains they came from,...
const MooseEnum _algorithm
Algorithm used to build the quadrilaterals.
void recombine(ReplicatedMesh &mesh) const
Replace the highest scoring pairs of adjacent triangles of the mesh by quadrilaterals.
static InputParameters validParams()
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
static RecombineCandidate buildCandidate(const Elem &elem, const unsigned int side, const Elem &neighbor)
Build the merge candidate for the two triangles that share a side.
static std::vector< QuadCorners > quadSubdivisionTemplate()
The four quadrilaterals that a quadrilateral is split into, one per corner, each of them built on tha...
A pair of adjacent triangles that the recombination algorithm can merge into one quadrilateral.
dof_id_type first_elem_id
Id of the lower numbered triangle of the pair.
std::array< dof_id_type, 4 > quad_node_ids
Node ids of the quadrilateral, in counter-clockwise order.
dof_id_type second_elem_id
Id of the higher numbered triangle of the pair.
Real eta
Quality score of the quadrilateral that the two triangles would form.