From e0a89775c23076ced3029b514d22cdf3d935823d Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Tue, 23 Mar 2021 12:13:16 +0100 Subject: [PATCH] [PL/DS] Parse line segment and store in DS. --- ProcessLib/CreateDeactivatedSubdomain.cpp | 38 +++++++++++++++++++++++ ProcessLib/DeactivatedSubdomain.cpp | 3 ++ ProcessLib/DeactivatedSubdomain.h | 7 +++++ 3 files changed, 48 insertions(+) diff --git a/ProcessLib/CreateDeactivatedSubdomain.cpp b/ProcessLib/CreateDeactivatedSubdomain.cpp index d0b6a618f63..97765f26e0d 100644 --- a/ProcessLib/CreateDeactivatedSubdomain.cpp +++ b/ProcessLib/CreateDeactivatedSubdomain.cpp @@ -8,6 +8,8 @@ */ #include "CreateDeactivatedSubdomain.h" +#include <Eigen/Dense> + #include "BaseLib/ConfigTree.h" #include "BaseLib/Error.h" #include "DeactivatedSubdomain.h" @@ -128,6 +130,37 @@ static MathLib::PiecewiseLinearInterpolation parseTimeIntervalOrCurve( "given. One of them must be specified."); } +/// Returns a line segment represented by its begin and end points. +static std::pair<Eigen::Vector3d, Eigen::Vector3d> parseLineSegment( + BaseLib::ConfigTree const& config) +{ + DBUG("Constructing line segment"); + auto const start = + //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__line_segment__start} + config.getConfigParameter<std::vector<double>>("start"); + if (start.size() != 3) + { + OGS_FATAL( + "For construction of a line segment the start point must be a " + "3D point. Got a vector of size {}.", + start.size()); + } + + auto const end = + //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__line_segment__end} + config.getConfigParameter<std::vector<double>>("end"); + + if (end.size() != 3) + { + OGS_FATAL( + "For construction of a line segment the end point must be a " + "3D point. Got a vector of size {}.", + end.size()); + } + return {Eigen::Vector3d{start[0], start[1], start[2]}, + Eigen::Vector3d{end[0], end[1], end[2]}}; +} + std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh, std::map<std::string, @@ -144,6 +177,10 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( auto const time_interval = parseTimeIntervalOrCurve(time_interval_config, curve_name, curves); + auto const line_segment = + //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__line_segment} + parseLineSegment(config.getConfigSubtree("line_segment")); + auto deactivated_subdomain_material_ids = //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__material_ids} config.getConfigParameter("material_ids", std::vector<int>{}); @@ -179,6 +216,7 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( return std::make_unique<DeactivatedSubdomain const>( std::move(time_interval), + line_segment, std::move(deactivated_subdomain_material_ids), std::move(deactivated_subdomain_meshes)); } diff --git a/ProcessLib/DeactivatedSubdomain.cpp b/ProcessLib/DeactivatedSubdomain.cpp index 2a15afb030a..1669ad49413 100644 --- a/ProcessLib/DeactivatedSubdomain.cpp +++ b/ProcessLib/DeactivatedSubdomain.cpp @@ -32,10 +32,13 @@ DeactivatedSubdomainMesh::DeactivatedSubdomainMesh( DeactivatedSubdomain::DeactivatedSubdomain( MathLib::PiecewiseLinearInterpolation time_interval_, + std::pair<Eigen::Vector3d, Eigen::Vector3d> + line_segment, std::vector<int>&& materialIDs_, std::vector<std::unique_ptr<DeactivatedSubdomainMesh>>&& deactivated_subdomain_meshes_) : time_interval(std::move(time_interval_)), + line_segment(line_segment), materialIDs(std::move(materialIDs_)), deactivated_subdomain_meshes(std::move(deactivated_subdomain_meshes_)) { diff --git a/ProcessLib/DeactivatedSubdomain.h b/ProcessLib/DeactivatedSubdomain.h index 2330e9bf38b..f48b71c63fa 100644 --- a/ProcessLib/DeactivatedSubdomain.h +++ b/ProcessLib/DeactivatedSubdomain.h @@ -12,6 +12,7 @@ */ #pragma once +#include <Eigen/Dense> #include <memory> #include <string> #include <vector> @@ -40,6 +41,8 @@ struct DeactivatedSubdomain { DeactivatedSubdomain( MathLib::PiecewiseLinearInterpolation time_interval_, + std::pair<Eigen::Vector3d, Eigen::Vector3d> + line_segment, std::vector<int>&& materialIDs_, std::vector<std::unique_ptr<DeactivatedSubdomainMesh>>&& deactivated_subdomain_meshes_); @@ -48,6 +51,10 @@ struct DeactivatedSubdomain MathLib::PiecewiseLinearInterpolation const time_interval; + /// Line segment along which excavation progresses. Represented by start and + /// end points. + std::pair<Eigen::Vector3d, Eigen::Vector3d> line_segment; + /// The material IDs of the deactivated the subdomains std::vector<int> const materialIDs; -- GitLab