diff --git a/src/language/modules/SchemeModule.cpp b/src/language/modules/SchemeModule.cpp index 5d397223996c592687707711150705056e57879c..bc744e4d3318a6c5eda1981dccf4709430fbde35 100644 --- a/src/language/modules/SchemeModule.cpp +++ b/src/language/modules/SchemeModule.cpp @@ -158,19 +158,6 @@ SchemeModule::SchemeModule() )); - this->_addBuiltinFunction( - "interpolate", - std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr< - const IDiscreteFunction>(std::shared_ptr<const IMesh>, std::shared_ptr<const IDiscreteFunctionDescriptor>, - const std::vector<FunctionSymbolId>&)>>( - [](std::shared_ptr<const IMesh> mesh, - std::shared_ptr<const IDiscreteFunctionDescriptor> discrete_function_descriptor, - const std::vector<FunctionSymbolId>& function_id_list) -> std::shared_ptr<const IDiscreteFunction> { - return DiscreteFunctionVectorInterpoler{mesh, discrete_function_descriptor, function_id_list}.interpolate(); - } - - )); - this->_addBuiltinFunction("interpolate", std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr< const IDiscreteFunction>(std::shared_ptr<const IMesh>, @@ -182,9 +169,25 @@ SchemeModule::SchemeModule() std::shared_ptr<const IDiscreteFunctionDescriptor> discrete_function_descriptor, const std::vector<FunctionSymbolId>& function_id_list) -> std::shared_ptr<const IDiscreteFunction> { - return DiscreteFunctionVectorInterpoler{mesh, interpolation_zone_list, - discrete_function_descriptor, function_id_list} - .interpolate(); + switch (discrete_function_descriptor->type()) { + case DiscreteFunctionType::P0: { + if (function_id_list.size() != 1) { + throw NormalError("invalid function descriptor type"); + } + return DiscreteFunctionInterpoler{mesh, interpolation_zone_list, + discrete_function_descriptor, function_id_list[0]} + .interpolate(); + } + case DiscreteFunctionType::P0Vector: { + return DiscreteFunctionVectorInterpoler{mesh, interpolation_zone_list, + discrete_function_descriptor, + function_id_list} + .interpolate(); + } + default: { + throw NormalError("invalid function descriptor type"); + } + } } )); @@ -193,16 +196,19 @@ SchemeModule::SchemeModule() "interpolate", std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr< const IDiscreteFunction>(std::shared_ptr<const IMesh>, std::shared_ptr<const IDiscreteFunctionDescriptor>, - const FunctionSymbolId&)>>( + const std::vector<FunctionSymbolId>&)>>( [](std::shared_ptr<const IMesh> mesh, std::shared_ptr<const IDiscreteFunctionDescriptor> discrete_function_descriptor, - const FunctionSymbolId& function_id) -> std::shared_ptr<const IDiscreteFunction> { + const std::vector<FunctionSymbolId>& function_id_list) -> std::shared_ptr<const IDiscreteFunction> { switch (discrete_function_descriptor->type()) { case DiscreteFunctionType::P0: { - return DiscreteFunctionInterpoler{mesh, discrete_function_descriptor, function_id}.interpolate(); + if (function_id_list.size() != 1) { + throw NormalError("invalid function descriptor type"); + } + return DiscreteFunctionInterpoler{mesh, discrete_function_descriptor, function_id_list[0]}.interpolate(); } case DiscreteFunctionType::P0Vector: { - return DiscreteFunctionVectorInterpoler{mesh, discrete_function_descriptor, {function_id}}.interpolate(); + return DiscreteFunctionVectorInterpoler{mesh, discrete_function_descriptor, function_id_list}.interpolate(); } default: { throw NormalError("invalid function descriptor type"); @@ -212,71 +218,6 @@ SchemeModule::SchemeModule() )); - this->_addBuiltinFunction("interpolate", - std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr< - const IDiscreteFunction>(std::shared_ptr<const IMesh>, - const std::vector<std::shared_ptr<const IZoneDescriptor>>&, - std::shared_ptr<const IDiscreteFunctionDescriptor>, - const FunctionSymbolId&)>>( - [](std::shared_ptr<const IMesh> mesh, - const std::vector<std::shared_ptr<const IZoneDescriptor>>& interpolation_zone_list, - std::shared_ptr<const IDiscreteFunctionDescriptor> discrete_function_descriptor, - const FunctionSymbolId& function_id) -> std::shared_ptr<const IDiscreteFunction> { - switch (discrete_function_descriptor->type()) { - case DiscreteFunctionType::P0: { - return DiscreteFunctionInterpoler{mesh, interpolation_zone_list, - discrete_function_descriptor, function_id} - .interpolate(); - } - case DiscreteFunctionType::P0Vector: { - return DiscreteFunctionVectorInterpoler{mesh, - interpolation_zone_list, - discrete_function_descriptor, - {function_id}} - .interpolate(); - } - default: { - throw NormalError("invalid function descriptor type"); - } - } - } - - )); - - this - ->_addBuiltinFunction("interpolate", - std::make_shared<BuiltinFunctionEmbedder< - std::shared_ptr<const IDiscreteFunction>(std::shared_ptr<const IMesh>, - std::shared_ptr<const IZoneDescriptor>, - std::shared_ptr<const IDiscreteFunctionDescriptor>, - const FunctionSymbolId&)>>( - [](std::shared_ptr<const IMesh> mesh, - std::shared_ptr<const IZoneDescriptor> interpolation_zone, - std::shared_ptr<const IDiscreteFunctionDescriptor> discrete_function_descriptor, - const FunctionSymbolId& function_id) -> std::shared_ptr<const IDiscreteFunction> { - switch (discrete_function_descriptor->type()) { - case DiscreteFunctionType::P0: { - return DiscreteFunctionInterpoler{mesh, - {interpolation_zone}, - discrete_function_descriptor, - function_id} - .interpolate(); - } - case DiscreteFunctionType::P0Vector: { - return DiscreteFunctionVectorInterpoler{mesh, - {interpolation_zone}, - discrete_function_descriptor, - {function_id}} - .interpolate(); - } - default: { - throw NormalError("invalid function descriptor type"); - } - } - } - - )); - this->_addBuiltinFunction("randomizeMesh", std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr< const IMesh>(std::shared_ptr<const IMesh>,