From c425c4363d966965726c91e3b8c7339516b91108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Thu, 14 Apr 2022 17:20:48 +0200 Subject: [PATCH] Forbid MeshLineNodeBoundary in dimension 1 --- src/mesh/MeshLineNodeBoundary.cpp | 9 --------- src/mesh/MeshLineNodeBoundary.hpp | 2 ++ src/mesh/MeshRandomizer.cpp | 28 ++++++++++++++++++++-------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/mesh/MeshLineNodeBoundary.cpp b/src/mesh/MeshLineNodeBoundary.cpp index cae862f33..c7e3bb97a 100644 --- a/src/mesh/MeshLineNodeBoundary.cpp +++ b/src/mesh/MeshLineNodeBoundary.cpp @@ -34,14 +34,6 @@ MeshLineNodeBoundary<Dimension>::_checkBoundaryIsLine(const TinyVector<Dimension } } -template <> -template <> -TinyVector<1> -MeshLineNodeBoundary<1>::_getDirection(const Mesh<Connectivity<1>>&) -{ - throw UnexpectedError("MeshLineNodeBoundary makes no sense in dimension 1"); -} - template <> template <> TinyVector<2> @@ -142,6 +134,5 @@ getMeshLineNodeBoundary(const Mesh<Connectivity<Dimension>>& mesh, const IBounda throw NormalError(ost.str()); } -template MeshLineNodeBoundary<1> getMeshLineNodeBoundary(const Mesh<Connectivity<1>>&, const IBoundaryDescriptor&); template MeshLineNodeBoundary<2> getMeshLineNodeBoundary(const Mesh<Connectivity<2>>&, const IBoundaryDescriptor&); template MeshLineNodeBoundary<3> getMeshLineNodeBoundary(const Mesh<Connectivity<3>>&, const IBoundaryDescriptor&); diff --git a/src/mesh/MeshLineNodeBoundary.hpp b/src/mesh/MeshLineNodeBoundary.hpp index 8694dd257..3d9d989a0 100644 --- a/src/mesh/MeshLineNodeBoundary.hpp +++ b/src/mesh/MeshLineNodeBoundary.hpp @@ -9,6 +9,8 @@ class [[nodiscard]] MeshLineNodeBoundary final : public MeshNodeBoundary<Dimension> // clazy:exclude=copyable-polymorphic { public: + static_assert(Dimension > 1, "MeshNodeBoundary makes only sense in dimension greater than 1"); + using Rd = TinyVector<Dimension, double>; private: diff --git a/src/mesh/MeshRandomizer.cpp b/src/mesh/MeshRandomizer.cpp index 34087ff69..06028bab1 100644 --- a/src/mesh/MeshRandomizer.cpp +++ b/src/mesh/MeshRandomizer.cpp @@ -96,17 +96,21 @@ class MeshRandomizerHandler::MeshRandomizer }); } else if constexpr (std::is_same_v<BCType, AxisBoundaryCondition>) { - const Rd& t = bc.direction(); + if constexpr (Dimension > 1) { + const Rd& t = bc.direction(); - const Rdxd txt = tensorProduct(t, t); + const Rdxd txt = tensorProduct(t, t); - const Array<const NodeId>& node_list = bc.nodeList(); - parallel_for( - node_list.size(), PUGS_LAMBDA(const size_t i_node) { - const NodeId node_id = node_list[i_node]; + const Array<const NodeId>& node_list = bc.nodeList(); + parallel_for( + node_list.size(), PUGS_LAMBDA(const size_t i_node) { + const NodeId node_id = node_list[i_node]; - shift[node_id] = txt * shift[node_id]; - }); + shift[node_id] = txt * shift[node_id]; + }); + } else { + throw UnexpectedError("AxisBoundaryCondition make no sense in dimension 1"); + } } else if constexpr (std::is_same_v<BCType, FixedBoundaryCondition>) { const Array<const NodeId>& node_list = bc.nodeList(); @@ -300,6 +304,14 @@ class MeshRandomizerHandler::MeshRandomizer<Dimension>::AxisBoundaryCondition ~AxisBoundaryCondition() = default; }; +template <> +class MeshRandomizerHandler::MeshRandomizer<1>::AxisBoundaryCondition +{ + public: + AxisBoundaryCondition() = default; + ~AxisBoundaryCondition() = default; +}; + template <size_t Dimension> class MeshRandomizerHandler::MeshRandomizer<Dimension>::FixedBoundaryCondition { -- GitLab