Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
os: windows-2022,
}
- {
name: "Ubuntu 20.04",
name: "Ubuntu 24.04",
build_type: "Release",
os: ubuntu-20.04,
os: ubuntu-24.04,
}
- {
name: "Ubuntu 20.04 with SuperLU",
name: "Ubuntu 24.04 with SuperLU",
build_type: "Release",
super_lu: true,
os: ubuntu-20.04,
os: ubuntu-24.04,
}
- {
name: "macOS Ventura",
Expand Down
8 changes: 8 additions & 0 deletions src/bindings/c/geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ int get_local_node_f_c(const char *ndimension, int *dimension_len, const char *n
void define_rad_from_geom_c(const char *order_system, int *order_system_len, double *control_param,
const char *start_from, int *start_from_len, double *start_rad,
const char *group_type, int *group_type_len, const char *group_options, int *group_options_len);
void occlude_vessel_c(int *VESSEL_NUMBER, double *RATIO);
void element_connectivity_1d_c(void);
void evaluate_ordering_c(void);
void volume_of_mesh_c(double *volume_model, double *volume_tree);
Expand Down Expand Up @@ -141,6 +142,13 @@ void define_rad_from_geom(const char *order_system, double control_param, const

}

void occlude_vessel(int VESSEL_NUMBER, double RATIO)
{

occlude_vessel_c(&VESSEL_NUMBER, &RATIO);

}

void element_connectivity_1d()
{
element_connectivity_1d_c();
Expand Down
44 changes: 31 additions & 13 deletions src/bindings/c/geometry.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module geometry_c
use indices
!use mesh_functions
!use precision ! sets dp for precision
!use math_constants !pi
!use math_constants !pi

implicit none
private
Expand Down Expand Up @@ -184,7 +184,7 @@ subroutine list_tree_statistics_c(filename, filename_len) &
integer,intent(in) :: filename_len
type(c_ptr), value, intent(in) :: filename
character(len=MAX_FILENAME_LEN) :: filename_f

call strncpy(filename_f, filename, filename_len)

call list_tree_statistics(filename_f)
Expand All @@ -194,34 +194,34 @@ end subroutine list_tree_statistics_c
!###################################################################################
!
subroutine internal_mesh_reorder_c() bind(C, name="internal_mesh_reorder_c")

use geometry,only: internal_mesh_reorder
implicit none

call internal_mesh_reorder()

end subroutine internal_mesh_reorder_c

!
!###################################################################################
!
subroutine make_data_grid_c(surface_elems_len, surface_elems, num_target, offset, spacing)&
bind(C, name="make_data_grid_c")

use arrays,only: dp
use iso_c_binding, only: c_ptr
use utils_c, only: strncpy
use other_consts, only: MAX_FILENAME_LEN, MAX_STRING_LEN
use geometry, only: make_data_grid
implicit none

integer,intent(in) :: surface_elems_len
integer,intent(in) :: surface_elems(surface_elems_len)
integer,intent(in) :: num_target
real(dp),intent(in) :: offset, spacing

call make_data_grid(surface_elems, num_target, offset, spacing)

end subroutine make_data_grid_c

!!!###################################################################################
Expand All @@ -236,7 +236,7 @@ subroutine make_2d_vessel_from_1d_c(elemlist, elemlist_len) bind(C, name="make_2
call make_2d_vessel_from_1d(elemlist)

end subroutine make_2d_vessel_from_1d_c

!
!###################################################################################
!
Expand Down Expand Up @@ -329,6 +329,26 @@ subroutine define_rad_from_geom_c(order_system, order_system_len, control_param,
call define_rad_from_geom(order_system_f, control_param, start_from_f, start_rad, group_type_f, group_options_f)

end subroutine define_rad_from_geom_c
!
!##################################################################################
!
!*define_rad_from_geom:* Defines vessel or airway radius based on their geometric structure
subroutine occlude_vessel_c(VESSEL_NUMBER, RATIO) bind(C, name="occlude_vessel_c")

!use iso_c_binding, only: c_ptr
!use utils_c, only: strncpy
!use other_consts, only: MAX_STRING_LEN
use arrays, only: dp
use geometry, only: occlude_vessel
implicit none

integer,intent(in) :: VESSEL_NUMBER
real(dp),intent(in) :: RATIO
!character(len=MAX_STRING_LEN) :: order_system_f, start_from_f, group_type_f, group_options_f

call occlude_vessel(VESSEL_NUMBER, RATIO)

end subroutine occlude_vessel_c
!
!###########################################################################
!
Expand Down Expand Up @@ -373,10 +393,10 @@ function get_local_node_f_c(ndimension,np_global) result(get_local_node) bind(C,
use arrays, only: dp
use geometry, only: get_local_node_f
implicit none

integer :: ndimension,np_global
integer :: get_local_node

get_local_node=get_local_node_f(ndimension,np_global)

end function get_local_node_f_c
Expand Down Expand Up @@ -443,5 +463,3 @@ end subroutine write_node_geometry_2d_c
!

end module geometry_c


1 change: 1 addition & 0 deletions src/bindings/c/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SHO_PUBLIC void define_rad_from_file(const char *FIELDFILE, const char *radius_t
SHO_PUBLIC int get_local_node_f(const char *ndimenstion, const char *np_global);
SHO_PUBLIC void define_rad_from_geom(const char *ORDER_SYSTEM, double CONTROL_PARAM, const char *START_FROM,
double START_RAD, const char *GROUP_TYPE, const char *GROUP_OPTIONS);
SHO_PUBLIC void occlude_vessel(int VESSEL_NUMBER, double RATIO);
SHO_PUBLIC void element_connectivity_1d();
SHO_PUBLIC void evaluate_ordering();
SHO_PUBLIC void volume_of_mesh(double *volume_model, double *volume_tree);
Expand Down
13 changes: 13 additions & 0 deletions src/bindings/c/pressure_resistance_flow.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
#include "pressure_resistance_flow.h"
#include <string.h>

extern void compliance_list_c(int *elemlist2_len, int elemlist2[]);
extern void occlusion_list_c(int *elemlist_len, int elemlist[]);

void evaluate_prq_c(const char *mesh_type, int *mesh_type_len, const char *vessel_type, int *vessel_type_len,int *grav_dirn, double *grav_factor, const char *bc_type, int *bc_type_len, double *inlet_bc, double *outlet_bc, double *remodeling_grade);

void compliance_list(int elemlist2_len, int elemlist2[])
{
compliance_list_c(&elemlist2_len, elemlist2);
}

void occlusion_list(int elemlist_len, int elemlist[])
{
occlusion_list_c(&elemlist_len, elemlist);
}

void evaluate_prq(const char *mesh_type, const char *vessel_type,int grav_dirn, double grav_factor, const char *bc_type, double inlet_bc, double outlet_bc, double remodeling_grade)
{
int mesh_type_len = strlen(mesh_type);
Expand Down
41 changes: 41 additions & 0 deletions src/bindings/c/pressure_resistance_flow.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,47 @@ module pressure_resistance_flow_c

contains



!
!###################################################################################
!
! the main growing subroutine. Generates a volume-filling tree into a closed surface.
subroutine occlusion_list_c(surface_elems_len, surface_elems) bind(C, name="occlusion_list_c")

!use arrays,only: dp
!use iso_c_binding, only: c_ptr
!use utils_c, only: strncpy
!use other_consts, only: MAX_FILENAME_LEN
use pressure_resistance_flow,only: occlusion_list
implicit none

integer,intent(in) :: surface_elems_len
integer,intent(in) :: surface_elems(surface_elems_len)

call occlusion_list(surface_elems)

end subroutine occlusion_list_c
!
!###################################################################################
!
! makes the vessels given rigid.
subroutine compliance_list_c(surface_elems_len, surface_elems) bind(C, name="compliance_list_c")

!use arrays,only: dp
!use iso_c_binding, only: c_ptr
!use utils_c, only: strncpy
!use other_consts, only: MAX_FILENAME_LEN
use pressure_resistance_flow,only: compliance_list
implicit none

integer,intent(in) :: surface_elems_len
integer,intent(in) :: surface_elems(surface_elems_len)

call compliance_list(surface_elems)

end subroutine compliance_list_c

!!!###################################################################################

subroutine evaluate_prq_c(mesh_type,mesh_type_len,vessel_type,vessel_type_len,grav_dirn,grav_factor,bc_type,bc_type_len,inlet_bc, &
Expand Down
3 changes: 2 additions & 1 deletion src/bindings/c/pressure_resistance_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

#include "symbol_export.h"


SHO_PUBLIC void occlusion_list(int elemlist_len, int elemlist[]);
SHO_PUBLIC void compliance_list(int elemlist2_len, int elemlist2[]);
SHO_PUBLIC void evaluate_prq(const char *mesh_type, const char *vessel_type, int grav_dirn, double grav_factor, const char *bc_type, double inlet_bc, double outlet_bc, double remodeling_grade);


Expand Down
49 changes: 48 additions & 1 deletion src/bindings/interface/pressure_resistance_flow.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@

%module(package="aether") pressure_resistance_flow
%include symbol_export.h
%include pressure_resistance_flow.h

%typemap(in) (int elemlist_len, int elemlist[]) {
int i;
if (!PyList_Check($input)) {
PyErr_SetString(PyExc_ValueError, "Expecting a list");
SWIG_fail;
}
$1 = PyList_Size($input);
$2 = (int *) malloc(($1)*sizeof(int));
for (i = 0; i < $1; i++) {
PyObject *o = PyList_GetItem($input, i);
if (!PyInt_Check(o)) {
free($2);
PyErr_SetString(PyExc_ValueError, "List items must be integers");
SWIG_fail;
}
$2[i] = PyInt_AsLong(o);
}
}

%typemap(in) (int elemlist2_len, int elemlist2[]) {
int i;
if (!PyList_Check($input)) {
PyErr_SetString(PyExc_ValueError, "Expecting a list");
SWIG_fail;
}
$1 = PyList_Size($input);
$2 = (int *) malloc(($1)*sizeof(int));
for (i = 0; i < $1; i++) {
PyObject *o = PyList_GetItem($input, i);
if (!PyInt_Check(o)) {
free($2);
PyErr_SetString(PyExc_ValueError, "List items must be integers");
SWIG_fail;
}
$2[i] = PyInt_AsLong(o);
}
}

%typemap(freearg) (int elemlist_len, int elemlist[]) {
if ($2) free($2);
}

%typemap(freearg) (int elemlist2_len, int elemlist2[]) {
if ($2) free($2);
}

%{
#include "pressure_resistance_flow.h"
%}

%include pressure_resistance_flow.h
Loading