@@ -58,18 +58,17 @@ def prolong(coarse, fine):
58
58
repeat = (fine_level - coarse_level )* refinements_per_level
59
59
next_level = coarse_level * refinements_per_level
60
60
61
- element = Vc .ufl_element ()
62
61
meshes = hierarchy ._meshes
63
62
for j in range (repeat ):
64
63
next_level += 1
65
64
if j == repeat - 1 :
66
65
next = fine
67
66
Vf = fine .function_space ()
68
67
else :
69
- Vf = firedrake . FunctionSpace ( meshes [next_level ], element )
68
+ Vf = Vc . reconstruct ( mesh = meshes [next_level ])
70
69
next = firedrake .Function (Vf )
71
70
72
- coarse_coords = Vc . mesh (). coordinates
71
+ coarse_coords = get_coordinates ( Vc )
73
72
fine_to_coarse = utils .fine_node_to_coarse_node_map (Vf , Vc )
74
73
fine_to_coarse_coords = utils .fine_node_to_coarse_node_map (Vf , coarse_coords .function_space ())
75
74
kernel = kernels .prolong_kernel (coarse )
@@ -119,7 +118,6 @@ def restrict(fine_dual, coarse_dual):
119
118
repeat = (fine_level - coarse_level )* refinements_per_level
120
119
next_level = fine_level * refinements_per_level
121
120
122
- element = Vc .ufl_element ()
123
121
meshes = hierarchy ._meshes
124
122
125
123
for j in range (repeat ):
@@ -128,15 +126,15 @@ def restrict(fine_dual, coarse_dual):
128
126
coarse_dual .dat .zero ()
129
127
next = coarse_dual
130
128
else :
131
- Vc = firedrake . FunctionSpace ( meshes [next_level ], element )
129
+ Vc = Vf . reconstruct ( mesh = meshes [next_level ])
132
130
next = firedrake .Cofunction (Vc .dual ())
133
131
Vc = next .function_space ()
134
132
# XXX: Should be able to figure out locations by pushing forward
135
133
# reference cell node locations to physical space.
136
134
# x = \sum_i c_i \phi_i(x_hat)
137
- node_locations = utils .physical_node_locations (Vf )
135
+ node_locations = utils .physical_node_locations (Vf . dual () )
138
136
139
- coarse_coords = Vc .mesh (). coordinates
137
+ coarse_coords = get_coordinates ( Vc .dual ())
140
138
fine_to_coarse = utils .fine_node_to_coarse_node_map (Vf , Vc )
141
139
fine_to_coarse_coords = utils .fine_node_to_coarse_node_map (Vf , coarse_coords .function_space ())
142
140
# Have to do this, because the node set core size is not right for
@@ -195,7 +193,6 @@ def inject(fine, coarse):
195
193
repeat = (fine_level - coarse_level )* refinements_per_level
196
194
next_level = fine_level * refinements_per_level
197
195
198
- element = Vc .ufl_element ()
199
196
meshes = hierarchy ._meshes
200
197
201
198
for j in range (repeat ):
@@ -205,12 +202,12 @@ def inject(fine, coarse):
205
202
next = coarse
206
203
Vc = next .function_space ()
207
204
else :
208
- Vc = firedrake . FunctionSpace ( meshes [next_level ], element )
205
+ Vc = Vf . reconstruct ( mesh = meshes [next_level ])
209
206
next = firedrake .Function (Vc )
210
207
if not dg :
211
208
node_locations = utils .physical_node_locations (Vc )
212
209
213
- fine_coords = Vf . mesh (). coordinates
210
+ fine_coords = get_coordinates ( Vf )
214
211
coarse_node_to_fine_nodes = utils .coarse_node_to_fine_node_map (Vc , Vf )
215
212
coarse_node_to_fine_coords = utils .coarse_node_to_fine_node_map (Vc , fine_coords .function_space ())
216
213
@@ -242,3 +239,11 @@ def inject(fine, coarse):
242
239
fine = next
243
240
Vf = Vc
244
241
return coarse
242
+
243
+
244
+ def get_coordinates (V ):
245
+ coords = V .mesh ().coordinates
246
+ if V .boundary_set :
247
+ W = V .reconstruct (element = coords .function_space ().ufl_element ())
248
+ coords = firedrake .Function (W ).interpolate (coords )
249
+ return coords
0 commit comments