Skip to content
Snippets Groups Projects
mygrid.hh 1.08 KiB
Newer Older
Elias Pipping's avatar
Elias Pipping committed
#ifndef SRC_SLIDING_BLOCK_DATA_MYGRID_HH
#define SRC_SLIDING_BLOCK_DATA_MYGRID_HH

#include <dune/grid/common/gridfactory.hh>

#include <dune/fufem/boundarypatch.hh>

#include "mygeometry.hh"

template <class Grid>
std::shared_ptr<Grid> constructGrid(MyGeometry const &myGeometry) {
  std::array<unsigned int, 2> elements = { { 5, 1 } };
  return Dune::StructuredGridFactory<Grid>::createSimplexGrid(
      myGeometry.A, myGeometry.C, elements);
}

template <class GridView, class MyGeometry> class MyFaces {
private:
  bool isClose(double a, double b) {
    return std::abs(a - b) < 1e-14;
  };

public:
  MyFaces(GridView const &gridView, MyGeometry const &myGeometry)
      : lower(gridView), upper(gridView) {
    lower.insertFacesByProperty([&](typename GridView::Intersection const &in) {
      return isClose(myGeometry.A[1], in.geometry().center()[1]);
    });

    upper.insertFacesByProperty([&](typename GridView::Intersection const &in) {
      return isClose(myGeometry.C[1], in.geometry().center()[1]);
    });
  }

  BoundaryPatch<GridView> lower;
  BoundaryPatch<GridView> upper;
};
Elias Pipping's avatar
Elias Pipping committed
#endif