This commit is contained in:
@@ -0,0 +1,452 @@
|
||||
module fem_buckling_general
|
||||
use fem_precision
|
||||
use fem_error
|
||||
use fem_control
|
||||
use fem_database
|
||||
use fem_database_lookup, only: database_find_node
|
||||
use fem_sparse_csr
|
||||
use fem_assembly_csr
|
||||
use fem_solver_implicit_support, only: assemble_linear_stiffness
|
||||
use fem_solver_implicit, only: implicit_solve_linear_static
|
||||
use fem_implicit_constraints, only: collect_dirichlet_constraints
|
||||
use fem_element_internal, only: element_compute_internal_force
|
||||
use fem_element_topology, only: element_is_solid
|
||||
use fem_geometric_stiffness, only: geom_truss3d_stiffness, &
|
||||
geom_effective_axial_force, geom_solid_initial_kg
|
||||
use fem_buckling_solver, only: buckling_dense_solve
|
||||
use fem_output_csv, only: output_csv_build_path
|
||||
use fem_modal_output, only: modal_write_output_csv, modal_scale_to_max
|
||||
implicit none
|
||||
|
||||
private
|
||||
|
||||
integer, parameter :: BUCKLING_DENSE_MAX_FREE = 256
|
||||
|
||||
public :: buckling_general_run
|
||||
|
||||
contains
|
||||
|
||||
subroutine buckling_general_run(factors, residuals, mode_count, ierr)
|
||||
real(rk), intent(out) :: factors(:)
|
||||
real(rk), intent(out) :: residuals(:)
|
||||
integer, intent(out) :: mode_count
|
||||
integer, intent(out) :: ierr
|
||||
type(csr_matrix) :: kmat
|
||||
real(rk), allocatable :: kfull(:,:)
|
||||
real(rk), allocatable :: kgfull(:,:)
|
||||
real(rk), allocatable :: kred(:,:)
|
||||
real(rk), allocatable :: kgred(:,:)
|
||||
real(rk), allocatable :: modes(:,:)
|
||||
real(rk), allocatable :: full_modes(:,:)
|
||||
real(rk), allocatable :: values(:)
|
||||
integer, allocatable :: free_ids(:)
|
||||
logical, allocatable :: fixed(:)
|
||||
integer :: nfree
|
||||
integer :: mode
|
||||
integer :: row
|
||||
integer :: col
|
||||
integer :: stat
|
||||
integer :: tmp_ierr
|
||||
|
||||
mode_count = 0
|
||||
factors = ZERO
|
||||
residuals = ZERO
|
||||
call csr_init(kmat)
|
||||
|
||||
if (ndof .le. 0) then
|
||||
call error_set(FEM_ERR_SOLVER, 'generic buckling requires positive ndof', ierr)
|
||||
return
|
||||
end if
|
||||
if (buckling_geom_line_count .le. 0 .and. &
|
||||
.not. buckling_static_preload_req) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'generic buckling requires geometric stiffness data or static preload', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
allocate(kfull(ndof,ndof), kgfull(ndof,ndof), fixed(ndof), values(ndof), &
|
||||
free_ids(ndof), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'failed to allocate buckling dense arrays', ierr)
|
||||
return
|
||||
end if
|
||||
kfull = ZERO
|
||||
kgfull = ZERO
|
||||
fixed = .false.
|
||||
values = ZERO
|
||||
free_ids = 0
|
||||
|
||||
call run_static_preload_if_requested(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
|
||||
call assembly_build_csr_pattern(kmat, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
call assemble_linear_stiffness(kmat, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
call csr_to_dense(kmat, kfull, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
|
||||
call assemble_geometric_stiffness(kgfull, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
|
||||
call collect_dirichlet_constraints(fixed, values, ZERO, .true., ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
call build_free_ids(fixed, kgfull, free_ids, nfree)
|
||||
if (nfree .le. 0) then
|
||||
call error_set(FEM_ERR_SOLVER, 'generic buckling has no free dofs', ierr)
|
||||
go to 900
|
||||
end if
|
||||
if (nfree .gt. BUCKLING_DENSE_MAX_FREE) then
|
||||
call error_set(FEM_ERR_SOLVER, 'generic dense buckling free dof limit exceeded', ierr)
|
||||
go to 900
|
||||
end if
|
||||
|
||||
mode_count = min(size(factors), size(residuals), buckling_num_modes, nfree)
|
||||
if (mode_count .le. 0) then
|
||||
call error_set(FEM_ERR_SOLVER, 'generic buckling mode count is invalid', ierr)
|
||||
go to 900
|
||||
end if
|
||||
|
||||
allocate(kred(nfree,nfree), kgred(nfree,nfree), modes(nfree,mode_count), &
|
||||
full_modes(ndof,mode_count), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'failed to allocate buckling reduced arrays', ierr)
|
||||
go to 900
|
||||
end if
|
||||
do row = 1, nfree
|
||||
do col = 1, nfree
|
||||
kred(row,col) = kfull(free_ids(row), free_ids(col))
|
||||
kgred(row,col) = kgfull(free_ids(row), free_ids(col))
|
||||
end do
|
||||
end do
|
||||
|
||||
call buckling_dense_solve(nfree, kred, kgred, mode_count, &
|
||||
factors(1:mode_count), modes, &
|
||||
residuals(1:mode_count), ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
|
||||
full_modes = ZERO
|
||||
do mode = 1, mode_count
|
||||
do row = 1, nfree
|
||||
full_modes(free_ids(row),mode) = modes(row,mode)
|
||||
end do
|
||||
end do
|
||||
call modal_scale_to_max(ndof, mode_count, full_modes, ONE, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
call write_outputs(mode_count, factors(1:mode_count), &
|
||||
residuals(1:mode_count), full_modes, ierr)
|
||||
|
||||
900 continue
|
||||
call csr_free(kmat, tmp_ierr)
|
||||
if (allocated(kfull)) deallocate(kfull)
|
||||
if (allocated(kgfull)) deallocate(kgfull)
|
||||
if (allocated(kred)) deallocate(kred)
|
||||
if (allocated(kgred)) deallocate(kgred)
|
||||
if (allocated(modes)) deallocate(modes)
|
||||
if (allocated(full_modes)) deallocate(full_modes)
|
||||
if (allocated(values)) deallocate(values)
|
||||
if (allocated(free_ids)) deallocate(free_ids)
|
||||
if (allocated(fixed)) deallocate(fixed)
|
||||
end subroutine buckling_general_run
|
||||
|
||||
subroutine run_static_preload_if_requested(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: iter
|
||||
integer :: iter_limit
|
||||
real(rk) :: res_norm
|
||||
|
||||
buckling_preload_completed = .false.
|
||||
buckling_preload_iter = 0
|
||||
buckling_preload_residual = ZERO
|
||||
if (.not. buckling_static_preload_req) then
|
||||
ierr = FEM_SUCCESS
|
||||
return
|
||||
end if
|
||||
if (time_end .le. ZERO) then
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'buckling static preload requires positive static time', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
iter_limit = max(500, 50 * max(1, ndof))
|
||||
call implicit_solve_linear_static(time_end, iter_limit, 1.0e-10_rk, &
|
||||
iter, res_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call element_compute_internal_force(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
buckling_preload_completed = .true.
|
||||
buckling_preload_iter = iter
|
||||
buckling_preload_residual = res_norm
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine run_static_preload_if_requested
|
||||
|
||||
subroutine csr_to_dense(kmat, dense, ierr)
|
||||
type(csr_matrix), intent(in) :: kmat
|
||||
real(rk), intent(out) :: dense(:,:)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: row
|
||||
integer :: k
|
||||
|
||||
if (size(dense,1) .ne. kmat%nrow .or. size(dense,2) .ne. kmat%ncol) then
|
||||
call error_set(FEM_ERR_SOLVER, 'CSR to dense buckling matrix size mismatch', ierr)
|
||||
return
|
||||
end if
|
||||
dense = ZERO
|
||||
do row = 1, kmat%nrow
|
||||
do k = kmat%row_ptr(row), kmat%row_ptr(row+1) - 1
|
||||
dense(row,kmat%col_ind(k)) = dense(row,kmat%col_ind(k)) + kmat%val(k)
|
||||
end do
|
||||
end do
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine csr_to_dense
|
||||
|
||||
subroutine assemble_geometric_stiffness(kgfull, ierr)
|
||||
real(rk), intent(inout) :: kgfull(:,:)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
kgfull = ZERO
|
||||
if (buckling_geom_line_count .gt. 0) then
|
||||
call assemble_line_geometric(kgfull, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
else if (buckling_static_preload_req) then
|
||||
call assemble_solid_init_kg(kgfull, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end if
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine assemble_geometric_stiffness
|
||||
|
||||
subroutine assemble_line_geometric(kgfull, ierr)
|
||||
real(rk), intent(inout) :: kgfull(:,:)
|
||||
integer, intent(out) :: ierr
|
||||
real(rk) :: kg(6,6)
|
||||
integer :: line
|
||||
integer :: node1
|
||||
integer :: node2
|
||||
integer :: ids(6)
|
||||
integer :: i
|
||||
integer :: j
|
||||
real(rk) :: axial_force
|
||||
do line = 1, buckling_geom_line_count
|
||||
node1 = database_find_node(buckling_geom_line_node1(line))
|
||||
node2 = database_find_node(buckling_geom_line_node2(line))
|
||||
if (node1 .eq. 0 .or. node2 .eq. 0) then
|
||||
call error_set(FEM_ERR_INPUT, 'buckling geometric line references unknown node', ierr)
|
||||
return
|
||||
end if
|
||||
call line_axial_force(line, node1, node2, axial_force, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call geom_truss3d_stiffness(coord0(:,node1), coord0(:,node2), &
|
||||
axial_force, kg, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
ids(1:3) = dof_id(1:3,node1)
|
||||
ids(4:6) = dof_id(1:3,node2)
|
||||
do i = 1, 6
|
||||
if (ids(i) .le. 0) then
|
||||
call error_set(FEM_ERR_INPUT, &
|
||||
'buckling geometric line requires active translational dofs', ierr)
|
||||
return
|
||||
end if
|
||||
do j = 1, 6
|
||||
kgfull(ids(i),ids(j)) = kgfull(ids(i),ids(j)) + kg(i,j)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine assemble_line_geometric
|
||||
|
||||
subroutine assemble_solid_init_kg(kgfull, ierr)
|
||||
real(rk), intent(inout) :: kgfull(:,:)
|
||||
integer, intent(out) :: ierr
|
||||
real(rk) :: kg(MAX_ELEM_DOF,MAX_ELEM_DOF)
|
||||
integer :: elem_dofs(MAX_ELEM_DOF)
|
||||
integer :: n_elem_dof
|
||||
integer :: elem
|
||||
integer :: row
|
||||
integer :: col
|
||||
integer :: active_count
|
||||
|
||||
if (.not. buckling_preload_completed) then
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'solid initial-stress buckling requires completed static preload', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
active_count = 0
|
||||
do elem = 1, nelem
|
||||
if (elem_status(elem) .ne. 0) cycle
|
||||
if (.not. element_is_solid(elem_type(elem))) cycle
|
||||
if (trim(elem_type(elem)) .ne. 'C3D4' .and. &
|
||||
trim(elem_type(elem)) .ne. 'C3D8') cycle
|
||||
call geom_solid_initial_kg(elem, elem_dofs, n_elem_dof, kg, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
active_count = active_count + 1
|
||||
do row = 1, n_elem_dof
|
||||
if (elem_dofs(row) .le. 0) cycle
|
||||
do col = 1, n_elem_dof
|
||||
if (elem_dofs(col) .le. 0) cycle
|
||||
kgfull(elem_dofs(row),elem_dofs(col)) = &
|
||||
kgfull(elem_dofs(row),elem_dofs(col)) + kg(row,col)
|
||||
end do
|
||||
end do
|
||||
end do
|
||||
|
||||
if (active_count .le. 0) then
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'solid initial-stress buckling found no supported C3D4/C3D8 elements', ierr)
|
||||
return
|
||||
end if
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine assemble_solid_init_kg
|
||||
|
||||
subroutine line_axial_force(line, node1, node2, axial_force, ierr)
|
||||
integer, intent(in) :: line
|
||||
integer, intent(in) :: node1
|
||||
integer, intent(in) :: node2
|
||||
real(rk), intent(out) :: axial_force
|
||||
integer, intent(out) :: ierr
|
||||
real(rk) :: avg_stress(NSTRESS)
|
||||
real(rk) :: direction(NDIM)
|
||||
|
||||
if (buck_geom_line_kind(line) .eq. BUCK_GEOM_EXPLICIT) then
|
||||
axial_force = buckling_geom_line_force(line)
|
||||
ierr = FEM_SUCCESS
|
||||
return
|
||||
end if
|
||||
if (.not. buckling_preload_completed) then
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'preload buckling geometric line requires completed static preload', &
|
||||
ierr)
|
||||
return
|
||||
end if
|
||||
call line_average_stress(node1, node2, avg_stress, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
direction = coord0(:,node2) - coord0(:,node1)
|
||||
call geom_effective_axial_force(avg_stress, direction, &
|
||||
buck_geom_line_area(line), &
|
||||
axial_force, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
if (axial_force .le. ZERO) then
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'preload buckling geometric line axial force is not positive', ierr)
|
||||
return
|
||||
end if
|
||||
buckling_geom_line_force(line) = axial_force
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine line_axial_force
|
||||
|
||||
subroutine line_average_stress(node1, node2, avg_stress, ierr)
|
||||
integer, intent(in) :: node1
|
||||
integer, intent(in) :: node2
|
||||
real(rk), intent(out) :: avg_stress(NSTRESS)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: elem
|
||||
integer :: q
|
||||
integer :: gp
|
||||
integer :: count
|
||||
|
||||
avg_stress = ZERO
|
||||
if (.not. allocated(stress) .or. .not. allocated(elem_gp_start) .or. &
|
||||
.not. allocated(elem_ngp)) then
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'preload buckling stress state is not allocated', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
do elem = 1, nelem
|
||||
if (elem_status(elem) .ne. 0) cycle
|
||||
if (.not. element_has_node(elem, node1)) cycle
|
||||
if (.not. element_has_node(elem, node2)) cycle
|
||||
count = elem_ngp(elem)
|
||||
if (count .le. 0) exit
|
||||
do q = 1, count
|
||||
gp = elem_gp_start(elem) + q - 1
|
||||
if (gp .ge. 1 .and. gp .le. size(stress,2)) then
|
||||
avg_stress = avg_stress + stress(:,gp)
|
||||
end if
|
||||
end do
|
||||
avg_stress = avg_stress / real(count, rk)
|
||||
ierr = FEM_SUCCESS
|
||||
return
|
||||
end do
|
||||
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'preload buckling geometric line has no host element stress', ierr)
|
||||
end subroutine line_average_stress
|
||||
|
||||
logical function element_has_node(elem, node)
|
||||
integer, intent(in) :: elem
|
||||
integer, intent(in) :: node
|
||||
integer :: local_node
|
||||
|
||||
element_has_node = .false.
|
||||
do local_node = 1, elem_nnode(elem)
|
||||
if (elem_conn(local_node,elem) .eq. node) then
|
||||
element_has_node = .true.
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end function element_has_node
|
||||
|
||||
subroutine build_free_ids(fixed, kgfull, free_ids, nfree)
|
||||
logical, intent(in) :: fixed(:)
|
||||
real(rk), intent(in) :: kgfull(:,:)
|
||||
integer, intent(out) :: free_ids(:)
|
||||
integer, intent(out) :: nfree
|
||||
integer :: dof
|
||||
real(rk) :: row_norm
|
||||
real(rk) :: scale
|
||||
|
||||
scale = max(ONE, maxval(abs(kgfull)))
|
||||
|
||||
nfree = 0
|
||||
do dof = 1, min(size(fixed), size(free_ids))
|
||||
if (fixed(dof)) cycle
|
||||
row_norm = sum(abs(kgfull(dof,:)))
|
||||
if (row_norm .le. 1.0e-12_rk * scale) cycle
|
||||
nfree = nfree + 1
|
||||
free_ids(nfree) = dof
|
||||
end do
|
||||
end subroutine build_free_ids
|
||||
|
||||
subroutine write_outputs(mode_count, factors, residuals, modes, ierr)
|
||||
integer, intent(in) :: mode_count
|
||||
real(rk), intent(in) :: factors(mode_count)
|
||||
real(rk), intent(in) :: residuals(mode_count)
|
||||
real(rk), intent(in) :: modes(ndof,mode_count)
|
||||
integer, intent(out) :: ierr
|
||||
character(len=512) :: path
|
||||
|
||||
call output_csv_build_path('buckling_summary.csv', path)
|
||||
call write_summary(trim(path), mode_count, factors, residuals, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call modal_write_output_csv('buckling_modes.csv', ndof, mode_count, &
|
||||
factors, residuals, modes, ierr)
|
||||
end subroutine write_outputs
|
||||
|
||||
subroutine write_summary(filename, mode_count, factors, residuals, ierr)
|
||||
character(len=*), intent(in) :: filename
|
||||
integer, intent(in) :: mode_count
|
||||
real(rk), intent(in) :: factors(mode_count)
|
||||
real(rk), intent(in) :: residuals(mode_count)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: unit_id
|
||||
integer :: ios
|
||||
integer :: mode
|
||||
|
||||
unit_id = 89
|
||||
open(unit=unit_id, file=filename, status='unknown', action='write', &
|
||||
iostat=ios)
|
||||
if (ios .ne. 0) then
|
||||
call error_set(FEM_ERR_OUTPUT, 'failed to open generic buckling summary', ierr)
|
||||
return
|
||||
end if
|
||||
write(unit_id,'(A)') 'mode,load_factor,residual'
|
||||
do mode = 1, mode_count
|
||||
write(unit_id,'(I0,A,ES24.16,A,ES24.16)') &
|
||||
mode, ',', factors(mode), ',', residuals(mode)
|
||||
end do
|
||||
close(unit_id)
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine write_summary
|
||||
|
||||
end module fem_buckling_general
|
||||
@@ -119,7 +119,7 @@ contains
|
||||
if (force_zero) then
|
||||
scale = ZERO
|
||||
else
|
||||
scale = load_factor * database_amplitude_value(bc_amp(item), time)
|
||||
scale = implicit_dirichlet_scale(bc_amp(item), time)
|
||||
end if
|
||||
value = scale * bc_value(item)
|
||||
do dof_num = bc_dof_start(item), bc_dof_end(item)
|
||||
@@ -132,6 +132,16 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine collect_dirichlet_constraints
|
||||
|
||||
real(rk) function implicit_dirichlet_scale(amp, time)
|
||||
integer, intent(in) :: amp
|
||||
real(rk), intent(in) :: time
|
||||
|
||||
implicit_dirichlet_scale = database_amplitude_value(amp, time)
|
||||
if (nonlinear_continuation_method .eq. NLC_ARC_DISP .and. amp .gt. 0) &
|
||||
return
|
||||
implicit_dirichlet_scale = load_factor * implicit_dirichlet_scale
|
||||
end function implicit_dirichlet_scale
|
||||
|
||||
subroutine mark_bc_target(fixed, values, target, dof_num, value, ierr)
|
||||
logical, intent(inout) :: fixed(:)
|
||||
real(rk), intent(inout) :: values(:)
|
||||
|
||||
@@ -88,6 +88,9 @@ contains
|
||||
end select
|
||||
|
||||
if (ierr .ne. FEM_SUCCESS) then
|
||||
call csr_residual_norm(a, b, x, final_resid, final_rel_resid, &
|
||||
audit_ierr)
|
||||
if (audit_ierr .eq. FEM_SUCCESS) res_norm = final_resid
|
||||
call linear_solver_record(method, preconditioner, iter, res_norm, &
|
||||
status, matrix_class, initial_resid, &
|
||||
final_rel_resid)
|
||||
|
||||
@@ -189,6 +189,10 @@ contains
|
||||
iter_total, res_norm, ierr)
|
||||
return
|
||||
end if
|
||||
if (nonlinear_continuation_method .eq. NLC_ARC_DISP .and. &
|
||||
use_disp_path_adaptive) then
|
||||
adaptive_mode = .true.
|
||||
end if
|
||||
|
||||
if (adaptive_mode) then
|
||||
call nonlinear_static_adaptive_loop(final_time, max_iter, tol, dt_inc, &
|
||||
|
||||
@@ -224,6 +224,7 @@ contains
|
||||
real(rk), intent(out) :: dt_next
|
||||
integer :: low_iter
|
||||
integer :: high_iter
|
||||
integer :: target_iter
|
||||
real(rk) :: raw_dt
|
||||
real(rk) :: min_allowed
|
||||
real(rk) :: grow
|
||||
@@ -240,9 +241,12 @@ contains
|
||||
shrink = nlc_shrink_factor
|
||||
if (shrink .le. ZERO .or. shrink .ge. ONE) shrink = 0.5_rk
|
||||
|
||||
low_iter = max(1, nlc_target_newton / 2)
|
||||
high_iter = max(low_iter + 1, nlc_target_newton + &
|
||||
max(1, nlc_target_newton / 2))
|
||||
target_iter = nlc_target_newton
|
||||
if (nonlinear_continuation_method .eq. NLC_ARC_DISP .and. &
|
||||
target_iter .eq. 6) target_iter = 12
|
||||
|
||||
low_iter = max(1, target_iter / 2)
|
||||
high_iter = max(low_iter + 1, target_iter + max(1, target_iter / 2))
|
||||
|
||||
if (iter_inc .le. low_iter) then
|
||||
raw_dt = dt_done * grow
|
||||
@@ -356,6 +360,8 @@ contains
|
||||
integer :: tmp_ierr
|
||||
integer :: restore_ierr
|
||||
integer :: gmres_ierr
|
||||
integer :: active_method
|
||||
logical :: auto_gmres
|
||||
|
||||
call linear_solver_get_settings(method, preconditioner, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
@@ -368,20 +374,27 @@ contains
|
||||
end if
|
||||
x_saved = x
|
||||
|
||||
call select_nonlinear_linear_solver(method, preconditioner, &
|
||||
active_method, auto_gmres)
|
||||
|
||||
call linear_solver_solve(kmat, rhs, x, iter_limit, tol, iter, res_norm, &
|
||||
ierr)
|
||||
if (ierr .eq. FEM_SUCCESS .or. method .ne. LSOLVER_CG) go to 900
|
||||
if (ierr .eq. FEM_SUCCESS) go to 800
|
||||
if (method .ne. LSOLVER_CG .and. .not. auto_gmres) go to 800
|
||||
|
||||
x = x_saved
|
||||
call error_clear(tmp_ierr)
|
||||
call linear_solver_configure(LSOLVER_GMRES, preconditioner, tmp_ierr)
|
||||
if (tmp_ierr .ne. FEM_SUCCESS) then
|
||||
ierr = tmp_ierr
|
||||
go to 900
|
||||
if (active_method .ne. LSOLVER_GMRES) then
|
||||
call linear_solver_configure(LSOLVER_GMRES, preconditioner, tmp_ierr)
|
||||
if (tmp_ierr .ne. FEM_SUCCESS) then
|
||||
ierr = tmp_ierr
|
||||
go to 800
|
||||
end if
|
||||
call linear_solver_solve(kmat, rhs, x, iter_limit, tol, iter, res_norm, &
|
||||
ierr)
|
||||
else
|
||||
tmp_ierr = FEM_SUCCESS
|
||||
end if
|
||||
|
||||
call linear_solver_solve(kmat, rhs, x, iter_limit, tol, iter, res_norm, &
|
||||
ierr)
|
||||
gmres_ierr = ierr
|
||||
if (gmres_ierr .ne. FEM_SUCCESS) then
|
||||
x = x_saved
|
||||
@@ -407,15 +420,42 @@ contains
|
||||
call solve_nl_dense_regularized(kmat, rhs, x_saved, x, iter_limit, &
|
||||
tol, iter, res_norm, ierr)
|
||||
end if
|
||||
|
||||
800 continue
|
||||
call linear_solver_configure(method, preconditioner, restore_ierr)
|
||||
if (ierr .eq. FEM_SUCCESS .and. restore_ierr .ne. FEM_SUCCESS) then
|
||||
ierr = restore_ierr
|
||||
end if
|
||||
|
||||
900 continue
|
||||
if (allocated(x_saved)) deallocate(x_saved)
|
||||
end subroutine solve_nl_linear_system
|
||||
|
||||
subroutine select_nonlinear_linear_solver(method, preconditioner, &
|
||||
active_method, auto_gmres)
|
||||
integer, intent(in) :: method
|
||||
integer, intent(in) :: preconditioner
|
||||
integer, intent(out) :: active_method
|
||||
logical, intent(out) :: auto_gmres
|
||||
integer :: tmp_ierr
|
||||
|
||||
active_method = method
|
||||
auto_gmres = .false.
|
||||
if (.not. shell_finite_strain_requested) return
|
||||
if (method .ne. LSOLVER_CG) return
|
||||
|
||||
call error_clear(tmp_ierr)
|
||||
if (ndof .le. 250) then
|
||||
call linear_solver_configure(LSOLVER_DENSE, preconditioner, tmp_ierr)
|
||||
if (tmp_ierr .eq. FEM_SUCCESS) active_method = LSOLVER_DENSE
|
||||
else
|
||||
call linear_solver_configure(LSOLVER_GMRES, preconditioner, tmp_ierr)
|
||||
if (tmp_ierr .eq. FEM_SUCCESS) then
|
||||
active_method = LSOLVER_GMRES
|
||||
auto_gmres = .true.
|
||||
end if
|
||||
end if
|
||||
end subroutine select_nonlinear_linear_solver
|
||||
|
||||
subroutine solve_nl_dense_regularized(kmat, rhs, x_saved, x, iter_limit, &
|
||||
tol, iter, res_norm, ierr)
|
||||
type(csr_matrix), intent(inout) :: kmat
|
||||
|
||||
@@ -10,6 +10,7 @@ module fem_solver_static_nonlinear
|
||||
use fem_boundary
|
||||
use fem_implicit_constraints, only: apply_nl_external_tangent, &
|
||||
collect_dirichlet_constraints
|
||||
use fem_output_csv, only: output_csv_write_path
|
||||
use fem_solver_implicit_support, only: zero_fixed_rhs, &
|
||||
begin_static_convergence, record_convergence_iteration, &
|
||||
record_convergence_correction, record_line_search_metrics, &
|
||||
@@ -34,6 +35,9 @@ module fem_solver_static_nonlinear
|
||||
real(rk), allocatable, save :: static_predictor_saved_du(:)
|
||||
real(rk), save :: static_predictor_saved_dt = ZERO
|
||||
logical, save :: static_predictor_saved = .false.
|
||||
real(rk), allocatable, save :: static_arc_saved_du(:)
|
||||
real(rk), save :: static_arc_saved_dl = ZERO
|
||||
logical, save :: static_arc_saved = .false.
|
||||
|
||||
contains
|
||||
subroutine select_static_arc_driver(final_time, arc_load_mode, ierr)
|
||||
@@ -93,6 +97,7 @@ contains
|
||||
integer :: cut_count
|
||||
integer :: iter_inc
|
||||
integer :: stat
|
||||
logical :: path_step_limited
|
||||
logical :: have_predictor
|
||||
|
||||
allocate(u_equil(ndof), du_last(ndof), stat=stat)
|
||||
@@ -131,6 +136,16 @@ contains
|
||||
remaining_time = final_time - current_time
|
||||
call adapt_static_next_dt(iter_inc, dt_try, dt_min_eff, dt_max_eff, &
|
||||
remaining_time, dt_next)
|
||||
call record_static_path_if_needed(sub_target_time, &
|
||||
base_load_factor, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
call limit_disp_path_next_dt(dt_try, dt_min_eff, dt_max_eff, &
|
||||
remaining_time, dt_next, &
|
||||
path_step_limited)
|
||||
if (path_step_limited) then
|
||||
call output_csv_write_path(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
end if
|
||||
dt_try = dt_next
|
||||
exit
|
||||
else if (can_cutback_static(dt_try, dt_min_eff, cut_count)) then
|
||||
@@ -218,6 +233,9 @@ contains
|
||||
nlc_next_target_dt = target_time - current_time
|
||||
if (abs(nlc_next_target_dt) .le. time_tol) nlc_next_target_dt = ZERO
|
||||
nlc_last_adjust = NLC_ADJ_KEEP
|
||||
call record_static_path_if_needed(sub_target_time, &
|
||||
base_load_factor, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
dt_try = target_time - current_time
|
||||
cut_count = 0
|
||||
else if (can_cutback_static(dt_try, dt_min_eff, cut_count)) then
|
||||
@@ -327,8 +345,19 @@ contains
|
||||
current_step = current_step + 1
|
||||
nlc_last_iter = iter_inc
|
||||
nlc_last_actual_dt = dt_try
|
||||
if (nonlinear_continuation_method .ne. NLC_ARC_DISP) then
|
||||
load_factor = base_load_factor
|
||||
end if
|
||||
call error_clear(ierr)
|
||||
end subroutine accept_static_increment
|
||||
|
||||
subroutine record_static_path_if_needed(time, base_load_factor, ierr)
|
||||
real(rk), intent(in) :: time
|
||||
real(rk), intent(in) :: base_load_factor
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (nonlinear_continuation_method .eq. NLC_ARC_DISP) then
|
||||
call record_static_disp_path(sub_target_time, ierr)
|
||||
call record_static_disp_path(time, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) then
|
||||
load_factor = base_load_factor
|
||||
return
|
||||
@@ -336,7 +365,49 @@ contains
|
||||
end if
|
||||
load_factor = base_load_factor
|
||||
call error_clear(ierr)
|
||||
end subroutine accept_static_increment
|
||||
end subroutine record_static_path_if_needed
|
||||
|
||||
subroutine limit_disp_path_next_dt(dt_done, dt_min_eff, dt_max_eff, &
|
||||
remaining_time, dt_next, limited)
|
||||
real(rk), intent(in) :: dt_done
|
||||
real(rk), intent(in) :: dt_min_eff
|
||||
real(rk), intent(in) :: dt_max_eff
|
||||
real(rk), intent(in) :: remaining_time
|
||||
real(rk), intent(inout) :: dt_next
|
||||
logical, intent(out) :: limited
|
||||
real(rk) :: prev_force
|
||||
real(rk) :: last_force
|
||||
real(rk) :: force_ref
|
||||
real(rk) :: rel_change
|
||||
real(rk) :: limited_dt
|
||||
real(rk) :: scale
|
||||
|
||||
limited = .false.
|
||||
if (nonlinear_continuation_method .ne. NLC_ARC_DISP) return
|
||||
if (remaining_time .le. ZERO .or. dt_next .le. ZERO) return
|
||||
if (nlc_path_count .lt. 2) return
|
||||
|
||||
prev_force = nlc_path_real(NLC_PATH_R_REACTION_GENERALIZED, &
|
||||
nlc_path_count - 1)
|
||||
last_force = nlc_path_real(NLC_PATH_R_REACTION_GENERALIZED, &
|
||||
nlc_path_count)
|
||||
force_ref = max(ONE, abs(prev_force), abs(last_force))
|
||||
rel_change = abs(last_force - prev_force) / force_ref
|
||||
if (rel_change .le. 0.08_rk) return
|
||||
|
||||
scale = max(0.35_rk, min(ONE, 0.08_rk / rel_change))
|
||||
limited_dt = max(min(dt_min_eff, remaining_time), dt_done * scale)
|
||||
limited_dt = min(limited_dt, dt_max_eff, remaining_time)
|
||||
if (limited_dt .lt. dt_next) then
|
||||
dt_next = limited_dt
|
||||
nlc_next_target_dt = dt_next
|
||||
nlc_last_adjust = NLC_ADJ_SHRINK
|
||||
nlc_path_real(NLC_PATH_R_NEXT_DT, nlc_path_count) = dt_next
|
||||
nlc_path_int(NLC_PATH_I_ADAPT_ADJUST, nlc_path_count) = &
|
||||
nlc_last_adjust
|
||||
limited = .true.
|
||||
end if
|
||||
end subroutine limit_disp_path_next_dt
|
||||
|
||||
logical function can_cutback_static(dt_try, dt_min_eff, cut_count)
|
||||
real(rk), intent(in) :: dt_try
|
||||
@@ -512,6 +583,7 @@ contains
|
||||
nonlinear_static_load_fraction(current_time, ramp_start_time, &
|
||||
final_time)
|
||||
end if
|
||||
call reset_static_arc_direction()
|
||||
dt_try = initial_adaptive_dt(final_time, dt_inc, dt_min_eff, dt_max_eff)
|
||||
call error_clear(ierr)
|
||||
end subroutine begin_static_arc_driver
|
||||
@@ -725,6 +797,8 @@ contains
|
||||
|
||||
call element_state_commit_trial(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
call store_static_arc_direction(u_start, lambda_start, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
ierr = FEM_SUCCESS
|
||||
|
||||
900 continue
|
||||
@@ -807,6 +881,7 @@ contains
|
||||
integer, intent(out) :: ierr
|
||||
real(rk) :: delta_lambda
|
||||
real(rk) :: direction_norm
|
||||
real(rk) :: predictor_sign
|
||||
|
||||
call boundary_apply_dirichlet(target_time, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
@@ -830,12 +905,60 @@ contains
|
||||
'arc-length predictor has zero load direction', ierr)
|
||||
return
|
||||
end if
|
||||
delta_lambda = sign_dir * arc_radius / direction_norm
|
||||
predictor_sign = static_arc_predictor_sign(sign_dir, load_scale, du_load)
|
||||
delta_lambda = predictor_sign * arc_radius / direction_norm
|
||||
u = u_start + delta_lambda * du_load
|
||||
load_factor = lambda_start + delta_lambda
|
||||
call boundary_apply_dirichlet(target_time, ierr)
|
||||
end subroutine prepare_static_arc_predictor
|
||||
|
||||
subroutine reset_static_arc_direction()
|
||||
if (allocated(static_arc_saved_du)) deallocate(static_arc_saved_du)
|
||||
static_arc_saved_dl = ZERO
|
||||
static_arc_saved = .false.
|
||||
end subroutine reset_static_arc_direction
|
||||
|
||||
function static_arc_predictor_sign(sign_dir, load_scale, du_load) result(predictor_sign)
|
||||
real(rk), intent(in) :: sign_dir
|
||||
real(rk), intent(in) :: load_scale
|
||||
real(rk), intent(in) :: du_load(:)
|
||||
real(rk) :: predictor_sign
|
||||
real(rk) :: tangent_dot
|
||||
|
||||
predictor_sign = sign_dir
|
||||
if (.not. static_arc_saved) return
|
||||
if (.not. allocated(static_arc_saved_du)) return
|
||||
if (size(static_arc_saved_du) .ne. size(du_load)) return
|
||||
|
||||
tangent_dot = sum(static_arc_saved_du * du_load) + &
|
||||
load_scale * load_scale * static_arc_saved_dl
|
||||
if (predictor_sign * tangent_dot .lt. ZERO) predictor_sign = -predictor_sign
|
||||
end function static_arc_predictor_sign
|
||||
|
||||
subroutine store_static_arc_direction(u_start, lambda_start, ierr)
|
||||
real(rk), intent(in) :: u_start(:)
|
||||
real(rk), intent(in) :: lambda_start
|
||||
integer, intent(out) :: ierr
|
||||
integer :: stat
|
||||
|
||||
if (.not. allocated(static_arc_saved_du) .or. &
|
||||
size(static_arc_saved_du) .ne. size(u_start)) then
|
||||
if (allocated(static_arc_saved_du)) deallocate(static_arc_saved_du)
|
||||
allocate(static_arc_saved_du(size(u_start)), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'failed to allocate arc-length direction memory', ierr)
|
||||
return
|
||||
end if
|
||||
end if
|
||||
|
||||
static_arc_saved_du = u - u_start
|
||||
static_arc_saved_dl = load_factor - lambda_start
|
||||
static_arc_saved = sqrt(sum(static_arc_saved_du * static_arc_saved_du) + &
|
||||
static_arc_saved_dl * static_arc_saved_dl) .gt. tiny(ONE)
|
||||
call error_clear(ierr)
|
||||
end subroutine store_static_arc_direction
|
||||
|
||||
subroutine eval_static_arc_iteration(target_time, dt_inc, tol, iter, &
|
||||
u_start, lambda_start, load_scale, &
|
||||
arc_radius, arc_tol, residual, external, &
|
||||
@@ -1088,6 +1211,8 @@ contains
|
||||
convergence_iteration, convergence_residual_norm, &
|
||||
convergence_rel_resid_norm, convergence_correction_norm, &
|
||||
convergence_status_code, convergence_failure_code, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
call output_csv_write_path(ierr)
|
||||
|
||||
900 continue
|
||||
if (allocated(fref)) deallocate(fref)
|
||||
@@ -1185,6 +1310,17 @@ contains
|
||||
convergence_residual_norm, convergence_rel_resid_norm, &
|
||||
convergence_correction_norm, convergence_status_code, &
|
||||
convergence_failure_code, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) then
|
||||
deallocate(fixed)
|
||||
deallocate(values)
|
||||
return
|
||||
end if
|
||||
call output_csv_write_path(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) then
|
||||
deallocate(fixed)
|
||||
deallocate(values)
|
||||
return
|
||||
end if
|
||||
|
||||
deallocate(fixed)
|
||||
deallocate(values)
|
||||
@@ -1317,7 +1453,9 @@ contains
|
||||
trust_scale = ONE
|
||||
line_rejections = 0
|
||||
converged = .false.
|
||||
trust_mode = nonlinear_continuation_method .eq. NLC_TRUST_DAMPED
|
||||
trust_mode = nonlinear_continuation_method .eq. NLC_TRUST_DAMPED .or. &
|
||||
(nonlinear_continuation_method .eq. NLC_ARC_DISP .and. &
|
||||
nlc_trust_radius .gt. ZERO)
|
||||
call begin_static_convergence(increment_id, dt_inc)
|
||||
end subroutine init_static_inc_state
|
||||
|
||||
|
||||
Reference in New Issue
Block a user