diff --git a/opm/simulators/linalg/bda/WellContributions.cpp b/opm/simulators/linalg/bda/WellContributions.cpp index c284c9282..c09695132 100644 --- a/opm/simulators/linalg/bda/WellContributions.cpp +++ b/opm/simulators/linalg/bda/WellContributions.cpp @@ -62,10 +62,6 @@ WellContributions::~WellContributions() } #endif - if(num_std_wells > 0){ - delete[] val_pointers; - } - #if HAVE_OPENCL if(opencl_gpu){ if(num_ms_wells > 0){ @@ -181,7 +177,7 @@ void WellContributions::addMatrix([[maybe_unused]] MatrixType type, [[maybe_unus if (num_std_wells_so_far == num_std_wells - 1) { val_pointers[num_std_wells] = num_blocks; events.resize(1); - queue->enqueueWriteBuffer(*d_val_pointers_ocl, CL_FALSE, 0, sizeof(unsigned int) * (num_std_wells + 1), val_pointers, nullptr, &events[0]); + queue->enqueueWriteBuffer(*d_val_pointers_ocl, CL_FALSE, 0, sizeof(unsigned int) * (num_std_wells + 1), val_pointers.data(), nullptr, &events[0]); events[0].wait(); events.clear(); } @@ -227,7 +223,7 @@ void WellContributions::addNumBlocks(unsigned int numBlocks) void WellContributions::alloc() { if (num_std_wells > 0) { - val_pointers = new unsigned int[num_std_wells + 1]; + val_pointers.resize(num_std_wells+1); #if HAVE_CUDA if(cuda_gpu){ diff --git a/opm/simulators/linalg/bda/WellContributions.cu b/opm/simulators/linalg/bda/WellContributions.cu index 1ba663cf0..d374c5523 100644 --- a/opm/simulators/linalg/bda/WellContributions.cu +++ b/opm/simulators/linalg/bda/WellContributions.cu @@ -210,7 +210,7 @@ void WellContributions::addMatrixGpu(MatrixType type, int *colIndices, double *v val_pointers[num_std_wells_so_far] = num_blocks_so_far; if (num_std_wells_so_far == num_std_wells - 1) { val_pointers[num_std_wells] = num_blocks; - cudaMemcpy(d_val_pointers, val_pointers, sizeof(unsigned int) * (num_std_wells + 1), cudaMemcpyHostToDevice); + cudaMemcpy(d_val_pointers, val_pointers.data(), sizeof(unsigned int) * (num_std_wells + 1), cudaMemcpyHostToDevice); } break; default: diff --git a/opm/simulators/linalg/bda/WellContributions.hpp b/opm/simulators/linalg/bda/WellContributions.hpp index eec664b7c..c0735e715 100644 --- a/opm/simulators/linalg/bda/WellContributions.hpp +++ b/opm/simulators/linalg/bda/WellContributions.hpp @@ -86,7 +86,7 @@ private: unsigned int num_ms_wells = 0; // number of MultisegmentWells in this object, must equal multisegments.size() unsigned int num_blocks_so_far = 0; // keep track of where next data is written unsigned int num_std_wells_so_far = 0; // keep track of where next data is written - unsigned int *val_pointers = nullptr; // val_pointers[wellID] == index of first block for this well in Ccols and Bcols + std::vector val_pointers; // val_pointers[wellID] == index of first block for this well in Ccols and Bcols double *h_x = nullptr; double *h_y = nullptr;