@@ -50,11 +50,11 @@ function nonAdaptiveTOCollocation(
5050
5151 # Calculate the integral of shape function in the domain (dof order)
5252 shape_function_weights_domain_original = undoBCS (ctx_domain,
53- vec (sum (assembleMassMatrix ( ctx_domain, bdata= bdata_domain), dims= 1 )),
53+ vec (sum (assemble ( Mass (), ctx_domain, bdata= bdata_domain), dims= 1 )),
5454 bdata_domain)
5555 # Calculate the integral of shape functions in the codomain (dof order)
5656 # Do not include boundary conditions here, as we end up summing over this later
57- shape_function_weights_codomain = vec (sum (assembleMassMatrix ( ctx_codomain),dims= 1 ))
57+ shape_function_weights_codomain = vec (sum (assemble ( Mass (), ctx_codomain), dims= 1 ))
5858
5959 # This variable will hold approximate pullback (in the measure sense)
6060 # of shape_function_weights_codomain to domain via finv
@@ -102,23 +102,28 @@ function nonAdaptiveTOCollocation(
102102end
103103
104104"""
105- adaptiveTOCollocationStiffnessMatrix(ctx,flow_maps,times=nothing; [quadrature_order, on_torus,on_cylinder, LL, UR, bdata, volume_preserving=true,flow_map_mode=0] )
105+ adaptiveTOCollocationStiffnessMatrix(ctx, flow_maps, times=nothing; [quadrature_order, on_torus,on_cylinder, LL, UR, bdata, volume_preserving=true, flow_map_mode=0] )
106106
107- Calculate the matrix-representation of the bilinear form ``a(u,v) = 1/N \\ sum_n^N a_1(I_hT_nu,I_hT_nv)`` where
108- ``I_h`` is pointwise interpolation of the grid obtained by doing Delaunay triangulation on images of grid points from ctx
109- and ``T_n`` is the Transfer-operator for ``x \\ mapsto flow_maps(x,times)[n]`` and ``a_1`` is the weak form of the Laplacian on the codomain. Moreover,
110- ``N`` in the equation above is equal to `length(times)` and ``t_n`` ranges over the elements of `times`.
107+ Calculate the matrix-representation of the bilinear form ``a(u,v) = 1/N \\ sum_n^N a_1(I_hT_nu,I_hT_nv)``
108+ where ``I_h`` is pointwise interpolation of the grid obtained by doing Delaunay
109+ triangulation on images of grid points from `ctx` and ``T_n`` is the transfer operator for
110+ ``x \\ mapsto flow_maps(x, times)[n]`` and ``a_1`` is the weak form of the Laplacian on the
111+ codomain. Moreover, ``N`` in the equation above is equal to `length(times)` and ``t_n``
112+ ranges over the elements of `times`.
111113
112- If `times==nothing`, take ``N=1`` above and use the map ``x \\ mapsto flow_maps(x)` instead of the version with `t_n`.
114+ If `times==nothing`, take ``N=1`` above and use the map ``x \\ mapsto flow_maps(x)`` instead
115+ of the version with `t_n`.
113116
114- If `on_torus` is true, the Delaunay Triangulation is done on the torus.
115- If `on_cylinder` is true, then triangulation is done on cylinder (periodic) x. In both of these cases we require `bdata` for boundary information
116- on the original domain as well as `LL` and `UR` as lower-left and upper-right corners of the image.
117+ If `on_torus` is true, the Delaunay triangulation is done on the torus.
118+ If `on_cylinder` is true, then triangulation is done on an x-periodic cylinder. In both of
119+ these cases we require `bdata` for boundary information on the original domain as well as
120+ `LL` and `UR` as lower-left and upper-right corners of the image.
117121
118122If `volume_preserving == false`, add a volume_correction term to ``a_1`` (See paper by Froyland & Junge).
119123
120- If `flow_map_mode==0`, apply flow map to nodal basis function coordinates.
121- If `flow_map_mode==1`, apply flow map to nodal basis function index number (allows for precomputed trajectories).
124+ If `flow_map_mode=0`, apply flow map to nodal basis function coordinates.
125+ If `flow_map_mode=1`, apply flow map to nodal basis function index number (allows for
126+ precomputed trajectories).
122127"""
123128function adaptiveTOCollocationStiffnessMatrix (ctx:: GridContext{2} , flow_maps, times= nothing ;
124129 quadrature_order= default_quadrature_order,
@@ -183,58 +188,52 @@ function adaptiveTOCollocationStiffnessMatrix(ctx::GridContext{2}, flow_maps, ti
183188 # the old grid
184189 new_density_nodevals = new_density_bcdofvals
185190 while length (new_density_nodevals) != new_ctx. n
186- push! (new_density_nodevals,0.0 )
191+ push! (new_density_nodevals, 0.0 )
187192 end
188193
189- new_ctx. mass_weights = [evaluate_function_from_node_or_cellvals (new_ctx,new_density_nodevals,q)
190- for q in new_ctx. quadrature_points ]
194+ new_ctx. mass_weights = [evaluate_function_from_node_or_cellvals (new_ctx, new_density_nodevals, q)
195+ for q in new_ctx. quadrature_points]
191196 end
192- I, J, V = findnz (assembleStiffnessMatrix ( new_ctx,bdata= new_bdata))
197+ I, J, V = findnz (assemble ( Stiffness (), new_ctx, bdata= new_bdata))
193198 I .= translation_table[I]
194199 J .= translation_table[J]
195200 n = ctx. n - length (bdata. periodic_dofs_from)
196- push! (As,sparse (I,J,V,n, n))
201+ push! (As, sparse (I, J, V, n, n))
197202 end
198203 return mean (As)
199204end
200205
201206
202207# Reordering in the periodic case is slightly more tricky
203- function bcdofNewToBcdofOld (
204- old_ctx:: GridContext{dim} ,bdata:: BoundaryData ,
205- new_ctx:: GridContext{dim} ,new_bdata:: BoundaryData ,K
206- ) where {dim}
207-
208- I, J ,V = findnz (K)
209-
210- # Here I,J are in pdof order for new_ctx
211-
212- bcdof_to_node_new = bcdof_to_node (new_ctx,new_bdata)
213- node_to_bcdof_old = node_to_bcdof (old_ctx,bdata)
214- I .= node_to_bcdof_old[bcdof_to_node_new[I]]
215- J .= node_to_bcdof_old[bcdof_to_node_new[J]]
216-
217- old_pdof_n = old_ctx. n - length (bdata. periodic_dofs_from)
218-
219- return sparse (I,J,V,old_pdof_n,old_pdof_n)
208+ function bcdofNewToBcdofOld (old_ctx:: GridContext{dim} , bdata:: BoundaryData ,
209+ new_ctx:: GridContext{dim} , new_bdata:: BoundaryData , K) where {dim}
210+ I, J ,V = findnz (K)
211+
212+ # Here I,J are in pdof order for new_ctx
213+ bcdof_to_node_new = bcdof_to_node (new_ctx, new_bdata)
214+ node_to_bcdof_old = node_to_bcdof (old_ctx, bdata)
215+ I .= node_to_bcdof_old[bcdof_to_node_new[I]]
216+ J .= node_to_bcdof_old[bcdof_to_node_new[J]]
217+ old_pdof_n = old_ctx. n - length (bdata. periodic_dofs_from)
218+ return sparse (I, J, V, old_pdof_n, old_pdof_n)
220219end
221220
222- function node_to_bcdof (ctx:: GridContext{dim} ,bdata:: BoundaryData ) where {dim}
223- n_nodes = ctx. n - length (bdata. periodic_dofs_from)
224- bdata_table = BCTable (ctx,bdata)
225- return bdata_table[ctx. node_to_dof]
221+ function node_to_bcdof (ctx:: GridContext{dim} , bdata:: BoundaryData ) where {dim}
222+ n_nodes = ctx. n - length (bdata. periodic_dofs_from)
223+ bdata_table = BCTable (ctx, bdata)
224+ return bdata_table[ctx. node_to_dof]
226225end
227226
228227function bcdof_to_node (ctx:: GridContext{dim} ,bdata:: BoundaryData ) where {dim}
229- n_nodes = ctx. n - length (bdata. periodic_dofs_from)
230- bdata_table = BCTable (ctx,bdata)
231- result = zeros (Int,n_nodes)
232- for i in 1 : ctx. n
233- if result[bdata_table[ctx. node_to_dof[i]]] == 0
234- result[bdata_table[ctx. node_to_dof[i]]] = i
235- end
228+ n_nodes = ctx. n - length (bdata. periodic_dofs_from)
229+ bdata_table = BCTable (ctx,bdata)
230+ result = zeros (Int,n_nodes)
231+ for i in 1 : ctx. n
232+ if iszero (result[bdata_table[ctx. node_to_dof[i]]])
233+ result[bdata_table[ctx. node_to_dof[i]]] = i
236234 end
237- return result
235+ end
236+ return result
238237end
239238
240239
@@ -274,8 +273,8 @@ function adaptiveTOFutureGrid(ctx::GridContext{dim}, flow_map;
274273 # Do volume corrections
275274 # All values are in node order for new_ctx, which is the same as bcdof order for ctx2
276275 n_nodes = length (new_nodes_in_bcdof_order)
277- vols_new = sum (assembleMassMatrix ( new_ctx, bdata= new_bdata), dims= 1 )[1 , node_to_bcdof (new_ctx, new_bdata)[1 : n_nodes]]
278- vols_old = sum (assembleMassMatrix ( ctx, bdata= bdata), dims= 1 )[1 , 1 : n_nodes]
276+ vols_new = sum (assemble ( Mass (), new_ctx, bdata= new_bdata), dims= 1 )[1 , node_to_bcdof (new_ctx, new_bdata)[1 : n_nodes]]
277+ vols_old = sum (assemble ( Mass (), ctx, bdata= bdata), dims= 1 )[1 , 1 : n_nodes]
279278
280279 return new_ctx, new_bdata, vols_new ./ vols_old
281280end
@@ -319,12 +318,12 @@ function adaptiveTOCollocation(ctx::GridContext{dim}, flow_map;
319318 throw (AssertionError (" Invalid projection_method" ))
320319 end
321320 if volume_preserving
322- L = sparse (I, npoints, npoints)[node_to_bcdof (ctx,bdata)[bcdof_to_node (ctx_new,bdata_new)],:]
321+ L = sparse (I, npoints, npoints)[node_to_bcdof (ctx, bdata)[bcdof_to_node (ctx_new,bdata_new)],:]
323322 result = ALPHA_bc* L
324323 else
325324 volume_change_pdof = volume_change[bcdof_to_node (ctx,bdata)]
326- K = assembleStiffnessMatrix ( ctx,bdata= bdata)
327- M = assembleMassMatrix ( ctx,bdata= bdata)
325+ K = assemble ( Stiffness (), ctx, bdata = bdata)
326+ M = assemble ( Mass (), ctx, bdata = bdata)
328327 volume_change_pdof = (M - 1e-2 K)\ (M* volume_change_pdof)
329328 volume_change = volume_change_pdof[node_to_bcdof (ctx,bdata)]
330329
0 commit comments