Permalink
Browse files

Merge pull request #12808 from friedmud/generator_displacements_12712

Fix mesh generators with displaced mesh
  • Loading branch information...
permcody committed Feb 6, 2019
2 parents c978185 + f8d55f1 commit ba266fd6bb5e9913892093d46109e189c357b5ed
@@ -597,7 +597,15 @@ class MooseApp : public ConsoleStreamInterface, public libMesh::ParallelObject
/**
* Get the generated mesh generated by executeMeshGenerators();
*/
std::unique_ptr<MeshBase> getMeshGeneratorMesh() { return std::move(_final_generated_mesh); }
std::unique_ptr<MeshBase> getMeshGeneratorMesh()
{
auto mesh_unique_ptr_ptr = _final_generated_meshes.front();

// Because C++ is stupid
_final_generated_meshes.pop_front();

return std::move(*mesh_unique_ptr_ptr);
}

///@{
/**
@@ -881,7 +889,7 @@ class MooseApp : public ConsoleStreamInterface, public libMesh::ParallelObject
std::map<std::string, std::list<std::unique_ptr<MeshBase>>> _mesh_generator_outputs;

/// The final Mesh that is generated by the generators
std::unique_ptr<MeshBase> _final_generated_mesh;
std::list<std::unique_ptr<MeshBase> *> _final_generated_meshes;

/// Cache for a Backup to use for restart / recovery
std::shared_ptr<Backup> _cached_backup;
@@ -1485,12 +1485,21 @@ MooseApp::executeMeshGenerators()

if (ordered_generators.size())
{
// Grab the outputs from the final generator so MeshGeneratorMesh can pick them up
auto final_generator_name = ordered_generators.back()->name();

_final_generated_meshes.emplace_back(&getMeshGeneratorOutput(final_generator_name));

// Need to grab two if we're going to be making a displaced mesh
if (_action_warehouse.displacedMesh())
_final_generated_meshes.emplace_back(&getMeshGeneratorOutput(final_generator_name));

// Run the MeshGenerators in the proper order
for (const auto & generator : ordered_generators)
{
auto name = generator->name();

_final_generated_mesh = generator->generate();
auto current_mesh = generator->generate();

// Now we need to possibly give this mesh to downstream generators
auto & outputs = _mesh_generator_outputs[name];
@@ -1499,7 +1508,7 @@ MooseApp::executeMeshGenerators()
{
auto & first_output = *outputs.begin();

first_output = std::move(_final_generated_mesh);
first_output = std::move(current_mesh);

const auto & copy_from = *first_output;

@@ -88,7 +88,8 @@ AnnularMeshGenerator::AnnularMeshGenerator(const InputParameters & parameters)
std::unique_ptr<MeshBase>
AnnularMeshGenerator::generate()
{
std::unique_ptr<ReplicatedMesh> mesh = libmesh_make_unique<ReplicatedMesh>(comm(), 2);
// Have MOOSE construct the correct libMesh::Mesh object using Mesh block and CLI parameters.
auto mesh = _mesh->buildMeshBaseObject();

const Real dt = (_tmax - _tmin) / _nt;

@@ -0,0 +1,16 @@
[GlobalParams]
displacements = 'disp_x disp_y'
[]

[MeshGenerators]
[./mg]
type = AnnularMeshGenerator
rmin = 1.0
rmax = 2.0
nt = 20
[]
[]

[Mesh]
type = MeshGeneratorMesh
[]
Binary file not shown.
@@ -0,0 +1,12 @@
[Tests]
[./test]
type = 'Exodiff'
input = 'displaced_mesh.i'
exodiff = 'displaced_mesh_in.e'
cli_args = '--mesh-only'
recover = false
requirement = "The MeshGenerator system shall work with displaced mesh"
design = 'MeshGenerators/index.md'
issues = '#12712'
[../]
[]

0 comments on commit ba266fd

Please sign in to comment.