Advance V5 core capabilities and planning
This commit is contained in:
+102
-45
@@ -11,7 +11,9 @@ module fem_api
|
||||
use fem_element_internal
|
||||
use fem_solver_implicit
|
||||
use fem_linear_solver_cg, only: linear_solver_configure, &
|
||||
linear_solver_get_settings, linear_solver_get_stats
|
||||
linear_solver_get_settings, linear_solver_get_stats, &
|
||||
linear_solver_get_external_info, linear_solver_get_external_diag, &
|
||||
linear_solver_config_external
|
||||
use fem_coupling
|
||||
use fem_boundary
|
||||
use fem_contact
|
||||
@@ -23,20 +25,17 @@ module fem_api
|
||||
contact_get_cache_stats, &
|
||||
contact_reset_search_stats
|
||||
use fem_contact_history, only: contact_history_stats
|
||||
use fem_contact_multiplier, only: contact_multiplier_stats
|
||||
use fem_database_surface, only: db_surface_node_count, db_get_surface_nodes
|
||||
use fem_output_csv
|
||||
use fem_output_vtk
|
||||
use fem_restart
|
||||
implicit none
|
||||
|
||||
logical :: api_initialized = .false.
|
||||
|
||||
contains
|
||||
|
||||
subroutine fem_initialize(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: log_ierr
|
||||
|
||||
call error_clear(ierr)
|
||||
call control_set_defaults()
|
||||
call contact_reset_search_stats()
|
||||
@@ -45,7 +44,6 @@ contains
|
||||
call error_set(FEM_ERR_OUTPUT, 'failed to open femlite.log', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
api_initialized = .true.
|
||||
call log_info('FemLite initialized')
|
||||
ierr = FEM_SUCCESS
|
||||
@@ -53,12 +51,10 @@ contains
|
||||
|
||||
subroutine fem_finalize(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call cpl_finalize_facets()
|
||||
call contact_reset_search_stats()
|
||||
call database_finalize(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
call log_info('FemLite finalized')
|
||||
call log_close()
|
||||
api_initialized = .false.
|
||||
@@ -70,7 +66,6 @@ contains
|
||||
integer, intent(out) :: minor
|
||||
integer, intent(out) :: patch
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
major = FEMLITE_VERSION_MAJOR
|
||||
minor = FEMLITE_VERSION_MINOR
|
||||
patch = FEMLITE_VERSION_PATCH
|
||||
@@ -81,18 +76,15 @@ contains
|
||||
character(len=*), intent(in) :: filename
|
||||
integer, intent(out) :: ierr
|
||||
logical :: exists
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'fem_read_inp called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
inquire(file=filename, exist=exists)
|
||||
if (.not. exists) then
|
||||
call error_set(FEM_ERR_INPUT, 'input file does not exist: '//trim(filename), ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call cpl_finalize_facets()
|
||||
call output_csv_reset()
|
||||
time_start = ZERO
|
||||
@@ -102,22 +94,18 @@ contains
|
||||
use_user_dt = .false.
|
||||
call inp_read_file(filename, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
current_time = ZERO
|
||||
current_step = 0
|
||||
end subroutine fem_read_inp
|
||||
|
||||
subroutine fem_build_model(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'fem_build_model called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call database_validate_model(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
call cpl_build_facets(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
@@ -126,29 +114,23 @@ contains
|
||||
|
||||
subroutine fem_compute_lumped_mass(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'fem_compute_lumped_mass called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call element_compute_lumped_mass(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
call log_info('lumped mass computed')
|
||||
end subroutine fem_compute_lumped_mass
|
||||
|
||||
subroutine fem_compute_internal_force(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'fem_compute_internal_force called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call element_compute_internal_force(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
call log_info('internal force computed')
|
||||
end subroutine fem_compute_internal_force
|
||||
|
||||
@@ -159,19 +141,16 @@ contains
|
||||
integer :: node
|
||||
integer :: idir
|
||||
integer :: dof
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'fem_get_mass_summary called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
total_mass = ZERO
|
||||
rotational_inertia = ZERO
|
||||
if (.not. allocated(mass_diag)) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'mass vector is not allocated', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
do node = 1, nnode
|
||||
dof = dof_id(1,node)
|
||||
if (dof .gt. 0) total_mass = total_mass + mass_diag(dof)
|
||||
@@ -181,13 +160,11 @@ contains
|
||||
if (dof .gt. 0) rotational_inertia = rotational_inertia + mass_diag(dof)
|
||||
end do
|
||||
end do
|
||||
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_get_mass_summary
|
||||
|
||||
subroutine fem_clear_sph_forces(ierr)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'fem_clear_sph_forces called before fem_initialize', ierr)
|
||||
return
|
||||
@@ -196,7 +173,6 @@ contains
|
||||
call error_set(FEM_ERR_INTERNAL, 'SPH force vector is not allocated', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
fsph = ZERO
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_clear_sph_forces
|
||||
@@ -208,7 +184,6 @@ contains
|
||||
integer :: node
|
||||
integer :: idir
|
||||
integer :: dof
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, 'fem_apply_sph_nodal_force called before fem_initialize', ierr)
|
||||
return
|
||||
@@ -217,18 +192,15 @@ contains
|
||||
call error_set(FEM_ERR_INTERNAL, 'SPH force vector is not allocated', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
node = database_find_node(node_id)
|
||||
if (node .eq. 0) then
|
||||
call error_set(FEM_ERR_COUPLING, 'SPH nodal force references unknown node', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
do idir = 1, NDIM
|
||||
dof = dof_id(idir,node)
|
||||
if (dof .gt. 0) fsph(dof) = fsph(dof) + force(idir)
|
||||
end do
|
||||
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_apply_sph_nodal_force
|
||||
|
||||
@@ -429,6 +401,30 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_get_contact_hist_stats
|
||||
|
||||
subroutine fem_get_contact_mult_stats(slot_count, active_count, &
|
||||
max_lambda, max_gap, ierr)
|
||||
integer, intent(out) :: slot_count
|
||||
integer, intent(out) :: active_count
|
||||
real(rk), intent(out) :: max_lambda
|
||||
real(rk), intent(out) :: max_gap
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
slot_count = 0
|
||||
active_count = 0
|
||||
max_lambda = ZERO
|
||||
max_gap = ZERO
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_get_contact_mult_stats called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call contact_multiplier_stats(slot_count, active_count, max_lambda, &
|
||||
max_gap)
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_get_contact_mult_stats
|
||||
|
||||
subroutine fem_get_contact_search_stats(facet_count, master_count, &
|
||||
broad_count, active_count, &
|
||||
bvh_node_count, ierr)
|
||||
@@ -621,21 +617,17 @@ contains
|
||||
integer, intent(in) :: method
|
||||
integer, intent(in) :: preconditioner
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_set_linear_solver called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call linear_solver_configure(method, preconditioner, ierr)
|
||||
end subroutine fem_set_linear_solver
|
||||
|
||||
subroutine fem_get_linear_solver_settings(method, preconditioner, ierr)
|
||||
integer, intent(out) :: method
|
||||
integer, intent(out) :: preconditioner
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
method = LSOLVER_CG
|
||||
preconditioner = LPRECOND_JACOBI
|
||||
if (.not. api_initialized) then
|
||||
@@ -643,10 +635,8 @@ contains
|
||||
'fem_get_linear_solver_settings called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call linear_solver_get_settings(method, preconditioner, ierr)
|
||||
end subroutine fem_get_linear_solver_settings
|
||||
|
||||
subroutine fem_get_linear_solver_stats(method, preconditioner, iteration, &
|
||||
residual_norm, status_code, ierr)
|
||||
integer, intent(out) :: method
|
||||
@@ -655,7 +645,6 @@ contains
|
||||
real(rk), intent(out) :: residual_norm
|
||||
integer, intent(out) :: status_code
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
method = LSOLVER_CG
|
||||
preconditioner = LPRECOND_JACOBI
|
||||
iteration = 0
|
||||
@@ -666,10 +655,63 @@ contains
|
||||
'fem_get_linear_solver_stats called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call linear_solver_get_stats(method, preconditioner, iteration, &
|
||||
residual_norm, status_code, ierr)
|
||||
end subroutine fem_get_linear_solver_stats
|
||||
subroutine fem_get_linsol_external(backend, available, capabilities, ierr)
|
||||
integer, intent(out) :: backend
|
||||
integer, intent(out) :: available
|
||||
integer, intent(out) :: capabilities
|
||||
integer, intent(out) :: ierr
|
||||
backend = 0
|
||||
available = 0
|
||||
capabilities = 0
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_get_linsol_external called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
call linear_solver_get_external_info(backend, available, capabilities, ierr)
|
||||
end subroutine fem_get_linsol_external
|
||||
subroutine fem_get_linsol_external_diag(valid, nrow, ncol, nnz, class_id, &
|
||||
symmetric_pattern, &
|
||||
symmetric_values, backend_status, &
|
||||
matrix_norm, rhs_norm, &
|
||||
initial_resid, initial_rel, ierr)
|
||||
integer, intent(out) :: valid
|
||||
integer, intent(out) :: nrow
|
||||
integer, intent(out) :: ncol
|
||||
integer, intent(out) :: nnz
|
||||
integer, intent(out) :: class_id
|
||||
integer, intent(out) :: symmetric_pattern
|
||||
integer, intent(out) :: symmetric_values
|
||||
integer, intent(out) :: backend_status
|
||||
real(rk), intent(out) :: matrix_norm
|
||||
real(rk), intent(out) :: rhs_norm
|
||||
real(rk), intent(out) :: initial_resid
|
||||
real(rk), intent(out) :: initial_rel
|
||||
integer, intent(out) :: ierr
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_get_linsol_external_diag called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
call linear_solver_get_external_diag(valid, nrow, ncol, nnz, class_id, &
|
||||
symmetric_pattern, symmetric_values, &
|
||||
backend_status, matrix_norm, &
|
||||
rhs_norm, initial_resid, initial_rel, &
|
||||
ierr)
|
||||
end subroutine fem_get_linsol_external_diag
|
||||
subroutine fem_set_linsol_external(backend, ierr)
|
||||
integer, intent(in) :: backend
|
||||
integer, intent(out) :: ierr
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_set_linsol_external called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
call linear_solver_config_external(backend, ierr)
|
||||
end subroutine fem_set_linsol_external
|
||||
|
||||
subroutine fem_set_shell_stabilization(drilling_factor, s3_shear_factor, &
|
||||
s3_shear_min_scale, ierr)
|
||||
@@ -677,7 +719,6 @@ contains
|
||||
real(rk), intent(in) :: s3_shear_factor
|
||||
real(rk), intent(in) :: s3_shear_min_scale
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_set_shell_stabilization called before fem_initialize', ierr)
|
||||
@@ -695,20 +736,17 @@ contains
|
||||
call error_set(FEM_ERR_INPUT, 'S3 shear minimum scale is out of range', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
shell_drilling_stiffness_factor = drilling_factor
|
||||
shell3_shear_locking_factor = s3_shear_factor
|
||||
shell3_shear_locking_min_scale = s3_shear_min_scale
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_set_shell_stabilization
|
||||
|
||||
subroutine fem_get_shell_stabilization(drilling_factor, s3_shear_factor, &
|
||||
s3_shear_min_scale, ierr)
|
||||
real(rk), intent(out) :: drilling_factor
|
||||
real(rk), intent(out) :: s3_shear_factor
|
||||
real(rk), intent(out) :: s3_shear_min_scale
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
drilling_factor = 1.0e-4_rk
|
||||
s3_shear_factor = 0.0625_rk
|
||||
s3_shear_min_scale = 1.0e-4_rk
|
||||
@@ -717,7 +755,6 @@ contains
|
||||
'fem_get_shell_stabilization called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
drilling_factor = shell_drilling_stiffness_factor
|
||||
s3_shear_factor = shell3_shear_locking_factor
|
||||
s3_shear_min_scale = shell3_shear_locking_min_scale
|
||||
@@ -857,6 +894,26 @@ contains
|
||||
call cpl_apply_facet_tractions(nfacet_in, facet_id, pressure, shear, ierr)
|
||||
end subroutine fem_apply_sph_facet_tractions
|
||||
|
||||
subroutine fem_apply_sph_facet_nodal_loads(nfacet_in, max_face_nodes_in, &
|
||||
facet_id, facet_nnode_in, &
|
||||
node_forces, ierr)
|
||||
integer, intent(in) :: nfacet_in
|
||||
integer, intent(in) :: max_face_nodes_in
|
||||
integer, intent(in) :: facet_id(nfacet_in)
|
||||
integer, intent(in) :: facet_nnode_in(nfacet_in)
|
||||
real(rk), intent(in) :: node_forces(NDIM,max_face_nodes_in,nfacet_in)
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_apply_sph_facet_nodal_loads called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
call cpl_apply_facet_nodal_loads(nfacet_in, max_face_nodes_in, facet_id, &
|
||||
facet_nnode_in, node_forces, ierr)
|
||||
end subroutine fem_apply_sph_facet_nodal_loads
|
||||
|
||||
subroutine fem_get_node_kinematics(node_id, displacement, velocity, acceleration, ierr)
|
||||
integer, intent(in) :: node_id
|
||||
real(rk), intent(out) :: displacement(NDIM)
|
||||
|
||||
Reference in New Issue
Block a user