10#include <kernel/adjacency/adjactor.hpp>
11#include <kernel/adjacency/base.hpp>
12#include <kernel/adjacency/graph.hpp>
14#include <kernel/global/remote_lambda.hpp>
15#include <kernel/trafo/inverse_mapping.hpp>
16#include <kernel/trafo/standard/mapping.hpp>
17#include <kernel/util/dist.hpp>
18#include <kernel/util/math.hpp>
19#include <kernel/util/string.hpp>
20#include <kernel/util/tiny_algebra.hpp>
42 template<
typename DataType_,
int shape_dim_,
int world_dim_ = shape_dim_>
75 ranks(std::move(other.ranks)),
76 cells(std::move(other.cells)),
87 ranks = std::move(other.ranks);
88 cells = std::move(other.cells);
121 template<
typename InverseMappingType_>
128 using TrafoType =
typename InverseMappingType::TrafoType;
130 using DataType =
typename InverseMappingType::DataType;
132 using ShapeType =
typename InverseMappingType::ShapeType;
150 std::reference_wrapper<const InverseMappingType>
_mapping;
185 template<
typename Po
intRange_>
191 std::vector<BoundingBoxType> bbs(
static_cast<std::size_t
>(total_ranks));
196 std::vector<int> ranks;
197 std::vector<Index> indices;
200 for(
auto it = points.begin(); it != points.end(); ++it)
203 for(
int i(0); i < total_ranks; i++)
210 indices.push_back(point_idx);
217 std::vector<std::vector<UnmappingResult>> result_pairs = rl.call(ranks, indices, points, [
this](
const ImagePointType& p)
221 auto local_result =
_mapping.get().unmap_point(p,
true);
224 std::vector<UnmappingResult> result;
225 result.reserve(local_result.size());
226 for(
Index i(0); i < local_result.size(); i++)
228 result.push_back({local_result.cells[i], local_result.dom_points[i]});
236 std::vector<InvMapDataType> result(std::size_t(std::distance(points.begin(), points.end())));
237 for(std::size_t i(0); i < ranks.size(); i++)
239 const int rank = ranks[i];
240 const Index idx = indices[i];
241 auto iter = points.begin();
242 std::advance(iter, idx);
245 std::vector<UnmappingResult>& pairs = result_pairs[i];
247 result[idx].img_point = image_point;
250 result[idx].cells.push_back(pair.cell);
251 result[idx].dom_points.push_back(pair.dom_point);
252 result[idx].ranks.push_back(rank);
266 if(p[i] > (bb[1][i] + bb_eps) || p[i] < (bb[0][i] - bb_eps))
277 const auto& vertex_set =
_mapping.get().get_trafo().get_mesh().get_vertex_set();
279 if(vertex_set.get_num_vertices() == 0)
287 local_bb[0] = vertex_set[0];
288 local_bb[1] = vertex_set[0];
289 for(
Index vtx_idx(0); vtx_idx < vertex_set.get_num_vertices(); vtx_idx++)
291 const auto& v = vertex_set[vtx_idx];
int size() const
Returns the size of this communicator.
int rank() const
Returns the rank of this process in this communicator.
void allgather(const void *sendbuf, std::size_t sendcount, const Datatype &sendtype, void *recvbuf, std::size_t recvcount, const Datatype &recvtype) const
Blocking gather-to-all.
Typemap & add_entry(std::size_t displacement, int blocklength=1)
Add a member to this typemap.
Data structure for InverseMapping evaluations.
GlobalInverseMappingData(const GlobalInverseMappingData &other)=default
use default copy constructor
GlobalInverseMappingData & operator=(GlobalInverseMappingData &&other)
move-assign operator
GlobalInverseMappingData & operator=(const GlobalInverseMappingData &other)=default
default copy assignment operator
bool empty() const
Checks whether no cells were found.
std::vector< int > ranks
the ranks of the cells that intersect with the image point
Tiny::Vector< DataType_, world_dim_ > ImagePointType
the image point type
std::vector< Index > cells
the indices of the cells that intersect with the image point
GlobalInverseMappingData(GlobalInverseMappingData &&other) noexcept
move constructor
std::vector< DomainPointType > dom_points
the domain points on each cell that map onto the image point
Tiny::Vector< DataType_, shape_dim_ > DomainPointType
the domain point type
ImagePointType img_point
the image point that was unmapped
GlobalInverseMappingData()=default
default constructor
BoundingBoxType get_local_bb()
Get bounding box of local part of domain.
typename InvMapDataType::ImagePointType ImagePointType
Point type for points on the mesh.
static constexpr int shape_dim
Shape dimension.
BoundingBoxType _local_bb
Bounding box of local patch.
typename InverseMappingType::DataType DataType
Datatype.
InverseMappingType_ InverseMappingType
Local inverse mapping type.
std::reference_wrapper< const InverseMappingType > _mapping
Reference to local inverse mapping.
typename InvMapDataType::DomainPointType DomainPointType
Point type for points on the reference element.
static bool is_in_bb(const BoundingBoxType &bb, const ImagePointType &p)
Check if a point is in a bounding box.
typename InverseMappingType::TrafoType TrafoType
Trafo type.
Dist::Comm _comm
Communicator that domain is distributed across.
static constexpr int world_dim
World dimension.
InverseMapping(const Dist::Comm &comm, const InverseMappingType &m)
Constructor.
typename InverseMappingType::ShapeType ShapeType
Shape type.
std::vector< InvMapDataType > unmap_points(const PointRange_ &points)
Unmap a range of points.
MPI-abstraction for running vector-valued lambdas on other ranks.
Global linear algebra namespace.
void mini(T_ &xmin, T_ x)
Updates the minimum of a set of values.
void maxi(T_ &xmax, T_ x)
Updates the maximum of a set of values.
std::uint64_t Index
Index data type.
@ dom_point
specifies whether the trafo should supply domain point coordinates
Pair for communicating cells and associated domain points between ranks.
static Dist::Typemap typemap()
Make type MPI-compatible.