From a604dc84d1c3a923985a959d099be85214cdc938 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Tue, 23 Mar 2021 16:39:04 +0100 Subject: [PATCH] [PL/DS] Add isDeactivated(point, t) query. Will be used to determine whether a point (e.g. a cell center) is deactivated or not. --- ProcessLib/DeactivatedSubdomain.cpp | 16 ++++++++++++++++ ProcessLib/DeactivatedSubdomain.h | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/ProcessLib/DeactivatedSubdomain.cpp b/ProcessLib/DeactivatedSubdomain.cpp index 1669ad49413..5422fa37813 100644 --- a/ProcessLib/DeactivatedSubdomain.cpp +++ b/ProcessLib/DeactivatedSubdomain.cpp @@ -50,4 +50,20 @@ bool DeactivatedSubdomain::includesTimeOf(double const t) const t <= time_interval.getSupportMax(); } +bool DeactivatedSubdomain::isDeactivated(MathLib::Point3d const& point, + double const time) const +{ + // Line from a to b. + auto const& a = line_segment.first; + auto const& b = line_segment.second; + // Tangent vector t = (b - a)/|b - a|. + Eigen::Vector3d const t = (b - a).normalized(); + + // Position r on the line at given time. + Eigen::Vector3d const r = a + t * time_interval.getValue(time); + Eigen::Map<Eigen::Vector3d const> const p{point.getCoords(), 3}; + + // Return true if p is "behind" the plane through r. + return (p - r).dot(t) <= 0; +} } // namespace ProcessLib diff --git a/ProcessLib/DeactivatedSubdomain.h b/ProcessLib/DeactivatedSubdomain.h index f48b71c63fa..a2832b63dd4 100644 --- a/ProcessLib/DeactivatedSubdomain.h +++ b/ProcessLib/DeactivatedSubdomain.h @@ -18,6 +18,7 @@ #include <vector> #include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h" +#include "MathLib/Point3d.h" namespace MeshLib { @@ -49,6 +50,12 @@ struct DeactivatedSubdomain bool includesTimeOf(double const t) const; + /// \returns true if the point is in the deactivated part of the subdomain. + /// The domain is split into two parts by a plane defined as a normal plane + /// of the line segment and the position on the line segment, where the + /// latter is defined by the time curve. + bool isDeactivated(MathLib::Point3d const& point, double const time) const; + MathLib::PiecewiseLinearInterpolation const time_interval; /// Line segment along which excavation progresses. Represented by start and -- GitLab