Permalink
Browse files

Merge pull request #12600 from leorachapuis/more_mesh_generator_work

More mesh generator work
  • Loading branch information...
moosebuild committed Jan 7, 2019
2 parents 394592d + 4572445 commit 11a4ff58d0ce53f0236e5768a613b51d412f5251
@@ -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
@@ -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",
@@ -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>

@@ -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");
@@ -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>
@@ -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 =
@@ -7,9 +7,6 @@
[./tmg]
type = TiledMeshGenerator
input = fmg
x_width = 10
y_width = 10
z_width = 10

left_boundary = left
right_boundary = right

0 comments on commit 11a4ff5

Please sign in to comment.