Loading...
Searching...
No Matches
gridglue.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-dune-grid-glue-exception
#ifndef DUNE_GRIDGLUE_GRIDGLUE_HH
#define DUNE_GRIDGLUE_GRIDGLUE_HH
#include <memory>
#include <tuple>
#include <type_traits>
#include <dune/common/deprecated.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/iteratorfacades.hh>
#include <dune/common/promotiontraits.hh>
#include <dune/common/shared_ptr.hh>
#include <dune/common/stdstreams.hh>
#include "adapter/gridgluecommunicate.hh"
#include <dune/grid-glue/merging/merger.hh>
#include <dune/common/parallel/mpitraits.hh>
#include <dune/common/parallel/mpicommunication.hh>
#include <dune/common/parallel/indexset.hh>
#include <dune/common/parallel/plocalindex.hh>
#include <dune/common/parallel/remoteindices.hh>
#include <dune/common/parallel/communicator.hh>
#include <dune/common/parallel/interface.hh>
namespace Dune {
namespace GridGlue {
// forward declarations
template<typename P0, typename P1>
class GridGlue;
template<typename P0, typename P1>
class IntersectionData;
template<typename P0, typename P1, int inside, int outside>
class Intersection;
template<typename P0, typename P1, int inside, int outside>
class IntersectionIterator;
template<typename P0, typename P1>
class IntersectionIndexSet;
template<typename P0, typename P1>
class GridGlue
{
private:
/* F R I E N D S */
friend class IntersectionData<P0,P1>;
friend class Intersection<P0,P1,0,1>;
friend class Intersection<P0,P1,1,0>;
friend class IntersectionIterator<P0,P1,0,1>;
friend class IntersectionIterator<P0,P1,1,0>;
friend class IntersectionIndexSet<P0,P1>;
/* P R I V A T E T Y P E S */
typedef ::Dune::GridGlue::GlobalId GlobalId;
typedef Dune::ParallelLocalIndex <Dune::PartitionType> LocalIndex;
typedef Dune::ParallelIndexSet <GlobalId, LocalIndex> PIndexSet;
public:
/* P U B L I C T Y P E S A N D C O N S T A N T S */
template<int side>
using GridPatch = std::conditional_t<side == 0, P0, std::conditional_t<side == 1, P1, void>>;
template<int side>
using GridView = typename GridPatch<side>::GridView;
template<int side>
using Grid = typename GridView<side>::Grid;
using Grid0View [[deprecated("please use GridView<0> instead")]] = GridView<0>;
using Grid0 [[deprecated("please use Grid<0> instead")]] = Grid<0>;
using Grid0Patch [[deprecated("please use GridPatch<0> instead")]] = GridPatch<0>;
template<int side>
static constexpr auto griddim()
{ return GridPatch<side>::dim; }
template<int side>
static constexpr auto griddimworld()
{ return GridPatch<side>::dimworld; }
[[deprecated("please use griddim<0>() instead")]]
static constexpr auto grid0dim = griddim<0>();
[[deprecated("please use griddim<0>() instead")]]
static constexpr auto domdim = griddim<0>();
[[deprecated("please use griddimworld<0>() instead")]]
static constexpr auto grid0dimworld = griddimworld<0>();
[[deprecated("please use griddimworld<0>() instead")]]
static constexpr auto domdimworld = griddimworld<0>();
using Grid1View [[deprecated("please use GridView<0> instead")]] = GridView<1>;
using Grid1 [[deprecated("please use Grid<1> instead")]] = Grid<1>;
using Grid1Patch [[deprecated("please use GridPatch<1> instead")]] = GridPatch<1>;
typedef unsigned int IndexType;
[[deprecated("please use griddim<1>() instead")]]
static constexpr auto grid1dim = griddim<1>();
[[deprecated("please use griddim<1>() instead")]]
static constexpr auto tardim = griddim<1>();
[[deprecated("please use griddimworld<1>() instead")]]
static constexpr auto grid1dimworld = griddimworld<1>();
[[deprecated("please use griddimworld<1>() instead")]]
static constexpr auto tardimworld = griddimworld<1>();
static constexpr int dimworld = (int)griddimworld<0>() > (int)griddimworld<1>() ? (int)griddimworld<0>() : (int)griddimworld<1>();
typedef typename PromotionTraits<typename GridView<0>::ctype,
typename GridView<1>::ctype>::PromotedType ctype;
typedef Dune::FieldVector<ctype, dimworld> Coords;
template<int side>
using GridElement = typename GridView<side>::Traits::template Codim<0>::Entity;
template<int side>
using GridVertex = typename GridView<side>::Traits::template Codim<Grid<side>::dimension>::Entity;
using Grid0Element [[deprecated("please use GridElement<0> instead")]] = GridElement<0>;
using Grid0Vertex [[deprecated("please use GridVertex<0> instead")]] = GridVertex<0>;
using Grid1Element [[deprecated("please use GridElement<1> instead")]] = GridElement<1>;
using Grid1Vertex [[deprecated("please use GridVertex<1> instead")]] = GridVertex<1>;
typedef Dune::GridGlue::Merger<ctype,
Grid<0>::dimension - GridPatch<0>::codim,
Grid<1>::dimension - GridPatch<1>::codim,
dimworld> Merger;
typedef Dune::GridGlue::Intersection<P0,P1,0,1> Intersection;
typedef Dune::GridGlue::IntersectionIndexSet<P0,P1> IndexSet;
template<int side>
using IntersectionIterator = Dune::GridGlue::IntersectionIterator<P0, P1, side, (side+1) % 2>;
using Grid0IntersectionIterator [[deprecated("please use IntersectionIterator<0> instead")]] = IntersectionIterator<0>;
using Grid1IntersectionIterator [[deprecated("please use IntersectionIterator<1> instead")]] = IntersectionIterator<1>;
private:
/* M E M B E R V A R I A B L E S */
using GridPatches = std::tuple<
const std::shared_ptr< const GridPatch<0> >,
const std::shared_ptr< const GridPatch<1> >
>;
const GridPatches patches_;
const std::shared_ptr<Merger> merger_;
IndexType index__sz = 0;
#if HAVE_MPI
MPI_Comm mpicomm_;
PIndexSet patch0_is_;
PIndexSet patch1_is_;
Dune::RemoteIndices<PIndexSet> remoteIndices_;
#endif // HAVE_MPI
typedef Dune::GridGlue::IntersectionData<P0,P1> IntersectionData;
mutable std::vector<IntersectionData> intersections_;
protected:
void mergePatches(const std::vector<Dune::FieldVector<ctype,dimworld> >& patch0coords,
const std::vector<unsigned int>& patch0entities,
const std::vector<Dune::GeometryType>& patch0types,
const int patch0rank,
const std::vector<Dune::FieldVector<ctype,dimworld> >& patch1coords,
const std::vector<unsigned int>& patch1entities,
const std::vector<Dune::GeometryType>& patch1types,
const int patch1rank);
template<typename Extractor>
void extractGrid (const Extractor & extractor,
std::vector<Dune::FieldVector<ctype, dimworld> > & coords,
std::vector<unsigned int> & faces,
std::vector<Dune::GeometryType>& geometryTypes) const;
public:
/* C O N S T R U C T O R S A N D D E S T R U C T O R S */
GridGlue(const std::shared_ptr< const GridPatch<0> >& gp0, const std::shared_ptr< const GridPatch<1> >& gp1, const std::shared_ptr<Merger>& merger);
/* G E T T E R S */
template<int P>
const GridPatch<P>& patch() const
{
return *std::get<P>(patches_);
}
template<int P>
const GridView<P>& gridView() const
{
return std::get<P>(patches_)->gridView();
}
/* F U N C T I O N A L I T Y */
void build();
/* I N T E R S E C T I O N S A N D I N T E R S E C T I O N I T E R A T O R S */
template<int I = 0>
IntersectionIterator<I> ibegin() const
{
return {this, 0};
}
template<int I = 0>
IntersectionIterator<I> iend() const
{
return {this, index__sz};
}
template<class DataHandleImp, class DataTypeImp>
void communicate (Dune::GridGlue::CommDataHandle<DataHandleImp,DataTypeImp> & data,
Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const;
/*
* @brief return an IndexSet mapping from Intersection to IndexType
*/
IndexSet indexSet() const
{
return IndexSet(this);
}
#if QUICKHACK_INDEX
// indexset size
size_t indexSet_size() const
{
return index__sz;
}
#endif
Intersection getIntersection(int i) const
{
return Intersection(this, & intersections_[i]);
}
size_t size() const
{
return index__sz;
}
};
} // end namespace GridGlue
} // end namespace Dune
#include "adapter/rangegenerators.hh"
#include "adapter/gridglue.cc"
#include "adapter/intersection.hh"
#include "adapter/intersectioniterator.hh"
#include "adapter/intersectionindexset.hh"
#endif // DUNE_GRIDGLUE_GRIDGLUE_HH
intersectioniterator.hh
Implement iterators over GridGlue intersections.
intersectionindexset.hh
intersection.hh
Model of the Intersection concept provided by GridGlue.
gridgluecommunicate.hh
Describes the parallel communication interface class for Dune::GridGlue.
rangegenerators.hh
gridglue.cc
merger.hh
Dune
Definition gridglue.hh:37
Dune::GridGlue::GridGlue
sequential adapter to couple two grids at specified close together boundaries
Definition gridglue.hh:67
Dune::GridGlue::GridGlue::Coords
Dune::FieldVector< ctype, dimworld > Coords
The type used for coordinate vectors.
Definition gridglue.hh:174
Dune::GridGlue::GridGlue::getIntersection
Intersection getIntersection(int i) const
Definition gridglue.hh:388
Dune::GridGlue::GridGlue::IndexSet
Dune::GridGlue::IntersectionIndexSet< P0, P1 > IndexSet
Type of remote intersection indexSet.
Definition gridglue.hh:206
Dune::GridGlue::GridGlue::IndexType
unsigned int IndexType
Definition gridglue.hh:147
Dune::GridGlue::GridGlue::ctype
PromotionTraits< typenameGridView< 0 >::ctype, typenameGridView< 1 >::ctype >::PromotedType ctype
The type used for coordinates.
Definition gridglue.hh:171
Dune::GridGlue::GridGlue::mergePatches
void mergePatches(const std::vector< Dune::FieldVector< ctype, dimworld > > &patch0coords, const std::vector< unsigned int > &patch0entities, const std::vector< Dune::GeometryType > &patch0types, const int patch0rank, const std::vector< Dune::FieldVector< ctype, dimworld > > &patch1coords, const std::vector< unsigned int > &patch1entities, const std::vector< Dune::GeometryType > &patch1types, const int patch1rank)
after building the merged grid the intersection can be updated through this method (for internal use)
Definition gridglue.cc:179
Dune::GridGlue::GridGlue::Intersection
Dune::GridGlue::Intersection< P0, P1, 0, 1 > Intersection
Type of remote intersection objects.
Definition gridglue.hh:203
Dune::GridGlue::GridGlue::griddimworld
static constexpr auto griddimworld()
Definition gridglue.hh:120
Dune::GridGlue::GridGlue::communicate
void communicate(Dune::GridGlue::CommDataHandle< DataHandleImp, DataTypeImp > &data, Dune::InterfaceType iftype, Dune::CommunicationDirection dir) const
Communicate information on the MergedGrid of a GridGlue.
Definition gridglue.cc:300
Dune::GridGlue::GridGlue::dimworld
static constexpr int dimworld
export the world dimension This is the maximum of the extractors' world dimensions.
Definition gridglue.hh:166
Dune::GridGlue::GridGlue::GridGlue
GridGlue(const std::shared_ptr< const GridPatch< 0 > > &gp0, const std::shared_ptr< const GridPatch< 1 > > &gp1, const std::shared_ptr< Merger > &merger)
constructor
Definition gridglue.cc:21
Dune::GridGlue::GridGlue::iend
IntersectionIterator< I > iend() const
gets the (general) end-iterator for grid glue iterations
Definition gridglue.hh:350
Dune::GridGlue::GridGlue::Merger
Dune::GridGlue::Merger< ctype, Grid< 0 >::dimension - GridPatch< 0 >::codim, Grid< 1 >::dimension - GridPatch< 1 >::codim, dimworld > Merger
Instance of a Merger.
Definition gridglue.hh:200
Dune::GridGlue::GridGlue::domdimworld
static constexpr auto domdimworld
Definition gridglue.hh:135
Dune::GridGlue::GridGlue::build
void build()
Definition gridglue.cc:36
Dune::GridGlue::GridGlue::extractGrid
void extractGrid(const Extractor &extractor, std::vector< Dune::FieldVector< ctype, dimworld > > &coords, std::vector< unsigned int > &faces, std::vector< Dune::GeometryType > &geometryTypes) const
Definition gridglue.cc:265
Dune::GridGlue::GridGlue::IntersectionIterator
Dune::GridGlue::IntersectionIterator< P0, P1, side,(side+1) % 2 > IntersectionIterator
Type of the iterator that iterates over remove intersections.
Definition gridglue.hh:210
Dune::GridGlue::GridGlue::grid0dim
static constexpr auto grid0dim
dimension of the grid 0 extractor
Definition gridglue.hh:125
Dune::GridGlue::GridGlue::gridView
const GridView< P > & gridView() const
getter for the GridView of patch P
Definition gridglue.hh:318
Dune::GridGlue::GridGlue::grid1dim
static constexpr auto grid1dim
dimension of the grid 1 extractor
Definition gridglue.hh:151
Dune::GridGlue::GridGlue::griddim
static constexpr auto griddim()
Definition gridglue.hh:116
Dune::GridGlue::GridGlue::patch
const GridPatch< P > & patch() const
Definition gridglue.hh:308
Dune::GridGlue::GridGlue::grid1dimworld
static constexpr auto grid1dimworld
world dimension of the grid 1 extractor
Definition gridglue.hh:158
Dune::GridGlue::GridGlue::domdim
static constexpr auto domdim
Definition gridglue.hh:128
Dune::GridGlue::GridGlue::grid0dimworld
static constexpr auto grid0dimworld
world dimension of the grid 0 extractor
Definition gridglue.hh:132
Dune::GridGlue::GridGlue::GridPatch
std::conditional_t< side==0, P0, std::conditional_t< side==1, P1, void > > GridPatch
Definition gridglue.hh:96
Dune::GridGlue::GridGlue::ibegin
IntersectionIterator< I > ibegin() const
gets an iterator over all remote intersections in the merged grid between grid0 and grid1
Definition gridglue.hh:337
Dune::GridGlue::GridGlue::GridView
typename GridPatch< side >::GridView GridView
Definition gridglue.hh:100
Dune::GridGlue::GridGlue::tardim
static constexpr auto tardim
Definition gridglue.hh:154
Dune::GridGlue::GridGlue::GridVertex
typename GridView< side >::Traits::template Codim< Grid< side >::dimension >::Entity GridVertex
type of grid vertices on side side
Definition gridglue.hh:182
Dune::GridGlue::GridGlue::GridElement
typename GridView< side >::Traits::template Codim< 0 >::Entity GridElement
type of grid elements on side side
Definition gridglue.hh:178
Dune::GridGlue::GridGlue::indexSet
IndexSet indexSet() const
Definition gridglue.hh:374
Dune::GridGlue::GridGlue::size
size_t size() const
Definition gridglue.hh:393
Dune::GridGlue::GridGlue::tardimworld
static constexpr auto tardimworld
Definition gridglue.hh:161
Dune::GridGlue::GridGlue::Grid
typename GridView< side >::Grid Grid
Definition gridglue.hh:104
Dune::GridGlue::IntersectionData
storage class for Dune::GridGlue::Intersection related data
Definition intersection.hh:38
Dune::GridGlue::Intersection
The intersection of two entities of the two patches of a GridGlue.
Definition intersection.hh:257
Dune::GridGlue::IntersectionIterator
Definition intersectioniterator.hh:25
Dune::GridGlue::IntersectionIndexSet
Definition intersectionindexset.hh:20
Dune::GridGlue::GlobalId
Definition gridgluecommunicate.hh:26
Dune::GridGlue::CommDataHandle
describes the features of a data handle for communication in parallel runs using the GridGlue::commun...
Definition gridgluecommunicate.hh:77
Dune::GridGlue::Extractor
Provides codimension-independent methods for grid extraction.
Definition extractor.hh:46
Dune::GridGlue::Merger
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition merger.hh:27