Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bond-associated Correspondence of Chen and Spencer #198

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3243456
Renaming NOSB* -> CC*
kaipartmann Oct 19, 2024
f7539e1
Add time `t` and time step `Δt` to force density calculation functions
kaipartmann Oct 19, 2024
7c835a9
Enhance CCMaterial: rm `maxjacobi` and add other fields
kaipartmann Oct 21, 2024
c63c798
Add benchmark suite & mode I benchmark
kaipartmann Oct 21, 2024
dd79784
Remove StatsPlots
kaipartmann Oct 21, 2024
e5d4f9d
Allow materials with parameters
kaipartmann Oct 24, 2024
5531538
Improve benchmarks
kaipartmann Oct 24, 2024
c04b5a7
Major changes regarding correspondence materials
kaipartmann Oct 24, 2024
df49615
Remove undefined export
kaipartmann Oct 24, 2024
4f4ab19
Smaller fixes to CCMaterial
kaipartmann Oct 25, 2024
49202da
First working draft, wave speed not correct (15% error)
kaipartmann Oct 25, 2024
725d003
Renaming
kaipartmann Oct 25, 2024
c980662
Copy-n-past bacc model as start for bark material
kaipartmann Oct 25, 2024
765ab92
Simplify neighborhood volumes calculation
kaipartmann Oct 25, 2024
7dbce7a
Minor enhancements
kaipartmann Oct 31, 2024
cb9259b
Renaming CC -> C
kaipartmann Nov 7, 2024
6ec7979
Remove `bark_correspondence`
kaipartmann Nov 7, 2024
dc2809d
Make bond horizon a point parameter
kaipartmann Nov 7, 2024
fb75d89
Minor cleanup
kaipartmann Nov 7, 2024
1fc1875
Remove `bark_correspondence`
kaipartmann Nov 7, 2024
2f02032
Remove undefined export
kaipartmann Nov 8, 2024
d644195
Exchange now part of force density calculation
kaipartmann Nov 8, 2024
e984e4c
Minor fix
kaipartmann Nov 8, 2024
55b433f
Change args order for consistency
kaipartmann Nov 8, 2024
08fcfa3
Dirty draft of RKC-PD
kaipartmann Nov 11, 2024
2a8871c
Minor improvements
kaipartmann Nov 12, 2024
906dee8
Refactor stress calculations to use first Piola-Kirchhoff stress and …
kaipartmann Nov 13, 2024
7537679
Add kernels to materials and precalculate in bond systems
kaipartmann Nov 14, 2024
fd39126
Working draft / wave speed wrong
kaipartmann Nov 18, 2024
c87e24c
Working version for small deformations
kaipartmann Nov 20, 2024
536606b
NSC-model is now working; problems with large deformations
kaipartmann Nov 20, 2024
dea94e0
Improved edge case handling
kaipartmann Nov 22, 2024
f1a3753
documentation updates
kaipartmann Dec 3, 2024
8d12c8a
Improved correspondence material interface
kaipartmann Dec 3, 2024
ae311e1
Experimental drafts and enhancements
kaipartmann Feb 6, 2025
9d24663
Cleanup + docs
kaipartmann Feb 7, 2025
4d17140
Merge branch 'main' into BAC-material
kaipartmann Feb 7, 2025
ca4ec19
Add docstrings
kaipartmann Feb 7, 2025
2482927
Use `mktempdir` for every temporary directory in tests
kaipartmann Feb 7, 2025
32aab07
Cleanup and docs for constitutive models
kaipartmann Feb 7, 2025
49fe7fd
Add new export fields to docs of CMaterial
kaipartmann Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const SUITE = BenchmarkGroup()
include(joinpath(@__DIR__, "mode_i.jl"))

