diff --git a/src/language/modules/SchemeModule.cpp b/src/language/modules/SchemeModule.cpp index 08df9ba86ecb63a18bbb9e55fae1adfa544fcb23..5d397223996c592687707711150705056e57879c 100644 --- a/src/language/modules/SchemeModule.cpp +++ b/src/language/modules/SchemeModule.cpp @@ -243,6 +243,40 @@ SchemeModule::SchemeModule() )); + 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>,