From 627ec220b940e1d44f74c896624d5c0d8d1aed58 Mon Sep 17 00:00:00 2001
From: Paul Dechamps <paul.dechamps@uliege.be>
Date: Thu, 14 Dec 2023 14:47:32 +0100
Subject: [PATCH] (def) Prevent computation for too small mesh

DDicretization now throws a runtime error if the mesh size is < 2 elements.
---
 blast/src/DDiscretization.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/blast/src/DDiscretization.cpp b/blast/src/DDiscretization.cpp
index 032e2d8..9a6796b 100644
--- a/blast/src/DDiscretization.cpp
+++ b/blast/src/DDiscretization.cpp
@@ -17,6 +17,8 @@ void Discretization::setGlob(std::vector<double> &_x, std::vector<double> &_y, s
 {
     if (_x.size() != _y.size() || _y.size() != _z.size() || _x.size() != _z.size())
         throw std::runtime_error("blast::Discretization Wrong mesh sizes.\n");
+    if (_x.size() < 2 || _y.size() < 2 || _z.size() < 2)
+        throw std::runtime_error("blast::Discretization Mesh too small.\n");
 
     nMarkers = _x.size();
     x.resize(nMarkers, 0.);
-- 
GitLab