5454
5555function BondSystem (body:: AbstractBody , pd:: PointDecomposition , chunk_id:: Int )
5656 check_bond_system_compat (body. mat)
57- bonds, n_neighbors = find_bonds (body, pd. decomp[chunk_id])
58- bond_ids = find_bond_ids (n_neighbors)
59- chunk_handler = get_chunk_handler (bonds, pd, chunk_id)
60- localize! (bonds, chunk_handler. localizer)
57+ bonds, n_neighbors, bond_ids, chunk_handler = get_bond_data (body, pd, chunk_id)
6158 position, volume = get_pos_and_vol_chunk (body, chunk_handler. point_ids)
6259 correction = get_correction (body. mat, chunk_handler. n_loc_points,
6360 length (chunk_handler. point_ids), length (bonds))
@@ -67,6 +64,16 @@ function BondSystem(body::AbstractBody, pd::PointDecomposition, chunk_id::Int)
6764 return system
6865end
6966
67+ function get_bond_data (body:: AbstractBody , pd:: PointDecomposition , chunk_id)
68+ loc_points = pd. decomp[chunk_id]
69+ bonds, n_neighbors = find_bonds (body, loc_points)
70+ halo_points = find_halo_points (bonds, loc_points)
71+ chunk_handler = ChunkHandler (pd, halo_points, chunk_id)
72+ localize! (bonds, chunk_handler. localizer)
73+ bond_ids = find_bond_ids (n_neighbors)
74+ return bonds, n_neighbors, bond_ids, chunk_handler
75+ end
76+
7077function get_system (body:: AbstractBody{Material} , pd:: PointDecomposition ,
7178 chunk_id:: Int ) where {Material<: AbstractBondSystemMaterial }
7279 return BondSystem (body, pd, chunk_id)
@@ -86,7 +93,7 @@ function check_bond_system_compat(::AbstractBondSystemMaterial)
8693 return nothing
8794end
8895
89- function find_bonds (body:: AbstractBody , loc_points:: UnitRange {Int} )
96+ function find_bonds (body:: AbstractBody , loc_points:: AbstractVector {Int} )
9097 δmax = maximum_horizon (body)
9198 nhs = GridNeighborhoodSearch {3} (search_radius= δmax, n_points= body. n_points)
9299 initialize_grid! (nhs, body. position)
@@ -125,15 +132,15 @@ end
125132end
126133
127134function filter_bonds! (bonds:: Vector{Bond} , n_neighbors:: Vector{Int} ,
128- loc_points:: UnitRange {Int} , body:: AbstractBody )
135+ loc_points:: AbstractVector {Int} , body:: AbstractBody )
129136 for crack in body. point_sets_precracks
130137 filter_bonds_by_crack! (bonds, n_neighbors, loc_points, crack, body)
131138 end
132139 return nothing
133140end
134141
135142function filter_bonds_by_crack! (bonds:: Vector{Bond} , n_neighbors:: Vector{Int} ,
136- loc_points:: UnitRange {Int} , crack:: PointSetsPreCrack ,
143+ loc_points:: AbstractVector {Int} , crack:: PointSetsPreCrack ,
137144 body:: AbstractBody )
138145 filter_bonds (crack) || return nothing
139146 set_a, set_b = body. point_sets[crack. set_a], body. point_sets[crack. set_b]
@@ -174,17 +181,6 @@ function get_pos_and_vol_chunk(body::AbstractBody, point_ids::AbstractVector{<:I
174181 return position, volume
175182end
176183
177- function get_chunk_handler (bonds:: Vector{Bond} , pd:: PointDecomposition , chunk_id:: Int )
178- loc_points = pd. decomp[chunk_id]
179- n_loc_points = length (loc_points)
180- halo_points = find_halo_points (bonds, loc_points)
181- hidxs_by_src = sort_halo_by_src! (halo_points, pd. point_src, length (loc_points))
182- point_ids = vcat (loc_points, halo_points)
183- localizer = find_localizer (point_ids)
184- return ChunkHandler (n_loc_points, point_ids, loc_points, halo_points, hidxs_by_src,
185- localizer)
186- end
187-
188184function find_kernels (body:: AbstractBody , chunk_handler:: ChunkHandler , bonds:: Vector{Bond} ,
189185 bond_ids:: Vector{UnitRange{Int}} )
190186 hasproperty (body. mat, :kernel ) || return Vector {Float64} ()
208204 return system. kernels[bond_id]
209205end
210206
211- function find_halo_points (bonds:: Vector{Bond} , loc_points:: UnitRange {Int} )
207+ function find_halo_points (bonds:: Vector{Bond} , loc_points:: AbstractVector {Int} )
212208 halo_points = Vector {Int} ()
213209 for bond in bonds
214210 j = bond. neighbor
@@ -219,7 +215,7 @@ function find_halo_points(bonds::Vector{Bond}, loc_points::UnitRange{Int})
219215 return halo_points
220216end
221217
222- @inline each_bond_idx (system:: AbstractBondSystem , point_id :: Int ) = system. bond_ids[point_id ]
218+ @inline each_bond_idx (system:: AbstractBondSystem , i :: Int ) = system. bond_ids[i ]
223219
224220function localize! (bonds:: Vector{Bond} , localizer:: Dict{Int,Int} )
225221 for i in eachindex (bonds)
0 commit comments