Add function to calculate volume for all active cells - omp
This commit is contained in:
parent
0cdd6ba3d8
commit
0cfc291039
@ -154,6 +154,7 @@ namespace Opm {
|
||||
std::array<double, 3> getCellCenter(size_t i,size_t j, size_t k) const;
|
||||
std::array<double, 3> getCellCenter(size_t globalIndex) const;
|
||||
std::array<double, 3> getCornerPos(size_t i,size_t j, size_t k, size_t corner_index) const;
|
||||
std::vector<double> activeVolume() const;
|
||||
double getCellVolume(size_t globalIndex) const;
|
||||
double getCellVolume(size_t i , size_t j , size_t k) const;
|
||||
double getCellThickness(size_t globalIndex) const;
|
||||
|
@ -66,7 +66,8 @@ ext_modules = [
|
||||
language='c++',
|
||||
undef_macros=["NDEBUG"],
|
||||
include_dirs=["pybind11/include"],
|
||||
extra_compile_args=['-std=c++17']
|
||||
extra_compile_args=['-std=c++17', '-fopenmp'],
|
||||
extra_link_args=['-fopenmp']
|
||||
)
|
||||
]
|
||||
|
||||
|
@ -1343,8 +1343,23 @@ std::vector<double> EclipseGrid::createDVector(const std::array<int,3>& dims, st
|
||||
assertIJK(i,j,k);
|
||||
|
||||
size_t globalIndex = getGlobalIndex(i,j,k);
|
||||
return this->cellActive(globalIndex);
|
||||
}
|
||||
|
||||
return m_actnum[globalIndex]>0;
|
||||
std::vector<double> EclipseGrid::activeVolume() const {
|
||||
std::vector<double> active_volume( this->m_nactive );
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
for (std::size_t active_index = 0; active_index < this->m_active_to_global.size(); active_index++) {
|
||||
std::array<double,8> X;
|
||||
std::array<double,8> Y;
|
||||
std::array<double,8> Z;
|
||||
auto global_index = this->m_active_to_global[active_index];
|
||||
this->getCellCorners(global_index, X, Y, Z );
|
||||
active_volume[active_index] = calculateCellVol(X, Y, Z);
|
||||
}
|
||||
|
||||
return active_volume;
|
||||
}
|
||||
|
||||
|
||||
@ -1666,9 +1681,6 @@ std::vector<double> EclipseGrid::createDVector(const std::array<int,3>& dims, st
|
||||
this->resetACTNUM();
|
||||
else {
|
||||
auto global_size = this->getCartesianSize();
|
||||
if (this->m_actnum.empty() || std::memcmp(actnum, this->m_actnum.data(), global_size * sizeof * actnum) != 0) {
|
||||
}
|
||||
|
||||
this->m_global_to_active.clear();
|
||||
this->m_active_to_global.clear();
|
||||
this->m_actnum.resize(global_size);
|
||||
@ -1682,15 +1694,16 @@ std::vector<double> EclipseGrid::createDVector(const std::array<int,3>& dims, st
|
||||
this->m_nactive++;
|
||||
} else {
|
||||
this->m_global_to_active.push_back(-1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EclipseGrid::resetACTNUM(const std::vector<int>& actnum) {
|
||||
if (actnum.size() != getCartesianSize()) {
|
||||
if (actnum.size() != getCartesianSize())
|
||||
throw std::runtime_error("resetACTNUM(): actnum vector size differs from logical cartesian size of grid.");
|
||||
}
|
||||
|
||||
this->resetACTNUM(actnum.data());
|
||||
}
|
||||
|
||||
|
@ -388,10 +388,7 @@ void handle_box_keyword(const DeckKeyword& deckKeyword, Box& box) {
|
||||
|
||||
|
||||
std::vector<double> extract_cell_volume(const EclipseGrid& grid) {
|
||||
std::vector<double> cell_volume(grid.getNumActive());
|
||||
for (std::size_t active_index = 0; active_index < grid.getNumActive(); active_index++)
|
||||
cell_volume[active_index] = grid.getCellVolume( grid.getGlobalIndex(active_index));
|
||||
return cell_volume;
|
||||
return grid.activeVolume();
|
||||
}
|
||||
|
||||
std::vector<double> extract_cell_depth(const EclipseGrid& grid) {
|
||||
|
Loading…
Reference in New Issue
Block a user