34 const std::string baseEvent =
"map.vci.computeMapping.From" +
input()->getName() +
"To" +
output()->getName();
46 searchSpace =
input();
49 const auto &fVertices = origins->vertices();
50 bool hasConnectivity =
true;
53 if (!fVertices.empty() && searchSpace->triangles().empty()) {
54 const bool hasEdges = searchSpace->hasEdges();
55 PRECICE_WARN(
"2D Mesh \"{}\" does not contain triangles{} "
56 "Linear cell interpolation falls back to nearest-{} mapping.",
57 searchSpace->getName(), hasEdges ?
"." :
" or edges.", hasEdges ?
"projection" :
"neighbor");
58 hasConnectivity =
false;
61 if (!fVertices.empty() && searchSpace->tetrahedra().empty()) {
62 const bool hasTriangles = searchSpace->hasTriangles();
63 const bool hasEdges = searchSpace->hasEdges();
64 PRECICE_WARN(
"3D Mesh \"{}\" does not contain tetrahedra{}{} "
65 "Linear cell interpolation falls back to nearest-{} mapping.",
66 searchSpace->getName(), hasEdges ?
"" :
", edges", hasTriangles ?
"." :
" or triangles.", (hasTriangles || hasEdges) ?
"projection" :
"neighbor");
67 hasConnectivity =
false;
75 constexpr int nnearest = 4;
77 auto &
index = searchSpace->index();
83 for (
const auto &fVertex : fVertices) {
85 auto match =
index.findCellOrProjection(fVertex.getCoords(), nnearest);
86 auto distance = match.polation.distance();
94 if (!fallbackStatistics.
empty()) {
95 if (hasConnectivity) {
98 "Linear Cell Interpolation is used, but some points from {} don't lie in the domain defined by the {}. "
99 "These points have been projected on the domain boundary. This could come from non-matching discrete geometries or erroneous connectivity information."
100 "If distances seem too large, please check your mesh. "
101 "The fallback statistics are: {} ",
102 searchSpace->getName(),
getDimensions() == 2 ?
"triangles" :
"tetrahedra",
106 PRECICE_INFO(
"Fallback mapping statistics: {}", fallbackStatistics);
109 if (!hasConnectivity) {
111 PRECICE_INFO(
"All vertices are inside cells, no fallback required");
115 PRECICE_INFO(
"Successfully computed linear-cell-interpolation mapping.");
124 return "linear-cell interpolation";
#define PRECICE_WARN(...)
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_INFO(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
Base class for interpolation based mappings, where mapping is done using a geometry-based linear comb...
std::vector< Polation > _interpolations
void computeMapping() final override
Computes the projections and interpolation relations.
LinearCellInterpolationMapping(Constraint constraint, int dimensions)
Constructor, taking mapping constraint.
std::string getName() const final override
name of the lci mapping
mesh::PtrMesh output() const
Returns pointer to output mesh.
Constraint
Specifies additional constraints for a mapping.
@ SCALED_CONSISTENT_SURFACE
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.
bool empty() const
Returns count == 0.
contains data mapping from points to meshes.
constexpr bool equals(const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &B, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares two Eigen::MatrixBase for equality up to tolerance.
static constexpr SynchronizeTag Synchronize
Convenience instance of the SynchronizeTag.