From c04352063bd6cbb75f2f85dca9e8ca7a0a2afe6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Sat, 20 May 2023 10:50:13 +0200 Subject: [PATCH] Prepare use of R^d -> (R) function for P0 vector interpolation --- .../DiscreteFunctionVectorInterpoler.cpp | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/scheme/DiscreteFunctionVectorInterpoler.cpp b/src/scheme/DiscreteFunctionVectorInterpoler.cpp index b416400c6..57724b772 100644 --- a/src/scheme/DiscreteFunctionVectorInterpoler.cpp +++ b/src/scheme/DiscreteFunctionVectorInterpoler.cpp @@ -96,11 +96,7 @@ template <size_t Dimension> DiscreteFunctionVariant DiscreteFunctionVectorInterpoler::_interpolate() const { - for (const auto& function_id : m_function_id_list) { - const auto& function_descriptor = function_id.descriptor(); - Assert(function_descriptor.domainMappingNode().children[1]->m_data_type == ASTNodeDataType::typename_t); - const ASTNodeDataType& data_type = function_descriptor.domainMappingNode().children[1]->m_data_type.contentType(); - + auto check_data_type = [](const ASTNodeDataType& data_type) { switch (data_type) { case ASTNodeDataType::bool_t: case ASTNodeDataType::unsigned_int_t: @@ -115,7 +111,32 @@ DiscreteFunctionVectorInterpoler::_interpolate() const throw NormalError(os.str()); } } + }; + + if (m_function_id_list.size() == 1) { + const auto& function_descriptor = m_function_id_list[0].descriptor(); + if ((function_descriptor.domainMappingNode().children[1]->m_data_type == ASTNodeDataType::typename_t) or + (function_descriptor.domainMappingNode().children[1]->m_data_type == ASTNodeDataType::tuple_t)) { + const ASTNodeDataType& data_type = function_descriptor.domainMappingNode().children[1]->m_data_type.contentType(); + + check_data_type(data_type); + } else { + throw UnexpectedError("incorrect function"); + } + } else { + for (const auto& function_id : m_function_id_list) { + const auto& function_descriptor = function_id.descriptor(); + if (function_descriptor.domainMappingNode().children[1]->m_data_type == ASTNodeDataType::typename_t) { + const ASTNodeDataType& data_type = + function_descriptor.domainMappingNode().children[1]->m_data_type.contentType(); + + check_data_type(data_type); + } else { + throw UnexpectedError("incorrect function"); + } + } } + return this->_interpolate<Dimension, double>(); } -- GitLab