Skip to content

StructuredGridFactory for AlbertaGrid not usable

When working with AlbertaGrid several constraints must be fulfilled by the grid (numbering) in order to allow refinement. In 2d an automatic mesh check could be performed to correct wrong numberings. In 3d this check is not performed and not implemented and for the AlbertaGrid in general also not implementable, I think.

This restriction on the vertex numbering is a bit difficult for the user because there is not even a warning if something is wrong. For example, when using the StructuredGridFactory to create a macro grid for AlbertaGrid, the produced numbering always leads to infinite loops when you try to refine that grid.

Possible solution:

  • Make a class template specialization of StructuredGridFactory for AlbertaGrid
  • Instead of implementing the Kuhn-triangulation, one could first make a structured cube grid and second refine each cube using a predefined subdivision into 2 triangles (in 2d) or 6 tetrahedra (in 3d).
  • If in the subdivided cube elements the required numbering (and maybe other constraints) are fulfilled, it is given for the whole grid.

A proof-of-concept implementation of the insertElement() method could look like:

void insertElement (const GeometryType& type, const std::vector<unsigned int>& vertices) override
{
  // triangulation of reference cube
  static const auto reference_cubes = std::make_tuple(
    /*1d*/ std::array{std::array{0,1}},
    /*2d*/ std::array{std::array{3,0,1}, std::array{0,3,2}},
    /*3d*/ std::array{std::array{0,7,3,1}, std::array{0,7,5,1},
                      std::array{0,7,5,4}, std::array{0,7,3,2},
                      std::array{0,7,6,2}, std::array{0,7,6,4}} );

  assert(type == GeometryTypes::cube(dim));

  const auto& simplices = std::get<dim-1>(reference_cubes);
  std::vector<unsigned int> corners(dim+1);
  for (const auto& simplex : simplices) {
    for (std::size_t i = 0; i < simplex.size(); ++i)
      corners[i] = vertices[simplex[i]];

    factory_->insertElement(GeometryTypes::simplex(dim), corners);
  }
}

with the cube structured grid created using a YaspGrid or something similar.