9
9
def test_linear_problem ():
10
10
mesh = IntervalMesh (10 , 0 , 1 )
11
11
V = FunctionSpace (mesh , "Lagrange" , 1 )
12
-
12
+ R = FunctionSpace ( mesh , "R" , 0 )
13
13
f = Function (V )
14
14
f .vector ()[:] = 1
15
15
16
16
u = TrialFunction (V )
17
17
u_ = Function (V )
18
18
v = TestFunction (V )
19
- bc = DirichletBC (V , Constant ( 1 , domain = mesh ), "on_boundary" )
19
+ bc = DirichletBC (V , Function ( R , val = 1 ), "on_boundary" )
20
20
21
21
def J (f ):
22
22
a = inner (grad (u ), grad (v ))* dx
@@ -60,13 +60,13 @@ def test_nonlinear_problem():
60
60
"""This tests whether nullspace and solver_parameters are passed on in adjoint solves"""
61
61
mesh = IntervalMesh (10 , 0 , 1 )
62
62
V = FunctionSpace (mesh , "Lagrange" , 1 )
63
-
63
+ R = FunctionSpace ( mesh , "R" , 0 )
64
64
f = Function (V )
65
65
f .vector ()[:] = 1
66
66
67
67
u = Function (V )
68
68
v = TestFunction (V )
69
- bc = DirichletBC (V , Constant ( 1 , domain = mesh ), "on_boundary" )
69
+ bc = DirichletBC (V , Function ( R , val = 1 ), "on_boundary" )
70
70
71
71
def J (f ):
72
72
a = f * inner (grad (u ), grad (v ))* dx + u ** 2 * v * dx - f * v * dx
@@ -160,6 +160,7 @@ def test_wrt_function_neumann_boundary():
160
160
mesh = UnitSquareMesh (10 ,10 )
161
161
162
162
V = FunctionSpace (mesh ,"CG" ,1 )
163
+ R = FunctionSpace (mesh ,"R" ,0 )
163
164
u = TrialFunction (V )
164
165
u_ = Function (V )
165
166
v = TestFunction (V )
@@ -169,8 +170,8 @@ def test_wrt_function_neumann_boundary():
169
170
bc2 = DirichletBC (V , 2 , 2 )
170
171
bc = [bc1 ,bc2 ]
171
172
172
- g1 = Constant ( 2 , domain = mesh )
173
- g2 = Constant ( 1 , domain = mesh )
173
+ g1 = Function ( R , val = 2 )
174
+ g2 = Function ( R , val = 1 )
174
175
f = Function (V )
175
176
f .vector ()[:] = 10
176
177
@@ -188,13 +189,14 @@ def J(g1):
188
189
def test_wrt_constant ():
189
190
mesh = IntervalMesh (10 , 0 , 1 )
190
191
V = FunctionSpace (mesh , "Lagrange" , 1 )
192
+ R = FunctionSpace (mesh , "R" , 0 )
191
193
192
- c = Constant ( 1 , domain = mesh )
194
+ c = Function ( R , val = 1 )
193
195
194
196
u = TrialFunction (V )
195
197
u_ = Function (V )
196
198
v = TestFunction (V )
197
- bc = DirichletBC (V , Constant ( 1 , domain = mesh ), "on_boundary" )
199
+ bc = DirichletBC (V , Function ( R , val = 1 ), "on_boundary" )
198
200
199
201
def J (c ):
200
202
a = inner (grad (u ), grad (v ))* dx
@@ -209,6 +211,7 @@ def test_wrt_constant_neumann_boundary():
209
211
mesh = UnitSquareMesh (10 ,10 )
210
212
211
213
V = FunctionSpace (mesh ,"CG" ,1 )
214
+ R = FunctionSpace (mesh ,"R" ,0 )
212
215
u = TrialFunction (V )
213
216
u_ = Function (V )
214
217
v = TestFunction (V )
@@ -218,8 +221,8 @@ def test_wrt_constant_neumann_boundary():
218
221
bc2 = DirichletBC (V , 2 , 2 )
219
222
bc = [bc1 ,bc2 ]
220
223
221
- g1 = Constant ( 2 , domain = mesh )
222
- g2 = Constant ( 1 , domain = mesh )
224
+ g1 = Function ( R , val = 2 )
225
+ g2 = Function ( R , val = 1 )
223
226
f = Function (V )
224
227
f .vector ()[:] = 10
225
228
@@ -240,6 +243,7 @@ def test_time_dependent():
240
243
241
244
# Defining function space, test and trial functions
242
245
V = FunctionSpace (mesh ,"CG" ,1 )
246
+ R = FunctionSpace (mesh ,"R" ,0 )
243
247
u = TrialFunction (V )
244
248
u_ = Function (V )
245
249
v = TestFunction (V )
@@ -252,7 +256,7 @@ def test_time_dependent():
252
256
# Some variables
253
257
T = 0.2
254
258
dt = 0.1
255
- f = Constant ( 1 , domain = mesh )
259
+ f = Function ( R , val = 1 )
256
260
257
261
def J (f ):
258
262
u_1 = Function (V )
@@ -277,11 +281,12 @@ def test_two_nonlinear_solves():
277
281
# regression test for firedrake issue #1841
278
282
mesh = UnitSquareMesh (1 ,1 )
279
283
V = FunctionSpace (mesh , "CG" , 1 )
284
+ R = FunctionSpace (mesh , "R" , 0 )
280
285
v = TestFunction (V )
281
286
u0 = Function (V )
282
287
u1 = Function (V )
283
288
284
- ui = Constant ( 2.0 , domain = mesh )
289
+ ui = Function ( R , val = 2.0 )
285
290
c = Control (ui )
286
291
u0 .assign (ui )
287
292
F = dot (v , (u1 - u0 ))* dx - dot (v , u0 * u1 )* dx
0 commit comments