Skip to content

Commit 5993566

Browse files
authored
Merge pull request #240 from kaipartmann/newton-raphson-serial
Experimental: Newton Raphson solver (only serial)
2 parents 0d0f657 + 59795f4 commit 5993566

24 files changed

+1566
-63
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
name = "Peridynamics"
22
uuid = "4dc47793-80f3-4232-b30e-ca78ca9d621b"
3-
authors = ["Kai Partmann"]
43
version = "0.5.0-DEV"
4+
authors = ["Kai Partmann"]
55

66
[deps]
77
AbaqusReader = "bc6b9049-e460-56d6-94b4-a597b2c0390d"
88
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
99
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
1010
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
11+
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
1112
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
1213
LightXML = "9c8b4983-aa76-5018-a973-4c85ecc9e179"
1314
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -26,6 +27,7 @@ AbaqusReader = "0.2"
2627
Base64 = "1.8"
2728
CodecZlib = "0.7"
2829
Dates = "1.8"
30+
IterativeSolvers = "0.9.4"
2931
LibGit2 = "1.8"
3032
LightXML = "0.9"
3133
LinearAlgebra = "1.8"

docs/src/private_api_reference.md

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,8 @@
88
Pages = ["private_api_reference.md"]
99
```
1010

11+
## Types
1112
```@docs
12-
Peridynamics.failure_permit!
13-
Peridynamics.get_frac_params
14-
Peridynamics.set_failure_permissions!
15-
Peridynamics.has_fracture
16-
Peridynamics.check_pos_and_vol
17-
Peridynamics.pre_submission_check
18-
Peridynamics.get_paramsetup
19-
Peridynamics.get_params
20-
Peridynamics.check_if_sets_intersect
21-
Peridynamics.check_if_set_is_defined
22-
Peridynamics.find_points
23-
Peridynamics.apply_precracks!
24-
Peridynamics.apply_precrack!
25-
Peridynamics.point_sets_intersect
26-
Peridynamics.displacement_bc!
27-
Peridynamics.velocity_databc!
28-
Peridynamics.forcedensity_databc!
29-
Peridynamics.invreg
30-
3113
Peridynamics.InterfaceError
3214
Peridynamics.HaloExchange
3315
Peridynamics.JobOptions
@@ -56,7 +38,37 @@ Peridynamics.BACPointParameters
5638
Peridynamics.SingleDimIC
5739
Peridynamics.PosDepSingleDimIC
5840
Peridynamics.ShortRangeForceContact
41+
```
5942

43+
## Functions
44+
```@docs
45+
Peridynamics.failure_permit!
46+
Peridynamics.get_frac_params
47+
Peridynamics.set_failure_permissions!
48+
Peridynamics.has_fracture
49+
Peridynamics.check_pos_and_vol
50+
Peridynamics.pre_submission_check
51+
Peridynamics.get_paramsetup
52+
Peridynamics.get_params
53+
Peridynamics.check_if_sets_intersect
54+
Peridynamics.check_if_set_is_defined
55+
Peridynamics.find_points
56+
Peridynamics.apply_precracks!
57+
Peridynamics.apply_precrack!
58+
Peridynamics.point_sets_intersect
59+
Peridynamics.invreg
60+
```
61+
62+
## Macros
63+
```@docs
6064
Peridynamics.@storage
6165
Peridynamics.@autoinfiltrate
66+
```
67+
68+
## Experimental Features
69+
```@docs
70+
Peridynamics.displacement_bc!
71+
Peridynamics.velocity_databc!
72+
Peridynamics.forcedensity_databc!
73+
Peridynamics.NewtonRaphson
6274
```

src/Peridynamics.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Peridynamics
22

33
using Base.Threads, Printf, LinearAlgebra, StaticArrays, PointNeighbors, ProgressMeter,
4-
WriteVTK, TimerOutputs, MPI, PrecompileTools
4+
WriteVTK, TimerOutputs, MPI, PrecompileTools, IterativeSolvers
55
@static if Sys.islinux()
66
using ThreadPinning
77
end
@@ -135,6 +135,7 @@ include("core/mpi_multibody_data_handler.jl")
135135

136136
include("time_solvers/velocity_verlet.jl")
137137
include("time_solvers/dynamic_relaxation.jl")
138+
include("time_solvers/newton_raphson.jl")
138139

139140
include("physics/bond_based.jl")
140141
include("physics/dh_bond_based.jl")

src/auxiliary/docs.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,14 @@ function internal_api_warning()
1111
end
1212
return msg
1313
end
14+
15+
function experimental_api_warning()
16+
msg = """
17+
!!! danger "Experimental feature"
18+
Please note that this is an experimental feature. It is *not*
19+
part of the public API of Peridynamics.jl, and thus can be altered (or removed)
20+
at any time without it being considered a breaking change. Also, the feature may be
21+
incomplete and/or contain bugs. Please use with caution.
22+
"""
23+
return msg
24+
end

src/core/time_solvers.jl

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,6 @@ function required_fields_timesolvers()
2929
return Tuple(unique(all_fields))
3030
end
3131

32-
# function required_point_data_fields_timesolvers()
33-
# all_fields = Vector{Symbol}()
34-
# for solver in registered_solvers()
35-
# push!(all_fields, req_point_data_fields_timesolver(solver)...)
36-
# end
37-
# return Tuple(unique(all_fields))
38-
# end
39-
40-
# function required_bond_data_fields_timesolvers()
41-
# all_fields = Vector{Symbol}()
42-
# for solver in registered_solvers()
43-
# push!(all_fields, req_bond_data_fields_timesolver(solver)...)
44-
# end
45-
# return Tuple(unique(all_fields))
46-
# end
47-
48-
# function required_data_fields_timesolvers()
49-
# all_fields = Vector{Symbol}()
50-
# for solver in registered_solvers()
51-
# push!(all_fields, req_data_fields_timesolver(solver)...)
52-
# end
53-
# return Tuple(unique(all_fields))
54-
# end
55-
5632
function req_point_data_fields_timesolver(::Type{TS}) where {TS}
5733
return throw(InterfaceError(TS, "req_point_data_fields_timesolver"))
5834
end

src/discretization/bond_system.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,22 @@ function calc_force_density!(chunk::AbstractBodyChunk{<:AbstractBondSystem}, t,
261261
return nothing
262262
end
263263

264+
function calc_force_density!(storage::AbstractStorage, system::AbstractBondSystem,
265+
mat::AbstractBondSystemMaterial,
266+
paramsetup::AbstractParameterSetup, idxs::AbstractVector{Int},
267+
t, Δt)
268+
(; dmgmodel) = mat
269+
@inbounds storage.b_int[:, idxs] .= 0.0
270+
@inbounds storage.n_active_bonds[idxs] .= 0
271+
for i in idxs
272+
calc_failure!(storage, system, mat, dmgmodel, paramsetup, i)
273+
calc_damage!(storage, system, mat, dmgmodel, paramsetup, i)
274+
force_density_point!(storage, system, mat, paramsetup, t, Δt, i)
275+
end
276+
nancheck(storage, t, Δt)
277+
return nothing
278+
end
279+
264280
function calc_force_density!(storage::AbstractStorage, system::AbstractBondSystem,
265281
mat::AbstractBondSystemMaterial,
266282
paramsetup::AbstractParameterSetup, t, Δt)
@@ -322,6 +338,13 @@ function calc_damage!(storage::AbstractStorage, system::AbstractBondSystem,
322338
return nothing
323339
end
324340

341+
function get_affected_points(system::AbstractBondSystem, i)
342+
points = [bond.neighbor for bond in system.bonds[each_bond_idx(system, i)]]
343+
pushfirst!(points, i)
344+
sort!(points)
345+
return points
346+
end
347+
325348
function log_system(::Type{System}, options::AbstractJobOptions,
326349
dh::AbstractDataHandler) where {System<:AbstractBondSystem}
327350
n_bonds = calc_n_bonds(dh)

src/discretization/interaction_system.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,22 @@ function calc_force_density!(chunk::AbstractBodyChunk{<:InteractionSystem}, t,
428428
return nothing
429429
end
430430

431+
function calc_force_density!(storage::AbstractStorage, system::InteractionSystem,
432+
mat::AbstractInteractionSystemMaterial,
433+
paramsetup::AbstractParameterSetup, idxs::AbstractVector{Int},
434+
t, Δt)
435+
(; dmgmodel) = mat
436+
@inbounds storage.b_int[:, idxs] .= 0
437+
@inbounds storage.n_active_one_nis[idxs] .= 0
438+
for i in idxs
439+
calc_failure!(storage, system, mat, dmgmodel, paramsetup, i)
440+
calc_damage!(storage, system, mat, dmgmodel, paramsetup, i)
441+
force_density_point!(storage, system, mat, paramsetup, t, Δt, i)
442+
end
443+
nancheck(storage, t, Δt)
444+
return nothing
445+
end
446+
431447
function calc_failure!(storage::AbstractStorage, system::InteractionSystem,
432448
mat::AbstractInteractionSystemMaterial, dmgmodel::CriticalStretch,
433449
paramsetup::AbstractParameterSetup, i)
@@ -467,6 +483,13 @@ end
467483
return storage.one_ni_active[one_ni_id]
468484
end
469485

486+
function get_affected_points(system::InteractionSystem, i)
487+
points = [one_ni.neighbor for one_ni in system.one_nis[each_one_ni_idx(system, i)]]
488+
pushfirst!(points, i)
489+
sort!(points)
490+
return points
491+
end
492+
470493
function log_msg_interaction_system(n_one_nis::Int, n_two_nis::Int, n_three_nis::Int)
471494
msg = msg_qty("number of one-neighbor-interactions", n_one_nis)
472495
msg *= msg_qty("number of two-neighbor-interactions", n_two_nis)

src/physics/ba_correspondence.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,18 @@ end
168168
@pointfield b_ext::Matrix{Float64}
169169
@pointfield density_matrix::Matrix{Float64}
170170
@pointfield damage::Vector{Float64}
171-
bond_active::Vector{Bool}
172171
@pointfield n_active_bonds::Vector{Int}
173172
@pointfield stress::Matrix{Float64}
174173
@pointfield von_mises_stress::Vector{Float64}
174+
bond_active::Vector{Bool}
175+
residual::Vector{Float64}
176+
jacobian::Matrix{Float64}
177+
displacement_copy::Matrix{Float64}
178+
b_int_copy::Matrix{Float64}
179+
temp_force_a::Vector{Float64}
180+
temp_force_b::Vector{Float64}
181+
Δu::Vector{Float64}
182+
affected_points::Vector{Vector{Int}}
175183
end
176184

177185
function init_field(::BACMaterial, ::AbstractTimeSolver, system::BondAssociatedSystem,

src/physics/bond_based.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,18 @@ end
126126
@pointfield b_ext::Matrix{Float64}
127127
@pointfield density_matrix::Matrix{Float64}
128128
@pointfield damage::Vector{Float64}
129-
bond_length::Vector{Float64}
130-
bond_active::Vector{Bool}
131129
@pointfield n_active_bonds::Vector{Int}
132130
@pointfield strain_energy_density::Vector{Float64}
131+
bond_length::Vector{Float64}
132+
bond_active::Vector{Bool}
133+
residual::Vector{Float64}
134+
jacobian::Matrix{Float64}
135+
displacement_copy::Matrix{Float64}
136+
b_int_copy::Matrix{Float64}
137+
temp_force_a::Vector{Float64}
138+
temp_force_b::Vector{Float64}
139+
Δu::Vector{Float64}
140+
affected_points::Vector{Vector{Int}}
133141
end
134142

135143
function init_field(::AbstractBondBasedMaterial, ::AbstractTimeSolver, system::BondSystem,

src/physics/boundary_conditions.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ end
438438
velocity_databc!(body, data, set_name, dims)
439439
440440
$(internal_api_warning())
441+
$(experimental_api_warning())
441442
442443
Specifies velocity boundary conditions for points of the set `set_name` in `body`.
443444
The value of the boundary condition is assigned by reading the corresponding positions
@@ -577,6 +578,7 @@ end
577578
forcedensity_databc!(body, data, set_name, dims)
578579
579580
$(internal_api_warning())
581+
$(experimental_api_warning())
580582
581583
Specifies forcedensity boundary conditions for points of the set `set_name` in `body`.
582584
The value of the boundary condition is assigned by reading the corresponding positions
@@ -633,12 +635,12 @@ end
633635
displacement_bc!(f::Function, body::Body, points::Vector{Int}, dim::Int)
634636
635637
$(internal_api_warning())
638+
$(experimental_api_warning())
636639
637-
Apply a displacement boundary condition to specified points in a given dimension.
638-
639-
!!! warn "Compatibility limited"
640-
This boundary condition type only works with static solvers for now.
640+
!!! warning "Compatibility limited"
641+
This boundary condition type only works with the NewtonRaphson solver for now.
641642
643+
Apply a displacement boundary condition to specified points in a given dimension.
642644
A factor `β` is calculated as `n / n_steps`, where `n` is the current step number and
643645
`n_steps` is the total number of steps. Then the return value of the function `f` is
644646
multiplicated with `β` at each time step. This means that the displacement will be applied

0 commit comments

Comments
 (0)