11#include "libmesh/parallel_implementation.h"
12#include "libmesh/parallel_algebra.h"
19 params.
addParam<
bool>(
"use_auto_area_func",
21 "Use the automatic area function for the triangle meshing region.");
23 "auto_area_func_default_size",
25 "Background size for automatic area function, or 0 to use non background size");
26 params.
addParam<Real>(
"auto_area_func_default_size_dist",
28 "Effective distance of background size for automatic area "
29 "function, or negative to use non background size");
30 params.
addParam<
unsigned int>(
"auto_area_function_num_points",
32 "Maximum number of nearest points used for the inverse distance "
33 "interpolation algorithm for automatic area function calculation.");
35 "auto_area_function_power",
37 "auto_area_function_power>0",
38 "Polynomial power of the inverse distance interpolation algorithm for automatic area "
39 "function calculation.");
41 params.
addClassDescription(
"Base class for Delaunay mesh generators applied to a surface.");
44 "use_auto_area_func auto_area_func_default_size auto_area_func_default_size_dist "
45 "auto_area_function_num_points auto_area_function_power",
46 "Automatic triangle meshing area control");
49 "max_angle_deviation",
51 "max_angle_deviation>0 & max_angle_deviation<90",
52 "Maximum angle deviation from the global average normal vector in the input mesh.");
54 "verbose",
false,
"Whether the generator should output additional information");
60 _use_auto_area_func(getParam<bool>(
"use_auto_area_func")),
61 _auto_area_func_default_size(getParam<Real>(
"auto_area_func_default_size")),
62 _auto_area_func_default_size_dist(getParam<Real>(
"auto_area_func_default_size_dist")),
63 _auto_area_function_num_points(getParam<unsigned
int>(
"auto_area_function_num_points")),
64 _auto_area_function_power(getParam<Real>(
"auto_area_function_power")),
65 _max_angle_deviation(getParam<Real>(
"max_angle_deviation")),
66 _verbose(getParam<bool>(
"verbose"))
73 mooseAssert(elem.n_vertices() == 3 || elem.n_vertices() == 4,
"unsupported element type.");
75 const Point & p0 = *elem.node_ptr(0);
76 const Point & p1 = *elem.node_ptr(1);
77 const Point & p2 = *elem.node_ptr(2);
79 if (elem.n_vertices() == 4)
81 const Point & p3 = *elem.node_ptr(3);
82 return ((p2 - p0).cross(p3 - p1)).unit();
85 return ((p2 - p1).cross(p0 - p1)).unit();
91 Point mesh_norm = Point(0.0, 0.0, 0.0);
95 for (
const auto & elem :
mesh.active_local_element_ptr_range())
97 const Real elem_area = elem->volume();
99 mesh_area += elem_area;
101 mesh.comm().sum(mesh_norm);
102 mesh.comm().sum(mesh_area);
103 mesh_norm /= mesh_area;
104 return mesh_norm.unit();
109 const Point & global_norm)
111 Real max_deviation(0.0);
113 for (
const auto & elem :
mesh.active_local_element_ptr_range())
115 const Real elem_deviation = std::acos(global_norm *
elemNormal(*elem)) / M_PI * 180.0;
116 max_deviation = std::max(max_deviation, elem_deviation);
118 _console <<
"Element " << elem->id() <<
" from subdomain ID " << elem->subdomain_id()
119 <<
" has normal deviation: " << elem_deviation << std::endl;
121 mesh.comm().max(max_deviation);
122 return max_deviation;
void ErrorVector unsigned int
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
MeshGenerators are objects that can modify or add to an existing mesh.
static InputParameters validParams()
const bool _verbose
Whether the generator should be verbose.
Real meshNormalDeviation2D(const MeshBase &mesh, const Point &global_norm)
Calculate the maximum deviation of the normal vectors in a given mesh from a global average normal ve...
Point meshNormal2D(const MeshBase &mesh)
Calculate the average normal vector of a 2D mesh based on the normal vectors of its elements using th...
static InputParameters validParams()
Point elemNormal(const Elem &elem)
Calculate the normal vector of a 2D element based the first three vertices.
SurfaceDelaunayGeneratorBase(const InputParameters ¶meters)
const Real _max_angle_deviation
Max angle deviation from the global average normal vector in the input mesh.