Skip to content

Commit c2cda49

Browse files
committed
Make the calc_force_density function dispatchable
1 parent 6f1a54e commit c2cda49

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/auxiliary/nans.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ function containsnan(K::T) where {T<:AbstractArray}
55
return false
66
end
77

8-
function nancheck(chunk::AbstractBodyChunk, t, Δt)
9-
if containsnan(chunk.storage.b_int)
8+
function nancheck(storage::AbstractStorage, t, Δt)
9+
if containsnan(storage.b_int)
1010
n = (t > 0 && Δt > 0) ? Int(t ÷ Δt) : 0
1111
msg = "NaN's found in field `b_int` at simulation time $(t), step $(n)!\n"
1212
error(msg)

src/discretization/bond_system.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,22 @@ end
257257

258258
function calc_force_density!(chunk::AbstractBodyChunk{<:AbstractBondSystem}, t, Δt)
259259
(; system, mat, paramsetup, storage) = chunk
260+
calc_force_density!(storage, system, mat, paramsetup, t, Δt)
261+
return nothing
262+
end
263+
264+
function calc_force_density!(storage::AbstractStorage, system::AbstractBondSystem,
265+
mat::AbstractBondSystemMaterial,
266+
paramsetup::AbstractParameterSetup, t, Δt)
260267
(; dmgmodel) = mat
261-
storage.b_int .= 0
268+
storage.b_int .= 0.0
262269
storage.n_active_bonds .= 0
263-
for i in each_point_idx(chunk)
270+
for i in each_point_idx(system)
264271
calc_failure!(storage, system, mat, dmgmodel, paramsetup, i)
265272
calc_damage!(storage, system, mat, dmgmodel, paramsetup, i)
266273
force_density_point!(storage, system, mat, paramsetup, t, Δt, i)
267274
end
268-
nancheck(chunk, t, Δt)
275+
nancheck(storage, t, Δt)
269276
return nothing
270277
end
271278

0 commit comments

Comments
 (0)