SUITE["mode_i"] = BenchmarkGroup()
SUITE["mode_i"]["BBMaterial, 40"] = mode_i(BBMaterial(), 40)
SUITE["mode_i"]["OSBMaterial, 40"] = mode_i(OSBMaterial(), 40)
SUITE["mode_i"]["CCMaterial, 40"] = mode_i(NOSBMaterial(), 40)

SUITE["mode_i"]["BBMaterial, 40"] = @benchmarkable submit(mode_i(BBMaterial(), 40))
SUITE["mode_i"]["OSBMaterial, 40"] = @benchmarkable submit(mode_i(OSBMaterial(), 40))
SUITE["mode_i"]["CMaterial, 40"] = @benchmarkable submit(mode_i(CMaterial(), 40))
6 changes: 4 additions & 2 deletions benchmark/mode_i.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Peridynamics

function mode_i(mat, npyz)
l, Δx, δ, a = 1.0, 1/npyz, 3.015/npyz, 0.5
Expand All @@ -13,6 +14,7 @@ function mode_i(mat, npyz)
velocity_bc!(t -> -30, body, :set_bottom, :y)
velocity_bc!(t -> 30, body, :set_top, :y)
vv = VelocityVerlet(steps=2000)
job = Job(body, vv; path=joinpath(@__DIR__, "results", "mode_i-BB-npyz$(npyz)"))
return @benchmarkable submit($job)
path = joinpath(@__DIR__, "results", "mode_i")
job = Job(body, vv; path)
return job
end
12 changes: 10 additions & 2 deletions docs/src/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ Pages = ["api_reference.md"]
```@docs
BBMaterial
OSBMaterial
NOSBMaterial
CMaterial
BACMaterial
CKIMaterial
```

## System related types
## System or material related types
```@docs
NoCorrection
EnergySurfaceCorrection
ZEMSilling
LinearElastic
NeoHooke
MooneyRivlin
SaintVenantKirchhoff
linear_kernel
cubic_b_spline_kernel
```

## Discretization
Expand Down
2 changes: 1 addition & 1 deletion docs/src/literate/tutorial_wave_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ npyz = 4
# With these parameters we now create a body, here using the non-ordinary state-based
# correspondence formulation.
pos, vol = uniform_box(lx, lyz, lyz, Δx)
body = Body(NOSBMaterial(), pos, vol)
body = Body(CMaterial(), pos, vol)
# Again, failure is not allowed in the whole body.
failure_permit!(body, false)

Expand Down
22 changes: 21 additions & 1 deletion src/Peridynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ end
import LibGit2, Dates

# Material models
export BBMaterial, OSBMaterial, NOSBMaterial, CKIMaterial
export BBMaterial, OSBMaterial, CMaterial, BACMaterial, CKIMaterial

# CMaterial related types
export LinearElastic, NeoHooke, MooneyRivlin, SaintVenantKirchhoff, ZEMSilling

# Kernels
export linear_kernel, cubic_b_spline_kernel

# Systems related types
export NoCorrection, EnergySurfaceCorrection
Expand Down Expand Up @@ -50,6 +56,7 @@ abstract type AbstractTimeSolver end
abstract type AbstractJob end
abstract type AbstractJobOptions end
abstract type AbstractSystem end
abstract type AbstractBondSystem <: AbstractSystem end
abstract type AbstractPredefinedCrack end
abstract type AbstractBodyChunk{S<:AbstractSystem,T<:AbstractMaterial} end
abstract type AbstractParameterHandler <: AbstractParameterSetup end
Expand All @@ -65,17 +72,25 @@ abstract type AbstractCorrection end
abstract type AbstractStorage end
abstract type AbstractCondition end
abstract type AbstractBondSystemMaterial{Correction} <: AbstractMaterial end
abstract type AbstractCorrespondenceMaterial{CM,ZEM} <: AbstractBondSystemMaterial{ZEM} end
abstract type AbstractBondAssociatedSystemMaterial <: AbstractMaterial end
abstract type AbstractConstitutiveModel end
abstract type AbstractStressIntegration end
abstract type AbstractZEMStabilization <: AbstractCorrection end
abstract type AbstractInteractionSystemMaterial <: AbstractMaterial end

