Prepare SPHLite 0.2.0 development baseline
This commit is contained in:
@@ -3,6 +3,14 @@ module sph_database
|
||||
use sph_error, only: SPH_SUCCESS, SPH_ERROR_ARGUMENT, SPH_ERROR_DATABASE, sph_error_set
|
||||
implicit none
|
||||
|
||||
integer, parameter :: SPH_NAME_LEN = 64
|
||||
integer, parameter :: SPH_MAX_MATERIALS = 32
|
||||
integer, parameter :: SPH_MAX_SECTIONS = 32
|
||||
integer, parameter :: SPH_MAX_SETS = 32
|
||||
integer, parameter :: SPH_MAX_REGIONS = 32
|
||||
integer, parameter :: SPH_MAX_ELEMENTS = 256
|
||||
integer, parameter :: SPH_MAX_ELEMENT_NODES = 8
|
||||
|
||||
integer, parameter :: SPH_PHASE_WATER = 1
|
||||
integer, parameter :: SPH_PHASE_GAS = 2
|
||||
integer, parameter :: SPH_PHASE_EXPLOSIVE = 3
|
||||
@@ -16,6 +24,10 @@ module sph_database
|
||||
integer, parameter :: SPH_STATUS_ACTIVE = 0
|
||||
integer, parameter :: SPH_STATUS_INACTIVE = 1
|
||||
integer, parameter :: SPH_STATUS_FAILED = 2
|
||||
integer, parameter :: SPH_STATUS_RESERVED = 3
|
||||
|
||||
integer, parameter :: SPH_REGION_COUPLING_CONTACT = 1
|
||||
integer, parameter :: SPH_REGION_COUPLING_CONTINUUM = 2
|
||||
|
||||
integer :: npart = 0
|
||||
integer, allocatable :: particle_id_ext(:)
|
||||
@@ -36,6 +48,41 @@ module sph_database
|
||||
real(rk), allocatable :: temperature(:)
|
||||
real(rk), allocatable :: h(:)
|
||||
|
||||
integer :: material_count = 0
|
||||
character(len=SPH_NAME_LEN) :: material_name(SPH_MAX_MATERIALS)
|
||||
character(len=SPH_NAME_LEN) :: material_type(SPH_MAX_MATERIALS)
|
||||
integer :: material_internal_id(SPH_MAX_MATERIALS)
|
||||
|
||||
integer :: section_count = 0
|
||||
character(len=SPH_NAME_LEN) :: section_name(SPH_MAX_SECTIONS)
|
||||
character(len=SPH_NAME_LEN) :: section_type(SPH_MAX_SECTIONS)
|
||||
character(len=SPH_NAME_LEN) :: section_material_name(SPH_MAX_SECTIONS)
|
||||
integer :: section_material_id(SPH_MAX_SECTIONS)
|
||||
real(rk) :: section_thickness(SPH_MAX_SECTIONS)
|
||||
integer :: section_integration_points(SPH_MAX_SECTIONS)
|
||||
|
||||
integer :: nset_count = 0
|
||||
character(len=SPH_NAME_LEN) :: nset_name(SPH_MAX_SETS)
|
||||
integer :: nset_member_count(SPH_MAX_SETS)
|
||||
integer :: nset_first_member(SPH_MAX_SETS)
|
||||
|
||||
integer :: elset_count = 0
|
||||
character(len=SPH_NAME_LEN) :: elset_name(SPH_MAX_SETS)
|
||||
integer :: elset_member_count(SPH_MAX_SETS)
|
||||
integer :: elset_first_member(SPH_MAX_SETS)
|
||||
|
||||
integer :: element_count = 0
|
||||
integer :: element_id_ext(SPH_MAX_ELEMENTS)
|
||||
character(len=SPH_NAME_LEN) :: element_type(SPH_MAX_ELEMENTS)
|
||||
integer :: element_conn_count(SPH_MAX_ELEMENTS)
|
||||
integer :: element_conn(SPH_MAX_ELEMENT_NODES, SPH_MAX_ELEMENTS)
|
||||
|
||||
integer :: coupling_region_count = 0
|
||||
character(len=SPH_NAME_LEN) :: coupling_region_name(SPH_MAX_REGIONS)
|
||||
character(len=SPH_NAME_LEN) :: coupling_region_set_name(SPH_MAX_REGIONS)
|
||||
integer :: coupling_region_type(SPH_MAX_REGIONS)
|
||||
integer :: coupling_region_internal_id(SPH_MAX_REGIONS)
|
||||
|
||||
contains
|
||||
|
||||
subroutine sph_db_allocate(count, ierr)
|
||||
@@ -114,8 +161,41 @@ contains
|
||||
if (allocated(temperature)) deallocate(temperature)
|
||||
if (allocated(h)) deallocate(h)
|
||||
npart = 0
|
||||
call sph_db_clear_metadata()
|
||||
end subroutine sph_db_free
|
||||
|
||||
subroutine sph_db_clear_metadata()
|
||||
material_count = 0
|
||||
material_name = ' '
|
||||
material_type = ' '
|
||||
material_internal_id = 0
|
||||
section_count = 0
|
||||
section_name = ' '
|
||||
section_type = ' '
|
||||
section_material_name = ' '
|
||||
section_material_id = 0
|
||||
section_thickness = 0.0_rk
|
||||
section_integration_points = 0
|
||||
nset_count = 0
|
||||
nset_name = ' '
|
||||
nset_member_count = 0
|
||||
nset_first_member = 0
|
||||
elset_count = 0
|
||||
elset_name = ' '
|
||||
elset_member_count = 0
|
||||
elset_first_member = 0
|
||||
element_count = 0
|
||||
element_id_ext = 0
|
||||
element_type = ' '
|
||||
element_conn_count = 0
|
||||
element_conn = 0
|
||||
coupling_region_count = 0
|
||||
coupling_region_name = ' '
|
||||
coupling_region_set_name = ' '
|
||||
coupling_region_type = 0
|
||||
coupling_region_internal_id = 0
|
||||
end subroutine sph_db_clear_metadata
|
||||
|
||||
subroutine sph_db_get_particle_count(count, ierr)
|
||||
integer, intent(out) :: count
|
||||
integer, intent(out) :: ierr
|
||||
@@ -124,6 +204,63 @@ contains
|
||||
ierr = SPH_SUCCESS
|
||||
end subroutine sph_db_get_particle_count
|
||||
|
||||
subroutine sph_db_get_particle_state_capacity(count, ndim, ierr)
|
||||
integer, intent(out) :: count
|
||||
integer, intent(out) :: ndim
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
count = npart
|
||||
ndim = SPH_NDIM
|
||||
ierr = SPH_SUCCESS
|
||||
end subroutine sph_db_get_particle_state_capacity
|
||||
|
||||
subroutine sph_db_get_particle_state(max_particles, particle_id_ext_out, &
|
||||
phase_out, status_out, material_id_out, section_id_out, x_out, v_out, &
|
||||
a_out, rho_out, pressure_out, internal_energy_out, temperature_out, &
|
||||
h_out, count, ierr)
|
||||
integer, intent(in) :: max_particles
|
||||
integer, intent(out) :: particle_id_ext_out(max_particles)
|
||||
integer, intent(out) :: phase_out(max_particles)
|
||||
integer, intent(out) :: status_out(max_particles)
|
||||
integer, intent(out) :: material_id_out(max_particles)
|
||||
integer, intent(out) :: section_id_out(max_particles)
|
||||
real(rk), intent(out) :: x_out(SPH_NDIM,max_particles)
|
||||
real(rk), intent(out) :: v_out(SPH_NDIM,max_particles)
|
||||
real(rk), intent(out) :: a_out(SPH_NDIM,max_particles)
|
||||
real(rk), intent(out) :: rho_out(max_particles)
|
||||
real(rk), intent(out) :: pressure_out(max_particles)
|
||||
real(rk), intent(out) :: internal_energy_out(max_particles)
|
||||
real(rk), intent(out) :: temperature_out(max_particles)
|
||||
real(rk), intent(out) :: h_out(max_particles)
|
||||
integer, intent(out) :: count
|
||||
integer, intent(out) :: ierr
|
||||
integer :: i
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
count = npart
|
||||
if (max_particles < npart) then
|
||||
call sph_error_set(SPH_ERROR_ARGUMENT, 'particle state buffer is too small')
|
||||
ierr = SPH_ERROR_ARGUMENT
|
||||
return
|
||||
end if
|
||||
|
||||
do i = 1, npart
|
||||
particle_id_ext_out(i) = particle_id_ext(i)
|
||||
phase_out(i) = particle_phase(i)
|
||||
status_out(i) = particle_status(i)
|
||||
material_id_out(i) = material_id(i)
|
||||
section_id_out(i) = section_id(i)
|
||||
x_out(:,i) = x(:,i)
|
||||
v_out(:,i) = v(:,i)
|
||||
a_out(:,i) = a(:,i)
|
||||
rho_out(i) = rho(i)
|
||||
pressure_out(i) = pressure(i)
|
||||
internal_energy_out(i) = internal_energy(i)
|
||||
temperature_out(i) = temperature(i)
|
||||
h_out(i) = h(i)
|
||||
end do
|
||||
end subroutine sph_db_get_particle_state
|
||||
|
||||
subroutine sph_db_set_node(index, ext_id, coords, ierr)
|
||||
integer, intent(in) :: index
|
||||
integer, intent(in) :: ext_id
|
||||
@@ -141,4 +278,124 @@ contains
|
||||
x(:,index) = coords(:)
|
||||
end subroutine sph_db_set_node
|
||||
|
||||
subroutine sph_db_add_material(name, mtype, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
character(len=*), intent(in) :: mtype
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (material_count >= SPH_MAX_MATERIALS) then
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'too many material records')
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
material_count = material_count + 1
|
||||
material_name(material_count) = name
|
||||
material_type(material_count) = mtype
|
||||
material_internal_id(material_count) = material_count
|
||||
end subroutine sph_db_add_material
|
||||
|
||||
subroutine sph_db_add_section(name, stype, mat_name, thickness, points, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
character(len=*), intent(in) :: stype
|
||||
character(len=*), intent(in) :: mat_name
|
||||
real(rk), intent(in) :: thickness
|
||||
integer, intent(in) :: points
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (section_count >= SPH_MAX_SECTIONS) then
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'too many section records')
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
section_count = section_count + 1
|
||||
section_name(section_count) = name
|
||||
section_type(section_count) = stype
|
||||
section_material_name(section_count) = mat_name
|
||||
section_material_id(section_count) = 1
|
||||
section_thickness(section_count) = thickness
|
||||
section_integration_points(section_count) = points
|
||||
end subroutine sph_db_add_section
|
||||
|
||||
subroutine sph_db_add_nset(name, member_count, first_member, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
integer, intent(in) :: member_count
|
||||
integer, intent(in) :: first_member
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (nset_count >= SPH_MAX_SETS) then
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'too many node set records')
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
nset_count = nset_count + 1
|
||||
nset_name(nset_count) = name
|
||||
nset_member_count(nset_count) = member_count
|
||||
nset_first_member(nset_count) = first_member
|
||||
end subroutine sph_db_add_nset
|
||||
|
||||
subroutine sph_db_add_elset(name, member_count, first_member, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
integer, intent(in) :: member_count
|
||||
integer, intent(in) :: first_member
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (elset_count >= SPH_MAX_SETS) then
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'too many element set records')
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
elset_count = elset_count + 1
|
||||
elset_name(elset_count) = name
|
||||
elset_member_count(elset_count) = member_count
|
||||
elset_first_member(elset_count) = first_member
|
||||
end subroutine sph_db_add_elset
|
||||
|
||||
subroutine sph_db_add_element(ext_id, etype, conn_count, conn_values, ierr)
|
||||
integer, intent(in) :: ext_id
|
||||
character(len=*), intent(in) :: etype
|
||||
integer, intent(in) :: conn_count
|
||||
integer, intent(in) :: conn_values(SPH_MAX_ELEMENT_NODES)
|
||||
integer, intent(out) :: ierr
|
||||
integer :: n
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (element_count >= SPH_MAX_ELEMENTS) then
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'too many element records')
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
element_count = element_count + 1
|
||||
element_id_ext(element_count) = ext_id
|
||||
element_type(element_count) = etype
|
||||
n = conn_count
|
||||
if (n > SPH_MAX_ELEMENT_NODES) n = SPH_MAX_ELEMENT_NODES
|
||||
if (n < 0) n = 0
|
||||
element_conn_count(element_count) = n
|
||||
element_conn(:,element_count) = 0
|
||||
if (n > 0) element_conn(1:n,element_count) = conn_values(1:n)
|
||||
end subroutine sph_db_add_element
|
||||
|
||||
subroutine sph_db_add_coupling_region(name, set_name, region_type, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
character(len=*), intent(in) :: set_name
|
||||
integer, intent(in) :: region_type
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (coupling_region_count >= SPH_MAX_REGIONS) then
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'too many coupling region records')
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
coupling_region_count = coupling_region_count + 1
|
||||
coupling_region_name(coupling_region_count) = name
|
||||
coupling_region_set_name(coupling_region_count) = set_name
|
||||
coupling_region_type(coupling_region_count) = region_type
|
||||
coupling_region_internal_id(coupling_region_count) = coupling_region_count
|
||||
end subroutine sph_db_add_coupling_region
|
||||
|
||||
end module sph_database
|
||||
|
||||
Reference in New Issue
Block a user