From 54dfd63654072ed0a2150b35f9deaa8371cba4e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Wed, 19 Feb 2025 09:44:13 +0100
Subject: [PATCH] Add get_mesh:Vh->mesh function to the language

It allows to get the mesh that carries a discrete function
---
 src/language/modules/SchemeModule.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/language/modules/SchemeModule.cpp b/src/language/modules/SchemeModule.cpp
index 40cc703cc..87b48504b 100644
--- a/src/language/modules/SchemeModule.cpp
+++ b/src/language/modules/SchemeModule.cpp
@@ -731,6 +731,20 @@ SchemeModule::SchemeModule()
 
                                                    ));
 
+  this->_addBuiltinFunction("get_mesh",
+                            std::function(
+
+                              [](const std::shared_ptr<const DiscreteFunctionVariant>& discrete_function_variant)
+                                -> std::shared_ptr<const MeshVariant> {
+                                return std::visit(   //
+                                  [](auto&& discrete_function) {
+                                    return discrete_function.meshVariant();   //
+                                  },
+                                  discrete_function_variant->discreteFunction());
+                              }
+
+                              ));
+
   MathFunctionRegisterForVh{*this};
 }
 
-- 
GitLab