Skip to content
Snippets Groups Projects
Commit 673ab052 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[md] deprecate mixeddimensionglue, forward to multidomainglue

parent 8f61fc1e
No related branches found
No related tags found
1 merge request!1616Feature/free-function-make-glue
......@@ -22,207 +22,52 @@
* \brief A class glueing two grids of different dimension geometrically
* Intersections are computed using axis-aligned bounding box trees
*/
#ifndef DUMUX_MULTIDOMAIN_MIXEDDIMENSION_GLUE_HH
#define DUMUX_MULTIDOMAIN_MIXEDDIMENSION_GLUE_HH
#include <iostream>
#include <fstream>
#include <string>
#include <utility>
#include <dune/common/timer.hh>
#include <dune/common/iteratorrange.hh>
#include <dune/geometry/affinegeometry.hh>
#include <dune/geometry/type.hh>
#include <dumux/common/geometry/geometricentityset.hh>
#include <dumux/common/geometry/boundingboxtree.hh>
#include <dumux/common/geometry/intersectingentities.hh>
#include <dumux/multidomain/glue.hh>
namespace Dumux {
// forward declaration
template<class BulkGridView, class LowDimGridView, class BulkMapper, class LowDimMapper>
class MixedDimensionGlue;
/*!
* \ingroup MixedDimension
* \brief Range generator to iterate with range-based for loops over all intersections
* as follows: for (const auto& is : intersections(glue)) { ... }
*/
template<class BulkGridView, class LowDimGridView, class BulkMapper, class LowDimMapper>
Dune::IteratorRange<typename MixedDimensionGlue<BulkGridView, LowDimGridView, BulkMapper, LowDimMapper>::Intersections::const_iterator>
intersections(const MixedDimensionGlue<BulkGridView, LowDimGridView, BulkMapper, LowDimMapper>& glue)
{ return {glue.ibegin(), glue.iend()}; }
namespace Glue {
/*!
* \ingroup MixedDimension
* \brief An intersection object representing an intersection
* between two grid entites of different grids
*/
template<class BulkGridView, class LowDimGridView, class BulkMapper, class LowDimMapper>
class Intersection
{
using BulkElement = typename BulkGridView::template Codim<0>::Entity;
using LowDimElement = typename LowDimGridView::template Codim<0>::Entity;
using BulkEntitySet = GridViewGeometricEntitySet<BulkGridView, 0, BulkMapper>;
using BulkTree = BoundingBoxTree<BulkEntitySet>;
using LowDimEntitySet = GridViewGeometricEntitySet<LowDimGridView, 0, LowDimMapper>;
using LowDimTree = BoundingBoxTree<LowDimEntitySet>;
enum {
dimWorld = BulkGridView::dimensionworld,
dimIs = LowDimGridView::dimension,
};
using Scalar = typename BulkGridView::ctype;
using Geometry = Dune::AffineGeometry<Scalar, dimIs, dimWorld>;
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
public:
Intersection(const BulkTree& bulkTree, const LowDimTree& lowDimTree)
: bulkTree_(bulkTree)
, lowDimTree_(lowDimTree)
{}
//! set the intersection geometry corners
void setCorners(const std::vector<GlobalPosition>& corners)
{
corners_ = corners;
assert(corners.size() == dimIs + 1); // Only simplex intersections are allowed
}
//! add a pair of neighbor elements
void addNeighbors(std::size_t bulk, std::size_t lowDim)
{
neighbors_[0].push_back(bulk);
neighbors_[1].push_back(lowDim);
}
//! get the intersection geometry
Geometry geometry() const
{ return Geometry(Dune::GeometryTypes::simplex(dimIs), corners_); }
//! get the number of neigbors
std::size_t neighbor(unsigned int side) const
{ return neighbors_[side].size(); }
//! get the inside neighbor
LowDimElement inside(unsigned int n) const
{ return lowDimTree_.entitySet().entity(neighbors_[1][n]); }
//! get the outside neighbor
BulkElement outside(unsigned int n) const
{ return bulkTree_.entitySet().entity(neighbors_[0][n]); }
private:
std::array<std::vector<std::size_t>, 2> neighbors_;
std::vector<GlobalPosition> corners_;
const BulkTree& bulkTree_;
const LowDimTree& lowDimTree_;
};
} // end namespace Glue
/*!
* \ingroup MixedDimension
* \brief Manages the coupling between bulk elements and lower dimensional elements
* Point sources on each integration point are computed by an AABB tree.
* Both domain are assumed to be discretized using a cc finite volume scheme.
*/
template<class BulkGridView, class LowDimGridView,
class BulkMapper = Dune::MultipleCodimMultipleGeomTypeMapper<BulkGridView>,
class LowDimMapper = Dune::MultipleCodimMultipleGeomTypeMapper<LowDimGridView>>
class MixedDimensionGlue
class DUNE_DEPRECATED_MSG("Use MultiDomainGlue instead. Will be removed after 3.1!")
MixedDimensionGlue
: public MultiDomainGlue<LowDimGridView, BulkGridView, LowDimMapper, BulkMapper>
{
using BulkEntitySet = GridViewGeometricEntitySet<BulkGridView, 0, BulkMapper>;
using BulkTree = BoundingBoxTree<BulkEntitySet>;
using LowDimEntitySet = GridViewGeometricEntitySet<LowDimGridView, 0, LowDimMapper>;
using LowDimTree = BoundingBoxTree<LowDimEntitySet>;
using Scalar = typename BulkGridView::ctype;
enum { dimWorld = BulkGridView::dimensionworld };
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
using ParentType = MultiDomainGlue<LowDimGridView, BulkGridView, LowDimMapper, BulkMapper>;
public:
// export intersection container type
using Intersections = std::vector<Glue::Intersection<BulkGridView, LowDimGridView, BulkMapper, LowDimMapper>>;
/*!
* \brief Default constructor
*/
//! Default constructor
MixedDimensionGlue() = default;
/*!
* \brief Constructor
* \brief constructor from bounding box trees
* \note The definition of Glue::Intersection::inside() has changed!
* inside() used to return the lower-dimensional entities
* (i.e. from LowDimGridView). Now, inside() returns the entities
* of the template argument DomainGridView, i.e. the Dune::GridView
* given as the first template argument. In order to be backwards
* compatible, we flip the order here (and in the definition of ParentType).
*/
template<class BulkTree, class LowDimTree>
MixedDimensionGlue(const BulkTree& bulkTree, const LowDimTree& lowDimTree)
{ build(bulkTree, lowDimTree); }
: ParentType(lowDimTree, bulkTree)
{}
/*!
* \brief construction from bounding box trees
* \note The definition of Glue::Intersection::inside() has changed!
* inside() used to return the lower-dimensional entities
* (i.e. from LowDimGridView). Now, inside() returns the entities
* of the template argument DomainGridView, i.e. the Dune::GridView
* given as the first template argument. In order to be backwards
* compatible, we flip the order here (and in the definition of ParentType).
*/
template<class BulkTree, class LowDimTree>
void build(const BulkTree& bulkTree, const LowDimTree& lowDimTree)
{
Dune::Timer timer;
// compute raw intersections
auto rawIntersections = intersectingEntities(bulkTree, lowDimTree);
// create a map to check whether intersection geometries were already inserted
std::vector<std::vector<std::vector<GlobalPosition>>> intersectionMap;
std::vector<std::vector<std::size_t>> intersectionIndex;
intersectionMap.resize(lowDimTree.entitySet().size());
intersectionIndex.resize(lowDimTree.entitySet().size());
for (const auto& rawIntersection : rawIntersections)
{
bool add = true;
for (int i = 0; i < intersectionMap[rawIntersection.second()].size(); ++i)
{
if (rawIntersection.cornersMatch(intersectionMap[rawIntersection.second()][i]))
{
add = false;
// only add the pair of neighbors using the insertionIndex
auto idx = intersectionIndex[rawIntersection.second()][i];
intersections_[idx].addNeighbors(rawIntersection.first(), rawIntersection.second());
break;
}
}
if(add)
{
// add to the map
intersectionMap[rawIntersection.second()].push_back(rawIntersection.corners());
intersectionIndex[rawIntersection.second()].push_back(intersections_.size());
// add new intersection and add the neighbors
intersections_.emplace_back(bulkTree, lowDimTree);
intersections_.back().setCorners(rawIntersection.corners());
intersections_.back().addNeighbors(rawIntersection.first(), rawIntersection.second());
}
}
std::cout << "Computed tree intersections in " << timer.elapsed() << std::endl;
ParentType::build(lowDimTree, bulkTree);
}
//! Return begin iterator to intersection container
typename Intersections::const_iterator ibegin() const
{ return intersections_.begin(); }
//! Return end iterator to intersection container
typename Intersections::const_iterator iend() const
{ return intersections_.end(); }
//! the number of intersections
std::size_t size() const
{ return intersections_.size(); }
private:
Intersections intersections_;
};
} // end namespace Dumux
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment