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"
12
13namespace ProcessLib
14{
16 "zero_for_element_deactivation_approach";
17
19{
20 return time_interval.getSupportMin() <= t &&
21 t <= time_interval.getSupportMax();
22}
23
25 double const time) const
26{
27 auto const& bulk_element_ids = deactivated_subdomain_mesh.bulk_element_ids;
28 if (!bulk_element_ids.contains(element.getID()))
29 {
30 return false;
31 }
32
33 if (line_segment)
34 {
35 auto const& element_center = getCenterOfGravity(element);
36 // Line from a to b.
37 auto const& a = line_segment->first;
38 auto const& b = line_segment->second;
39 // Tangent vector t = (b - a)/|b - a|.
40 Eigen::Vector3d const t = (b - a).normalized();
41
42 // Position r on the line at given time.
43 auto const curve_position = time_interval.getValue(time);
44 Eigen::Vector3d const r = a + t * curve_position;
45
46 // Return true if p is "behind" the plane through r.
47 return (element_center.asEigenVector3d() - r).dot(t) <= 0;
48 }
49
50 if (ball)
51 {
52 auto const& element_center = getCenterOfGravity(element);
53
54 auto const& center = ball->center;
55 // The radius at given time.
56 auto const r_t = time_interval.getValue(time);
57 if (r_t > ball->radius)
58 {
59 return false;
60 }
61
62 double const r_element_center =
63 (element_center.asEigenVector3d() - center).norm();
64
65 return r_element_center < r_t;
66 }
67
68 return true;
69}
70} // namespace ProcessLib
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:80
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
bool isInTimeSupportInterval(double const t) const
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