Split Grid Distribution Out to Helper Functions

Mostly to reduce the number of nested scopes in doLoadBalance_() and
to make the data flow a little easier to track for human readers.
While here, also use down-casts to pointer instead of references.
Doing so replaces try/catch blocks with simpler if/else blocks.

Reimplement face transmissibility calculation/extraction loop in
terms of helper functions elements() and intersections().
This commit is contained in:
Bård Skaflestad
2022-05-31 17:47:46 +02:00
parent 4e5745bf4a
commit 7537d7ab95
3 changed files with 317 additions and 179 deletions

View File

@@ -31,6 +31,15 @@
#include <opm/grid/CpGrid.hpp>
#include <functional>
#include <optional>
#include <vector>
namespace Opm {
class EclipseState;
class Schedule;
class Well;
class ParallelEclipseState;
}
namespace Opm {
@@ -113,25 +122,56 @@ protected:
* (For parallel simulation runs.)
*/
#if HAVE_MPI
void doLoadBalance_(Dune::EdgeWeightMethod edgeWeightsMethod,
bool ownersFirst, bool serialPartitioning,
bool enableDistributedWells, double zoltanImbalanceTol,
const GridView& gridv,
const Schedule& schedule,
std::vector<double>& centroids,
EclipseState& eclState,
void doLoadBalance_(const Dune::EdgeWeightMethod edgeWeightsMethod,
const bool ownersFirst,
const bool serialPartitioning,
const bool enableDistributedWells,
const double zoltanImbalanceTol,
const GridView& gridView,
const Schedule& schedule,
std::vector<double>& centroids,
EclipseState& eclState,
EclGenericVanguard::ParallelWellStruct& parallelWells,
int numJacobiBlocks);
const int numJacobiBlocks);
void distributeFieldProps_(EclipseState& eclState);
#endif
private:
std::vector<double> extractFaceTrans(const GridView& gridView) const;
void distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
const bool ownersFirst,
const bool serialPartitioning,
const bool enableDistributedWells,
const double zoltanImbalanceTol,
const bool loadBalancerSet,
const std::vector<double>& faceTrans,
const std::vector<Well>& wells,
std::vector<double>& centroids,
EclipseState& eclState,
EclGenericVanguard::ParallelWellStruct& parallelWells);
void distributeGrid(const Dune::EdgeWeightMethod edgeWeightsMethod,
const bool ownersFirst,
const bool serialPartitioning,
const bool enableDistributedWells,
const double zoltanImbalanceTol,
const bool loadBalancerSet,
const std::vector<double>& faceTrans,
const std::vector<Well>& wells,
std::vector<double>& centroids,
ParallelEclipseState* eclState,
EclGenericVanguard::ParallelWellStruct& parallelWells);
protected:
#endif // HAVE_MPI
void allocCartMapper();
void doCreateGrids_(EclipseState& eclState);
virtual void allocTrans() = 0;
virtual double getTransmissibility(unsigned I, unsigned J) = 0;
virtual double getTransmissibility(unsigned I, unsigned J) const = 0;
// removing some connection located in inactive grid cells
void doFilterConnections_(Schedule& schedule);