Skip to content

Commit

Permalink
two new subroutines and bindings, for scaling and offsetting 1d mesh …
Browse files Browse the repository at this point in the history
…coordinates
  • Loading branch information
Merryn Tawhai authored and Merryn Tawhai committed Oct 6, 2023
1 parent feaa796 commit 5c58453
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/bindings/c/geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ void define_rad_from_geom_c(const char *order_system, int *order_system_len, dou
const char *group_type, int *group_type_len, const char *group_options, int *group_options_len);
void element_connectivity_1d_c(void);
void evaluate_ordering_c(void);
extern void offset_1d_c(double *offset_x, double *offset_y, double *offset_z);
extern void scale_1d_c(double *scale_x, double *scale_y, double *scale_z);
void volume_of_mesh_c(double *volume_model, double *volume_tree);
void write_elem_geometry_2d_c(const char *ELEMFILE, int *filename_len);
void write_geo_file_c(int *ntype, const char *GEOFILE, int *filename_len);
Expand Down Expand Up @@ -140,6 +142,16 @@ void evaluate_ordering()
evaluate_ordering_c();
}

void offset_1d(double offset_x, double offset_y, double offset_z)
{
offset_1d_c(&offset_x, &offset_y, &offset_z);
}

void scale_1d(double scale_x, double scale_y, double scale_z)
{
scale_1d_c(&scale_x, &scale_y, &scale_z);
}

void volume_of_mesh(double *volume_model, double *volume_tree)
{
volume_of_mesh_c(volume_model, volume_tree);
Expand Down
30 changes: 30 additions & 0 deletions src/bindings/c/geometry.f90
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,36 @@ subroutine make_2d_vessel_from_1d_c(elemlist, elemlist_len) bind(C, name="make_2

end subroutine make_2d_vessel_from_1d_c

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

subroutine offset_1d_c(offset_x, offset_y, offset_z) bind(C, name="offset_1d_c")
use arrays, only: dp
use geometry, only: offset_1d
implicit none

real(dp),intent(in) :: offset_x, offset_y, offset_z

call offset_1d(offset_x, offset_y, offset_z)

end subroutine offset_1d_c

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

subroutine scale_1d_c(scale_x, scale_y, scale_z) bind(C, name="scale_1d_c")
use arrays, only: dp
use geometry, only: scale_1d
implicit none

real(dp),intent(in) :: scale_x, scale_y, scale_z

call scale_1d(scale_x, scale_y, scale_z)

end subroutine scale_1d_c

!
!###################################################################################
!
Expand Down
2 changes: 2 additions & 0 deletions src/bindings/c/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ SHO_PUBLIC void define_rad_from_geom(const char *ORDER_SYSTEM, double CONTROL_PA
double START_RAD, const char *GROUP_TYPE, const char *GROUP_OPTIONS);
SHO_PUBLIC void element_connectivity_1d();
SHO_PUBLIC void evaluate_ordering();
SHO_PUBLIC void offset_1d(double offset_x, double offset_y, double offset_z);
SHO_PUBLIC void scale_1d(double scale_x, double scale_y, double scale_z);
SHO_PUBLIC void volume_of_mesh(double *volume_model, double *volume_tree);
SHO_PUBLIC void write_elem_geometry_2d(const char *ELEMFILE);
SHO_PUBLIC void write_geo_file(int ntype, const char *GEOFILE);
Expand Down
48 changes: 48 additions & 0 deletions src/lib/geometry.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ module geometry
public import_ply_triangles
public make_data_grid
public make_2d_vessel_from_1d
public offset_1d
public reallocate_node_elem_arrays
public scale_1d
public set_initial_volume
public triangles_from_surface
public volume_of_mesh
Expand Down Expand Up @@ -3576,6 +3578,29 @@ subroutine geo_node_offset(node_xyz_offset)

end subroutine geo_node_offset

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

subroutine offset_1d(offset_x, offset_y, offset_z)
!*offset_1d:* offset the 1D tree by the given x,y,z offset values

real(dp),intent(in) :: offset_x, offset_y, offset_z

character(len=60) :: sub_name

! --------------------------------------------------------------------------

sub_name = 'offset_1d'
call enter_exit(sub_name,1)

node_xyz(1,1:num_nodes) = node_xyz(1,1:num_nodes) + offset_x
node_xyz(2,1:num_nodes) = node_xyz(2,1:num_nodes) + offset_y
node_xyz(3,1:num_nodes) = node_xyz(3,1:num_nodes) + offset_z

call enter_exit(sub_name,2)

end subroutine offset_1d


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

subroutine reallocate_node_elem_arrays(num_elems_new,num_nodes_new)
Expand Down Expand Up @@ -3707,6 +3732,29 @@ subroutine reallocate_node_elem_arrays(num_elems_new,num_nodes_new)

end subroutine reallocate_node_elem_arrays

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

subroutine scale_1d(scale_x, scale_y, scale_z)
!*scale_1d:* scale the 1D tree by the given x,y,z scale values

real(dp),intent(in) :: scale_x, scale_y, scale_z

character(len=60) :: sub_name

! --------------------------------------------------------------------------

sub_name = 'scale_1d'
call enter_exit(sub_name,1)

node_xyz(1,1:num_nodes) = node_xyz(1,1:num_nodes) * scale_x
node_xyz(2,1:num_nodes) = node_xyz(2,1:num_nodes) * scale_y
node_xyz(3,1:num_nodes) = node_xyz(3,1:num_nodes) * scale_z

call enter_exit(sub_name,2)

end subroutine scale_1d


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

function get_local_node_f(ndimension,np_global) result(get_local_node)
Expand Down

0 comments on commit 5c58453

Please sign in to comment.