Loading...
Searching...
No Matches
projection.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_COMMON_PROJECTIONHELPER2_HH
#define DUNE_GRIDGLUE_COMMON_PROJECTIONHELPER2_HH
#include <array>
#include <bitset>
#include <tuple>
namespace Dune {
namespace GridGlue {
template<typename Coordinate>
class Projection
{
public:
struct EdgeIntersection
{
std::array<unsigned, 2> edge;
std::array<Coordinate, 2> local;
};
constexpr static unsigned dim = Coordinate::dimension;
constexpr static unsigned maxEdgeIntersections = dim == 3 ? 9 : 0;
static_assert(dim == 2 || dim == 3, "Projection only implemented for dim=2 or dim=3");
typedef typename Coordinate::field_type Field;
typedef std::array<Coordinate, dim> Images;
typedef Images Preimages;
private:
const Field m_overlap;
const Field m_max_normal_product;
Field m_epsilon = Field(1e-12);
std::tuple<Images, Preimages> m_images;
std::tuple<std::bitset<dim>, std::bitset<dim> > m_success;
unsigned m_number_of_edge_intersections;
std::array<EdgeIntersection, maxEdgeIntersections> m_edge_intersections;
bool m_projection_valid;
template<typename Corners, typename Normals>
void doProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
template<typename Corners, typename Normals>
void doInverseProjection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
template<typename Corners, typename Normals>
void doEdgeIntersection(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
template<typename Corners, typename Normals>
inline bool projectionFeasible(const Coordinate& x, const Coordinate& nx, const Coordinate& px, const Corners& corners, const Normals& normals) const;
public:
Projection(const Field overlap = Field(0), const Field max_normal_product = Field(-0.1));
void epsilon(const Field epsilon);
template<typename Corners, typename Normals>
void project(const std::tuple<Corners&, Corners&>& corners, const std::tuple<Normals&, Normals&>& normals);
const std::tuple<Images, Preimages>& images() const
{ return m_images; }
const std::tuple<std::bitset<dim>, std::bitset<dim> >& success() const
{ return m_success; }
unsigned numberOfEdgeIntersections() const
{ return m_number_of_edge_intersections; }
const std::array<EdgeIntersection, maxEdgeIntersections>& edgeIntersections() const
{ return m_edge_intersections; }
};
} /* namespace GridGlue */
} /* namespace Dune */
#include "projection_impl.hh"
#endif
projection_impl.hh
Dune
Definition gridglue.hh:37
Dune::GridGlue
Definition gridglue.hh:38
Dune::GridGlue::Projection::Field
Coordinate::field_type Field
Scalar type.
Definition projection.hh:61
Dune::GridGlue::Projection::Projection
Projection(const Field overlap=Field(0), const Field max_normal_product=Field(-0.1))
Definition projection_impl.hh:130
Dune::GridGlue::Projection::success
const std::tuple< std::bitset< dim >, std::bitset< dim > > & success() const
Indicate whether projection (inverse projection) is valid for each corner or not.
Definition projection.hh:252
Dune::GridGlue::Projection::maxEdgeIntersections
static constexpr unsigned maxEdgeIntersections
maximum number of edge-edge intersections
Definition projection.hh:54
Dune::GridGlue::Projection::Preimages
Images Preimages
Definition projection.hh:78
Dune::GridGlue::Projection::Images
std::array< Coordinate, dim > Images
List of corner images.
Definition projection.hh:70
Dune::GridGlue::Projection::epsilon
void epsilon(const Field epsilon)
Set epsilon used for floating-point comparisons.
Definition projection_impl.hh:140
Dune::GridGlue::Projection::project
void project(const std::tuple< Corners &, Corners & > &corners, const std::tuple< Normals &, Normals & > &normals)
Do the actual projection.
Definition projection_impl.hh:469
Dune::GridGlue::Projection::dim
static constexpr unsigned dim
dimension of coordinates
Definition projection.hh:47
Dune::GridGlue::Projection::numberOfEdgeIntersections
unsigned numberOfEdgeIntersections() const
Number of edge intersections.
Definition projection.hh:262
Dune::GridGlue::Projection::images
const std::tuple< Images, Preimages > & images() const
Images and preimages of corners.
Definition projection.hh:235
Dune::GridGlue::Projection::edgeIntersections
const std::array< EdgeIntersection, maxEdgeIntersections > & edgeIntersections() const
Edge-edge intersections.
Definition projection.hh:273
Dune::GridGlue::Projection::EdgeIntersection
Intersection between two edges of a triangle.
Definition projection.hh:29
Dune::GridGlue::Projection::EdgeIntersection::local
std::array< Coordinate, 2 > local
Local coordinates of intersection and distance along normals.
Definition projection.hh:41
Dune::GridGlue::Projection::EdgeIntersection::edge
std::array< unsigned, 2 > edge
Edge numbers in image and preimage triangle.
Definition projection.hh:33