Skip to content

Commit 18aa52b

Browse files
author
Martin D. Weinberg
committed
Zero background arrays and only fill if disk object is instantiated
1 parent 3ebd453 commit 18aa52b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/cudaBiorthCyl.cu

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,19 @@ void BiorthCyl::initialize_cuda
187187
// Add background arrays
188188
//
189189
std::vector<thrust::host_vector<cuFP_t>> tt(ndim2);
190-
for (auto & v : tt) v.resize(numr);
190+
for (auto & v : tt) {
191+
v.resize(numr);
192+
thrust::fill(v.begin(), v.end(), 0.0);
193+
}
191194

192-
double dx0 = (xmax - xmin)/(numr - 1);
195+
if (disk) {
196+
double dx0 = (xmax - xmin)/(numr - 1);
193197

194-
for (int i=0; i<numr; i++) {
195-
double r = xi_to_r(xmin + dx0*i);
196-
tt[0][i] = disk->pot(r);
197-
tt[1][i] = disk->dpot(r);
198+
for (int i=0; i<numr; i++) {
199+
double r = xi_to_r(xmin + dx0*i);
200+
tt[0][i] = disk->pot(r);
201+
tt[1][i] = disk->dpot(r);
202+
}
198203
}
199204

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

0 commit comments

Comments
 (0)