@@ -150,3 +150,42 @@ def test_inverse_action(mat_type, rhs_type):
150
150
x = Function (V )
151
151
assemble (action (Ainv , b ), tensor = x )
152
152
assert np .allclose (x .dat .data , f .dat .data , rtol = 1.e-13 )
153
+
154
+
155
+ @pytest .mark .parametrize ("mat_type, rhs_type" , [
156
+ ("slate" , "slate" ), ("slate" , "form" ), ("slate" , "cofunction" ),
157
+ ("aij" , "cofunction" ), ("aij" , "form" ),
158
+ ("matfree" , "cofunction" ), ("matfree" , "form" )])
159
+ def test_solve_interface (mat_type , rhs_type ):
160
+ mesh = UnitSquareMesh (1 , 1 )
161
+ V = FunctionSpace (mesh , "HDivT" , 0 )
162
+ u = TrialFunction (V )
163
+ v = TestFunction (V )
164
+ f = Function (V ).assign (1.0 )
165
+ bcs = DirichletBC (V , f , "on_boundary" )
166
+
167
+ a = avg (inner (u , v ))* dS + inner (u , v )* ds
168
+ A = Tensor (a )
169
+ if mat_type != "slate" :
170
+ A = assemble (A , bcs = bcs , mat_type = mat_type )
171
+ bcs = None
172
+
173
+ L = action (a , f )
174
+ if rhs_type == "form" :
175
+ b = L
176
+ elif rhs_type == "cofunction" :
177
+ b = assemble (L )
178
+ elif rhs_type == "slate" :
179
+ b = Tensor (L )
180
+ else :
181
+ raise ValueError ("Invalid rhs type" )
182
+
183
+ sp = None
184
+ if mat_type == "matfree" :
185
+ sp = {"pc_type" : "none" }
186
+
187
+ x = Function (V )
188
+ problem = LinearVariationalProblem (A , b , x , bcs = bcs )
189
+ solver = LinearVariationalSolver (problem , solver_parameters = sp )
190
+ solver .solve ()
191
+ assert np .allclose (x .dat .data , f .dat .data , rtol = 1.e-13 )
0 commit comments