OGS
DeactivatedSubdomain.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <range/v3/algorithm/contains.hpp>
7
8#include "BaseLib/Error.h"
10#include "MeshLib/Node.h"
13
14namespace ProcessLib
15{
17 "zero_for_element_deactivation_approach";
18
20 MathLib::PiecewiseLinearInterpolation const& deactivation_curve,
21 double const t)
22{
23 return NumLib::TimeInterval{deactivation_curve.getSupportMin(),
24 deactivation_curve.getSupportMax()}
25 .contains(t);
26}
27
29 double const time) const
30{
31 auto const& bulk_element_ids = deactivated_subdomain_mesh.bulk_element_ids;
32 if (!bulk_element_ids.contains(element.getID()))
33 {
34 return false;
35 }
36
37 if (line_segment)
38 {
39 auto const& element_center = getCenterOfGravity(element);
40 // Line from a to b.
41 auto const& a = line_segment->first;
42 auto const& b = line_segment->second;
43 // Tangent vector t = (b - a)/|b - a|.
44 Eigen::Vector3d const t = (b - a).normalized();
45
46 // Position r on the line at given time.
47 auto const curve_position = time_interval.getValue(time);
48 Eigen::Vector3d const r = a + t * curve_position;
49
50 // Return true if p is "behind" the plane through r.
51 return (element_center.asEigenVector3d() - r).dot(t) <= 0;
52 }
53
54 if (ball)
55 {
56 auto const& element_center = getCenterOfGravity(element);
57
58 auto const& center = ball->center;
59 // The radius at given time.
60 auto const r_t = time_interval.getValue(time);
61 if (r_t > ball->radius)
62 {
63 return false;
64 }
65
66 double const r_element_center =
67 (element_center.asEigenVector3d() - center).norm();
68
69 return r_element_center < r_t;
70 }
71
72 return true;
73}
74} // namespace ProcessLib
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:80
bool isTimeInSupportInterval(MathLib::PiecewiseLinearInterpolation const &deactivation_curve, double const t)
bool contains(double const current_time) const
bool isDeactivated(MeshLib::Element const &element, double const time) const
static PROCESSLIB_EXPORT const std::string zero_parameter_name
MathLib::PiecewiseLinearInterpolation time_interval
DeactivatedSubdomainMesh deactivated_subdomain_mesh
std::optional< detail::Ball > ball
The shape of the deactivated domain is a ball, which is a disk for 2D.
std::optional< std::pair< Eigen::Vector3d, Eigen::Vector3d > > line_segment