Skip to content
Snippets Groups Projects
Commit e12854e8 authored by Stephan Schulz's avatar Stephan Schulz
Browse files

add get_neighbors to Fortran interface (#18)

parent 233726de
Branches
Tags
1 merge request!8Refactor
Pipeline #53195 failed
...@@ -249,6 +249,21 @@ void all_get_work_array_c(ALL_t *all_obj, double *work, int length) { ...@@ -249,6 +249,21 @@ void all_get_work_array_c(ALL_t *all_obj, double *work, int length) {
ALL_catch ALL_catch
} }
void all_get_number_of_neighbors_c(ALL_t *all_obj, int *count) {
ALL_try
std::vector<int> neighbors = all_obj->getNeighbors();
*count = neighbors.size();
ALL_catch
}
void all_get_neighbors_c(ALL_t *all_obj, int *neighbors, int count) {
ALL_try
std::vector<int> all_neighbors = all_obj->getNeighbors();
assert((int)all_neighbors.size() == count);
memcpy(neighbors,&all_neighbors[0],count*sizeof(*neighbors));
ALL_catch
}
#ifdef ALL_VTK_OUTPUT #ifdef ALL_VTK_OUTPUT
// print VTK outlines // print VTK outlines
void all_print_vtk_outlines_c(ALL_t * all_obj known_unused, int known_unused step) { void all_print_vtk_outlines_c(ALL_t * all_obj known_unused, int known_unused step) {
......
...@@ -181,6 +181,17 @@ module ALL_module ...@@ -181,6 +181,17 @@ module ALL_module
integer(c_int), value :: length integer(c_int), value :: length
real(c_double), dimension(length) :: work real(c_double), dimension(length) :: work
end subroutine end subroutine
subroutine all_get_number_of_neighbors_c(obj, count) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int) :: count
end subroutine
subroutine all_get_neighbors_c(obj, neighbors, count) bind(C)
use iso_c_binding
type(c_ptr), value :: obj
integer(c_int), value :: count
integer(c_int), dimension(count) :: neighbors
end subroutine
#ifdef ALL_VTK_OUTPUT #ifdef ALL_VTK_OUTPUT
subroutine all_print_vtk_outlines_c(obj, step) bind(C) subroutine all_print_vtk_outlines_c(obj, step) bind(C)
use iso_c_binding use iso_c_binding
...@@ -238,6 +249,8 @@ module ALL_module ...@@ -238,6 +249,8 @@ module ALL_module
procedure :: get_length_of_work => ALL_get_length_of_work procedure :: get_length_of_work => ALL_get_length_of_work
procedure :: get_work => ALL_get_work procedure :: get_work => ALL_get_work
procedure :: get_work_array => ALL_get_work_array procedure :: get_work_array => ALL_get_work_array
procedure :: get_number_of_neighbors => ALL_get_number_of_neighbors
procedure :: get_neighbors => ALL_get_neighbors
#ifdef ALL_VTK_OUTPUT #ifdef ALL_VTK_OUTPUT
procedure :: print_vtk_outlines => ALL_print_vtk_outlines procedure :: print_vtk_outlines => ALL_print_vtk_outlines
procedure :: print_vtk_vertices => ALL_print_vtk_vertices procedure :: print_vtk_vertices => ALL_print_vtk_vertices
...@@ -268,6 +281,8 @@ module ALL_module ...@@ -268,6 +281,8 @@ module ALL_module
public :: ALL_get_length_of_work public :: ALL_get_length_of_work
public :: ALL_get_work public :: ALL_get_work
public :: ALL_get_work_array public :: ALL_get_work_array
public :: ALL_get_number_of_neighbors
public :: ALL_get_neighbors
#ifdef ALL_VTK_OUTPUT #ifdef ALL_VTK_OUTPUT
public :: ALL_print_vtk_outlines public :: ALL_print_vtk_outlines
public :: ALL_print_vtk_vertices public :: ALL_print_vtk_vertices
...@@ -480,6 +495,25 @@ contains ...@@ -480,6 +495,25 @@ contains
endif endif
call all_get_work_array_c(this%object, work, size(work)) call all_get_work_array_c(this%object, work, size(work))
end subroutine end subroutine
!> Retrieve number of neighbors (i.e. length of neighbors list)
subroutine ALL_get_number_of_neighbors(this, count)
class(ALL_t), intent(in) :: this
integer(c_int), intent(out) :: count
call all_get_number_of_vertices_c(this%object, count)
end subroutine
!> Retrieve list of neighboring ranks (must be correct size already)
subroutine ALL_get_neighbors(this, neighbors)
class(ALL_t), intent(in) :: this
integer(c_int), dimension(:), intent(out) :: neighbors
integer :: count
call ALL_get_number_of_neighbors(this, count)
if(size(neighbors) /= count) then
write(error_unit,'(a)') "ALL_get_neighbors: neighbors has wrong length!"
stop
endif
call all_get_neighbors_c(this%object, neighbors, size(neighbors))
end subroutine
#ifdef ALL_VTK_OUTPUT #ifdef ALL_VTK_OUTPUT
!> Print VTK outlines (must be enabled in build step) !> Print VTK outlines (must be enabled in build step)
subroutine ALL_print_vtk_outlines(this, step) subroutine ALL_print_vtk_outlines(this, step)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment