Skip to content

Commit

Permalink
Moving some functions to custom_data
Browse files Browse the repository at this point in the history
  • Loading branch information
bergolho committed Jan 22, 2024
1 parent 197f4e1 commit 8ec255a
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 1,304 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ src/*/custom_functions.c
src/*/custom_functions_BACKUP.c
src/*/custom_functions.h

bsbash/find_functions_with_mpi.sh

.cache/
.ccls-cache/

Expand Down
11 changes: 8 additions & 3 deletions example_configs/introduction_to_monoalg3d/plot_ecg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ def read_ecg_readings (input_file):

def plot_ecg_readings (t, currents, nleads):

fig, axs = plt.subplots(nleads, 1, sharex=True, sharey=False)
# Plot 3 signals => 1 = Lead A, 2 = Lead B, 3 = (Lead B + Lead A)
fig, axs = plt.subplots(nleads+1, 1, sharex=True, sharey=False)
fig.text(0.5, 0.04, 'Time (ms)', ha='center', fontsize=10)
fig.text(0.02, 0.5, 'Current (mA)', va='center', rotation='vertical', fontsize=10)
# Signals 1 and 2
for i in range(nleads):
axs[i].plot(t, currents[:,i], label="lead_%d" % (i), c="black", linewidth=2.0)
axs[i].set_title("ECG reading - Lead %d" % (i),fontsize=14)

axs[i].set_title("ECG reading - Lead %d" % (i),fontsize=10)
# Signal 3
axs[nleads].plot(t, currents[:,1]+currents[:,0], label="lead_%d" % (nleads), c="black", linewidth=2.0)
axs[nleads].set_title("ECG reading - Lead %d" % (nleads),fontsize=10)

#plt.show()
#plt.savefig("ecg.pdf")
plt.savefig("ecg.png", dpi=300)
Expand Down
76 changes: 0 additions & 76 deletions src/matrix_assembly_library/matrix_assembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,79 +1220,3 @@ ASSEMBLY_MATRIX(anisotropic_sigma_assembly_matrix_with_fast_endocardium_layer) {
free(s);
free(n);
}

// Albert`s code
ASSEMBLY_MATRIX(anisotropic_sigma_assembly_matrix_with_scaling) {

uint32_t num_active_cells = the_grid->num_active_cells;
struct cell_node **ac = the_grid->active_cells;

initialize_diagonal_elements(the_solver, the_grid);

real_cpu D[3][3];
int i;

real_cpu sigma_l = 0.0;
real_cpu sigma_t = 0.0;
real_cpu sigma_n = 0.0;

char *fiber_file = NULL;
GET_PARAMETER_STRING_VALUE_OR_USE_DEFAULT(fiber_file, config, "fibers_file");

struct fiber_coords_scale *fibers = NULL;
struct fiber_coords *fibers2 = NULL;

GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, sigma_l, config, "sigma_l");
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, sigma_t, config, "sigma_t");
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, sigma_n, config, "sigma_n");

real_cpu *f = NULL;
real_cpu *s = NULL;
real_cpu *n = NULL;
real_cpu *x = NULL;

if(fiber_file) {
log_info("Loading mesh fibers\n");
fibers = read_fibers_scale(fiber_file);
fibers2 = read_fibers(fiber_file, false);
}
else {
log_error_and_exit("Fibers file not provided");
}

OMP(parallel for private(D))
for(i = 0; i < num_active_cells; i++) {

int fiber_index = ac[i]->original_position_in_file;

if(fiber_index == -1) {
log_error_and_exit("fiber_index should not be -1, but it is for cell in index %d - %lf, %lf, %lf\n", i, ac[i]->center.x, ac[i]->center.y, ac[i]->center.z);
}

if(sigma_t == sigma_n) {
calc_tensor2(D, fibers[fiber_index].f, sigma_l*fibers[fiber_index].x[0], sigma_t*fibers[fiber_index].x[1]);
}
else {
calc_tensor(D, fibers[fiber_index].f, fibers[fiber_index].s, fibers[fiber_index].n, sigma_l*fibers[fiber_index].x[0], sigma_t*fibers[fiber_index].x[1], sigma_n*fibers[fiber_index].x[2]);
}
ac[i]->sigma.fibers = fibers2[fiber_index];

ac[i]->sigma.x = D[0][0];
ac[i]->sigma.y = D[1][1];
ac[i]->sigma.z = D[2][2];

ac[i]->sigma.xy = D[0][1];
ac[i]->sigma.xz = D[0][2];
ac[i]->sigma.yz = D[1][2];
}

OMP(parallel for)
for(i = 0; i < num_active_cells; i++) {
fill_discretization_matrix_elements_aniso(ac[i]);
}

free(f);
free(s);
free(n);
free(x);
}
Binary file removed src/models_library/CRN/.DS_Store
Binary file not shown.
Loading

0 comments on commit 8ec255a

Please sign in to comment.