@@ -87,7 +87,7 @@ function Gridap.Adaptivity.change_domain_o2n(
87
87
f_old,
88
88
old_trian:: Triangulation{Dc} ,
89
89
new_trian:: AdaptedTriangulation ,
90
- glue:: AdaptivityGlue ) where {Dc}
90
+ glue:: AdaptivityGlue{<:Gridap.Adaptivity.MixedGlue} ) where {Dc}
91
91
92
92
oglue = get_glue (old_trian,Val (Dc))
93
93
nglue = get_glue (new_trian,Val (Dc))
@@ -143,38 +143,34 @@ struct OldToNewField <: Gridap.Fields.Field
143
143
end
144
144
145
145
function OldToNewField (old_fields:: AbstractArray{<:Gridap.Fields.Field} ,rrule:: RefinementRule ,child_id:: Integer )
146
- if length (old_fields)== 1
146
+ if child_id != - 1
147
+ @assert length (old_fields)== 1
147
148
cell_map = get_cell_map (rrule)[child_id]
148
149
old_field= old_fields[1 ]
149
150
fine_to_coarse_field= Gridap. Adaptivity. FineToCoarseField (
150
151
[old_field for i= 1 : Gridap. Adaptivity. num_subcells (rrule)],
151
- rrule)
152
+ rrule,
153
+ [i for i= 1 : Gridap. Adaptivity. num_subcells (rrule)])
152
154
refined_or_untouched_field= old_field∘ cell_map
153
155
OldToNewField (RefinedOrUntouchedNewFieldType (),fine_to_coarse_field,refined_or_untouched_field)
154
156
else
155
- Gridap. Helpers. @check length (old_fields) == Gridap. Adaptivity. num_subcells (rrule)
156
- Gridap. Helpers. @check child_id== - 1
157
+ @assert length (old_fields) <= Gridap. Adaptivity. num_subcells (rrule)
158
+ if (length (old_fields)== Gridap. Adaptivity. num_subcells (rrule))
159
+ # Use optimized version of FineToCoarseField (we can do this for the coarsened owned cells)
160
+ child_ids= [i for i= 1 : length (old_fields)]
161
+ fine_to_coarse_field= Gridap. Adaptivity. FineToCoarseField (old_fields,rrule,child_ids)
162
+ else
163
+ # For the ghost coarsened cells we are missing information. Namely the child_ids of the children.
164
+ # TO-DO: by now we can use the wrong child_ids, but we should fix this in the future.
165
+ child_ids= [i for i= 1 : length (old_fields)]
166
+ fine_to_coarse_field= Gridap. Adaptivity. FineToCoarseField (old_fields,rrule,child_ids)
167
+ end
157
168
cell_map = get_cell_map (rrule)[1 ]
158
- fine_to_coarse_field= Gridap. Adaptivity. FineToCoarseField (old_fields,rrule)
159
169
refined_or_untouched_field= old_fields[1 ]∘ cell_map
160
170
OldToNewField (CoarsenedNewFieldType (),fine_to_coarse_field,refined_or_untouched_field)
161
171
end
162
172
end
163
173
164
- function OldToNewField (old_field:: Gridap.Fields.Field ,rrule:: RefinementRule ,child_id:: Integer )
165
- Gridap. Helpers. @notimplemented
166
- end
167
-
168
- # # Necessary for distributed meshes, where not all children of a coarse cell may belong to the processor.
169
- # function FineToCoarseField(fine_fields::AbstractArray{<:Field},rrule::RefinementRule,child_ids::AbstractArray{<:Integer})
170
- # fields = Vector{Field}(undef,num_subcells(rrule))
171
- # fields = fill!(fields,ConstantField(0.0))
172
- # for (k,id) in enumerate(child_ids)
173
- # fields[id] = fine_fields[k]
174
- # end
175
- # return FineToCoarseField(fields,rrule)
176
- # end
177
-
178
174
function Gridap. Fields. return_cache (a:: OldToNewField ,x:: AbstractArray{<:Point} )
179
175
f2c_cache= Gridap. Fields. return_cache (a. fine_to_coarse_field,x)
180
176
rou_cache= Gridap. Fields. return_cache (a. refined_or_untouched_field,x)
@@ -190,15 +186,4 @@ function Gridap.Fields.evaluate!(cache,a::OldToNewField,x::AbstractArray{<:Point
190
186
f2c_cache,rou_cache = cache
191
187
Gridap. Fields. evaluate! (rou_cache,a. refined_or_untouched_field,x)
192
188
end
193
- end
194
-
195
- # Fast evaluation of FineToCoarseFields:
196
- # Points are pre-classified into the children cells, which allows for the search to be
197
- # skipped entirely.
198
- function Gridap. Fields. return_cache (a:: OldToNewField ,x:: AbstractArray{<:Point} ,child_ids:: AbstractArray{<:Integer} )
199
- Gridap. Helpers. @notimplemented
200
- end
201
-
202
- function Gridap. Fields. evaluate! (cache,a:: OldToNewField ,x:: AbstractArray{<:Point} ,child_ids:: AbstractArray{<:Integer} )
203
- Gridap. Helpers. @notimplemented
204
189
end
0 commit comments