include("auxiliary/function_arguments.jl")
include("auxiliary/io.jl")
include("auxiliary/logs.jl")
include("auxiliary/mpi.jl")
include("auxiliary/errors.jl")
include("auxiliary/static_arrays.jl")
include("auxiliary/nans.jl")

include("physics/boundary_conditions.jl")
include("physics/initial_conditions.jl")
include("physics/material_parameters.jl")
include("physics/stress.jl")
include("physics/fracture.jl")
include("physics/short_range_force_contact.jl")

Expand All @@ -86,8 +101,11 @@ include("discretization/body.jl")
include("discretization/multibody_setup.jl")
include("discretization/decomposition.jl")
include("discretization/chunk_handler.jl")
include("discretization/kernels.jl")
include("discretization/bond_system.jl")
include("discretization/bond_system_corrections.jl")
include("discretization/zem_stabilization.jl")
include("discretization/bond_associated_system.jl")
include("discretization/interaction_system.jl")
include("discretization/body_chunk.jl")

Expand All @@ -111,7 +129,9 @@ include("time_solvers/dynamic_relaxation.jl")
include("physics/bond_based.jl")
include("physics/continuum_kinematics_inspired.jl")
include("physics/ordinary_state_based.jl")
include("physics/constitutive_models.jl")
include("physics/correspondence.jl")
include("physics/ba_correspondence.jl")

include("VtkReader/VtkReader.jl")
using .VtkReader
Expand Down
14 changes: 14 additions & 0 deletions src/auxiliary/nans.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function containsnan(K::T) where {T<:AbstractArray}
@simd for i in eachindex(K)
isnan(K[i]) && return true
end

Check warning on line 4 in src/auxiliary/nans.jl

View check run for this annotation

Codecov / codecov/patch

src/auxiliary/nans.jl#L4

Added line #L4 was not covered by tests
return false
end

function nancheck(chunk::AbstractBodyChunk, t)
if containsnan(chunk.storage.b_int)
msg = "NaN's found in field `b_int` at simulation time $(t)!\n"
error(msg)

Check warning on line 11 in src/auxiliary/nans.jl

View check run for this annotation

Codecov / codecov/patch

src/auxiliary/nans.jl#L10-L11

Added lines #L10 - L11 were not covered by tests
end
return nothing
end
10 changes: 4 additions & 6 deletions src/auxiliary/precompile_workload.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
msg *= "Trigger package precompilation manually and then restart the mpirun!\n"
error(msg)
end
root = joinpath(@__DIR__, "temp_precompilation")
root = mktempdir()
pos1, vol1 = uniform_box(1, 1, 1, 0.5; center=(0.5, 0.5, 0.5))
pos2, vol2 = uniform_box(1, 1, 1, 0.5; center=(-0.5, 0.5, 0.5))
path_bb = joinpath(root, "BB")
path_osb = joinpath(root, "OSB")
path_nosb = joinpath(root, "NOSB")
path_cc = joinpath(root, "CC")
path_ms = joinpath(root, "MS")

@compile_workload begin
Expand Down Expand Up @@ -43,7 +43,7 @@
velocity_bc!(t -> -1, b2, :set_a, :x)
velocity_bc!(t -> 1, b2, :set_b, 1)

b3 = Body(NOSBMaterial(), pos1, vol1)
b3 = Body(CMaterial(), pos1, vol1)
material!(b3; horizon=2, E=2.1e5, nu=0.25, rho=8e-6, Gc=2.7)
point_set!(p -> p[1] ≤ 0.5, b3, :set_a)
point_set!(x -> x > 0.5, b3, :set_b)
Expand All @@ -65,9 +65,7 @@

