|  | 
| 1 | 1 | """Functionals used to define the dual sets.""" | 
| 2 | 2 | from .symbolic import subs, x, t | 
| 3 | 3 | from .vectors import vdot | 
|  | 4 | +from .calculus import derivative, jacobian_component | 
| 4 | 5 | 
 | 
| 5 | 6 | 
 | 
| 6 | 7 | class BaseFunctional: | 
| @@ -47,6 +48,66 @@ def entity_dim(self): | 
| 47 | 48 |     name = "Point evaluation" | 
| 48 | 49 | 
 | 
| 49 | 50 | 
 | 
|  | 51 | +class PointDirectionalDerivativeEvaluation(BaseFunctional): | 
|  | 52 | +    """A point evaluation of a derivative in a fixed direction.""" | 
|  | 53 | + | 
|  | 54 | +    def __init__(self, point, direction, entity_dim=None): | 
|  | 55 | +        self.point = point | 
|  | 56 | +        self.dir = direction | 
|  | 57 | +        self._entity_dim = entity_dim | 
|  | 58 | + | 
|  | 59 | +    def eval(self, function): | 
|  | 60 | +        """Apply to the functional to a function.""" | 
|  | 61 | +        return subs(derivative(function, self.dir), x, self.point) | 
|  | 62 | + | 
|  | 63 | +    def dof_point(self): | 
|  | 64 | +        """Get the location of the DOF in the cell.""" | 
|  | 65 | +        return self.point | 
|  | 66 | + | 
|  | 67 | +    def dof_direction(self): | 
|  | 68 | +        """Get the direction of the DOF.""" | 
|  | 69 | +        return self.dir | 
|  | 70 | + | 
|  | 71 | +    def entity_dim(self): | 
|  | 72 | +        """Get the dimension of the entitiy this DOF is associated with.""" | 
|  | 73 | +        return self._entity_dim | 
|  | 74 | + | 
|  | 75 | +    name = "Point evaluation of directional derivative" | 
|  | 76 | + | 
|  | 77 | + | 
|  | 78 | +class PointNormalDerivativeEvaluation(PointDirectionalDerivativeEvaluation): | 
|  | 79 | +    """A point evaluation of a normal derivative.""" | 
|  | 80 | + | 
|  | 81 | +    def __init__(self, point, edge): | 
|  | 82 | +        super().__init__(point, edge.normal(), entity_dim=edge.tdim) | 
|  | 83 | +        self.reference = edge | 
|  | 84 | + | 
|  | 85 | +    name = "Point evaluation of normal derivative" | 
|  | 86 | + | 
|  | 87 | + | 
|  | 88 | +class PointComponentSecondDerivativeEvaluation(BaseFunctional): | 
|  | 89 | +    """A point evaluation of a component of a second derivative.""" | 
|  | 90 | + | 
|  | 91 | +    def __init__(self, point, component, entity_dim=None): | 
|  | 92 | +        self.point = point | 
|  | 93 | +        self.component = component | 
|  | 94 | +        self._entity_dim = entity_dim | 
|  | 95 | + | 
|  | 96 | +    def eval(self, function): | 
|  | 97 | +        """Apply to the functional to a function.""" | 
|  | 98 | +        return subs(jacobian_component(function, self.component), x, self.point) | 
|  | 99 | + | 
|  | 100 | +    def dof_point(self): | 
|  | 101 | +        """Get the location of the DOF in the cell.""" | 
|  | 102 | +        return self.point | 
|  | 103 | + | 
|  | 104 | +    def entity_dim(self): | 
|  | 105 | +        """Get the dimension of the entitiy this DOF is associated with.""" | 
|  | 106 | +        return self._entity_dim | 
|  | 107 | + | 
|  | 108 | +    name = "Point evaluation of Jacobian component" | 
|  | 109 | + | 
|  | 110 | + | 
| 50 | 111 | class PointInnerProduct(BaseFunctional): | 
| 51 | 112 |     """An evaluation of an inner product at a point.""" | 
| 52 | 113 | 
 | 
|  | 
0 commit comments