Skip to content

Commit

Permalink
Backtrack to old conic domain function/Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bergolho committed Jun 2, 2024
1 parent 736bf15 commit 829226b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 636 deletions.
11 changes: 4 additions & 7 deletions src/domains_library/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,8 @@ SET_SPATIAL_DOMAIN(initialize_grid_with_cuboid_and_sphere_fibrotic_mesh_with_con
real_cpu phi = 0.0;
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, phi, config, "phi");

real_cpu plain_center_x = 0.0;
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, plain_center_x, config, "plain_center_x");

real_cpu plain_center_y = 0.0;
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, plain_center_y, config, "plain_center_y");
real_cpu plain_center = 0.0;
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, plain_center, config, "plain_center");

real_cpu sphere_radius = 0.0;
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, sphere_radius, config, "sphere_radius");
Expand All @@ -449,7 +446,7 @@ SET_SPATIAL_DOMAIN(initialize_grid_with_cuboid_and_sphere_fibrotic_mesh_with_con

//set_square_mesh(config, the_grid);
set_cuboid_domain_mesh(the_grid, start_dx, start_dy, start_dz, side_length_x, side_length_y, side_length_z);
set_cuboid_sphere_fibrosis_with_conic_path(the_grid, phi, plain_center_x, plain_center_y, sphere_radius, border_zone_size, border_zone_radius, seed, conic_slope);
set_cuboid_sphere_fibrosis_with_conic_path(the_grid, phi, plain_center, sphere_radius, border_zone_size, border_zone_radius, seed, conic_slope);

return 1;
}
}
40 changes: 18 additions & 22 deletions src/domains_library/domain_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1010,10 +1010,10 @@ int calc_num_refs(real_cpu start_h, real_cpu desired_h) {
return num_refs;
}

