From 191165267635133f346ea7f4f1d9a27fc1c2e6b9 Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Thu, 13 Feb 2020 08:58:12 +0100 Subject: [PATCH] Add MeshNormalFunctor --- .../framework_integration/astnodes.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pystencils_autodiff/framework_integration/astnodes.py b/src/pystencils_autodiff/framework_integration/astnodes.py index df11dab..4b0b830 100644 --- a/src/pystencils_autodiff/framework_integration/astnodes.py +++ b/src/pystencils_autodiff/framework_integration/astnodes.py @@ -328,3 +328,20 @@ class DynamicFunction(sp.Function): def __repr__(self): return self.__str__() + + +class MeshNormalFunctor(DynamicFunction): + def __new__(cls, mesh_name, base_dtype, *args): + from pystencils.data_types import TypedMatrixSymbol + + A = TypedMatrixSymbol('A', 3, 1, base_dtype, 'Vector3<real_t>') + obj = DynamicFunction.__new__(cls, + TypedSymbol(str(mesh_name), + 'std::function<Vector3<real_t>(int, int, int)>'), + A.dtype, + *args) + obj.mesh_name = mesh_name + return obj + + def __getnewargs__(self): + return self.mesh_name, self.dtype.base_dtype, self.args[2:] -- GitLab