Skip to content

Commit

Permalink
Merge pull request #12600 from leorachapuis/more_mesh_generator_work
Browse files Browse the repository at this point in the history
More mesh generator work
  • Loading branch information
moosebuild committed Jan 7, 2019
2 parents 394592d + 4572445 commit 11a4ff5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
6 changes: 3 additions & 3 deletions framework/include/meshgenerators/TiledMeshGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class TiledMeshGenerator : public MeshGenerator
std::unique_ptr<MeshBase> & _input;

/// The mesh width in the x, y and z directions
const Real _x_width;
const Real _y_width;
const Real _z_width;
Real _x_width;
Real _y_width;
Real _z_width;
};

#endif // TILEDMESHGENERATOR_H
2 changes: 1 addition & 1 deletion framework/src/meshgenerators/MeshExtruderGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ validParams<MeshExtruderGenerator>()
{
InputParameters params = validParams<MeshGenerator>();

params.addParam<MeshGeneratorName>("input", "the mesh we want to extrude");
params.addRequiredParam<MeshGeneratorName>("input", "the mesh we want to extrude");
params.addClassDescription("Takes a 1D or 2D mesh and extrudes the entire structure along the "
"specified axis increasing the dimensionality of the mesh.");
params.addRequiredParam<RealVectorValue>("extrusion_vector",
Expand Down
38 changes: 26 additions & 12 deletions framework/src/meshgenerators/TiledMeshGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "libmesh/distributed_mesh.h"
#include "libmesh/boundary_info.h"
#include "libmesh/mesh_modification.h"
#include "libmesh/bounding_box.h"
#include "libmesh/mesh_tools.h"
#include "libmesh/point.h"

#include <typeinfo>

Expand All @@ -25,11 +28,7 @@ validParams<TiledMeshGenerator>()
{
InputParameters params = validParams<MeshGenerator>();

params.addParam<MeshGeneratorName>("input", "The mesh we want to repeat");

params.addParam<Real>("x_width", 0, "The tile width in the x direction");
params.addParam<Real>("y_width", 0, "The tile width in the y direction");
params.addParam<Real>("z_width", 0, "The tile width in the z direction");
params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to repeat");

// x boundary names
params.addParam<BoundaryName>("left_boundary", "left", "name of the left (x) boundary");
Expand Down Expand Up @@ -60,14 +59,10 @@ validParams<TiledMeshGenerator>()
}

TiledMeshGenerator::TiledMeshGenerator(const InputParameters & parameters)
: MeshGenerator(parameters),
_input(getMesh("input")),
_x_width(getParam<Real>("x_width")),
_y_width(getParam<Real>("y_width")),
_z_width(getParam<Real>("z_width"))
: MeshGenerator(parameters), _input(getMesh("input"))
{
if (typeid(_input).name() == typeid(DistributedMesh).name())
mooseError("TiledMesh only works with ReplicatedMesh.");
if (dynamic_pointer_cast<DistributedMesh>(_input) != nullptr)
mooseError("TiledMeshGenerator only works with ReplicatedMesh.");
}

std::unique_ptr<MeshBase>
Expand All @@ -76,6 +71,25 @@ TiledMeshGenerator::generate()
std::unique_ptr<MeshBase> initial_mesh = std::move(_input);
std::unique_ptr<ReplicatedMesh> mesh = dynamic_pointer_cast<ReplicatedMesh>(initial_mesh);

// Getting the x,y,z widths
std::set<subdomain_id_type> sub_ids;
mesh->subdomain_ids(sub_ids);
BoundingBox bbox(Point(std::numeric_limits<Real>::max(),
std::numeric_limits<Real>::max(),
std::numeric_limits<Real>::max()),
Point(std::numeric_limits<Real>::lowest(),
std::numeric_limits<Real>::lowest(),
std::numeric_limits<Real>::lowest()));
for (auto id : sub_ids)
{
BoundingBox sub_bbox = MeshTools::create_subdomain_bounding_box(*mesh, id);
bbox.union_with(sub_bbox);
}

_x_width = bbox.max()(0) - bbox.min()(0);
_y_width = bbox.max()(1) - bbox.min()(1);
_z_width = bbox.max()(2) - bbox.min()(2);

boundary_id_type left =
mesh->get_boundary_info().get_id_by_name(getParam<BoundaryName>("left_boundary"));
boundary_id_type right =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[./tmg]
type = TiledMeshGenerator
input = fmg
x_width = 10
y_width = 10
z_width = 10

left_boundary = left
right_boundary = right
Expand Down

0 comments on commit 11a4ff5

Please sign in to comment.