submit(Job(b1, vv; path=path_bb, freq=1); quiet=true)
submit(Job(b2, vv; path=path_osb, freq=1); quiet=true)
submit(Job(b3, vv; path=path_nosb, freq=1); quiet=true)
submit(Job(b3, vv; path=path_cc, freq=1); quiet=true)
submit(Job(ms, vv; path=path_ms, freq=1); quiet=true)
end

rm(root; recursive=true, force=true)
end
44 changes: 44 additions & 0 deletions src/auxiliary/static_arrays.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

@inline function get_tensor(T::AbstractMatrix, i::Int)
tensor = SMatrix{3,3}(T[1, i], T[2, i], T[3, i], T[4, i], T[5, i], T[6, i], T[7, i],

Check warning on line 3 in src/auxiliary/static_arrays.jl

View check run for this annotation

Codecov / codecov/patch

src/auxiliary/static_arrays.jl#L2-L3

Added lines #L2 - L3 were not covered by tests
T[8, i], T[9, i])
return tensor

Check warning on line 5 in src/auxiliary/static_arrays.jl

View check run for this annotation

Codecov / codecov/patch

src/auxiliary/static_arrays.jl#L5

Added line #L5 was not covered by tests
end

@inline function update_tensor!(Tₙ::AbstractMatrix, i::Int, Tₙ₊₁::SMatrix{3,3})
Tₙ[1, i] = Tₙ₊₁[1, 1]
Tₙ[2, i] = Tₙ₊₁[1, 2]
Tₙ[3, i] = Tₙ₊₁[1, 3]
Tₙ[4, i] = Tₙ₊₁[2, 1]
Tₙ[5, i] = Tₙ₊₁[2, 2]
Tₙ[6, i] = Tₙ₊₁[2, 3]
Tₙ[7, i] = Tₙ₊₁[3, 1]
Tₙ[8, i] = Tₙ₊₁[3, 2]
Tₙ[9, i] = Tₙ₊₁[3, 3]
return nothing
end

@inline function get_vector(M::AbstractMatrix, i::Int)
V = SVector{3}(M[1, i], M[2, i], M[3, i])
return V

Check warning on line 23 in src/auxiliary/static_arrays.jl

View check run for this annotation

Codecov / codecov/patch

src/auxiliary/static_arrays.jl#L21-L23

Added lines #L21 - L23 were not covered by tests
end

@inline function update_vector!(Mₙ::AbstractMatrix, i::Int, Vₙ₊₁::SVector{3})
Mₙ[1, i] = Vₙ₊₁[1]
Mₙ[2, i] = Vₙ₊₁[2]
Mₙ[3, i] = Vₙ₊₁[3]
return nothing

Check warning on line 30 in src/auxiliary/static_arrays.jl

View check run for this annotation

Codecov / codecov/patch

src/auxiliary/static_arrays.jl#L26-L30

Added lines #L26 - L30 were not covered by tests
end

@inline function get_vector_diff(M::AbstractMatrix, i::Int, j::Int)
V = SVector{3}(M[1, j] - M[1, i], M[2, j] - M[2, i], M[3, j] - M[3, i])
return V

Check warning on line 35 in src/auxiliary/static_arrays.jl

View check run for this annotation

Codecov / codecov/patch

src/auxiliary/static_arrays.jl#L33-L35

Added lines #L33 - L35 were not covered by tests
end

function invreg(M::StaticMatrix{N,N,T}, threshold::Real=eps()) where {N,T}
U, S, V = svd(M)
Sinvreg = SVector{N,T}((s > threshold ? 1/s : 0) for s in S)
Sinv = Diagonal{T,SVector{N,T}}(Sinvreg)
Minv = V * Sinv * U'
return Minv

Check warning on line 43 in src/auxiliary/static_arrays.jl

View check run for this annotation

Codecov / codecov/patch

src/auxiliary/static_arrays.jl#L38-L43

