@@ -113,8 +113,10 @@ When specifying the `fields` keyword of [`Job`](@ref) for a [`Body`](@ref) with
113113- `b_ext::Matrix{Float64}`: External force density of each point
114114- `damage::Vector{Float64}`: Damage of each point
115115- `n_active_bonds::Vector{Int}`: Number of intact bonds of each point
116- - `stress ::Matrix{Float64}`: Stress tensor of each point
116+ - `cauchy_stress ::Matrix{Float64}`: Cauchy stress tensor of each point
117117- `von_mises_stress::Vector{Float64}`: Von Mises stress of each point
118+ - `hydrostatic_stress::Vector{Float64}`: Hydrostatic stress of each point.
119+ - `strain_energy_density::Vector{Float64}`: Strain energy density of each point.
118120"""
119121struct RKCMaterial{CM,K,DM} <: AbstractRKCMaterial{CM,NoCorrection}
120122 kernel:: K
@@ -172,12 +174,13 @@ end
172174 bond_active:: Vector{Bool}
173175 @pointfield n_active_bonds:: Vector{Int}
174176 @pointfield update_gradients:: Vector{Bool}
175- @pointfield stress :: Matrix{Float64}
177+ @pointfield cauchy_stress :: Matrix{Float64}
176178 @pointfield von_mises_stress:: Vector{Float64}
179+ @pointfield strain_energy_density:: Vector{Float64}
177180 @lthfield defgrad:: Matrix{Float64}
178181 @lthfield weighted_volume:: Vector{Float64}
179182 gradient_weight:: Matrix{Float64}
180- first_piola_kirchhoff :: Matrix{Float64}
183+ bond_first_piola_kirchhoff :: Matrix{Float64}
181184end
182185
183186function init_field (:: AbstractRKCMaterial , :: AbstractTimeSolver , system:: BondSystem ,
@@ -191,7 +194,7 @@ function init_field(::AbstractRKCMaterial, ::AbstractTimeSolver, system::BondSys
191194end
192195
193196function init_field (:: AbstractRKCMaterial , :: AbstractTimeSolver , system:: BondSystem ,
194- :: Val{:stress } )
197+ :: Val{:cauchy_stress } )
195198 return zeros (9 , get_n_loc_points (system))
196199end
197200
@@ -200,6 +203,11 @@ function init_field(::AbstractRKCMaterial, ::AbstractTimeSolver, system::BondSys
200203 return zeros (get_n_loc_points (system))
201204end
202205
206+ function init_field (:: AbstractRKCMaterial , :: AbstractTimeSolver , system:: BondSystem ,
207+ :: Val{:strain_energy_density} )
208+ return zeros (get_n_loc_points (system))
209+ end
210+
203211function init_field (:: AbstractRKCMaterial , :: AbstractTimeSolver , system:: BondSystem ,
204212 :: Val{:defgrad} )
205213 return zeros (9 , get_n_points (system))
@@ -216,7 +224,7 @@ function init_field(::AbstractRKCMaterial, ::AbstractTimeSolver, system::BondSys
216224end
217225
218226function init_field (:: AbstractRKCMaterial , :: AbstractTimeSolver , system:: BondSystem ,
219- :: Val{:first_piola_kirchhoff } )
227+ :: Val{:bond_first_piola_kirchhoff } )
220228 return zeros (9 , get_n_bonds (system))
221229end
222230
@@ -499,15 +507,15 @@ function rkc_force_density!(storage::AbstractStorage, system::AbstractBondSystem
499507 mat:: AbstractRKCMaterial , params:: AbstractPointParameters ,
500508 ∑P, t, Δt, i)
501509 (; bonds, volume) = system
502- (; bond_active, gradient_weight, first_piola_kirchhoff , weighted_volume,
510+ (; bond_active, gradient_weight, bond_first_piola_kirchhoff , weighted_volume,
503511 b_int) = storage
504512 wi = weighted_volume[i]
505513 for bond_id in each_bond_idx (system, i)
506514 if bond_active[bond_id]
507515 bond = bonds[bond_id]
508516 j, L = bond. neighbor, bond. length
509517 ΔXij = get_vector_diff (system. position, i, j)
510- Pij = get_tensor (first_piola_kirchhoff , bond_id)
518+ Pij = get_tensor (bond_first_piola_kirchhoff , bond_id)
511519 Φij = get_vector (gradient_weight, bond_id)
512520 ϕ = 1 / wi
513521 ω̃ij = kernel (system, bond_id) * ϕ
522530function calc_first_piola_kirchhoff! (storage:: RKCStorage , mat:: RKCMaterial ,
523531 params:: StandardPointParameters , F, bond_id)
524532 P = first_piola_kirchhoff (mat. constitutive_model, storage, params, F)
525- update_tensor! (storage. first_piola_kirchhoff , bond_id, P)
533+ update_tensor! (storage. bond_first_piola_kirchhoff , bond_id, P)
526534 return P
527535end
528536
@@ -542,3 +550,77 @@ function bond_avg(Fi, Fj, ΔXij, Δxij, L)
542550 Fij = Favg + Fcor
543551 return Fij
544552end
553+
554+ function cauchy_stress_point! (storage:: AbstractStorage , system:: BondSystem ,
555+ :: AbstractRKCMaterial , :: StandardPointParameters , i)
556+ (; bonds) = system
557+ (; bond_active, defgrad, bond_first_piola_kirchhoff, n_active_bonds) = storage
558+ Fi = get_tensor (defgrad, i)
559+ σi = zero (SMatrix{3 ,3 ,Float64,9 })
560+ for bond_id in each_bond_idx (system, i)
561+ if bond_active[bond_id]
562+ bond = bonds[bond_id]
563+ j, L = bond. neighbor, bond. length
564+ ΔXij = get_vector_diff (system. position, i, j)
565+ Δxij = get_vector_diff (storage. position, i, j)
566+ Fj = get_tensor (defgrad, j)
567+ Fij = bond_avg (Fi, Fj, ΔXij, Δxij, L)
568+ Pij = get_tensor (bond_first_piola_kirchhoff, bond_id)
569+ σij = cauchy_stress (Pij, Fij)
570+ σi += σij
571+ end
572+ end
573+ update_tensor! (storage. cauchy_stress, i, σi ./ n_active_bonds[i])
574+ return nothing
575+ end
576+
577+ # calculate the Cauchy stress tensor just when exporting
578+ function export_field (:: Val{:cauchy_stress} , mat:: AbstractRKCMaterial , system:: BondSystem ,
579+ storage:: AbstractStorage , paramsetup:: AbstractParameterSetup , t)
580+ for i in each_point_idx (system)
581+ params = get_params (paramsetup, i)
582+ cauchy_stress_point! (storage, system, mat, params, i)
583+ end
584+ return storage. cauchy_stress
585+ end
586+
587+ # calculate the von Mises stress from the Cauchy stress tensor just when exporting
588+ function export_field (:: Val{:von_mises_stress} , mat:: AbstractRKCMaterial ,
589+ system:: BondSystem , storage:: AbstractStorage ,
590+ paramsetup:: AbstractParameterSetup , t)
591+ for i in each_point_idx (system)
592+ params = get_params (paramsetup, i)
593+ cauchy_stress_point! (storage, system, mat, params, i)
594+ σ = get_tensor (storage. cauchy_stress, i)
595+ storage. von_mises_stress[i] = von_mises_stress (σ)
596+ end
597+ return storage. von_mises_stress
598+ end
599+
600+ # calculate the von hydrostatic stress from the Cauchy stress tensor just when exporting,
601+ # use the `von_mises_stress` field to store the hydrostatic stress
602+ function export_field (:: Val{:hydrostatic_stress} , mat:: AbstractRKCMaterial ,
603+ system:: BondSystem , storage:: AbstractStorage ,
604+ paramsetup:: AbstractParameterSetup , t)
605+ for i in each_point_idx (system)
606+ params = get_params (paramsetup, i)
607+ cauchy_stress_point! (storage, system, mat, params, i)
608+ σ = get_tensor (storage. cauchy_stress, i)
609+ storage. von_mises_stress[i] = 1 / 3 * (σ[1 ,1 ] + σ[2 ,2 ] + σ[3 ,3 ])
610+ end
611+ return storage. von_mises_stress
612+ end
613+ custom_field (:: Type{RKCStorage} , :: Val{:hydrostatic_stress} ) = true
614+
615+ # calculate the strain energy density from the deformation gradient just when exporting
616+ function export_field (:: Val{:strain_energy_density} , mat:: AbstractRKCMaterial ,
617+ system:: BondSystem , storage:: AbstractStorage ,
618+ paramsetup:: AbstractParameterSetup , t)
619+ model = mat. constitutive_model
620+ for i in each_point_idx (system)
621+ params = get_params (paramsetup, i)
622+ F = get_tensor (storage. defgrad, i)
623+ storage. strain_energy_density[i] = strain_energy_density (model, storage, params, F)
624+ end
625+ return storage. strain_energy_density
626+ end
0 commit comments