mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
changed: use unique_ptr for MultisegmentWellContributions
less manual pointer management is always good
This commit is contained in:
parent
5bfac05827
commit
2b0508af8b
@ -54,10 +54,6 @@ WellContributions::WellContributions(std::string accelerator_mode, bool useWellC
|
||||
|
||||
WellContributions::~WellContributions()
|
||||
{
|
||||
// delete MultisegmentWellContributions
|
||||
for (auto ms: multisegments) {
|
||||
delete ms;
|
||||
}
|
||||
multisegments.clear();
|
||||
|
||||
#if HAVE_CUDA
|
||||
@ -121,7 +117,7 @@ void WellContributions::apply_mswells(cl::Buffer d_x, cl::Buffer d_y){
|
||||
events.clear();
|
||||
|
||||
// actually apply MultisegmentWells
|
||||
for(Opm::MultisegmentWellContribution *well: multisegments){
|
||||
for (auto& well : multisegments) {
|
||||
well->setReordering(h_toOrder, reorder);
|
||||
well->apply(h_x, h_y);
|
||||
}
|
||||
@ -253,15 +249,30 @@ void WellContributions::alloc()
|
||||
}
|
||||
}
|
||||
|
||||
void WellContributions::addMultisegmentWellContribution(unsigned int dim_, unsigned int dim_wells_,
|
||||
unsigned int Mb,
|
||||
std::vector<double> &Bvalues, std::vector<unsigned int> &BcolIndices, std::vector<unsigned int> &BrowPointers,
|
||||
unsigned int DnumBlocks, double *Dvalues, UMFPackIndex *DcolPointers, UMFPackIndex *DrowIndices,
|
||||
std::vector<double> &Cvalues)
|
||||
void WellContributions::addMultisegmentWellContribution(unsigned int dim_,
|
||||
unsigned int dim_wells_,
|
||||
unsigned int Mb,
|
||||
std::vector<double>& Bvalues,
|
||||
std::vector<unsigned int>& BcolIndices,
|
||||
std::vector<unsigned int>& BrowPointers,
|
||||
unsigned int DnumBlocks,
|
||||
double* Dvalues,
|
||||
UMFPackIndex* DcolPointers,
|
||||
UMFPackIndex* DrowIndices,
|
||||
std::vector<double>& Cvalues)
|
||||
{
|
||||
assert(dim==dim_);
|
||||
MultisegmentWellContribution *well = new MultisegmentWellContribution(dim_, dim_wells_, Mb, Bvalues, BcolIndices, BrowPointers, DnumBlocks, Dvalues, DcolPointers, DrowIndices, Cvalues);
|
||||
multisegments.emplace_back(well);
|
||||
multisegments.push_back(std::make_unique<MultisegmentWellContribution>(dim_,
|
||||
dim_wells_,
|
||||
Mb,
|
||||
Bvalues,
|
||||
BcolIndices,
|
||||
BrowPointers,
|
||||
DnumBlocks,
|
||||
Dvalues,
|
||||
DcolPointers,
|
||||
DrowIndices,
|
||||
Cvalues));
|
||||
++num_ms_wells;
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ void WellContributions::apply(double *d_x, double *d_y)
|
||||
cudaStreamSynchronize(stream);
|
||||
|
||||
// actually apply MultisegmentWells
|
||||
for (MultisegmentWellContribution *well : multisegments) {
|
||||
for (auto& well : multisegments) {
|
||||
well->apply(h_x, h_y);
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ void WellContributions::addMatrixGpu(MatrixType type, int *colIndices, double *v
|
||||
void WellContributions::setCudaStream(cudaStream_t stream_)
|
||||
{
|
||||
this->stream = stream_;
|
||||
for (MultisegmentWellContribution *well : multisegments) {
|
||||
for (auto& well : multisegments) {
|
||||
well->setCudaStream(stream_);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <opm/simulators/linalg/bda/openclKernels.hpp>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/simulators/linalg/bda/MultisegmentWellContribution.hpp>
|
||||
@ -89,7 +90,7 @@ private:
|
||||
|
||||
double *h_x = nullptr;
|
||||
double *h_y = nullptr;
|
||||
std::vector<MultisegmentWellContribution*> multisegments;
|
||||
std::vector<std::unique_ptr<MultisegmentWellContribution>> multisegments;
|
||||
|
||||
#if HAVE_OPENCL
|
||||
cl::Context *context;
|
||||
|
Loading…
Reference in New Issue
Block a user