https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FlattenRefinementGenerator.C
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
11
12#include "libmesh/mesh_modification.h"
13
15
18{
21 "Removes the refinement tree of an h-refined mesh, keeping only the finest "
22 "elements as unrefined (level-0) elements.");
23 params.addRequiredParam<MeshGeneratorName>("input",
24 "The mesh whose refinement will be flattened");
25 params.addParam<bool>(
26 "first_order",
27 false,
28 "Whether to also convert the flattened mesh to first-order elements. If false, the element "
29 "order of the input mesh is preserved.");
30 return params;
31}
32
34 : MeshGenerator(parameters), _input(getMesh("input")), _first_order(getParam<bool>("first_order"))
35{
36}
37
38std::unique_ptr<MeshBase>
40{
41 std::unique_ptr<MeshBase> mesh = std::move(_input);
42
43 // flatten() asserts that the mesh is prepared (or replicated) because it relies on boundary
44 // information while rebuilding the finest elements as level-0 elements
45 if (!mesh->is_prepared())
46 mesh->prepare_for_use();
47
48 // Discard the refinement tree, promoting the finest (active) elements to level 0
49 MeshTools::Modification::flatten(*mesh);
50
51 // Optionally drop to first order now that the refinement pattern is gone
52 if (_first_order)
53 mesh->all_first_order();
54
55 // Both flatten and all_first_order currently leave the mesh prepared.
56 mooseAssert(mesh->is_prepared(), "Mesh should already be prepared after flattening");
57
58 return mesh;
59}
registerMooseObject("MooseApp", FlattenRefinementGenerator)
Removes the refinement tree of an h-refined input mesh, keeping only the finest (active) elements as ...
std::unique_ptr< MeshBase > & _input
The input mesh whose refinement will be flattened.
FlattenRefinementGenerator(const InputParameters &parameters)
static InputParameters validParams()
virtual std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
const bool _first_order
Whether to also convert the flattened mesh to first order.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
MeshGenerators are objects that can modify or add to an existing mesh.
static InputParameters validParams()
MeshBase & mesh