Skip to content
Snippets Groups Projects
Commit 76038007 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add P0Vector discrete functions interpolation from single scalar function

parent 5b31abc6
No related branches found
No related tags found
1 merge request!89Add missing compatibility check when affecting lists to R^d or R^dxd
......@@ -10,6 +10,7 @@
#include <scheme/AcousticSolver.hpp>
#include <scheme/DirichletBoundaryConditionDescriptor.hpp>
#include <scheme/DiscreteFunctionDescriptorP0.hpp>
#include <scheme/DiscreteFunctionDescriptorP0Vector.hpp>
#include <scheme/DiscreteFunctionInterpoler.hpp>
#include <scheme/DiscreteFunctionUtils.hpp>
#include <scheme/DiscreteFunctionVectorInterpoler.hpp>
......@@ -44,6 +45,15 @@ SchemeModule::SchemeModule()
));
this->_addBuiltinFunction("P0Vector",
std::make_shared<
BuiltinFunctionEmbedder<std::shared_ptr<const IDiscreteFunctionDescriptor>()>>(
[]() -> std::shared_ptr<const IDiscreteFunctionDescriptor> {
return std::make_shared<DiscreteFunctionDescriptorP0Vector>();
}
));
this->_addBuiltinFunction(
"interpolate",
std::make_shared<BuiltinFunctionEmbedder<std::shared_ptr<
......@@ -65,8 +75,18 @@ SchemeModule::SchemeModule()
[](std::shared_ptr<const IMesh> mesh,
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, discrete_function_descriptor, function_id}.interpolate();
}
case DiscreteFunctionType::P0Vector: {
return DiscreteFunctionVectorInterpoler{mesh, discrete_function_descriptor, {function_id}}.interpolate();
}
default: {
throw NormalError("invalid function descriptor type");
}
}
}
));
......
......@@ -49,6 +49,10 @@ DiscreteFunctionVectorInterpoler::_interpolate() const
std::shared_ptr<IDiscreteFunction>
DiscreteFunctionVectorInterpoler::interpolate() const
{
if (m_discrete_function_descriptor->type() != DiscreteFunctionType::P0Vector) {
throw NormalError("invalid discrete function type for vector interpolation");
}
std::shared_ptr<IDiscreteFunction> discrete_function;
switch (m_mesh->dimension()) {
case 1: {
......@@ -64,5 +68,4 @@ DiscreteFunctionVectorInterpoler::interpolate() const
throw UnexpectedError("invalid dimension");
}
}
return nullptr;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment