Loading...
Searching...
No Matches
ParallelPAvgDynamicSourceData.hpp
/*
Copyright 2023 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PARALLEL_PAVG_DYNAMIC_SOURCE_DATA_HPP
#define PARALLEL_PAVG_DYNAMIC_SOURCE_DATA_HPP
#include <opm/input/eclipse/Schedule/Well/PAvgDynamicSourceData.hpp>
#include <opm/simulators/utils/ParallelCommunication.hpp>
#include <cstddef>
#include <functional>
#include <vector>
namespace Opm {
template<class Scalar>
class ParallelPAvgDynamicSourceData : public PAvgDynamicSourceData<Scalar>
{
public:
using GlobalToLocal = std::function<int(const std::size_t)>;
template <typename T>
using SourceDataSpan = typename
PAvgDynamicSourceData<Scalar>::template SourceDataSpan<T>;
using Evaluator = std::function<void(int, SourceDataSpan<Scalar>)>;
ParallelPAvgDynamicSourceData(const Parallel::Communication& comm,
const std::vector<std::size_t>& sourceLocations,
GlobalToLocal localCellIdx);
void setToZero();
void reconstruct(const std::vector<std::size_t>& sourceLocations,
GlobalToLocal localCellIdx);
void collectLocalSources(Evaluator eval);
void synchroniseSources();
private:
struct LocalLocation
{
std::size_t ix{};
int cell{};
};
std::reference_wrapper<const Parallel::Communication> comm_;
std::vector<LocalLocation> locations_{};
std::vector<Scalar> localSrc_{};
std::vector<typename std::vector<Scalar>::size_type> storageIndex_{};
std::vector<int> allSizes_{}; // Type int to meet API requirements.
std::vector<int> startPointers_{}; // Type int to meet API requirements.
[[nodiscard]] typename std::vector<Scalar>::size_type
storageIndex(typename std::vector<Scalar>::size_type elemIndex) const override;
void finaliseConstruction(const std::vector<std::size_t>& sourceLocations,
GlobalToLocal localCellIdx);
[[nodiscard]] SourceDataSpan<Scalar>
localSourceTerm(const std::size_t localIx);
void defineCommunication();
};
} // namespace Opm
#endif // PARALLEL_PAVG_DYNAMIC_SOURCE_DATA_HPP
Opm::ParallelPAvgDynamicSourceData::Evaluator
std::function< void(int, SourceDataSpan< Scalar >)> Evaluator
Collect source term contributions from local, on-rank, cell.
Definition ParallelPAvgDynamicSourceData.hpp:64
Opm::ParallelPAvgDynamicSourceData::SourceDataSpan
typename PAvgDynamicSourceData< Scalar >::template SourceDataSpan< T > SourceDataSpan
Fixed-width span/view of a underlying range of contiguous elements.
Definition ParallelPAvgDynamicSourceData.hpp:52
Opm::ParallelPAvgDynamicSourceData::setToZero
void setToZero()
Clear contents of local source term contributions.
Definition ParallelPAvgDynamicSourceData.cpp:48
Opm::ParallelPAvgDynamicSourceData::synchroniseSources
void synchroniseSources()
Exchange local contributions to build full, global view of all source terms.
Definition ParallelPAvgDynamicSourceData.cpp:73
Opm::ParallelPAvgDynamicSourceData::GlobalToLocal
std::function< int(const std::size_t)> GlobalToLocal
Translate globally unique, linearised Cartesian cell indices to local, on-rank, cell indices.
Definition ParallelPAvgDynamicSourceData.hpp:42
Opm::ParallelPAvgDynamicSourceData::collectLocalSources
void collectLocalSources(Evaluator eval)
Compute local, on-rank, contributions to the collection of source terms.
Definition ParallelPAvgDynamicSourceData.cpp:63
Opm::ParallelPAvgDynamicSourceData::reconstruct
void reconstruct(const std::vector< std::size_t > &sourceLocations, GlobalToLocal localCellIdx)
Reconstruct Source Data backing storage and internal mapping tables.
Definition ParallelPAvgDynamicSourceData.cpp:55
Opm::ParallelPAvgDynamicSourceData::ParallelPAvgDynamicSourceData
ParallelPAvgDynamicSourceData(const Parallel::Communication &comm, const std::vector< std::size_t > &sourceLocations, GlobalToLocal localCellIdx)
Constructor.
Definition ParallelPAvgDynamicSourceData.cpp:38
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43