8#include <kernel/trafo/mapping_base.hpp> 
   20      template<
typename Shape_>
 
   21      struct InverseMappingHelper;
 
   46      template<
typename DT_, 
int n_, 
int s_>
 
   70    template<
typename DataType_, 
int shape_dim_, 
int world_dim_ = shape_dim_>
 
  110          cells = std::forward<std::vector<Index>>(other.cells);
 
  111          dom_points = std::forward<std::vector<DomainPointType>>(other.dom_points);
 
  121        return cells.empty();
 
  155    template<
typename Trafo_, 
typename DataType_>
 
  240        const auto& mesh = 
_trafo.get_mesh();
 
  242        const auto& vtx_set = mesh.get_vertex_set();
 
  244        const auto& vert_idx = mesh.template get_index_set<shape_dim, 0>();
 
  247        _bboxes.resize(std::size_t(mesh.get_num_elements()));
 
  250        for(
Index cell(0); cell < vert_idx.get_num_entities(); ++cell)
 
  253          const auto& vidx = vert_idx[cell];
 
  259          bbox[0] = bbox[1] = vtx_set[vidx[0]];
 
  260          for(
int i(1); i < vert_idx.get_num_indices(); ++i)
 
  263            const auto& vtx = vtx_set[vidx[i]];
 
  274            DataType bb_extra = bbox_tol * (bbox[1][j] - bbox[0][j]);
 
  275            bbox[0][j] -= bb_extra;
 
  276            bbox[1][j] += bb_extra;
 
  324        std::vector<Index> cells;
 
  329        for(
Index cell : cells)
 
  351          inv_data.
cells.push_back(cell);
 
  410        for(
Index cell : cells)
 
  432          inv_data.
cells.push_back(cell);
 
  466        for(std::size_t cell(0); cell < 
_bboxes.size(); ++cell)
 
  483            cells.push_back(
Index(cell));
 
  486        return !cells.empty();
 
  508        typedef typename TrafoType::template Evaluator<ShapeType, DataType>::Type TrafoEvaluator;
 
  509        TrafoEvaluator trafo_eval(
_trafo);
 
  515        typename TrafoEvaluator::template ConfigTraits<trafo_tags>::EvalDataType trafo_data;
 
  525        bool converged = 
false;
 
  528        trafo_eval.prepare(cell);
 
  576      struct InverseMappingHelper<Shape::Simplex<dim_>>
 
  579        template<
typename PT_, 
typename DT_>
 
  580        static bool is_on_ref(
const PT_& p, 
const DT_ tol)
 
  585          for(
int i(0); i < dim_; ++i)
 
  588            if((p[i] < -tol) || (p[i] > DT_(1)+tol))
 
  593          return (s <= DT_(1) + tol);
 
  598      struct InverseMappingHelper<Shape::Hypercube<dim_>>
 
  601        template<
typename PT_, 
typename DT_>
 
  602        static bool is_on_ref(
const PT_& p, 
const DT_ tol)
 
  605          for(
int i(0); i < dim_; ++i)
 
  608            if((p[i] < -DT_(1)-tol) || (p[i] > DT_(1)+tol))
 
String class implementation.
Tiny Matrix class template.
Tiny Vector class template.
CUDA_HOST_DEVICE DataType norm_euclid_sqr() const
Computes the squared euclid norm of this vector.
Data structure for InverseMapping evaluations.
Tiny::Vector< DataType_, shape_dim_ > DomainPointType
the domain point type
InverseMappingData & operator=(InverseMappingData &&other)
move-assign operator
ImagePointType img_point
the image point that was unmapped
std::vector< Index > cells
the indices of the cells that intersect with the image point
InverseMappingData()
default constructor
InverseMappingData(const InverseMappingData &other)=default
use default copy constructor
std::vector< DomainPointType > dom_points
the domain points on each cell that map onto the image point
Tiny::Vector< DataType_, world_dim_ > ImagePointType
the image point type
InverseMappingData(InverseMappingData &&other)
move constructor
bool empty() const
Checks whether no cells were found.
Inverse Trafo Mapping Error class.
InverseMappingError(const Tiny::Vector< DT_, n_, s_ > &point, Index cell)
Constructor.
Inverse Trafo mapping class template.
std::vector< BBox > _bboxes
the array of cell bounding boxes
bool find_candidate_cells(std::vector< Index > &cells, const ImagePointType &img_point) const
Determines a set of candidate cells by a bounding-box test.
Index _newton_max_iter
maximum number of newton iterations for unmapping
void init_bounding_boxes(DataType bbox_tol)
Initializes the cell bounding boxes array.
Tiny::Matrix< DataType_, 2, world_dim > BBox
our bounding box type
static constexpr int shape_dim
the shape dimension
Trafo_ TrafoType
the underlying trafo type
bool unmap_point_by_newton(DomainPointType &dom_point, const ImagePointType &img_point, const Index cell) const
Unmaps a given point on a particular cell by Newton iteration.
DataType_ DataType
the datatype to be used
bool test_domain_point(const DomainPointType &dom_point) const
Tests whether a given domain point is on the reference element.
InverseMappingData< DataType, shape_dim, world_dim > InvMapDataType
the inverse mapping data type
InvMapDataType::DomainPointType DomainPointType
the domain point type
InverseMapping(const TrafoType &trafo, DataType bbox_tol=DataType(1E-2), DataType domain_tol=DataType(1E-4))
Constructor.
InvMapDataType unmap_point(const ImagePointType &img_point, const std::vector< Index > &cells, bool ignore_failures=false) const
Unmaps a given image point.
InvMapDataType::ImagePointType ImagePointType
the image point type
InvMapDataType unmap_point(const ImagePointType &img_point, bool ignore_failures=false) const
Unmaps a given image point.
static constexpr int world_dim
the world dimension
virtual ~InverseMapping()
virtual destructor
DataType _domain_tol
tolerance for unmapped domain coordinates
DataType _newton_tol
absolute tolerance for newton iteration
const TrafoType & _trafo
the trafo mapping
TrafoType::ShapeType ShapeType
the shape type
void minimax(T_ x, T_ &a, T_ &b)
Updates the minimum and maximum.
T_ sqr(T_ x)
Returns the square of a value.
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.
TrafoTags
Trafo configuration tags enum.
@ img_point
specifies whether the trafo should supply image point coordinates
@ dom_point
specifies whether the trafo should supply domain point coordinates
@ jac_inv
specifies whether the trafo should supply inverse jacobian matrices
Reference cell traits structure.