added custom math function capability with custom headers. You can create your own math function like this
from ufl.mathfunctions import MathFunction
class MyFunction(MathFunction)
def format(self,v):
if self._order == 0.5 and self._use_approx:
return "semifem::fd_integral_half_approximation("+v+")"
elif self._order == -0.5 and self._use_approx:
return "semifem::fd_integral_mhalf_approximation("+v+")"
else:
raise NotImplementedError
def derivative(self, ):
"""Used in ufl.algorithms.forward_ad"""
return self.__class__(self._order-1, self._argument, self._n+1)
def _ufl_expr_reconstruct_(self, argument):
"Return a new object of the same type with new operands."
return self.__class__(self._order, argument, self._n )
added custom math function capability with custom headers. You can create your own math function like this
from ufl.mathfunctions import MathFunction class MyFunction(MathFunction) def format(self,v): if self._order == 0.5 and self._use_approx: return "semifem::fd_integral_half_approximation("+v+")" elif self._order == -0.5 and self._use_approx: return "semifem::fd_integral_mhalf_approximation("+v+")" else: raise NotImplementedError def derivative(self, ): """Used in ufl.algorithms.forward_ad""" return self.__class__(self._order-1, self._argument, self._n+1) def _ufl_expr_reconstruct_(self, argument): "Return a new object of the same type with new operands." return self.__class__(self._order, argument, self._n )