@@ -58,18 +58,17 @@ def prolong(coarse, fine):
5858 repeat = (fine_level - coarse_level )* refinements_per_level
5959 next_level = coarse_level * refinements_per_level
6060
61- element = Vc .ufl_element ()
6261 meshes = hierarchy ._meshes
6362 for j in range (repeat ):
6463 next_level += 1
6564 if j == repeat - 1 :
6665 next = fine
6766 Vf = fine .function_space ()
6867 else :
69- Vf = firedrake . FunctionSpace ( meshes [next_level ], element )
68+ Vf = Vc . reconstruct ( mesh = meshes [next_level ])
7069 next = firedrake .Function (Vf )
7170
72- coarse_coords = Vc . mesh (). coordinates
71+ coarse_coords = get_coordinates ( Vc )
7372 fine_to_coarse = utils .fine_node_to_coarse_node_map (Vf , Vc )
7473 fine_to_coarse_coords = utils .fine_node_to_coarse_node_map (Vf , coarse_coords .function_space ())
7574 kernel = kernels .prolong_kernel (coarse )
@@ -119,7 +118,6 @@ def restrict(fine_dual, coarse_dual):
119118 repeat = (fine_level - coarse_level )* refinements_per_level
120119 next_level = fine_level * refinements_per_level
121120
122- element = Vc .ufl_element ()
123121 meshes = hierarchy ._meshes
124122
125123 for j in range (repeat ):
@@ -128,15 +126,15 @@ def restrict(fine_dual, coarse_dual):
128126 coarse_dual .dat .zero ()
129127 next = coarse_dual
130128 else :
131- Vc = firedrake . FunctionSpace ( meshes [next_level ], element )
129+ Vc = Vf . reconstruct ( mesh = meshes [next_level ])
132130 next = firedrake .Cofunction (Vc .dual ())
133131 Vc = next .function_space ()
134132 # XXX: Should be able to figure out locations by pushing forward
135133 # reference cell node locations to physical space.
136134 # 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 () )
138136
139- coarse_coords = Vc .mesh (). coordinates
137+ coarse_coords = get_coordinates ( Vc .dual ())
140138 fine_to_coarse = utils .fine_node_to_coarse_node_map (Vf , Vc )
141139 fine_to_coarse_coords = utils .fine_node_to_coarse_node_map (Vf , coarse_coords .function_space ())
142140 # Have to do this, because the node set core size is not right for
@@ -195,7 +193,6 @@ def inject(fine, coarse):
195193 repeat = (fine_level - coarse_level )* refinements_per_level
196194 next_level = fine_level * refinements_per_level
197195
198- element = Vc .ufl_element ()
199196 meshes = hierarchy ._meshes
200197
201198 for j in range (repeat ):
@@ -205,12 +202,12 @@ def inject(fine, coarse):
205202 next = coarse
206203 Vc = next .function_space ()
207204 else :
208- Vc = firedrake . FunctionSpace ( meshes [next_level ], element )
205+ Vc = Vf . reconstruct ( mesh = meshes [next_level ])
209206 next = firedrake .Function (Vc )
210207 if not dg :
211208 node_locations = utils .physical_node_locations (Vc )
212209
213- fine_coords = Vf . mesh (). coordinates
210+ fine_coords = get_coordinates ( Vf )
214211 coarse_node_to_fine_nodes = utils .coarse_node_to_fine_node_map (Vc , Vf )
215212 coarse_node_to_fine_coords = utils .coarse_node_to_fine_node_map (Vc , fine_coords .function_space ())
216213
@@ -242,3 +239,11 @@ def inject(fine, coarse):
242239 fine = next
243240 Vf = Vc
244241 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