Пример #1
0
void
StitchedMesh::buildMesh()
{
  // Read the first mesh into the original mesh... then we'll stitch all of the others into that
  _original_mesh->read(_files[0]);

  _meshes.reserve(_files.size() - 1);

  // Read in all of the other meshes
  for (auto i = beginIndex(_files, 1); i < _files.size(); ++i)
  {
    _meshes.emplace_back(libmesh_make_unique<ReplicatedMesh>(_communicator));
    auto & mesh = _meshes.back();

    mesh->read(_files[i]);
  }

  // Stich 'em
  for (auto i = beginIndex(_meshes); i < _meshes.size(); i++)
  {
    auto & boundary_pair = _stitch_boundaries_pairs[i];

    BoundaryID first = getBoundaryID(boundary_pair.first);
    BoundaryID second = getBoundaryID(boundary_pair.second);

    _original_mesh->stitch_meshes(
        *_meshes[i], first, second, TOLERANCE, _clear_stitched_boundary_ids);
  }
}
Пример #2
0
void
PatternedMesh::buildMesh()
{
  // Local pointers to simplify algorithm
  std::vector<ReplicatedMesh *> row_meshes;
  row_meshes.reserve(_pattern.size());
  // First row is the original mesh
  row_meshes.push_back(_original_mesh);
  // Copy the remaining raw pointers into the local vector
  for (const auto & row_mesh: _row_meshes)
    row_meshes.push_back(row_mesh.get());

  BoundaryID left = getBoundaryID(getParam<BoundaryName>("left_boundary"));
  BoundaryID right = getBoundaryID(getParam<BoundaryName>("right_boundary"));
  BoundaryID top = getBoundaryID(getParam<BoundaryName>("top_boundary"));
  BoundaryID bottom = getBoundaryID(getParam<BoundaryName>("bottom_boundary"));

  // Build each row mesh
  for (auto i = beginIndex(_pattern); i < _pattern.size(); ++i)
    for (auto j = beginIndex(_pattern[i]); j < _pattern[i].size(); ++j)
    {
      Real
        deltax = j * _x_width,
        deltay = i * _y_width;

      // If this is the first cell of the row initialize the row mesh
      if (j == 0)
      {
        row_meshes[i]->read(_files[_pattern[i][j]]);

        MeshTools::Modification::translate(*row_meshes[i], deltax, -deltay, 0);

        continue;
      }

      ReplicatedMesh & cell_mesh = *_meshes[_pattern[i][j]];

      // Move the mesh into the right spot.  -i because we are starting at the top
      MeshTools::Modification::translate(cell_mesh, deltax, -deltay, 0);

      row_meshes[i]->stitch_meshes(dynamic_cast<ReplicatedMesh &>(cell_mesh), right, left, TOLERANCE, /*clear_stitched_boundary_ids=*/true);

      // Undo the translation
      MeshTools::Modification::translate(cell_mesh, -deltax, deltay, 0);
    }

  // Now stitch together the rows
  // We're going to stitch them all to row 0 (which is the real mesh)
  for (auto i = beginIndex(_pattern, 1); i < _pattern.size(); i++)
    row_meshes[0]->stitch_meshes(*row_meshes[i], bottom, top, TOLERANCE, /*clear_stitched_boundary_ids=*/true);
}
Пример #3
0
void
TiledMesh::buildMesh()
{
  // stitch_meshes() is only implemented for ReplicatedMesh.  So make sure
  // we have one here before continuing.
  ReplicatedMesh * serial_mesh = dynamic_cast<ReplicatedMesh *>(&getMesh());

  if (!serial_mesh)
    mooseError("Error, TiledMesh calls stitch_meshes() which only works on ReplicatedMesh.");
  else
  {
    std::string mesh_file(getParam<MeshFileName>("file"));

    if (mesh_file.rfind(".exd") < mesh_file.size() || mesh_file.rfind(".e") < mesh_file.size())
    {
      ExodusII_IO ex(*this);
      ex.read(mesh_file);
      serial_mesh->prepare_for_use();
    }
    else
      serial_mesh->read(mesh_file);

    BoundaryID left = getBoundaryID(getParam<BoundaryName>("left_boundary"));
    BoundaryID right = getBoundaryID(getParam<BoundaryName>("right_boundary"));
    BoundaryID top = getBoundaryID(getParam<BoundaryName>("top_boundary"));
    BoundaryID bottom = getBoundaryID(getParam<BoundaryName>("bottom_boundary"));
    BoundaryID front = getBoundaryID(getParam<BoundaryName>("front_boundary"));
    BoundaryID back = getBoundaryID(getParam<BoundaryName>("back_boundary"));

    {
      std::unique_ptr<MeshBase> clone = serial_mesh->clone();

      // Build X Tiles
      for (unsigned int i = 1; i < getParam<unsigned int>("x_tiles"); ++i)
      {
        MeshTools::Modification::translate(*clone, _x_width, 0, 0);
        serial_mesh->stitch_meshes(dynamic_cast<ReplicatedMesh &>(*clone),
                                   right,
                                   left,
                                   TOLERANCE,
                                   /*clear_stitched_boundary_ids=*/true);
      }
    }
    {
      std::unique_ptr<MeshBase> clone = serial_mesh->clone();

      // Build Y Tiles
      for (unsigned int i = 1; i < getParam<unsigned int>("y_tiles"); ++i)
      {
        MeshTools::Modification::translate(*clone, 0, _y_width, 0);
        serial_mesh->stitch_meshes(dynamic_cast<ReplicatedMesh &>(*clone),
                                   top,
                                   bottom,
                                   TOLERANCE,
                                   /*clear_stitched_boundary_ids=*/true);
      }
    }
    {
      std::unique_ptr<MeshBase> clone = serial_mesh->clone();

      // Build Z Tiles
      for (unsigned int i = 1; i < getParam<unsigned int>("z_tiles"); ++i)
      {
        MeshTools::Modification::translate(*clone, 0, 0, _z_width);
        serial_mesh->stitch_meshes(dynamic_cast<ReplicatedMesh &>(*clone),
                                   front,
                                   back,
                                   TOLERANCE,
                                   /*clear_stitched_boundary_ids=*/true);
      }
    }
  }
}