Loading...
Searching...
No Matches
computeintersection.hh
Go to the documentation of this file.
// 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_MERGING_COMPUTEINTERSECTION_HH
#define DUNE_GRIDGLUE_MERGING_COMPUTEINTERSECTION_HH
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
namespace Dune {
namespace GridGlue {
template<int dimWorld, int dim1, int dim2, typename T = double>
class ComputationMethod {
public:
typedef FieldVector<T, dimWorld> Vector;
static const int grid1Dimension = dim1;
static const int grid2Dimension = dim2;
static const int intersectionDimension = (dim1 < dim2)?(dim1):(dim2);
static bool computeIntersectionPoints(const std::vector<Vector> X,
const std::vector<Vector> Y,
std::vector<std::vector<int> >& SX,
std::vector<std::vector<int> >& SY,
std::vector<Vector>& P);
static void grid1_subdivisions(const std::vector<Vector> elementCorners,
std::vector<std::vector<unsigned int> >& subElements,
std::vector<std::vector<int> >& faceIds);
static void grid2_subdivisions(const std::vector<Vector> elementCorners,
std::vector<std::vector<unsigned int> >& subElements,
std::vector<std::vector<int> >& faceIds);
};
template<class CM>
class IntersectionComputation {
private:
typedef typename CM::Vector V;
const int dimWorld = V::dimension;
const int dim1 = CM::grid1Dimension;
const int dim2 = CM::grid2Dimension;
public:
static bool computeIntersection(const std::vector<V>& X,
const std::vector<V>& Y,
std::vector<std::vector<int> >& SX,
std::vector<std::vector<int> >& SY,
std::vector<V>& P);
template<int isDim, int dW>
static void orderPoints(const V& centroid,
const std::vector<std::vector<int> >& SX,
const std::vector<std::vector<int> >& SY,
const std::vector<V>& P,
std::vector<std::vector<int> >& H)
{
if (isDim > 1)
orderPoints_(std::integral_constant<int,isDim>(),std::integral_constant<int,dW>(),
centroid, SX, SY, P,H);
}
private:
static void orderPoints_(std::integral_constant<int,1>,
std::integral_constant<int,1>,
const V& centroid,
const std::vector<std::vector<int> >& SX,
const std::vector<std::vector<int> >& SY,
const std::vector<V>& P,
std::vector<std::vector<int> >& H) {}
static void orderPoints_(std::integral_constant<int,1>,
std::integral_constant<int,2>,
const V& centroid,
const std::vector<std::vector<int> >& SX,
const std::vector<std::vector<int> >& SY,
const std::vector<V>& P,
std::vector<std::vector<int> >& H) {}
static void orderPoints_(std::integral_constant<int,1>,
std::integral_constant<int,3>,
const V& centroid,
const std::vector<std::vector<int> >& SX,
const std::vector<std::vector<int> >& SY,
const std::vector<V>& P,
std::vector<std::vector<int> >& H) {}
static void orderPoints_(std::integral_constant<int,2>,
std::integral_constant<int,2>,
const V& centroid,
const std::vector<std::vector<int> >& SX,
const std::vector<std::vector<int> >& SY,
const std::vector<V>& P,
std::vector<std::vector<int> >& H);
static void orderPoints_(std::integral_constant<int,2>,
std::integral_constant<int,3>,
const V& centroid,
const std::vector<std::vector<int> >& SX,
const std::vector<std::vector<int> >& SY,
const std::vector<V>& P,
std::vector<std::vector<int> >& H);
static void orderPoints_(std::integral_constant<int,3>,
std::integral_constant<int,3>,
const V& centroid,
const std::vector<std::vector<int> >& SX,
const std::vector<std::vector<int> >& SY,
const std::vector<V>& P,
std::vector<std::vector<int> > & H);
static void orderPointsCC(std::integral_constant<int,2>,
const V& centroid,
std::vector<int> &id,
const std::vector<V>& P);
static void orderPointsCC(std::integral_constant<int,3>,
const V& centroid,
std::vector<int> &id,
const std::vector<V>& P);
static void removeDuplicates( std::vector<int> & p);
static bool newFace3D(const std::vector<int>& id,
const std::vector<std::vector<int> >& H);
};
template<class V>
inline int insertPoint(const V p, std::vector<V>& P)
{
double eps= 1e-8; // tolerance for identical nodes
std::size_t k=0 ;
if (P.size()>0) {
while ((k<P.size())&&
((p - P[k]).infinity_norm()>eps*(P[k].infinity_norm()) &&
(p - P[k]).infinity_norm()>eps*(p.infinity_norm())) &&
!(p.infinity_norm() < eps && P[k].infinity_norm() <eps &&
(p - P[k]).infinity_norm() < eps))
k++ ;
if (k>=P.size())
P.push_back(p) ; // new node is not contained in P
}
else
P.push_back(p);
return k ;
}
} /* namespace Dune::GridGlue */
} /* namespace Dune */
#include "simplexintersection.cc"
#include "computeintersection.cc"
#endif
simplexintersection.cc
computeintersection.cc
Dune
Definition gridglue.hh:37
Dune::GridGlue
Definition gridglue.hh:38
Dune::GridGlue::insertPoint
int insertPoint(const V p, std::vector< V > &P)
Definition computeintersection.hh:164
Dune::GridGlue::ComputationMethod
Definition computeintersection.hh:13
Dune::GridGlue::ComputationMethod::grid2_subdivisions
static void grid2_subdivisions(const std::vector< Vector > elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Dune::GridGlue::ComputationMethod::computeIntersectionPoints
static bool computeIntersectionPoints(const std::vector< Vector > X, const std::vector< Vector > Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< Vector > &P)
Dune::GridGlue::ComputationMethod::Vector
FieldVector< T, dimWorld > Vector
Definition computeintersection.hh:15
Dune::GridGlue::ComputationMethod::grid1Dimension
static const int grid1Dimension
Definition computeintersection.hh:16
Dune::GridGlue::ComputationMethod::grid1_subdivisions
static void grid1_subdivisions(const std::vector< Vector > elementCorners, std::vector< std::vector< unsigned int > > &subElements, std::vector< std::vector< int > > &faceIds)
Dune::GridGlue::ComputationMethod::grid2Dimension
static const int grid2Dimension
Definition computeintersection.hh:17
Dune::GridGlue::ComputationMethod::intersectionDimension
static const int intersectionDimension
Definition computeintersection.hh:18
Dune::GridGlue::IntersectionComputation
Intersection computation method for two elements of arbitrary dimension.
Definition computeintersection.hh:39
Dune::GridGlue::IntersectionComputation::orderPoints
static void orderPoints(const V &centroid, const std::vector< std::vector< int > > &SX, const std::vector< std::vector< int > > &SY, const std::vector< V > &P, std::vector< std::vector< int > > &H)
Order Points in the point list P face-wise such that a subsimplex subdivision can be constructed.
Definition computeintersection.hh:75
Dune::GridGlue::IntersectionComputation::computeIntersection
static bool computeIntersection(const std::vector< V > &X, const std::vector< V > &Y, std::vector< std::vector< int > > &SX, std::vector< std::vector< int > > &SY, std::vector< V > &P)
Compute the intersection of two elements X and Y Compute the intersection of two elements X and Y,...
Definition computeintersection.cc:14