Permalink
Browse files

Merge pull request #12782 from permcody/mesh_generator_cleanup

Mesh generator cleanup
  • Loading branch information...
permcody committed Jan 31, 2019
2 parents e595b55 + 0d90293 commit 5d74fe86fa61da7e93cd1cdf2db1f02b0d576ed7
Showing with 309 additions and 132 deletions.
  1. +1 −0 framework/include/base/MooseObjectUnitTest.h
  2. +5 −1 framework/include/mesh/FileMesh.h
  3. +21 −4 framework/include/mesh/MooseMesh.h
  4. +1 −1 framework/include/mesh/PatternedMesh.h
  5. +0 −2 framework/include/mesh/StitchedMesh.h
  6. +6 −0 framework/include/meshgenerators/MeshGenerator.h
  7. +3 −0 framework/src/actions/AddMeshGeneratorAction.C
  8. +7 −1 framework/src/actions/SetupMeshAction.C
  9. +5 −3 framework/src/base/Moose.C
  10. +1 −18 framework/src/base/MooseApp.C
  11. +3 −2 framework/src/mesh/FileMesh.C
  12. +85 −61 framework/src/mesh/MooseMesh.C
  13. +15 −21 framework/src/mesh/PatternedMesh.C
  14. +3 −7 framework/src/mesh/StitchedMesh.C
  15. +13 −6 framework/src/meshgenerators/GeneratedMeshGenerator.C
  16. +3 −1 framework/src/meshgenerators/MeshGenerator.C
  17. +2 −4 modules/tensor_mechanics/src/actions/LineElementAction.C
  18. +49 −0 test/tests/mesh/no_mesh_block/generators_no_mesh_block.i
  19. +39 −0 test/tests/mesh/no_mesh_block/no_mesh_block.i
  20. +22 −0 test/tests/mesh/no_mesh_block/tests
  21. +4 −0 test/tests/meshgenerators/generate_sidesets_bounding_box/error_no_elements_in_bounding_box.i
  22. +4 −0 test/tests/meshgenerators/generate_sidesets_bounding_box/error_no_nodes_found.i
  23. +4 −0 test/tests/meshgenerators/generate_sidesets_bounding_box/error_no_side_sets_found.i
  24. +4 −0 test/tests/meshgenerators/sidesets_bounding_box_generator/error_no_elements_in_bounding_box.i
  25. +4 −0 test/tests/meshgenerators/sidesets_bounding_box_generator/error_no_nodes_found.i
  26. +4 −0 test/tests/meshgenerators/sidesets_bounding_box_generator/error_no_side_sets_found.i
  27. +1 −0 unit/include/ParsedFunctionTest.h
@@ -78,6 +78,7 @@ class MooseObjectUnitTest : public ::testing::Test
mesh_params.set<std::string>("_type") = "GeneratedMesh";
mesh_params.set<MooseEnum>("dim") = "3";
_mesh = libmesh_make_unique<GeneratedMesh>(mesh_params);
_mesh->setMeshBase(_mesh->buildMeshBaseObject());

InputParameters problem_params = _factory.getValidParams("FEProblem");
problem_params.set<MooseMesh *>("mesh") = _mesh.get();
@@ -43,8 +43,12 @@ class FileMesh : public MooseMesh
/// Auxiliary object for restart
std::unique_ptr<ExodusII_IO> _exreader;

/// The requested dimension of the mesh. For some file meshes, this is not required may be implied
/// from the element type(s).
const unsigned int _dim;

/// Timers
PerfID _read_mesh_timer;
const PerfID _read_mesh_timer;
};

#endif // FILEMESH_H
@@ -78,11 +78,16 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
MooseMesh(const InputParameters & parameters);
MooseMesh(const MooseMesh & other_mesh);

/**
* Destructor
*/
virtual ~MooseMesh();

// The type of libMesh::MeshBase that will be used
enum class ParallelType
{
DEFAULT,
REPLICATED,
DISTRIBUTED
};

