@@ -167,13 +167,13 @@ if !@isdefined(T8CODE_OBJECT_TRACKER)
167
167
end
168
168
169
169
"""
170
- T8codeForestWrapper
170
+ ForestWrapper
171
171
172
172
Lightweight `t8_forest_t` pointer wrapper which helps to free
173
173
resources allocated by t8code in an orderly fashion.
174
174
175
175
When initialized with a t8code forest pointer the wrapper
176
- registers itself with a t8code object tracker called `__T8CODE_OBJECT_TRACKER `.
176
+ registers itself with a t8code object tracker called `T8CODE_OBJECT_TRACKER `.
177
177
178
178
In serial mode the wrapper and in consequence the t8code forest
179
179
can be finalized immediately whenever Julia's garbage collector sees fit.
@@ -182,22 +182,20 @@ In (MPI) parallel mode the wrapper (and the t8code forest) is kept till the end
182
182
of the session or when finalized explicitly. At the end of the session (resp.
183
183
when the program shuts down) the object tracker finalizes all registered t8code
184
184
objects in sync with all MPI ranks. This is necessary since t8code internally
185
- allocates MPI shared arrays. See `src/auxiliary/t8code.jl` for the finalization
186
- code when Trixi is shutting down.
185
+ allocates MPI shared arrays.
187
186
"""
188
187
mutable struct ForestWrapper
189
188
pointer:: Ptr{t8_forest} # cpointer to t8code forest
190
- unique_id:: UInt
191
189
192
190
function ForestWrapper (pointer:: Ptr{t8_forest} )
193
191
wrapper = new (pointer)
194
192
195
- # Compute the unique id from the T8codeForestWrapper object.
196
- wrapper . unique_id = pointer_from_objref (wrapper)
193
+ # Compute a unique id from the ForestWrapper object.
194
+ unique_id = UInt64 ( pointer_from_objref (wrapper) )
197
195
198
196
if MPI. Comm_size (MPI. Comm (t8_forest_get_mpicomm (pointer))) > 1
199
197
# Make sure the unique id is identical for each MPI rank.
200
- wrapper . unique_id = MPI. bcast (wrapper . unique_id, MPI. Comm (t8_forest_get_mpicomm (pointer)))
198
+ unique_id = MPI. bcast (unique_id, MPI. Comm (t8_forest_get_mpicomm (pointer)))
201
199
end
202
200
203
201
finalizer (wrapper) do wrapper
@@ -211,11 +209,11 @@ mutable struct ForestWrapper
211
209
t8_forest_unref (Ref (wrapper. pointer))
212
210
213
211
# Deregister from the object tracker.
214
- delete! (T8CODE_OBJECT_TRACKER, wrapper . unique_id)
212
+ delete! (T8CODE_OBJECT_TRACKER, unique_id)
215
213
end
216
214
217
215
# Register the T8codeForestWrapper with the object tracker.
218
- T8CODE_OBJECT_TRACKER[wrapper . unique_id] = wrapper
216
+ T8CODE_OBJECT_TRACKER[unique_id] = wrapper
219
217
end
220
218
end
221
219
0 commit comments