21#ifndef OPM_WELLCONNECTIONAUXILIARYMODULE_HEADER_INCLUDED
22#define OPM_WELLCONNECTIONAUXILIARYMODULE_HEADER_INCLUDED
24#include <opm/models/discretization/common/baseauxiliarymodule.hh>
26#include <opm/grid/CpGrid.hpp>
28#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
32template<
class TypeTag>
34 :
public BaseAuxiliaryModule<TypeTag>
36 using GlobalEqVector = GetPropType<TypeTag, Properties::GlobalEqVector>;
37 using SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>;
41 using NeighborSet = typename
42 ::Opm::BaseAuxiliaryModule<TypeTag>::NeighborSet;
45 const Dune::CpGrid& grid)
48 const auto& globalCell = grid.globalCell();
49 const auto& cartesianSize = grid.logicalCartesianSize();
51 auto size = cartesianSize[0]*cartesianSize[1]*cartesianSize[2];
53 std::vector<int> cartesianToCompressed(size, -1);
54 auto begin = globalCell.begin();
56 for (
auto cell = begin, end= globalCell.end(); cell != end; ++cell )
58 cartesianToCompressed[ *cell ] = cell - begin;
61 const auto& schedule_wells = schedule.getWellsatEnd();
62 wells_.reserve(schedule_wells.size());
65 for (
const auto& well : schedule_wells )
67 std::vector<int> compressed_well_perforations;
69 const auto& completionSet = well.getConnections();
70 compressed_well_perforations.reserve(completionSet.size());
72 for (
size_t c=0; c < completionSet.size(); c++ )
74 const auto& completion = completionSet.get(c);
75 int i = completion.getI();
76 int j = completion.getJ();
77 int k = completion.getK();
78 int cart_grid_idx = i + cartesianSize[0]*(j + cartesianSize[1]*k);
79 int compressed_idx = cartesianToCompressed[cart_grid_idx];
81 if ( compressed_idx >= 0 )
83 compressed_well_perforations.push_back(compressed_idx);
87 if ( ! compressed_well_perforations.empty() )
89 std::sort(compressed_well_perforations.begin(),
90 compressed_well_perforations.end());
92 wells_.push_back(compressed_well_perforations);
97 unsigned numDofs()
const
103 void addNeighbors(std::vector<NeighborSet>& neighbors)
const
105 for(
const auto& well_perforations : wells_)
107 for(
const auto& perforation : well_perforations)
108 neighbors[perforation].insert(well_perforations.begin(),
109 well_perforations.end());
116 void linearize(SparseMatrixAdapter& , GlobalEqVector&)
123 std::vector<std::vector<int> > wells_;
Definition: WellConnectionAuxiliaryModule.hpp:35
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27