dune-grid-glue  2.9
merger.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
5 #ifndef DUNE_GRIDGLUE_MERGING_MERGER_HH
6 #define DUNE_GRIDGLUE_MERGING_MERGER_HH
7 
8 #include <vector>
9 
10 #include <dune/common/fvector.hh>
11 #include <dune/geometry/type.hh>
12 
14 
15 namespace Dune {
16 namespace GridGlue {
17 
25 template <class ctype, int grid1Dim, int grid2Dim, int dimworld>
26 class Merger
27 {
28 public:
29 
31  typedef Dune::FieldVector<ctype, grid1Dim> Grid1Coords;
32 
34  typedef Dune::FieldVector<ctype, grid2Dim> Grid2Coords;
35 
37  typedef Dune::FieldVector<ctype, dimworld> WorldCoords;
38 
40 
54  virtual void build(const std::vector<Dune::FieldVector<ctype,dimworld> >& grid1_coords,
55  const std::vector<unsigned int>& grid1_elements,
56  const std::vector<Dune::GeometryType>& grid1_element_types,
57  const std::vector<Dune::FieldVector<ctype,dimworld> >& grid2_coords,
58  const std::vector<unsigned int>& grid2_elements,
59  const std::vector<Dune::GeometryType>& grid2_element_types) = 0;
60 
64  unsigned int nSimplices() const
65  { return intersectionList()->size(); }
66 
67  virtual void clear() = 0;
68 
74  virtual std::shared_ptr<IntersectionList> intersectionList() const = 0;
75 
79  template<int n>
80  unsigned int parents(unsigned int idx) const {
81  return intersectionList()->template parents<n>(idx);
82  }
83 
90  template<int n>
91  unsigned int parent(unsigned int idx, unsigned int parId = 0) const
92  {
93  return intersectionList()->template parent<n>(idx, parId);
94  }
95 
104  template<int n>
105  auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId = 0) const
106  {
107  return intersectionList()->template corner<n>(idx, corner, parId);
108  }
109 
114  unsigned int counter;
115 };
116 
117 } /* namespace GridGlue */
118 } /* namespace Dune */
119 
120 #endif
Definition: gridglue.hh:37
Coordinate corner(unsigned c)
Definition: projection_impl.hh:24
Definition: intersectionlist.hh:134
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition: merger.hh:27
unsigned int parent(unsigned int idx, unsigned int parId=0) const
get index of grid-n's parent simplex for given merged grid simplex
Definition: merger.hh:91
virtual void clear()=0
Dune::FieldVector< ctype, dimworld > WorldCoords
the coordinate type used in this interface
Definition: merger.hh:37
Dune::FieldVector< ctype, grid1Dim > Grid1Coords
the local coordinate type for the grid1 coordinates
Definition: merger.hh:31
unsigned int counter
Counts the number of times the computeIntersection method has been called.
Definition: merger.hh:114
auto parentLocal(unsigned int idx, unsigned int corner, unsigned int parId=0) const
get the grid-n parent's simplex local coordinates for a particular merged grid simplex corner (parent...
Definition: merger.hh:105
virtual std::shared_ptr< IntersectionList > intersectionList() const =0
virtual void build(const std::vector< Dune::FieldVector< ctype, dimworld > > &grid1_coords, const std::vector< unsigned int > &grid1_elements, const std::vector< Dune::GeometryType > &grid1_element_types, const std::vector< Dune::FieldVector< ctype, dimworld > > &grid2_coords, const std::vector< unsigned int > &grid2_elements, const std::vector< Dune::GeometryType > &grid2_element_types)=0
builds the merged grid
unsigned int nSimplices() const
get the number of simplices in the merged grid The indices are then in 0..nSimplices()-1
Definition: merger.hh:64
unsigned int parents(unsigned int idx) const
Definition: merger.hh:80
Dune::FieldVector< ctype, grid2Dim > Grid2Coords
the local coordinate type for the grid2 coordinates
Definition: merger.hh:34