mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
fixe openmp
fixed add well matrix in new system
This commit is contained in:
parent
cf208af541
commit
b7f2a85534
@ -194,7 +194,7 @@ public:
|
|||||||
Scalar Vex = problem.volume(globalIndexEx, /*timeIdx=*/0);
|
Scalar Vex = problem.volume(globalIndexEx, /*timeIdx=*/0);
|
||||||
|
|
||||||
|
|
||||||
Scalar trans = problem.transmissibility(globalIndexIn,globalIndexEx);
|
Scalar trans = 1.0;//problem.transmissibility(globalIndexIn,globalIndexEx);
|
||||||
//Scalar faceArea = problem.area(globalIndexIn,globalIndexEx);
|
//Scalar faceArea = problem.area(globalIndexIn,globalIndexEx);
|
||||||
Scalar faceArea = 1.0;//NB need correct calculation local residual
|
Scalar faceArea = 1.0;//NB need correct calculation local residual
|
||||||
Scalar thpres = problem.thresholdPressure(globalIndexIn, globalIndexEx);
|
Scalar thpres = problem.thresholdPressure(globalIndexIn, globalIndexEx);
|
||||||
@ -215,7 +215,7 @@ public:
|
|||||||
|
|
||||||
// the distances from the DOF's depths. (i.e., the additional depth of the
|
// the distances from the DOF's depths. (i.e., the additional depth of the
|
||||||
// exterior DOF)
|
// exterior DOF)
|
||||||
Scalar distZ = zIn - zEx;
|
Scalar distZ = zIn - zEx;// NB could be precalculated
|
||||||
|
|
||||||
//
|
//
|
||||||
//const ExtensiveQuantities& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
|
//const ExtensiveQuantities& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
|
||||||
|
@ -801,7 +801,7 @@ public:
|
|||||||
//invalidateIntensiveQuantitiesCache(timeIdx);
|
//invalidateIntensiveQuantitiesCache(timeIdx);
|
||||||
size_t numGridDof = primaryVars.size();
|
size_t numGridDof = primaryVars.size();
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel
|
#pragma omp parallel for
|
||||||
#endif
|
#endif
|
||||||
for (unsigned dofIdx = 0; dofIdx < numGridDof; ++dofIdx) {
|
for (unsigned dofIdx = 0; dofIdx < numGridDof; ++dofIdx) {
|
||||||
const auto& primaryVar = primaryVars[dofIdx];
|
const auto& primaryVar = primaryVars[dofIdx];
|
||||||
|
@ -42,6 +42,8 @@
|
|||||||
#include <dune/common/fvector.hh>
|
#include <dune/common/fvector.hh>
|
||||||
#include <dune/common/fmatrix.hh>
|
#include <dune/common/fmatrix.hh>
|
||||||
|
|
||||||
|
#include <opm/grid/utility/SparseTable.hpp>
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -363,6 +365,7 @@ private:
|
|||||||
|
|
||||||
// add the additional neighbors and degrees of freedom caused by the auxiliary
|
// add the additional neighbors and degrees of freedom caused by the auxiliary
|
||||||
// equations
|
// equations
|
||||||
|
auto reservoirSparsityPattern = sparsityPattern;
|
||||||
size_t numAuxMod = model.numAuxiliaryModules();
|
size_t numAuxMod = model.numAuxiliaryModules();
|
||||||
for (unsigned auxModIdx = 0; auxModIdx < numAuxMod; ++auxModIdx)
|
for (unsigned auxModIdx = 0; auxModIdx < numAuxMod; ++auxModIdx)
|
||||||
model.auxiliaryModule(auxModIdx)->addNeighbors(sparsityPattern);
|
model.auxiliaryModule(auxModIdx)->addNeighbors(sparsityPattern);
|
||||||
@ -372,9 +375,25 @@ private:
|
|||||||
|
|
||||||
// create matrix structure based on sparsity pattern
|
// create matrix structure based on sparsity pattern
|
||||||
jacobian_->reserve(sparsityPattern);
|
jacobian_->reserve(sparsityPattern);
|
||||||
neighbours_ = sparsityPattern;
|
//neighbours_ = sparsityPattern;
|
||||||
for(unsigned globI= 0; globI < model.numTotalDof(); globI++){
|
for(unsigned globI= 0; globI < model.numTotalDof(); globI++){
|
||||||
neighbours_[globI].erase(globI);
|
reservoirSparsityPattern[globI].erase(globI);
|
||||||
|
}
|
||||||
|
unsigned numCells = model.numTotalDof();
|
||||||
|
neighbours_.reserve(numCells,6*numCells);
|
||||||
|
trans_.reserve(numCells,6*numCells);
|
||||||
|
std::vector<double> loctrans;
|
||||||
|
for(unsigned globI= 0; globI < numCells; globI++){
|
||||||
|
const auto& cells = reservoirSparsityPattern[globI];
|
||||||
|
neighbours_.appendRow(cells.begin(),cells.end());
|
||||||
|
unsigned n = cells.size();
|
||||||
|
loctrans.resize(n);
|
||||||
|
short loc = 0;
|
||||||
|
for(const int& cell : cells){
|
||||||
|
loctrans[loc] = problem_().transmissibility(globI, cell);
|
||||||
|
loc ++;
|
||||||
|
}
|
||||||
|
trans_.appendRow(loctrans.begin(),loctrans.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,13 +473,13 @@ private:
|
|||||||
resetSystem_();
|
resetSystem_();
|
||||||
unsigned numCells = model_().numTotalDof();
|
unsigned numCells = model_().numTotalDof();
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel
|
#pragma omp parallel for
|
||||||
#endif
|
#endif
|
||||||
for(unsigned globI = 0; globI < numCells; globI++){
|
for(unsigned globI = 0; globI < numCells; globI++){
|
||||||
const auto& neighbours = neighbours_[globI];// this is a set but should maybe be changed
|
const auto& neighbours = neighbours_[globI];// this is a set but should maybe be changed
|
||||||
// accumulation term
|
// accumulation term
|
||||||
double dt = simulator_().timeStepSize();
|
double dt = simulator_().timeStepSize();
|
||||||
double volume = model_().dofTotalVolume(globI);;
|
double volume = model_().dofTotalVolume(globI);
|
||||||
Scalar storefac = volume/dt;
|
Scalar storefac = volume/dt;
|
||||||
ADVectorBlock adres(0.0);
|
ADVectorBlock adres(0.0);
|
||||||
const IntensiveQuantities* intQuantsInP = model_().cachedIntensiveQuantities(globI, /*timeIdx*/0);
|
const IntensiveQuantities* intQuantsInP = model_().cachedIntensiveQuantities(globI, /*timeIdx*/0);
|
||||||
@ -490,6 +509,7 @@ private:
|
|||||||
residual_[globI] += res;
|
residual_[globI] += res;
|
||||||
jacobian_->addToBlock(globI, globI, bMat);
|
jacobian_->addToBlock(globI, globI, bMat);
|
||||||
}
|
}
|
||||||
|
short loc = 0;
|
||||||
for(const auto& globJ: neighbours){
|
for(const auto& globJ: neighbours){
|
||||||
assert(globJ != globI);
|
assert(globJ != globI);
|
||||||
res = 0.0;
|
res = 0.0;
|
||||||
@ -506,12 +526,14 @@ private:
|
|||||||
globJ,
|
globJ,
|
||||||
intQuantsIn,
|
intQuantsIn,
|
||||||
intQuantsEx,
|
intQuantsEx,
|
||||||
0);
|
0);
|
||||||
|
adres *= trans_[globI][loc];
|
||||||
setResAndJacobi(res, bMat, adres);
|
setResAndJacobi(res, bMat, adres);
|
||||||
residual_[globI] += res;
|
residual_[globI] += res;
|
||||||
jacobian_->addToBlock(globI, globI, bMat);
|
jacobian_->addToBlock(globI, globI, bMat);
|
||||||
bMat *= -1.0;
|
bMat *= -1.0;
|
||||||
jacobian_->addToBlock(globJ, globI, bMat);
|
jacobian_->addToBlock(globJ, globI, bMat);
|
||||||
|
loc ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -695,8 +717,11 @@ private:
|
|||||||
LinearizationType linearizationType_;
|
LinearizationType linearizationType_;
|
||||||
|
|
||||||
std::mutex globalMatrixMutex_;
|
std::mutex globalMatrixMutex_;
|
||||||
using NeighborSet = std::set< unsigned >;
|
//using NeighborSet = std::set< unsigned >;
|
||||||
std::vector<NeighborSet> neighbours_;
|
//std::vector< std::vector<int>>
|
||||||
|
SparseTable<unsigned> neighbours_;
|
||||||
|
//std::vector< std::vector<double>> trans_;
|
||||||
|
SparseTable<double> trans_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
Loading…
Reference in New Issue
Block a user