/**
* Clone method. Allocates memory you are responsible to clean up.
*/
@@ -95,6 +100,18 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf
*/
virtual std::unique_ptr<MooseMesh> safeClone() const = 0;

/**
* Method to construct a libMesh::MeshBase object that is normally set and used by the MooseMesh
* object during the "init()" phase.
*/
std::unique_ptr<MeshBase> buildMeshBaseObject(ParallelType override_type = ParallelType::DEFAULT);

/**
* Method to set the mesh_base object. If this method is NOT called prior to calling init(), a
* MeshBase object will be automatically constructed and set.
*/
void setMeshBase(std::unique_ptr<MeshBase> mesh_base);

/**
* Initialize the Mesh object. Most of the time this will turn around
* and call build_mesh so the child class can build the Mesh object.
@@ -838,7 +855,7 @@ class MooseMesh : public MooseObject, public Restartable, public PerfGraphInterf

/// Can be set to DISTRIBUTED, REPLICATED, or DEFAULT. Determines whether
/// the underlying libMesh mesh is a ReplicatedMesh or DistributedMesh.
MooseEnum _mesh_parallel_type;
ParallelType _parallel_type;

/// False by default. Final value is determined by several factors
/// including the 'distribution' setting in the input file, and whether
@@ -38,7 +38,7 @@ class PatternedMesh : public MooseMesh
public:
PatternedMesh(const InputParameters & parameters);
PatternedMesh(const PatternedMesh & other_mesh);
virtual ~PatternedMesh();
virtual ~PatternedMesh() = default;

virtual std::unique_ptr<MooseMesh> safeClone() const override;

@@ -33,8 +33,6 @@ class StitchedMesh : public MooseMesh
StitchedMesh(const InputParameters & parameters);
StitchedMesh(const StitchedMesh & other_mesh);

virtual ~StitchedMesh();

virtual std::unique_ptr<MooseMesh> safeClone() const override;

virtual void buildMesh() override;
@@ -13,6 +13,9 @@
#include "MooseObject.h"
#include "Restartable.h"

// Included so mesh generators don't need to include this when constructing MeshBase objects
#include "MooseMesh.h"

#include "libmesh/mesh_base.h"

// Forward declarations
@@ -66,6 +69,9 @@ class MeshGenerator : public MooseObject, public Restartable
std::unique_ptr<MeshBase> &
getMeshByName(const MeshGeneratorName & input_mesh_generator_parameter_name);

/// References to the mesh and displaced mesh (currently in the ActionWarehouse)
std::shared_ptr<MooseMesh> & _mesh;

private:
/// A list of generators that are required to run before this generator may run
std::vector<std::string> _depends_on;
@@ -34,5 +34,8 @@ AddMeshGeneratorAction::act()
if (_app.isRecovering())
return;

if (!_mesh)
mooseError("No mesh file was supplied and no generation block was provided");

_app.addMeshGenerator(_type, _name, _moose_object_pars);
}
@@ -16,7 +16,7 @@
#include "Factory.h"

registerMooseAction("MooseApp", SetupMeshAction, "setup_mesh");

registerMooseAction("MooseApp", SetupMeshAction, "set_mesh_base");
registerMooseAction("MooseApp", SetupMeshAction, "init_mesh");

template <>
@@ -218,6 +218,12 @@ SetupMeshAction::act()
if (isParamValid("displacements") && getParam<bool>("use_displaced_mesh"))
_displaced_mesh = _factory.create<MooseMesh>(_type, "displaced_mesh", _moose_object_pars);
}
else if (_current_task == "set_mesh_base")
{
_mesh->setMeshBase(_mesh->buildMeshBaseObject());
if (isParamValid("displacements") && getParam<bool>("use_displaced_mesh"))
_displaced_mesh->setMeshBase(_displaced_mesh->buildMeshBaseObject());
}
else if (_current_task == "init_mesh")
{
_mesh->init();
@@ -97,9 +97,10 @@ addActionTypes(Syntax & syntax)
registerMooseObjectTask("determine_system_type", Executioner, true);

registerMooseObjectTask("setup_mesh", MooseMesh, false);
registerMooseObjectTask("set_mesh_base", MooseMesh, false);
registerMooseObjectTask("init_mesh", MooseMesh, false);
registerMooseObjectTask("add_mesh_modifier", MeshModifier, false);
registerMooseObjectTask("add_mesh_generator", MeshGenerator, false);
registerMooseObjectTask("add_mesh_generator", MeshGenerator, false);

registerMooseObjectTask("add_kernel", Kernel, false);
appendMooseObjectTask ("add_kernel", EigenKernel);
@@ -171,7 +172,7 @@ addActionTypes(Syntax & syntax)
registerTask("uniform_refine_mesh", false);
registerTask("prepare_mesh", false);
registerTask("add_geometric_rm", true);
registerTask("setup_mesh_complete", false); // calls prepare
registerTask("setup_mesh_complete", true); // calls prepare

registerTask("init_displaced_problem", false);

@@ -232,10 +233,11 @@ addActionTypes(Syntax & syntax)
"(common_output)"
"(set_global_params)"
"(setup_recover_file_base)"
"(setup_mesh)"
"(add_mesh_generator)"
"(execute_mesh_generators)"
"(set_mesh_base)"
"(check_copy_nodal_vars)"
"(setup_mesh)"
"(add_partitioner)"
"(add_geometric_rm)"
"(init_mesh)"
@@ -1538,9 +1538,6 @@ MooseApp::executeMeshGenerators()
}
}
}

// Prepare the final mesh
_final_generated_mesh->prepare_for_use();
}
}

@@ -1589,12 +1586,11 @@ MooseApp::createMinimalApp()
{
TIME_SECTION(_create_minimal_app_timer);

// SetupMeshAction (setup_mesh)
// SetupMeshAction
{
// Build the Action parameters
InputParameters action_params = _action_factory.getValidParams("SetupMeshAction");
action_params.set<std::string>("type") = "GeneratedMesh";
action_params.set<std::string>("task") = "setup_mesh";

// Create The Action
std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
@@ -1609,19 +1605,6 @@ MooseApp::createMinimalApp()
_action_warehouse.addActionBlock(action);
}

// SetupMeshAction (init_mesh)
{
// Action parameters
InputParameters action_params = _action_factory.getValidParams("SetupMeshAction");
action_params.set<std::string>("type") = "GeneratedMesh";
action_params.set<std::string>("task") = "init_mesh";

// Build the action
std::shared_ptr<Action> action =
_action_factory.create("SetupMeshAction", "Mesh", action_params);
_action_warehouse.addActionBlock(action);
}

// Executioner
{
// Build the Action parameters
@@ -32,14 +32,15 @@ validParams<FileMesh>()
FileMesh::FileMesh(const InputParameters & parameters)
: MooseMesh(parameters),
_file_name(getParam<MeshFileName>("file")),
_dim(getParam<MooseEnum>("dim")),
_read_mesh_timer(registerTimedSection("readMesh", 2))
{
getMesh().set_mesh_dimension(getParam<MooseEnum>("dim"));
}

FileMesh::FileMesh(const FileMesh & other_mesh)
: MooseMesh(other_mesh),
_file_name(other_mesh._file_name),
_dim(other_mesh._dim),
_read_mesh_timer(other_mesh._read_mesh_timer)
{
}
@@ -57,7 +58,7 @@ FileMesh::buildMesh()
{
TIME_SECTION(_read_mesh_timer);

std::string _file_name = getParam<MeshFileName>("file");
getMesh().set_mesh_dimension(getParam<MooseEnum>("dim"));

if (_is_nemesis)
{
Oops, something went wrong.

0 comments on commit 5d74fe8

Please sign in to comment.