Added lines #L38 - L43 were not covered by tests
end
8 changes: 8 additions & 0 deletions src/core/mpi_body_data_handler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ function recv_htl!(get_field_function::F, dh::MPIBodyDataHandler,
return nothing
end

function calc_force_density!(dh::MPIBodyDataHandler, t, Δt)
(; chunk) = dh
@timeit_debug TO "exchange_loc_to_halo!" exchange_loc_to_halo!(dh)
@timeit_debug TO "calc_force_density!" calc_force_density!(chunk, t, Δt)
@timeit_debug TO "exchange_halo_to_loc!" exchange_halo_to_loc!(dh)
return nothing
end

function export_results(dh::MPIBodyDataHandler, options::AbstractJobOptions, n::Int,
t::Float64)
options.export_allowed || return nothing
Expand Down
1 change: 1 addition & 0 deletions src/core/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function macrocheck_input_material(material)
material isa Symbol && return nothing
(material isa Expr && material.head === :.) && return nothing
(material isa Expr && material.head === :escape) && return nothing
(material isa Expr && material.head === :curly) && return nothing
return throw(ArgumentError("argument `$material` is not a valid material input!\n"))
end

Expand Down
11 changes: 11 additions & 0 deletions src/core/threads_body_data_handler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@
return nothing
end

function calc_force_density!(dh::ThreadsBodyDataHandler, t, Δt)
@threads :static for chunk_id in eachindex(dh.chunks)
exchange_loc_to_halo!(dh, chunk_id)
calc_force_density!(dh.chunks[chunk_id], t, Δt)
end

Check warning on line 164 in src/core/threads_body_data_handler.jl

View check run for this annotation

Codecov / codecov/patch

src/core/threads_body_data_handler.jl#L164

Added line #L164 was not covered by tests
@threads :static for chunk_id in eachindex(dh.chunks)
exchange_halo_to_loc!(dh, chunk_id)
end

Check warning on line 167 in src/core/threads_body_data_handler.jl

View check run for this annotation

Codecov / codecov/patch

src/core/threads_body_data_handler.jl#L167

Added line #L167 was not covered by tests
return nothing
end

function export_results(dh::ThreadsBodyDataHandler, options::AbstractJobOptions,
chunk_id::Int, timestep::Int, time::Float64)
options.export_allowed || return nothing
Expand Down
11 changes: 11 additions & 0 deletions src/core/threads_multibody_data_handler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@
@inline each_body_name(dh::ThreadsMultibodyDataHandler) = dh.body_names
@inline each_body_idx(dh::ThreadsMultibodyDataHandler) = eachindex(dh.body_dhs)

function calc_force_density!(dh::ThreadsMultibodyDataHandler, t, Δt)
for body_idx in each_body_idx(dh)
body_dh = get_body_dh(dh, body_idx)
@threads :static for chunk_id in eachindex(body_dh.chunks)
exchange_loc_to_halo!(body_dh, chunk_id)
calc_force_density!(body_dh.chunks[chunk_id], t, Δt)
end

Check warning on line 42 in src/core/threads_multibody_data_handler.jl

View check run for this annotation

Codecov / codecov/patch

src/core/threads_multibody_data_handler.jl#L42

Added line #L42 was not covered by tests
end
return nothing
end

function update_caches!(dh::ThreadsMultibodyDataHandler)
for body_idx in each_body_idx(dh)
body_dh = get_body_dh(dh, body_idx)
Expand Down
4 changes: 4 additions & 0 deletions src/discretization/body.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ function pre_submission_check(body::Body; body_in_multibody_setup::Bool=false)
return nothing
end

@inline function get_point_param(b::AbstractBody, i::Int)
return b.point_params[b.params_map[i]]
end

@inline function get_point_param(b::AbstractBody, key::Symbol, i::Int)
return getfield(b.point_params[b.params_map[i]], key)
end
Expand Down
Loading
Loading