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