13 #include "libmesh/mesh_smoother_laplace.h" 14 #include "libmesh/mesh_smoother_vsmoother.h" 15 #include "libmesh/unstructured_mesh.h" 16 #include "libmesh/replicated_mesh.h" 27 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The mesh we want to smooth.");
28 params.
addClassDescription(
"Utilizes the specified smoothing algorithm to attempt to improve " 31 MooseEnum SmootherAlgorithm(
"variational laplace",
"variational");
32 params.
addParam<
MooseEnum>(
"algorithm", SmootherAlgorithm,
"The smoothing algorithm to use.");
34 "iterations", 1,
"Laplace algorithm only: the number of smoothing iterations to do.");
38 "dilation_weight >= 0.0 & dilation_weight <= 1.0",
39 "Variational algorithm only: the weight of the dilation metric. The distortion metric is " 40 "given weight 1 - dilation_weight.");
41 params.
addParam<
bool>(
"preserve_subdomain_boundaries",
43 "Variational algorithm only: whether the input mesh's subdomain boundaries " 44 "should be preserved during the smoothing process.");
46 TOLERANCE * TOLERANCE,
47 "Variational algorithm only: solver relative residual tolerance.");
49 TOLERANCE * TOLERANCE,
50 "Variational algorithm only: solver absolute residual tolerance.");
54 "0 <= verbosity <= 100",
55 "Variational algorithm only: verbosity level between 0 and 100.");
62 _input(getMesh(
"input")),
63 _algorithm(getParam<
MooseEnum>(
"algorithm")),
64 _iterations(getParam<unsigned
int>(
"iterations")),
65 _dilation_weight(getParam<
Real>(
"dilation_weight")),
66 _preserve_subdomain_boundaries(getParam<bool>(
"preserve_subdomain_boundaries")),
67 _relative_residual_tolerance(getParam<
Real>(
"relative_residual_tolerance")),
68 _absolute_residual_tolerance(getParam<
Real>(
"absolute_residual_tolerance")),
69 _verbosity(getParam<unsigned
int>(
"verbosity"))
76 std::vector<std::string> check_params;
77 std::string other_algorithm;
80 other_algorithm =
"variational";
81 check_params = {
"dilation_weight",
82 "preserve_subdomain_boundaries",
83 "relative_residual_tolerance",
84 "absolute_residual_tolerance",
90 other_algorithm =
"laplace";
91 check_params = {
"iterations"};
94 for (
const auto & param_name : check_params)
98 "' applies to algorithm='",
100 "' only and has no effect on the ",
101 "currently selected algorithm='",
107 std::unique_ptr<MeshBase>
112 std::unique_ptr<libMesh::MeshSmoother> smoother =
nullptr;
116 if (!
mesh->is_serial())
118 "SmoothMeshGenerator with algorithm='laplace' is not implemented for distributed meshes");
120 smoother = std::make_unique<libMesh::LaplaceMeshSmoother>(*
mesh,
_iterations);
125 smoother = std::make_unique<libMesh::VariationalMeshSmoother>(*
mesh,
const Real _dilation_weight
Variational only: the dilation weight (variational smoother only)
const Real _relative_residual_tolerance
Variational only: solver relative residual tolerance.
static InputParameters validParams()
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
const unsigned int _verbosity
Variational only: verbosity level between 0 and 100.
const unsigned int _iterations
Laplace only: the number of smoothing passes to do.
std::unique_ptr< MeshBase > & _input
Mesh that possibly comes from another generator.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
registerMooseObject("MooseApp", SmoothMeshGenerator)
static InputParameters validParams()
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
SmoothMeshGenerator(const InputParameters ¶meters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
const MooseEnum _algorithm
Smoothing algorithm to use.
const Real _absolute_residual_tolerance
Variational only: solver absolute residual tolerance.
MeshGenerator for doing mesh smoothing.
const bool _preserve_subdomain_boundaries
Variational only: whether to preserve subdomain/block boundaries during smoothing.
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
MeshGenerators are objects that can modify or add to an existing mesh.
void ErrorVector unsigned int