Skip to content

Commit

Permalink
Zero background arrays and only fill if disk object is instantiated
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed Nov 21, 2024
1 parent 3ebd453 commit 18aa52b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/cudaBiorthCyl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,19 @@ void BiorthCyl::initialize_cuda
// Add background arrays
//
std::vector<thrust::host_vector<cuFP_t>> tt(ndim2);
for (auto & v : tt) v.resize(numr);
for (auto & v : tt) {
v.resize(numr);
thrust::fill(v.begin(), v.end(), 0.0);
}

double dx0 = (xmax - xmin)/(numr - 1);
if (disk) {
double dx0 = (xmax - xmin)/(numr - 1);

for (int i=0; i<numr; i++) {
double r = xi_to_r(xmin + dx0*i);
tt[0][i] = disk->pot(r);
tt[1][i] = disk->dpot(r);
for (int i=0; i<numr; i++) {
double r = xi_to_r(xmin + dx0*i);
tt[0][i] = disk->pot(r);
tt[1][i] = disk->dpot(r);
}
}

// Allocate CUDA array in device memory (a one-dimension 'channel')
Expand Down

0 comments on commit 18aa52b

Please sign in to comment.