3535)
3636from ufl .algorithms .expand_indices import expand_indices
3737from ufl .core .interpolate import Interpolate
38- from ufl .form import FormSum
38+ from ufl .form import Form , FormSum
3939from ufl .pullback import identity_pullback
4040from ufl .sobolevspace import H1
4141
@@ -110,7 +110,7 @@ def test_action_adjoint(V1, V2):
110110 Iu = Interpolate (u , vstar )
111111
112112 v1 = TrialFunction (V1 )
113- Iv = Interpolate (v1 , vstar )
113+ Iv = Interpolate (v1 , vstar ) # V1 -> V2
114114
115115 assert Iv .argument_slots () == (vstar , v1 )
116116 assert Iv .arguments () == (vstar , v1 )
@@ -126,6 +126,18 @@ def test_action_adjoint(V1, V2):
126126 # -- Adjoint -- #
127127 adjoint (Iv ) == Adjoint (Iv )
128128
129+ # action of one-form on interpolation operator
130+ one_form = Argument (V2 , 0 ) * dx
131+ action_one_form = action (one_form , Iv ) # adjoint interpolation V2^* -> V1^*
132+ assert isinstance (action_one_form , Interpolate )
133+ assert action_one_form .arguments () == (Argument (V1 , 0 ),)
134+ assert action_one_form .ufl_function_space () == V1 .dual ()
135+
136+ # zero-form case
137+ action_zero_form = action (one_form , Iu ) # a number
138+ assert isinstance (action_zero_form , Form )
139+ assert action_zero_form .arguments () == ()
140+
129141
130142def test_differentiation (V1 , V2 ):
131143 u = Coefficient (V1 )
@@ -180,6 +192,12 @@ def test_differentiation(V1, V2):
180192 # Need to expand indices to be able to match equal (different MultiIndex used for both).
181193 assert expand_indices (dFdIu ) == expand_indices (dFdw )
182194
195+ # Derivative of form I(u, V2) wrt coefficient u
196+ J = Iu * dx
197+ dJdu = expand_derivatives (derivative (J , u ))
198+ assert isinstance (dJdu , Interpolate )
199+ assert dJdu .arguments () == (Argument (V1 , 0 ),)
200+
183201
184202def test_extract_base_form_operators (V1 , V2 ):
185203 u = Coefficient (V1 )
0 commit comments