Skip to content

Commit 2f0f749

Browse files
authored
Build Asc_ortho only in matrix version (#56)
1 parent 326dcfa commit 2f0f749

1 file changed

Lines changed: 31 additions & 29 deletions

File tree

src/polar_multigrid.cpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -419,35 +419,37 @@ void gmgpolar::prepare_op_levels()
419419
// define Asc blocks
420420
v_level[l]->build_Asc();
421421

422-
// 1 block matrix per row (column) for the circle (radial) smoother
423-
v_level[l]->A_Zebra_Mix_r.assign(4, std::vector<int>());
424-
v_level[l]->A_Zebra_Mix_c.assign(4, std::vector<int>());
425-
v_level[l]->A_Zebra_Mix_v.assign(4, std::vector<double>());
426-
for (int smoother = 0; smoother < 4; smoother++) {
427-
int nsc = v_level[l]->nz_sc_ortho[smoother];
428-
v_level[l]->A_Zebra_Mix_r[smoother] = std::vector<int>(nsc);
429-
v_level[l]->A_Zebra_Mix_c[smoother] = std::vector<int>(nsc);
430-
v_level[l]->A_Zebra_Mix_v[smoother] = std::vector<double>(nsc, 0);
431-
432-
// define Asc_ortho block
433-
v_level[l]->build_Asc_ortho(smoother);
434-
435-
// Build vectors necessary for the parallel application of Asc_ortho:
436-
// - ptr contains the nz entry for the points in the first radial line
437-
// - shift contains the number of entries per node
438-
int size_radial_line = v_level[l]->nr_int - v_level[l]->delete_circles;
439-
v_level[l]->shift_vect_s2 =
440-
std::vector<int>(size_radial_line); // shift between 2 radial lines for smoother 2
441-
v_level[l]->shift_vect_s3 = std::vector<int>(size_radial_line); // idem for smoother 3
442-
v_level[l]->ptr_vect_s2 = std::vector<int>(size_radial_line); // ptr to a radial line for smoother 2
443-
v_level[l]->ptr_vect_s3 = std::vector<int>(size_radial_line); // idem for smoother 3
444-
std::vector<int> ptr_vect;
445-
for (int j = v_level[l]->delete_circles; j < v_level[l]->nr_int; j++) {
446-
ptr_vect = v_level[l]->get_ptr_sc(j, 2, 1);
447-
v_level[l]->ptr_vect_s2[j - v_level[l]->delete_circles] = ptr_vect[0];
448-
v_level[l]->ptr_vect_s3[j - v_level[l]->delete_circles] = ptr_vect[1];
449-
v_level[l]->shift_vect_s2[j - v_level[l]->delete_circles] = ptr_vect[2] - ptr_vect[0];
450-
v_level[l]->shift_vect_s3[j - v_level[l]->delete_circles] = ptr_vect[3] - ptr_vect[1];
422+
if (gyro::icntl[Param::matrix_free] == 0) {
423+
// 1 block matrix per row (column) for the circle (radial) smoother
424+
v_level[l]->A_Zebra_Mix_r.assign(4, std::vector<int>());
425+
v_level[l]->A_Zebra_Mix_c.assign(4, std::vector<int>());
426+
v_level[l]->A_Zebra_Mix_v.assign(4, std::vector<double>());
427+
for (int smoother = 0; smoother < 4; smoother++) {
428+
int nsc = v_level[l]->nz_sc_ortho[smoother];
429+
v_level[l]->A_Zebra_Mix_r[smoother] = std::vector<int>(nsc);
430+
v_level[l]->A_Zebra_Mix_c[smoother] = std::vector<int>(nsc);
431+
v_level[l]->A_Zebra_Mix_v[smoother] = std::vector<double>(nsc, 0);
432+
433+
// define Asc_ortho block
434+
v_level[l]->build_Asc_ortho(smoother);
435+
436+
// Build vectors necessary for the parallel application of Asc_ortho:
437+
// - ptr contains the nz entry for the points in the first radial line
438+
// - shift contains the number of entries per node
439+
int size_radial_line = v_level[l]->nr_int - v_level[l]->delete_circles;
440+
v_level[l]->shift_vect_s2 =
441+
std::vector<int>(size_radial_line); // shift between 2 radial lines for smoother 2
442+
v_level[l]->shift_vect_s3 = std::vector<int>(size_radial_line); // idem for smoother 3
443+
v_level[l]->ptr_vect_s2 = std::vector<int>(size_radial_line); // ptr to a radial line for smoother 2
444+
v_level[l]->ptr_vect_s3 = std::vector<int>(size_radial_line); // idem for smoother 3
445+
std::vector<int> ptr_vect;
446+
for (int j = v_level[l]->delete_circles; j < v_level[l]->nr_int; j++) {
447+
ptr_vect = v_level[l]->get_ptr_sc(j, 2, 1);
448+
v_level[l]->ptr_vect_s2[j - v_level[l]->delete_circles] = ptr_vect[0];
449+
v_level[l]->ptr_vect_s3[j - v_level[l]->delete_circles] = ptr_vect[1];
450+
v_level[l]->shift_vect_s2[j - v_level[l]->delete_circles] = ptr_vect[2] - ptr_vect[0];
451+
v_level[l]->shift_vect_s3[j - v_level[l]->delete_circles] = ptr_vect[3] - ptr_vect[1];
452+
}
451453
}
452454
}
453455
}

0 commit comments

Comments
 (0)