Files
FemLite/tests/module/test_implicit_inp.f90
T
shenw 0440ed5a64
FemLite CI / build-test (push) Has been cancelled
Release FemLite 0.6.4
2026-07-05 17:23:34 +08:00

1524 lines
58 KiB
Fortran

program test_implicit_inp
use fem_precision
use fem_control
use fem_api
use fem_database, only: ncontact_pair, contact_pair_slave, &
contact_pair_master, contact_pair_penalty, &
contact_pair_damping, contact_pair_search, &
contact_pair_friction, n_surface, surface_name, &
surface_start, surface_count, surface_target, &
surface_face, surface_owner, surface_type, &
surface_plane_normal, surface_plane_offset, &
n_contact_property, contact_property_name, &
contact_property_penalty, contact_property_damping, &
contact_property_search, contact_property_friction, &
contact_property_friction_reg, &
contact_property_aug_factor, contact_pair_friction_reg, &
contact_pair_aug_factor, &
contact_pair_property, n_section_layer, section_type, &
section_thickness, section_layer_start, &
section_layer_count, section_layer_thickness, &
section_layer_material_name, section_layer_material, &
elem_mat, fint, nmpc, nmpc_term, mpc_start, &
mpc_count, mpc_node, mpc_dof, mpc_coeff, mpc_penalty
use fem_database_surface, only: db_contact_facet_match, &
db_contact_facet_normal_sign, &
db_contact_facet_has_side
use fem_inp_nlc, only: parse_nlc_header
use fem_element_internal, only: element_compute_internal_force
use fem_sparse_csr_diagnostics, only: CSR_CLASS_GENERAL, &
CSR_CLASS_SPD_CAND
implicit none
real(rk), parameter :: TOL = 1.0e-10_rk
call check_implicit_linear_compat()
call check_static_linear_inp()
call check_static_cpl_rhs()
call check_static_patch_file('tests/data/c3d8_static_patch.inp', 2, 0.01_rk, 60)
call check_static_patch_file('tests/data/c3d10_static_patch.inp', 2, 0.01_rk, 80)
call check_static_patch_file('tests/data/c3d20_static_patch.inp', 2, 0.01_rk, 100)
call check_shell_static_patch('tests/data/s4_static_patch.inp', 2, 130)
call check_shell_static_patch('tests/data/s3_static_patch.inp', 2, 160)
call check_shell_static_patch('tests/data/s6_static_patch.inp', 2, 190)
call check_shell_static_patch('tests/data/s8_static_patch.inp', 2, 220)
call check_s4_comp_section_inp()
call check_static_nonlinear_elastic()
call check_static_nl_fail_reason()
call check_static_nonlinear_j2_disp()
call check_buckling_step_inp()
call check_buckling_preload_inp()
call check_buck_solid_preload()
call check_cyclic_solid_inp()
call check_cyclic_symmetry_inp()
call check_nlc_inp()
call check_arc_disp_continuation_api()
call check_sph_zero_int()
call check_shell_finite_unsupported()
call check_implicit_newmark_inp()
call check_contact_pair_inp()
contains
subroutine check_implicit_linear_compat()
integer :: ierr
integer :: iter
integer :: step
integer :: conv_increment
integer :: conv_iteration
integer :: linsol_method
integer :: linsol_preconditioner
integer :: linsol_iteration
integer :: linsol_status
integer :: linsol_matrix_class
real(rk) :: res_norm
real(rk) :: conv_residual_norm
real(rk) :: conv_correction_norm
real(rk) :: linsol_initial_residual
real(rk) :: linsol_residual
real(rk) :: linsol_relative_residual
real(rk) :: time
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
logical :: conv_converged
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1)
call fem_read_inp('tests/data/c3d4_implicit_pull.inp', ierr)
if (ierr .ne. 0) call fail(2)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(3)
call fem_set_linear_solver(LSOLVER_BICGSTAB, LPRECOND_JACOBI, ierr)
if (ierr .ne. 0) call fail(1004)
call fem_solve_implicit_linear(50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(4)
if (iter .le. 0 .or. iter .gt. 5) call fail(5)
if (res_norm .gt. TOL) call fail(6)
call fem_get_convergence_status(conv_increment, conv_iteration, &
conv_residual_norm, conv_correction_norm, conv_converged, ierr)
if (ierr .ne. 0) call fail(17)
if (.not. conv_converged) call fail(18)
if (conv_increment .ne. 1) call fail(19)
if (conv_iteration .ne. iter) call fail(1001)
call check_close(conv_residual_norm, res_norm, 1002)
call check_close(conv_correction_norm, ZERO, 1003)
call fem_get_linear_solver_stats(linsol_method, linsol_preconditioner, &
linsol_iteration, linsol_residual, linsol_status, ierr)
if (ierr .ne. 0) call fail(1005)
if (linsol_method .ne. LSOLVER_BICGSTAB) call fail(1006)
if (linsol_preconditioner .ne. LPRECOND_JACOBI) call fail(1007)
if (linsol_status .ne. LS_STATUS_CONVERGED) call fail(1008)
if (linsol_iteration .le. 0) call fail(1009)
if (linsol_residual .gt. 1.0e-10_rk) call fail(1010)
call fem_get_linsol_diagnostics(linsol_matrix_class, &
linsol_initial_residual, linsol_residual, linsol_relative_residual, &
linsol_status, ierr)
if (ierr .ne. 0) call fail(1012)
if (linsol_matrix_class .lt. CSR_CLASS_GENERAL .or. &
linsol_matrix_class .gt. CSR_CLASS_SPD_CAND) call fail(1013)
if (linsol_initial_residual .le. linsol_residual) call fail(1014)
if (linsol_residual .gt. 1.0e-10_rk) call fail(1015)
if (linsol_relative_residual .gt. 1.0e-10_rk) call fail(1016)
if (linsol_status .ne. LS_STATUS_CONVERGED) call fail(1017)
call fem_set_linear_solver(LSOLVER_CG, LPRECOND_JACOBI, ierr)
if (ierr .ne. 0) call fail(1011)
call fem_get_node_kinematics(2, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(7)
call check_close(displacement(1), 5.0_rk / 6.0_rk, 8)
call check_close(displacement(2), ZERO, 9)
call check_close(displacement(3), ZERO, 10)
call check_close(maxval(abs(velocity)), ZERO, 11)
call check_close(maxval(abs(acceleration)), ZERO, 12)
call fem_get_current_time(time, step, ierr)
if (ierr .ne. 0) call fail(13)
call check_close(time, ZERO, 14)
if (step .ne. 1) call fail(15)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(16)
end subroutine check_implicit_linear_compat
subroutine check_cyclic_solid_inp()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(2200)
call fem_read_inp('tests/data/c3d4_cyclic_symmetry.inp', ierr)
if (ierr .ne. 0) call fail(2201)
if (cyclic_num_sectors .ne. 4) call fail(2202)
if (cyclic_dof_count .ne. 3) call fail(2203)
if (cyclic_pair_count .ne. 1) call fail(2204)
if (nmpc .ne. 3) call fail(2205)
if (nmpc_term .ne. 6) call fail(2206)
call check_cyclic_equation(1, 2, 1, ONE, 1, 2, ONE, 2210)
call check_cyclic_equation(2, 2, 2, ONE, 1, 1, -ONE, 2220)
call check_cyclic_equation(3, 2, 3, ONE, 1, 3, -ONE, 2230)
end subroutine check_cyclic_solid_inp
subroutine check_buck_solid_preload()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(2250)
call fem_read_inp('tests/data/c3d4_buckling_solid_preload.inp', ierr)
if (ierr .ne. 0) call fail(2251)
if (analysis_type .ne. ANALYSIS_BUCKLING) call fail(2252)
if (.not. buckling_static_preload_req) call fail(2253)
if (buckling_num_modes .ne. 1) call fail(2254)
if (buckling_geom_line_count .ne. 0) call fail(2255)
end subroutine check_buck_solid_preload
subroutine check_cyclic_symmetry_inp()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(2300)
call fem_read_inp('tests/data/s4_cyclic_symmetry.inp', ierr)
if (ierr .ne. 0) call fail(2301)
if (cyclic_num_sectors .ne. 4) call fail(2302)
if (cyclic_wave_number .ne. 0) call fail(2303)
if (cyclic_dof_count .ne. 6) call fail(2304)
if (cyclic_pair_count .ne. 1) call fail(2305)
if (nmpc .ne. 6) call fail(2306)
if (nmpc_term .ne. 12) call fail(2307)
if (abs(mpc_penalty(1) - 1.0e9_rk) .gt. ONE) call fail(2308)
call check_cyclic_equation(1, 2, 1, ONE, 1, 2, ONE, 2310)
call check_cyclic_equation(2, 2, 2, ONE, 1, 1, -ONE, 2320)
call check_cyclic_equation(3, 2, 3, ONE, 1, 3, -ONE, 2330)
call check_cyclic_equation(4, 2, 4, ONE, 1, 5, ONE, 2340)
call check_cyclic_equation(5, 2, 5, ONE, 1, 4, -ONE, 2350)
call check_cyclic_equation(6, 2, 6, ONE, 1, 6, -ONE, 2360)
end subroutine check_cyclic_symmetry_inp
subroutine check_cyclic_equation(eqn, slave_node, slave_dof, slave_coeff, &
master_node, master_dof, master_coeff, code)
integer, intent(in) :: eqn
integer, intent(in) :: slave_node
integer, intent(in) :: slave_dof
integer, intent(in) :: master_node
integer, intent(in) :: master_dof
integer, intent(in) :: code
real(rk), intent(in) :: slave_coeff
real(rk), intent(in) :: master_coeff
integer :: start_pos
if (mpc_count(eqn) .ne. 2) call fail(code)
start_pos = mpc_start(eqn)
if (mpc_node(start_pos) .ne. slave_node) call fail(code + 1)
if (mpc_dof(start_pos) .ne. slave_dof) call fail(code + 2)
call check_close(mpc_coeff(start_pos), slave_coeff, code + 3)
if (mpc_node(start_pos + 1) .ne. master_node) call fail(code + 4)
if (mpc_dof(start_pos + 1) .ne. master_dof) call fail(code + 5)
call check_close(mpc_coeff(start_pos + 1), master_coeff, code + 6)
end subroutine check_cyclic_equation
subroutine check_static_linear_inp()
integer :: ierr
integer :: iter
integer :: step
integer :: max_steps
logical :: user_dt
real(rk) :: res_norm
real(rk) :: time
real(rk) :: dt
real(rk) :: end_time
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
integer :: query_nodes(4)
real(rk) :: reactions(NDOF_NODE,4)
integer :: query_elems(1)
real(rk) :: stress_out(NSTRESS,1)
real(rk) :: strain_out(NSTRESS,1)
real(rk) :: plastic_strain(NSTRESS,1)
real(rk) :: eqps(1)
real(rk) :: damage(1)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(20)
call fem_read_inp('tests/data/c3d4_static_pull.inp', ierr)
if (ierr .ne. 0) call fail(21)
if (analysis_type .ne. ANALYSIS_STATIC_LINEAR) call fail(22)
call fem_get_time_control(dt, end_time, max_steps, user_dt, ierr)
if (ierr .ne. 0) call fail(23)
call check_close(dt, 0.1_rk, 24)
call check_close(end_time, ONE, 25)
if (.not. user_dt) call fail(26)
if (max_steps .ne. 10) call fail(27)
if (max_increment .ne. 10) call fail(28)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(29)
call fem_solve_static_linear(50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(30)
if (iter .le. 0 .or. iter .gt. 5) call fail(31)
if (res_norm .gt. TOL) call fail(32)
call fem_get_node_kinematics(2, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(33)
call check_close(displacement(1), 5.0_rk / 6.0_rk, 34)
call check_close(displacement(2), ZERO, 35)
call check_close(displacement(3), ZERO, 36)
call check_close(maxval(abs(velocity)), ZERO, 37)
call check_close(maxval(abs(acceleration)), ZERO, 38)
call fem_get_current_time(time, step, ierr)
if (ierr .ne. 0) call fail(39)
call check_close(time, ONE, 40)
if (step .ne. 1) call fail(41)
query_nodes(1) = 1
query_nodes(2) = 2
query_nodes(3) = 3
query_nodes(4) = 4
call fem_get_nodal_reactions(4, query_nodes, reactions, ierr)
if (ierr .ne. 0) call fail(42)
call check_close(sum(reactions(1,:)), -5.0_rk, 43)
call check_close(sum(reactions(2,:)), ZERO, 44)
call check_close(sum(reactions(3,:)), ZERO, 45)
query_elems(1) = 1
call fem_get_element_average_state(1, query_elems, stress_out, strain_out, &
plastic_strain, eqps, damage, ierr)
if (ierr .ne. 0) call fail(46)
call check_close(strain_out(1,1), 5.0_rk / 6.0_rk, 47)
call check_close(strain_out(2,1), ZERO, 48)
call check_close(strain_out(3,1), ZERO, 49)
call check_close(stress_out(1,1), 30.0_rk, 50)
call check_close(stress_out(2,1), 10.0_rk, 51)
call check_close(stress_out(3,1), 10.0_rk, 52)
call check_close(maxval(abs(stress_out(4:6,1))), ZERO, 53)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(54)
end subroutine check_static_linear_inp
subroutine check_static_cpl_rhs()
integer :: ierr
integer :: iter
integer :: accepted_count
integer :: rejected_nonfinite
integer :: rejected_unknown_node
integer :: rejected_capacity
integer :: node_ids(1)
integer :: source_ids(1)
integer :: load_mode(1)
integer :: valid_flags(1)
real(rk) :: res_norm
real(rk) :: forces(NDIM,1)
real(rk) :: total_force(NDIM)
real(rk) :: total_moment(NDIM)
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1360)
call fem_read_inp('tests/data/c3d4_static_coupling_pull.inp', ierr)
if (ierr .ne. 0) call fail(1361)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(1362)
call fem_clear_coupling_loads(ierr)
if (ierr .ne. 0) call fail(1363)
node_ids(1) = 2
source_ids(1) = 77
load_mode(1) = 1
valid_flags(1) = 1
forces(:,1) = ZERO
forces(1,1) = 5.0_rk
call fem_apply_coupling_nodal_forces(1, node_ids, forces, source_ids, &
load_mode, valid_flags, ierr)
if (ierr .ne. 0) call fail(1364)
call fem_get_coupling_load_diag(total_force, total_moment, accepted_count, &
rejected_nonfinite, rejected_unknown_node, &
rejected_capacity, ierr)
if (ierr .ne. 0) call fail(1365)
if (accepted_count .ne. 1 .or. rejected_nonfinite .ne. 0 .or. &
rejected_unknown_node .ne. 0 .or. rejected_capacity .ne. 0) then
call fail(1366)
end if
call check_close(total_force(1), 5.0_rk, 1367)
call check_close(total_force(2), ZERO, 1368)
call check_close(total_force(3), ZERO, 1369)
call check_close(maxval(abs(total_moment)), ZERO, 1370)
call fem_solve_static_linear(50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(1371)
if (iter .le. 0 .or. iter .gt. 5) call fail(1372)
if (res_norm .gt. TOL) call fail(1373)
call fem_get_node_kinematics(2, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(1374)
call check_close(displacement(1), 5.0_rk / 6.0_rk, 1375)
call check_close(displacement(2), ZERO, 1376)
call check_close(displacement(3), ZERO, 1377)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1378)
end subroutine check_static_cpl_rhs
subroutine check_buckling_step_inp()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1230)
call fem_read_inp('tests/data/c3d4_buckling_step.inp', ierr)
if (ierr .ne. 0) call fail(1231)
if (analysis_type .ne. ANALYSIS_BUCKLING) call fail(1232)
if (buckling_static_preload_req) call fail(1265)
if (buckling_num_modes .ne. 1) call fail(1260)
if (buckling_geom_line_count .ne. 1) call fail(1261)
if (buckling_geom_line_node1(1) .ne. 1) call fail(1262)
if (buckling_geom_line_node2(1) .ne. 2) call fail(1263)
call check_close(buckling_geom_line_force(1), ONE, 1264)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1233)
end subroutine check_buckling_step_inp
subroutine check_buckling_preload_inp()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1270)
call fem_read_inp('tests/data/c3d4_buckling_static_preload.inp', ierr)
if (ierr .ne. 0) call fail(1271)
if (analysis_type .ne. ANALYSIS_BUCKLING) call fail(1272)
if (.not. buckling_static_preload_req) call fail(1273)
if (buckling_num_modes .ne. 1) call fail(1274)
if (buckling_geom_line_count .ne. 1) call fail(1275)
if (buck_geom_line_kind(1) .ne. BUCK_GEOM_PRELOAD) call fail(1277)
call check_close(buck_geom_line_area(1), ONE, 1278)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1276)
end subroutine check_buckling_preload_inp
subroutine check_s4_comp_section_inp()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(2301)
call fem_read_inp('tests/data/s4_composite_section.inp', ierr)
if (ierr .ne. 0) call fail(2302)
if (n_section_layer .ne. 2) call fail(2303)
if (trim(section_type(1)) .ne. 'SHELL_COMPOSITE') call fail(2304)
if (section_layer_start(1) .ne. 1) call fail(2305)
if (section_layer_count(1) .ne. 2) call fail(2306)
call check_close(section_thickness(1), 0.2_rk, 2307)
call check_close(section_layer_thickness(1), 0.1_rk, 2308)
call check_close(section_layer_thickness(2), 0.1_rk, 2309)
if (trim(section_layer_material_name(1)) .ne. 'LOW') call fail(2310)
if (trim(section_layer_material_name(2)) .ne. 'HIGH') call fail(2311)
if (elem_mat(1) .ne. 1) call fail(2312)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(2313)
if (section_layer_material(1) .ne. 1) call fail(2314)
if (section_layer_material(2) .ne. 2) call fail(2315)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(2316)
end subroutine check_s4_comp_section_inp
subroutine check_static_nonlinear_elastic()
integer :: ierr
integer :: iter
integer :: step
integer :: conv_increment
integer :: conv_iteration
integer :: conv_cutback_count
integer :: conv_status_code
integer :: conv_failure_code
integer :: conv_reason_id
integer :: query_nodes(4)
integer :: query_elems(1)
real(rk) :: res_norm
real(rk) :: conv_residual_norm
real(rk) :: conv_correction_norm
real(rk) :: conv_last_dt
real(rk) :: conv_last_accepted_time
real(rk) :: conv_relative_residual
real(rk) :: conv_contact_gap
real(rk) :: conv_combined_norm
real(rk) :: time
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
real(rk) :: reactions(NDOF_NODE,4)
real(rk) :: stress_out(NSTRESS,1)
real(rk) :: strain_out(NSTRESS,1)
real(rk) :: plastic_strain(NSTRESS,1)
real(rk) :: eqps(1)
real(rk) :: damage(1)
logical :: conv_converged
character(len=64) :: conv_reason_name
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(250)
call fem_read_inp('tests/data/c3d4_static_nonlinear_elastic.inp', ierr)
if (ierr .ne. 0) call fail(251)
if (max_increment .ne. 4) call fail(252)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(253)
call fem_solve_static_nonlinear(4, 50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(254)
if (iter .le. 0 .or. iter .gt. 12) call fail(255)
if (res_norm .gt. TOL) call fail(256)
call fem_get_convergence_status(conv_increment, conv_iteration, &
conv_residual_norm, conv_correction_norm, conv_converged, ierr)
if (ierr .ne. 0) call fail(277)
if (.not. conv_converged) call fail(278)
if (conv_increment .ne. 4) call fail(279)
if (conv_iteration .le. 0) call fail(280)
if (conv_residual_norm .gt. TOL) call fail(281)
if (conv_correction_norm .lt. ZERO) call fail(282)
call fem_get_convergence_diagnostics(conv_cutback_count, conv_last_dt, &
conv_last_accepted_time, conv_status_code, conv_failure_code, ierr)
if (ierr .ne. 0) call fail(283)
if (conv_cutback_count .ne. 0) call fail(284)
call check_close(conv_last_dt, 0.25_rk, 285)
if (conv_status_code .ne. CONVERGENCE_STATUS_CONVERGED) call fail(286)
call check_close(conv_last_accepted_time, ONE, 287)
if (conv_failure_code .ne. CONV_FAIL_NONE) call fail(288)
call fem_get_convergence_reason(conv_reason_id, conv_reason_name, ierr)
if (ierr .ne. 0) call fail(2288)
if (conv_reason_id .ne. NFAIL_NONE) call fail(2289)
if (trim(conv_reason_name) .ne. 'none') call fail(2290)
call fem_get_convergence_metrics(conv_relative_residual, &
conv_contact_gap, conv_combined_norm, ierr)
if (ierr .ne. 0) call fail(289)
if (conv_relative_residual .gt. TOL) call fail(290)
call check_close(conv_contact_gap, ZERO, 291)
if (conv_combined_norm .lt. conv_relative_residual .or. &
conv_combined_norm .lt. conv_contact_gap) call fail(292)
call fem_get_node_kinematics(2, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(257)
call check_close(displacement(1), 5.0_rk / 6.0_rk, 258)
call check_close(displacement(2), ZERO, 259)
call check_close(displacement(3), ZERO, 260)
call check_close(maxval(abs(velocity)), ZERO, 261)
call check_close(maxval(abs(acceleration)), ZERO, 262)
call fem_get_current_time(time, step, ierr)
if (ierr .ne. 0) call fail(263)
call check_close(time, ONE, 264)
if (step .ne. 4) call fail(265)
query_nodes(1) = 1
query_nodes(2) = 2
query_nodes(3) = 3
query_nodes(4) = 4
call fem_get_nodal_reactions(4, query_nodes, reactions, ierr)
if (ierr .ne. 0) call fail(266)
call check_close(sum(reactions(1,:)), -5.0_rk, 267)
call check_close(sum(reactions(2,:)), ZERO, 268)
call check_close(sum(reactions(3,:)), ZERO, 269)
query_elems(1) = 1
call fem_get_element_average_state(1, query_elems, stress_out, strain_out, &
plastic_strain, eqps, damage, ierr)
if (ierr .ne. 0) call fail(270)
call check_close(strain_out(1,1), 5.0_rk / 6.0_rk, 271)
call check_close(stress_out(1,1), 30.0_rk, 272)
call check_close(stress_out(2,1), 10.0_rk, 273)
call check_close(stress_out(3,1), 10.0_rk, 274)
call check_close(maxval(abs(stress_out(4:6,1))), ZERO, 275)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(276)
end subroutine check_static_nonlinear_elastic
subroutine check_static_nl_fail_reason()
integer :: ierr
integer :: iter
integer :: conv_reason_id
real(rk) :: res_norm
character(len=64) :: conv_reason_name
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(2291)
call fem_read_inp('tests/data/c3d4_static_nonlinear_elastic.inp', ierr)
if (ierr .ne. 0) call fail(2292)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(2293)
call fem_solve_static_nonlinear(4, 1, 1.0e-30_rk, iter, res_norm, ierr)
if (ierr .eq. 0) call fail(2294)
call fem_get_convergence_reason(conv_reason_id, conv_reason_name, ierr)
if (ierr .ne. 0) call fail(2295)
if (conv_reason_id .ne. NFAIL_MIN_STEP) call fail(2296)
if (trim(conv_reason_name) .ne. 'minimum-step-exhausted') call fail(2297)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(2298)
end subroutine check_static_nl_fail_reason
subroutine check_static_nonlinear_j2_disp()
integer :: ierr
integer :: iter
integer :: step
integer :: query_elems(1)
real(rk) :: res_norm
real(rk) :: time
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
real(rk) :: stress_out(NSTRESS,1)
real(rk) :: strain_out(NSTRESS,1)
real(rk) :: plastic_strain(NSTRESS,1)
real(rk) :: eqps(1)
real(rk) :: damage(1)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(300)
call fem_read_inp('tests/data/c3d4_static_nonlinear_j2_disp.inp', ierr)
if (ierr .ne. 0) call fail(301)
if (max_increment .ne. 4) call fail(302)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(303)
call fem_solve_static_nonlinear(4, 50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(304)
if (iter .le. 0 .or. iter .gt. 4) call fail(305)
if (res_norm .gt. TOL) call fail(306)
call fem_get_node_kinematics(2, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(307)
call check_close(displacement(1), 0.05_rk, 308)
call check_close(displacement(2), ZERO, 309)
call check_close(displacement(3), ZERO, 310)
call fem_get_current_time(time, step, ierr)
if (ierr .ne. 0) call fail(311)
call check_close(time, ONE, 312)
if (step .ne. 4) call fail(313)
query_elems(1) = 1
call fem_get_element_average_state(1, query_elems, stress_out, strain_out, &
plastic_strain, eqps, damage, ierr)
if (ierr .ne. 0) call fail(314)
call check_close(strain_out(1,1), 0.05_rk, 315)
if (eqps(1) .le. 1.0e-8_rk) call fail(316)
if (stress_out(1,1) .ge. 18.0_rk) call fail(317)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(318)
end subroutine check_static_nonlinear_j2_disp
subroutine check_implicit_newmark_inp()
integer :: ierr
integer :: iter
integer :: step
integer :: max_steps
logical :: user_dt
real(rk) :: res_norm
real(rk) :: time
real(rk) :: dt
real(rk) :: end_time
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(330)
call fem_read_inp('tests/data/c3d4_implicit_newmark_pull.inp', ierr)
if (ierr .ne. 0) call fail(331)
call fem_get_time_control(dt, end_time, max_steps, user_dt, ierr)
if (ierr .ne. 0) call fail(332)
call check_close(dt, 0.1_rk, 333)
call check_close(end_time, 0.1_rk, 334)
if (.not. user_dt) call fail(335)
if (max_steps .ne. 1) call fail(336)
call fem_set_output_interval(0, ierr)
if (ierr .ne. 0) call fail(337)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(338)
call fem_run_implicit_newmark(50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(339)
if (iter .le. 0 .or. iter .gt. 5) call fail(340)
if (res_norm .gt. TOL) call fail(341)
call fem_get_node_kinematics(2, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(342)
call check_close(displacement(1), 15.0_rk / 68.0_rk, 343)
call check_close(velocity(1), 75.0_rk / 17.0_rk, 344)
call check_close(acceleration(1), 1500.0_rk / 17.0_rk, 345)
call check_close(displacement(2), ZERO, 346)
call check_close(displacement(3), ZERO, 347)
call fem_get_current_time(time, step, ierr)
if (ierr .ne. 0) call fail(348)
call check_close(time, 0.1_rk, 349)
if (step .ne. 1) call fail(350)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(351)
end subroutine check_implicit_newmark_inp
subroutine check_nlc_inp()
call check_nlc_file_defaults()
call check_nlc_method_ids()
call check_nlc_method_symbols()
call check_nlc_valid_options()
call check_nlc_error_rollbacks()
end subroutine check_nlc_inp
subroutine check_nlc_file_defaults()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1100)
if (nonlinear_continuation_method .ne. NLC_DEFAULT) call fail(1101)
call fem_read_inp('tests/data/c3d4_static_nonlinear_elastic.inp', ierr)
if (ierr .ne. 0) call fail(1102)
if (nonlinear_continuation_method .ne. NLC_DEFAULT) call fail(1103)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1104)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1110)
call fem_read_inp('tests/data/c3d4_static_nonlinear_continuation.inp', &
ierr)
if (ierr .ne. 0) call fail(1111)
if (nonlinear_continuation_method .ne. &
NLC_ADAPT_NEWTON) call fail(1112)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1113)
end subroutine check_nlc_file_defaults
subroutine check_nlc_method_ids()
integer :: ierr
integer :: method
character(len=256) :: header
do method = NLC_TWO_STAGE, NLC_MC_SUBSTEP
call control_set_defaults()
write(header,'(A,I0)') '*NONLINEAR CONTINUATION, METHOD=', method
call parse_nlc_header(header, ierr)
if (ierr .ne. 0) call fail(1120 + method)
if (nonlinear_continuation_method .ne. method) call fail(1130 + method)
end do
end subroutine check_nlc_method_ids
subroutine check_nlc_method_symbols()
call check_nlc_symbol('TWO_STAGE_LOAD_STRENGTH', &
NLC_TWO_STAGE, 1140)
call check_nlc_symbol('ADAPTIVE_TARGET_NEWTON', &
NLC_ADAPT_NEWTON, 1150)
call check_nlc_symbol('TRUST_REGION_DAMPED_NEWTON', &
NLC_TRUST_DAMPED, 1160)
call check_nlc_symbol('ARC_LENGTH_OR_DISPLACEMENT_CONTROL', &
NLC_ARC_DISP, 1170)
call check_nlc_symbol('MC_SUBSTEPPING_SEMISMOOTH', &
NLC_MC_SUBSTEP, 1180)
end subroutine check_nlc_method_symbols
subroutine check_nlc_valid_options()
integer :: ierr
call control_set_defaults()
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=MC_SUBSTEPPING_SEMISMOOTH,'// &
' MC_MIN_SUBSTEPS=3, MC_MAX_SUBSTEPS=24,'// &
' MC_TARGET_STRAIN=2.5E-4, MC_YIELD_TOL=1.0E-9,'// &
' MC_PLASTIC_LIMIT=2.5E-2', ierr)
if (ierr .ne. 0) call fail(1220)
if (nonlinear_continuation_method .ne. NLC_MC_SUBSTEP) call fail(1221)
if (nlc_mc_min_substeps .ne. 3) call fail(1222)
if (nlc_mc_max_substeps .ne. 24) call fail(1223)
call check_close(nlc_mc_target_strain, 2.5e-4_rk, 1224)
call check_close(nlc_mc_yield_tolerance, 1.0e-9_rk, 1225)
call check_close(nlc_mc_plastic_limit, 2.5e-2_rk, 1226)
call control_set_defaults()
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=ADAPTIVE_TARGET_NEWTON,'// &
' TARGET_NEWTON=9, GROWTH=1.75, SHRINK=0.4', ierr)
if (ierr .ne. 0) call fail(1185)
if (nonlinear_continuation_method .ne. NLC_ADAPT_NEWTON) call fail(1186)
if (nlc_target_newton .ne. 9) call fail(1187)
call check_close(nlc_growth_factor, 1.75_rk, 1188)
call check_close(nlc_shrink_factor, 0.4_rk, 1189)
call control_set_defaults()
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=TRUST_REGION_DAMPED_NEWTON,'// &
' TRUST_RADIUS=0.2, TRUST_MIN_RADIUS=0.05,'// &
' TRUST_MAX_RADIUS=0.4, TRUST_GROWTH=1.8,'// &
' TRUST_SHRINK=0.35, TRUST_ACCEPT_RATIO=0.1,'// &
' TRUST_GOOD_RATIO=0.7', ierr)
if (ierr .ne. 0) call fail(1200)
if (nonlinear_continuation_method .ne. NLC_TRUST_DAMPED) call fail(1201)
call check_close(nlc_trust_radius, 0.2_rk, 1202)
call check_close(nlc_trust_min_radius, 0.05_rk, 1203)
call check_close(nlc_trust_max_radius, 0.4_rk, 1204)
call check_close(nlc_trust_growth_factor, 1.8_rk, 1205)
call check_close(nlc_trust_shrink_factor, 0.35_rk, 1206)
call check_close(nlc_trust_accept_ratio, 0.1_rk, 1207)
call check_close(nlc_trust_good_ratio, 0.7_rk, 1208)
call control_set_defaults()
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL,'// &
' ARC_LENGTH=0.35, ARC_LOAD_SCALE=2.5, SHELL_GEOMETRIC=FINITE_STRAIN,'// &
' DISP_ADAPTIVE=YES', ierr)
if (ierr .ne. 0) call fail(1260)
if (nonlinear_continuation_method .ne. NLC_ARC_DISP) call fail(1261)
if (.not. shell_finite_strain_requested) call fail(1262)
if (.not. use_disp_path_adaptive) call fail(1271)
call check_close(nlc_arc_length_radius, 0.35_rk, 1267)
call check_close(nlc_arc_load_scale, 2.5_rk, 1268)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL,'// &
' TRUST_RADIUS=0.12, TRUST_MIN_RADIUS=0.01, TRUST_MAX_RADIUS=0.2', &
ierr)
if (ierr .ne. 0) call fail(1277)
if (nonlinear_continuation_method .ne. NLC_ARC_DISP) call fail(1278)
call check_close(nlc_trust_radius, 0.12_rk, 1279)
call check_close(nlc_trust_min_radius, 0.01_rk, 1280)
call check_close(nlc_trust_max_radius, 0.2_rk, 1281)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL,'// &
' SHELL_GEOMETRIC=LINEAR, DISP_ADAPTIVE=NO', ierr)
if (ierr .ne. 0) call fail(1263)
if (shell_finite_strain_requested) call fail(1264)
if (use_disp_path_adaptive) call fail(1272)
end subroutine check_nlc_valid_options
subroutine check_nlc_error_rollbacks()
integer :: ierr
shell_finite_strain_requested = .true.
use_disp_path_adaptive = .true.
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, SHELL_GEOMETRIC=MAYBE', ierr)
if (ierr .eq. 0) call fail(1265)
if (.not. shell_finite_strain_requested) call fail(1266)
if (.not. use_disp_path_adaptive) call fail(1273)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, COROTATIONAL_SHELL=NO', ierr)
if (ierr .eq. 0) call fail(1269)
if (.not. shell_finite_strain_requested) call fail(1270)
if (.not. use_disp_path_adaptive) call fail(1274)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, DISP_ADAPTIVE=MAYBE', ierr)
if (ierr .eq. 0) call fail(1275)
if (.not. use_disp_path_adaptive) call fail(1276)
call control_set_defaults()
nonlinear_continuation_method = NLC_ADAPT_NEWTON
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=6', ierr)
if (ierr .eq. 0) call fail(1190)
if (nonlinear_continuation_method .ne. &
NLC_ADAPT_NEWTON) call fail(1191)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=NOT_A_METHOD', ierr)
if (ierr .eq. 0) call fail(1192)
if (nonlinear_continuation_method .ne. &
NLC_ADAPT_NEWTON) call fail(1193)
nlc_target_newton = 7
nlc_growth_factor = 1.6_rk
nlc_shrink_factor = 0.3_rk
nlc_trust_radius = 0.2_rk
nlc_trust_min_radius = 0.05_rk
nlc_trust_max_radius = 0.4_rk
nlc_trust_growth_factor = 1.8_rk
nlc_trust_shrink_factor = 0.35_rk
nlc_trust_accept_ratio = 0.1_rk
nlc_trust_good_ratio = 0.7_rk
nlc_arc_length_radius = 0.25_rk
nlc_arc_load_scale = 2.0_rk
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=ADAPTIVE_TARGET_NEWTON,'// &
' TARGET_NEWTON=0', ierr)
if (ierr .eq. 0) call fail(1194)
if (nlc_target_newton .ne. 7) call fail(1195)
call check_close(nlc_growth_factor, 1.6_rk, 1196)
call check_close(nlc_shrink_factor, 0.3_rk, 1197)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=TRUST_REGION_DAMPED_NEWTON,'// &
' TRUST_RADIUS=0.01, TRUST_MIN_RADIUS=0.02', ierr)
if (ierr .eq. 0) call fail(1210)
call check_close(nlc_trust_radius, 0.2_rk, 1211)
call check_close(nlc_trust_min_radius, 0.05_rk, 1212)
call check_close(nlc_trust_max_radius, 0.4_rk, 1213)
call check_close(nlc_trust_growth_factor, 1.8_rk, 1214)
call check_close(nlc_trust_shrink_factor, 0.35_rk, 1215)
call check_close(nlc_trust_accept_ratio, 0.1_rk, 1216)
call check_close(nlc_trust_good_ratio, 0.7_rk, 1217)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL,'// &
' ARC_LENGTH=-0.1', ierr)
if (ierr .eq. 0) call fail(1282)
call check_close(nlc_arc_length_radius, 0.25_rk, 1283)
call check_close(nlc_arc_load_scale, 2.0_rk, 1284)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL,'// &
' ARC_LOAD_SCALE=0.0', ierr)
if (ierr .eq. 0) call fail(1285)
call check_close(nlc_arc_length_radius, 0.25_rk, 1286)
call check_close(nlc_arc_load_scale, 2.0_rk, 1287)
nlc_mc_min_substeps = 4
nlc_mc_max_substeps = 16
nlc_mc_target_strain = 1.0e-3_rk
nlc_mc_yield_tolerance = 1.0e-8_rk
nlc_mc_plastic_limit = 4.0e-2_rk
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=MC_SUBSTEPPING_SEMISMOOTH,'// &
' MC_MIN_SUBSTEPS=8, MC_MAX_SUBSTEPS=2', ierr)
if (ierr .eq. 0) call fail(1230)
if (nlc_mc_min_substeps .ne. 4) call fail(1231)
if (nlc_mc_max_substeps .ne. 16) call fail(1232)
call check_close(nlc_mc_target_strain, 1.0e-3_rk, 1233)
call check_close(nlc_mc_yield_tolerance, 1.0e-8_rk, 1234)
call check_close(nlc_mc_plastic_limit, 4.0e-2_rk, 1235)
call parse_nlc_header( &
'*NONLINEAR CONTINUATION, METHOD=MC_SUBSTEPPING_SEMISMOOTH,'// &
' MC_TARGET_STRAIN=0.0', ierr)
if (ierr .eq. 0) call fail(1236)
if (nlc_mc_min_substeps .ne. 4) call fail(1237)
if (nlc_mc_max_substeps .ne. 16) call fail(1238)
end subroutine check_nlc_error_rollbacks
subroutine check_nlc_symbol(symbol, expected, code_base)
character(len=*), intent(in) :: symbol
integer, intent(in) :: expected
integer, intent(in) :: code_base
integer :: ierr
character(len=160) :: header
call control_set_defaults()
header = '*NONLINEAR CONTINUATION, METHOD='//trim(symbol)
call parse_nlc_header(header, ierr)
if (ierr .ne. 0) call fail(code_base)
if (nonlinear_continuation_method .ne. expected) call fail(code_base + 1)
end subroutine check_nlc_symbol
subroutine check_arc_disp_continuation_api()
integer :: ierr
integer :: iter
integer :: path_count
integer :: row_step
integer :: control_dof_count
integer :: row_iteration
integer :: status_code
integer :: failure_code
real(rk) :: res_norm
real(rk) :: row_time
real(rk) :: control_parameter
real(rk) :: prescribed_l2
real(rk) :: prescribed_max
real(rk) :: actual_l2
real(rk) :: actual_max
real(rk) :: residual_linf
real(rk) :: residual_l2
real(rk) :: reaction_sum
real(rk) :: reaction_generalized
real(rk) :: work
real(rk) :: residual_norm
real(rk) :: relative_residual
real(rk) :: correction_norm
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1220)
call fem_read_inp('tests/data/c3d4_static_arc_disp_continuation.inp', &
ierr)
if (ierr .ne. 0) call fail(1221)
if (nonlinear_continuation_method .ne. NLC_ARC_DISP) call fail(1222)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(1223)
call fem_solve_static_nonlinear(2, 50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(1224)
if (iter .le. 0) call fail(1225)
if (res_norm .gt. TOL) call fail(1226)
call fem_get_continuation_path_count(path_count, ierr)
if (ierr .ne. 0) call fail(1227)
if (path_count .ne. 2) call fail(1228)
call fem_get_continuation_path_row(1, row_step, row_time, &
control_parameter, control_dof_count, prescribed_l2, prescribed_max, &
actual_l2, actual_max, residual_linf, residual_l2, reaction_sum, &
reaction_generalized, work, row_iteration, residual_norm, &
relative_residual, correction_norm, status_code, failure_code, ierr)
if (ierr .ne. 0) call fail(1229)
if (row_step .ne. 1) call fail(1230)
call check_close(row_time, 0.5_rk, 1231)
call check_close(control_parameter, 0.5_rk, 1232)
if (control_dof_count .ne. 1) call fail(1233)
call check_close(prescribed_l2, 0.125_rk, 1234)
call check_close(prescribed_max, 0.125_rk, 1235)
call check_close(actual_l2, 0.125_rk, 1236)
if (residual_linf .gt. TOL) call fail(1237)
if (residual_l2 .gt. TOL) call fail(1238)
if (abs(reaction_sum) .le. TOL) call fail(1239)
if (row_iteration .le. 0) call fail(1240)
if (status_code .ne. CONVERGENCE_STATUS_CONVERGED) call fail(1241)
if (failure_code .ne. CONV_FAIL_NONE) call fail(1242)
call fem_get_continuation_path_row(2, row_step, row_time, &
control_parameter, control_dof_count, prescribed_l2, prescribed_max, &
actual_l2, actual_max, residual_linf, residual_l2, reaction_sum, &
reaction_generalized, work, row_iteration, residual_norm, &
relative_residual, correction_norm, status_code, failure_code, ierr)
if (ierr .ne. 0) call fail(1243)
if (row_step .ne. 2) call fail(1244)
call check_close(row_time, ONE, 1245)
call check_close(control_parameter, ONE, 1246)
if (control_dof_count .ne. 1) call fail(1247)
call check_close(prescribed_l2, 0.25_rk, 1248)
call check_close(actual_l2, 0.25_rk, 1249)
if (residual_linf .gt. TOL) call fail(1250)
if (residual_l2 .gt. TOL) call fail(1251)
if (abs(reaction_generalized) .le. TOL) call fail(1252)
if (status_code .ne. CONVERGENCE_STATUS_CONVERGED) call fail(1253)
if (failure_code .ne. CONV_FAIL_NONE) call fail(1254)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1255)
end subroutine check_arc_disp_continuation_api
subroutine check_shell_finite_unsupported()
integer :: ierr
integer :: iter
integer :: error_code
real(rk) :: res_norm
character(len=256) :: message
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1450)
call fem_read_inp('tests/data/s3_static_finite_strain_unsupported.inp', &
ierr)
if (ierr .ne. 0) call fail(1451)
if (.not. shell_finite_strain_requested) call fail(1452)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(1453)
call fem_solve_static_nonlinear(1, 10, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .eq. 0) call fail(1454)
call fem_get_last_error(error_code, message, ierr)
if (ierr .ne. 0) call fail(1455)
if (index(trim(message), 'supports S4 elements only') .le. 0) &
call fail(1456)
if (.not. shell_finite_strain_requested) call fail(1457)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1458)
end subroutine check_shell_finite_unsupported
subroutine check_sph_zero_int()
integer :: ierr
real(rk) :: max_force
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1400)
call fem_read_inp('tests/data/s4_static_zero_internal_finite.inp', ierr)
if (ierr .ne. 0) call fail(1401)
if (.not. shell_finite_strain_requested) call fail(1406)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(1402)
call element_compute_internal_force(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(1403)
max_force = maxval(abs(fint))
if (max_force .gt. 1.0e-5_rk) then
write(*,'(A,ES16.8)') 'finite S4 zero internal max force=', max_force
call fail(1404)
end if
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1405)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1407)
call fem_read_inp('tests/data/s4_static_zero_internal_linear.inp', ierr)
if (ierr .ne. 0) call fail(1408)
if (shell_finite_strain_requested) call fail(1409)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(1410)
call element_compute_internal_force(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(1411)
max_force = maxval(abs(fint))
if (max_force .gt. 1.0e-7_rk) then
write(*,'(A,ES16.8)') 'linear S4 zero internal max force=', max_force
call fail(1412)
end if
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(1413)
end subroutine check_sph_zero_int
subroutine check_contact_pair_inp()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(370)
call fem_read_inp('tests/data/s4_contact_pair.inp', ierr)
if (ierr .ne. 0) call fail(371)
if (ncontact_pair .ne. 1) call fail(372)
if (trim(contact_pair_slave(1)) .ne. 'SLAVE') call fail(373)
if (trim(contact_pair_master(1)) .ne. 'MASTER') call fail(374)
call check_close(contact_pair_penalty(1), 1000.0_rk, 375)
call check_close(contact_pair_damping(1), 2.0_rk, 376)
call check_close(contact_pair_search(1), 0.1_rk, 377)
call check_close(contact_pair_friction(1), 0.2_rk, 378)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(379)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(380)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(381)
call fem_read_inp('tests/data/s4_contact_pair_surface.inp', ierr)
if (ierr .ne. 0) call fail(382)
if (n_surface .ne. 3) call fail(383)
if (trim(surface_name(1)) .ne. 'MASTER_SURF') call fail(384)
if (trim(surface_name(2)) .ne. 'SLAVE_SURF') call fail(385)
if (trim(surface_target(1)) .ne. 'MASTER') call fail(386)
if (trim(surface_face(1)) .ne. 'SPOS') call fail(387)
if (trim(surface_target(2)) .ne. 'SLAVE') call fail(388)
if (trim(surface_face(2)) .ne. 'SNEG') call fail(389)
if (trim(surface_name(3)) .ne. 'MASTER_FACE') call fail(410)
if (trim(surface_target(3)) .ne. 'MASTER') call fail(411)
if (trim(surface_face(3)) .ne. 'S1') call fail(412)
if (db_contact_facet_normal_sign(1, 1, 'MASTER_SURF') .ne. 1) &
call fail(450)
if (db_contact_facet_normal_sign(2, 1, 'SLAVE_SURF') .ne. -1) &
call fail(451)
if (.not. db_contact_facet_has_side(2, 1, 'SLAVE_SURF')) &
call fail(452)
if (db_contact_facet_has_side(1, 1, 'MASTER_FACE')) &
call fail(453)
if (.not. db_contact_facet_match(1, 1, 'MASTER_FACE')) call fail(413)
if (db_contact_facet_match(1, 2, 'MASTER_FACE')) call fail(414)
if (ncontact_pair .ne. 1) call fail(390)
if (trim(contact_pair_slave(1)) .ne. 'SLAVE_SURF') call fail(391)
if (trim(contact_pair_master(1)) .ne. 'MASTER_SURF') call fail(392)
call check_close(contact_pair_penalty(1), 1000.0_rk, 393)
call check_close(contact_pair_damping(1), 2.0_rk, 394)
call check_close(contact_pair_search(1), 0.1_rk, 395)
call check_close(contact_pair_friction(1), 0.2_rk, 396)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(397)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(398)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(420)
call fem_read_inp('tests/data/s4_contact_pair_surface_mixed.inp', ierr)
if (ierr .ne. 0) call fail(421)
if (n_surface .ne. 2) call fail(422)
if (trim(surface_name(1)) .ne. 'MASTER_ALL') call fail(423)
if (trim(surface_name(2)) .ne. 'SLAVE_ALL') call fail(424)
if (surface_start(1) .ne. 1) call fail(425)
if (surface_count(1) .ne. 2) call fail(426)
if (surface_start(2) .ne. 3) call fail(427)
if (surface_count(2) .ne. 1) call fail(428)
if (trim(surface_target(1)) .ne. 'MASTER') call fail(429)
if (len_trim(surface_face(1)) .ne. 0) call fail(430)
if (trim(surface_target(2)) .ne. '1') call fail(431)
if (trim(surface_face(2)) .ne. 'S1') call fail(432)
if (trim(surface_target(3)) .ne. '2') call fail(433)
if (len_trim(surface_face(3)) .ne. 0) call fail(434)
if (.not. db_contact_facet_match(1, 1, 'MASTER_ALL')) call fail(435)
if (.not. db_contact_facet_match(1, 6, 'MASTER_ALL')) call fail(436)
if (db_contact_facet_match(2, 1, 'MASTER_ALL')) call fail(437)
if (.not. db_contact_facet_match(2, 1, 'SLAVE_ALL')) call fail(438)
if (ncontact_pair .ne. 1) call fail(439)
if (trim(contact_pair_slave(1)) .ne. 'SLAVE_ALL') call fail(440)
if (trim(contact_pair_master(1)) .ne. 'MASTER_ALL') call fail(441)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(442)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(443)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(460)
call fem_read_inp('tests/data/s4_contact_pair_surface_ops.inp', ierr)
if (ierr .ne. 0) call fail(461)
if (n_surface .ne. 2) call fail(462)
if (trim(surface_name(1)) .ne. 'MASTER_OP') call fail(463)
if (trim(surface_name(2)) .ne. 'SLAVE_OP') call fail(464)
if (surface_count(1) .ne. 2) call fail(465)
if (surface_count(2) .ne. 1) call fail(466)
if (surface_owner(1) .ne. 1) call fail(467)
if (surface_owner(2) .ne. 0) call fail(468)
if (surface_owner(3) .ne. 1) call fail(469)
if (surface_owner(4) .ne. 2) call fail(470)
if (.not. db_contact_facet_match(1, 1, 'MASTER_OP')) call fail(471)
if (db_contact_facet_normal_sign(2, 1, 'SLAVE_OP') .ne. 1) &
call fail(472)
if (.not. db_contact_facet_has_side(2, 1, 'SLAVE_OP')) call fail(473)
if (ncontact_pair .ne. 1) call fail(474)
if (trim(contact_pair_slave(1)) .ne. 'SLAVE_OP') call fail(475)
if (trim(contact_pair_master(1)) .ne. 'MASTER_OP') call fail(476)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(477)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(478)
call check_node_surface_inp()
call check_contact_property_inp()
call check_contact_analytical_inp()
call check_contact_pair_input_errors()
end subroutine check_contact_pair_inp
subroutine check_contact_analytical_inp()
integer :: ierr
integer :: node_count
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(560)
call fem_read_inp('tests/data/s4_contact_analytical_plane.inp', ierr)
if (ierr .ne. 0) call fail(561)
if (n_surface .ne. 2) call fail(562)
if (trim(surface_type(1)) .ne. 'NODE') call fail(563)
if (trim(surface_type(2)) .ne. 'ANALYTICAL') call fail(564)
if (trim(surface_target(2)) .ne. 'PLANE') call fail(565)
call check_close(surface_plane_normal(1,2), ZERO, 566)
call check_close(surface_plane_normal(2,2), ZERO, 567)
call check_close(surface_plane_normal(3,2), ONE, 568)
call check_close(surface_plane_offset(2), ZERO, 569)
if (trim(contact_pair_slave(1)) .ne. 'SLAVE_NODES') call fail(570)
if (trim(contact_pair_master(1)) .ne. 'RIGID_PLANE') call fail(571)
call fem_get_surface_node_count('SLAVE_NODES', node_count, ierr)
if (ierr .ne. 0) call fail(572)
if (node_count .ne. 1) call fail(573)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(574)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(575)
end subroutine check_contact_analytical_inp
subroutine check_contact_property_inp()
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(530)
call fem_read_inp('tests/data/s4_contact_property.inp', ierr)
if (ierr .ne. 0) call fail(531)
if (n_contact_property .ne. 1) call fail(532)
if (trim(contact_property_name(1)) .ne. 'PROP1') call fail(533)
call check_close(contact_property_penalty(1), 1000.0_rk, 534)
call check_close(contact_property_damping(1), 2.0_rk, 535)
call check_close(contact_property_search(1), 0.1_rk, 536)
call check_close(contact_property_friction(1), 0.2_rk, 537)
call check_close(contact_property_aug_factor(1), 0.25_rk, 545)
call check_close(contact_property_friction_reg(1), 0.05_rk, 547)
if (trim(contact_pair_property(1)) .ne. 'PROP1') call fail(538)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(539)
call check_close(contact_pair_penalty(1), 1000.0_rk, 540)
call check_close(contact_pair_damping(1), 2.0_rk, 541)
call check_close(contact_pair_search(1), 0.1_rk, 542)
call check_close(contact_pair_friction(1), 0.2_rk, 543)
call check_close(contact_pair_aug_factor(1), 0.25_rk, 546)
call check_close(contact_pair_friction_reg(1), 0.05_rk, 548)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(544)
end subroutine check_contact_property_inp
subroutine check_contact_pair_input_errors()
call check_contact_pair_inp_error('tests/data/s4_contact_pair_missing_slave.inp', 401)
call check_contact_pair_inp_error('tests/data/s4_contact_pair_missing_master.inp', 404)
call check_contact_pair_inp_error('tests/data/s4_contact_pair_missing_penalty.inp', 407)
call check_contact_pair_build_error('tests/data/s4_contact_pair_surface_bad_face.inp', 415)
call check_contact_pair_inp_error( &
'tests/data/s4_contact_pair_surface_bad_analytical_line.inp', 445)
call check_contact_pair_build_error('tests/data/s4_contact_pair_unknown_property.inp', 548)
call check_contact_pair_build_error( &
'tests/data/s4_node_surface_element_master.inp', 552)
end subroutine check_contact_pair_input_errors
subroutine check_node_surface_inp()
integer :: ierr
integer :: node_count
integer :: node_ids(4)
integer :: small_node_ids(2)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(480)
call fem_read_inp('tests/data/s4_node_surface.inp', ierr)
if (ierr .ne. 0) call fail(481)
if (n_surface .ne. 1) call fail(482)
if (trim(surface_name(1)) .ne. 'NODE_SURF') call fail(483)
if (trim(surface_type(1)) .ne. 'NODE') call fail(484)
if (surface_start(1) .ne. 1) call fail(485)
if (surface_count(1) .ne. 2) call fail(486)
if (trim(surface_target(1)) .ne. 'TOP_NODES') call fail(487)
if (trim(surface_target(2)) .ne. '1') call fail(488)
if (db_contact_facet_match(1, 1, 'NODE_SURF')) call fail(489)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(490)
call fem_get_surface_node_count('NODE_SURF', node_count, ierr)
if (ierr .ne. 0) call fail(492)
if (node_count .ne. 3) call fail(493)
call fem_get_surface_nodes('NODE_SURF', 4, node_ids, node_count, ierr)
if (ierr .ne. 0) call fail(494)
if (node_count .ne. 3) call fail(495)
if (node_ids(1) .ne. 3 .or. node_ids(2) .ne. 4 .or. &
node_ids(3) .ne. 1) call fail(496)
call fem_get_surface_nodes('NODE_SURF', 2, small_node_ids, node_count, ierr)
if (ierr .eq. 0) call fail(497)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(491)
end subroutine check_node_surface_inp
subroutine check_contact_pair_inp_error(path, code_base)
character(len=*), intent(in) :: path
integer, intent(in) :: code_base
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(code_base)
call fem_read_inp(path, ierr)
if (ierr .eq. 0) call fail(code_base + 1)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(code_base + 2)
end subroutine check_contact_pair_inp_error
subroutine check_contact_pair_build_error(path, code_base)
character(len=*), intent(in) :: path
integer, intent(in) :: code_base
integer :: ierr
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(code_base)
call fem_read_inp(path, ierr)
if (ierr .ne. 0) call fail(code_base + 1)
call fem_build_model(ierr)
if (ierr .eq. 0) call fail(code_base + 2)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(code_base + 3)
end subroutine check_contact_pair_build_error
subroutine check_static_patch_file(path, probe_node, expected_ux, code_base)
character(len=*), intent(in) :: path
integer, intent(in) :: probe_node
real(rk), intent(in) :: expected_ux
integer, intent(in) :: code_base
integer :: ierr
integer :: iter
integer :: step
integer :: query_elems(1)
real(rk) :: res_norm
real(rk) :: time
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
real(rk) :: stress_out(NSTRESS,1)
real(rk) :: strain_out(NSTRESS,1)
real(rk) :: plastic_strain(NSTRESS,1)
real(rk) :: eqps(1)
real(rk) :: damage(1)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(code_base + 1)
call fem_read_inp(path, ierr)
if (ierr .ne. 0) call fail(code_base + 2)
if (analysis_type .ne. ANALYSIS_STATIC_LINEAR) call fail(code_base + 3)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(code_base + 4)
call fem_solve_static_linear(50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(code_base + 5)
if (iter .le. 0 .or. iter .gt. 5) call fail(code_base + 6)
if (res_norm .gt. TOL) call fail(code_base + 7)
call fem_get_node_kinematics(probe_node, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(code_base + 8)
call check_close(displacement(1), expected_ux, code_base + 9)
call check_close(displacement(2), ZERO, code_base + 10)
call check_close(displacement(3), ZERO, code_base + 11)
query_elems(1) = 1
call fem_get_element_average_state(1, query_elems, stress_out, strain_out, &
plastic_strain, eqps, damage, ierr)
if (ierr .ne. 0) call fail(code_base + 12)
call check_close(strain_out(1,1), 0.01_rk, code_base + 13)
call check_close(strain_out(2,1), ZERO, code_base + 14)
call check_close(strain_out(3,1), ZERO, code_base + 15)
call check_close(stress_out(1,1), 0.36_rk, code_base + 16)
call check_close(stress_out(2,1), 0.12_rk, code_base + 17)
call check_close(stress_out(3,1), 0.12_rk, code_base + 18)
call check_close(maxval(abs(stress_out(4:6,1))), ZERO, code_base + 19)
call fem_get_current_time(time, step, ierr)
if (ierr .ne. 0) call fail(code_base + 20)
call check_close(time, ONE, code_base + 21)
if (step .ne. 1) call fail(code_base + 22)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(code_base + 23)
end subroutine check_static_patch_file
subroutine check_shell_static_patch(path, probe_node, code_base)
character(len=*), intent(in) :: path
integer, intent(in) :: probe_node
integer, intent(in) :: code_base
integer :: ierr
integer :: iter
integer :: step
integer :: query_elems(1)
real(rk) :: res_norm
real(rk) :: time
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
real(rk) :: stress_out(NSTRESS,1)
real(rk) :: strain_out(NSTRESS,1)
real(rk) :: plastic_strain(NSTRESS,1)
real(rk) :: eqps(1)
real(rk) :: damage(1)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(code_base)
call fem_read_inp(path, ierr)
if (ierr .ne. 0) call fail(code_base + 1)
if (analysis_type .ne. ANALYSIS_STATIC_LINEAR) call fail(code_base + 2)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(code_base + 3)
call fem_solve_static_linear(50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(code_base + 4)
if (iter .le. 0 .or. iter .gt. 5) call fail(code_base + 5)
if (res_norm .gt. TOL) call fail(code_base + 6)
call fem_get_node_kinematics(probe_node, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(code_base + 7)
call check_close(displacement(1), 0.01_rk, code_base + 8)
call check_close(displacement(2), ZERO, code_base + 9)
call check_close(displacement(3), ZERO, code_base + 10)
query_elems(1) = 1
call fem_get_element_average_state(1, query_elems, stress_out, strain_out, &
plastic_strain, eqps, damage, ierr)
if (ierr .ne. 0) call fail(code_base + 11)
call check_close(strain_out(1,1), 0.01_rk, code_base + 12)
call check_close(strain_out(2,1), ZERO, code_base + 13)
call check_close(strain_out(3,1), ZERO, code_base + 14)
call check_close(stress_out(1,1), 0.32_rk, code_base + 15)
call check_close(stress_out(2,1), 0.08_rk, code_base + 16)
call check_close(stress_out(3,1), ZERO, code_base + 17)
call check_close(maxval(abs(stress_out(4:6,1))), ZERO, code_base + 18)
call fem_get_current_time(time, step, ierr)
if (ierr .ne. 0) call fail(code_base + 19)
call check_close(time, ONE, code_base + 20)
if (step .ne. 1) call fail(code_base + 21)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(code_base + 22)
end subroutine check_shell_static_patch
subroutine check_close(actual, expected, code)
real(rk), intent(in) :: actual
real(rk), intent(in) :: expected
integer, intent(in) :: code
if (abs(actual - expected) .gt. TOL) call fail(code)
end subroutine check_close
subroutine fail(code)
integer, intent(in) :: code
write(*,*) 'test_implicit_inp failed:', code
stop 1
end subroutine fail
end program test_implicit_inp