48 const std::string baseEvent =
"map.np.computeMapping.From" +
input()->getName() +
"To" +
output()->getName();
60 searchSpace =
input();
63 const auto &fVertices = origins->vertices();
67 "2D Mesh \"{}\" does not contain edges. "
68 "Nearest projection mapping falls back to nearest neighbor mapping.",
69 searchSpace->getName());
72 "3D Mesh \"{}\" does not contain triangles. "
73 "Nearest projection mapping will map to primitives of lower dimension.",
74 searchSpace->getName());
81 constexpr int nnearest = 4;
84 std::size_t toTriangles{0}, toEdges{0}, toVertices{0};
89 auto &index = searchSpace->index();
90 for (
const auto &fVertex : fVertices) {
93 auto match = index.findNearestProjection(fVertex.getCoords(), nnearest);
94 distanceStatistics(match.polation.distance());
95 switch (match.polation.nElements()) {
112 if (distanceStatistics.
empty()) {
113 PRECICE_INFO(
"Mapping distance not available due to empty partition.");
115 PRECICE_INFO(
"Mapping distance {}", distanceStatistics);
116 PRECICE_INFO(
"Nearest-projections are {} triangles, {} edges, and {} vertices", toTriangles, toEdges, toVertices);
124 return "nearest-projection";
#define PRECICE_WARN_IF(condition,...)
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_INFO(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
#define PRECICE_UNREACHABLE(...)
std::vector< Polation > _interpolations
BarycentricBaseMapping(Constraint constraint, int dimensions)
mesh::PtrMesh output() const
Returns pointer to output mesh.
Constraint
Specifies additional constraints for a mapping.
@ SCALED_CONSISTENT_VOLUME
int getDimensions() const
mesh::PtrMesh input() const
Returns pointer to input mesh.
bool _hasComputedMapping
Flag to indicate whether computeMapping() has been called.
bool isScaledConsistent() const
Returns true if mapping is a form of scaled consistent mapping.
void setInputRequirement(MeshRequirement requirement)
Sets the mesh requirement for the input mesh.
void setOutputRequirement(MeshRequirement requirement)
Sets the mesh requirement for the output mesh.
virtual bool hasConstraint(const Constraint &constraint) const
Checks whether the mapping has the given constraint or not.
std::string getName() const final override
name of the np mapping
void computeMapping() final override
Computes the projections and interpolation relations.
NearestProjectionMapping(Constraint constraint, int dimensions)
Constructor, taking mapping constraint.
bool empty() const
Returns count == 0.
contains data mapping from points to meshes.
std::shared_ptr< Mesh > PtrMesh
static constexpr SynchronizeTag Synchronize
Convenience instance of the SynchronizeTag.