void set_cuboid_sphere_fibrosis_with_conic_path(struct grid *the_grid, real_cpu phi, real_cpu plain_center_x, real_cpu plain_center_y, \
real_cpu sphere_radius, real_cpu bz_size, real_cpu bz_radius, unsigned fib_seed, real_cpu cone_slope) {
void set_cuboid_sphere_fibrosis_with_conic_path(struct grid *the_grid, real_cpu phi, real_cpu plain_center, real_cpu sphere_radius, real_cpu bz_size, real_cpu bz_radius,
unsigned fib_seed, real_cpu cone_slope) {

struct cell_node *grid_cell;
log_info("Making %.2lf %% of cells inactive\n", phi * 100.0f);

if(fib_seed == 0)
fib_seed = (unsigned)time(NULL) + getpid();
Expand All @@ -1022,29 +1022,29 @@ void set_cuboid_sphere_fibrosis_with_conic_path(struct grid *the_grid, real_cpu

log_info("Using %u as seed\n", fib_seed);

real_cpu a1 = (2.0*side_length) / (side_length - 2*source_sink_min_x);
real_cpu b1 = -source_sink_min_x*a1;
real_cpu a2 = (2.0*side_length) / (side_length - 2*source_sink_max_x);
real_cpu b2 = -source_sink_max_x*a2;
real_cpu bz_radius_2 = pow(bz_radius, 2.0);
real_cpu sphere_radius_2 = pow(sphere_radius, 2.0);
struct cell_node *grid_cell;

grid_cell = the_grid->first_cell;
while(grid_cell != 0) {
// Calculate distance to the center of the mesh
real_cpu distance = pow(grid_cell->center.x - plain_center_x, 2.0) + pow(grid_cell->center.y - plain_center_y, 2.0);
real_cpu h_distance = abs(grid_cell->center.y - plain_center_y);
//Calcula distância da célula para o centro da malha
real_cpu distance = pow(grid_cell->center.x - plain_center, 2.0) + pow(grid_cell->center.y - plain_center, 2.0);
real_cpu h_distance = abs(grid_cell->center.x - plain_center);

if(grid_cell->active) {

INITIALIZE_FIBROTIC_INFO(grid_cell);

if(distance <= bz_radius_2) {
// Inside border zone
//Dentro da border zone
if(distance <= sphere_radius_2) {
// Inside the sphere
if(h_distance < cone_slope*abs(the_grid->mesh_side_length.x - grid_cell->center.x)*plain_center_x) //abs(cone_slope*grid_cell->center.y)
//dentro da "esfera"
if(h_distance < cone_slope*grid_cell->center.y*plain_center) //abs(cone_slope*grid_cell->center.y)
{
// Inside the cone
FIBROTIC(grid_cell) = true;

//Dentro do cone
}
else{
grid_cell->active = false;
Expand All @@ -1069,20 +1069,16 @@ void set_cuboid_sphere_fibrosis_with_conic_path(struct grid *the_grid, real_cpu
grid_cell->active = false;
grid_cell->can_change = false;
} else if(BORDER_ZONE(grid_cell)) {
real_cpu distance_from_center = sqrt((grid_cell->center.x - plain_center_x) * (grid_cell->center.x - plain_center_x) +
(grid_cell->center.y - plain_center_y) * (grid_cell->center.y - plain_center_y));
real_cpu distance_from_center = sqrt((grid_cell->center.x - plain_center) * (grid_cell->center.x - plain_center) +
(grid_cell->center.y - plain_center) * (grid_cell->center.y - plain_center));
distance_from_center = (distance_from_center - sphere_radius) / bz_size;
real_cpu phi_local = phi - phi * distance_from_center;
real_cpu p = (real_cpu)(rand()) / (RAND_MAX);
if(p < phi) {
if(p < phi_local)
grid_cell->active = false;
}

INITIALIZE_FIBROTIC_INFO(grid_cell);
FIBROTIC(grid_cell) = true;
grid_cell->can_change = false;
}
}

grid_cell = grid_cell->next;
}
}
4 changes: 2 additions & 2 deletions src/domains_library/domain_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ uint32_t set_custom_mesh_from_file(struct grid *the_grid, const char *mesh_file,

void set_cube_sphere_fibrosis(struct grid *the_grid, real_cpu phi, real_cpu sphere_center[3], real_cpu sphere_radius, unsigned fib_seed);

void set_cuboid_sphere_fibrosis_with_conic_path(struct grid *the_grid, real_cpu phi, real_cpu plain_center_x, real_cpu plain_center_y, \
real_cpu sphere_radius, real_cpu bz_size, real_cpu bz_radius, unsigned fib_seed, real_cpu cone_slope);
void set_cuboid_sphere_fibrosis_with_conic_path (struct grid *the_grid, real_cpu phi, real_cpu plain_center, real_cpu sphere_radius, real_cpu bz_size, real_cpu bz_radius,
unsigned fib_seed, real_cpu cone_slope);

int calc_num_refs(real_cpu start_h, real_cpu desired_h);

Expand Down
23 changes: 0 additions & 23 deletions src/extra_data_library/extra_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,26 +627,3 @@ SET_EXTRA_DATA(set_extra_data_trovato) {
return (void*)extra_data;

}

// For cable simulations for tuneCV
SET_EXTRA_DATA(set_extra_data_for_cable_ToRORd_Land_mixed_endo_mid_epi_IKs) {
uint32_t num_active_cells = the_grid->num_active_cells;
struct cell_node ** ac = the_grid->active_cells;

struct extra_data_for_torord_land_twave *extra_data = NULL;
extra_data = set_common_torord_Land_twave_data(config, num_active_cells);

// All cells will be the same type
OMP(parallel for)
for (int i = 0; i < num_active_cells; i++) {
// ENDO
extra_data->transmurality[i] = 0.0;
extra_data->sf_IKs[i] = 1.0;
}

SET_EXTRA_DATA_SIZE(sizeof(struct extra_data_for_torord_land_twave));

return (void*)extra_data;


}
Loading

0 comments on commit 829226b

Please sign in to comment.