Loading...
Searching...
No Matches
PAvgCalculatorCollection.hpp
/*
Copyright 2020, 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 PAVE_CALC_COLLECTIONHPP
#define PAVE_CALC_COLLECTIONHPP
#include <cstddef>
#include <functional>
#include <memory>
#include <unordered_map>
#include <vector>
namespace Opm {
template<class Scalar> class PAvgCalculator;
} // namespace Opm
namespace Opm {
template<class Scalar>
class PAvgCalculatorCollection
{
public:
using CalculatorPtr = std::unique_ptr<PAvgCalculator<Scalar>>;
using ActivePredicate = std::function<
std::vector<bool>(const std::vector<std::size_t>&)>;
PAvgCalculatorCollection() = default;
~PAvgCalculatorCollection() = default;
PAvgCalculatorCollection(const PAvgCalculatorCollection&) = delete;
PAvgCalculatorCollection(PAvgCalculatorCollection&&) = default;
PAvgCalculatorCollection& operator=(const PAvgCalculatorCollection&) = delete;
PAvgCalculatorCollection& operator=(PAvgCalculatorCollection&&) = default;
std::size_t setCalculator(const std::size_t wellID, CalculatorPtr calculator);
void pruneInactiveWBPCells(ActivePredicate isActive);
PAvgCalculator<Scalar>& operator[](const std::size_t i);
const PAvgCalculator<Scalar>& operator[](const std::size_t i) const;
bool empty() const;
std::size_t numCalculators() const;
std::vector<std::size_t> allWBPCells() const;
private:
using CalcIndex = typename std::vector<CalculatorPtr>::size_type;
std::unordered_map<std::size_t, CalcIndex> index_{};
std::vector<CalculatorPtr> calculators_{};
};
} // namespace Opm
#endif // PAVE_CALC_COLLECTIONHPP
Opm::PAvgCalculatorCollection
Collection of WBPn calculation objects, one for each well.
Definition PAvgCalculatorCollection.hpp:38
Opm::PAvgCalculatorCollection::PAvgCalculatorCollection
PAvgCalculatorCollection()=default
Default constructor.
Opm::PAvgCalculatorCollection::numCalculators
std::size_t numCalculators() const
Number of WBPn calculation objects owned by this collection.
Definition PAvgCalculatorCollection.cpp:107
Opm::PAvgCalculatorCollection::operator=
PAvgCalculatorCollection & operator=(PAvgCalculatorCollection &&)=default
Move-assignment operator.
Opm::PAvgCalculatorCollection::PAvgCalculatorCollection
PAvgCalculatorCollection(const PAvgCalculatorCollection &)=delete
Copy constructor.
Opm::PAvgCalculatorCollection::allWBPCells
std::vector< std::size_t > allWBPCells() const
Union of all distinct/unique cells/source locations contributing to this complete collection of WBPn ...
Definition PAvgCalculatorCollection.cpp:114
Opm::PAvgCalculatorCollection::ActivePredicate
std::function< std::vector< bool >(const std::vector< std::size_t > &)> ActivePredicate
Predicate for whether or not a particular source location is active.
Definition PAvgCalculatorCollection.hpp:57
Opm::PAvgCalculatorCollection::operator[]
PAvgCalculator< Scalar > & operator[](const std::size_t i)
Access mutable WBPn calculation object.
Definition PAvgCalculatorCollection.cpp:88
Opm::PAvgCalculatorCollection::CalculatorPtr
std::unique_ptr< PAvgCalculator< Scalar > > CalculatorPtr
Wrapper for a WBPn calclation object.
Definition PAvgCalculatorCollection.hpp:44
Opm::PAvgCalculatorCollection::pruneInactiveWBPCells
void pruneInactiveWBPCells(ActivePredicate isActive)
Discard inactive source locations from all WBPn calculation objects.
Definition PAvgCalculatorCollection.cpp:61
Opm::PAvgCalculatorCollection::~PAvgCalculatorCollection
~PAvgCalculatorCollection()=default
Destructor.
Opm::PAvgCalculatorCollection::PAvgCalculatorCollection
PAvgCalculatorCollection(PAvgCalculatorCollection &&)=default
Move constructor.
Opm::PAvgCalculatorCollection::setCalculator
std::size_t setCalculator(const std::size_t wellID, CalculatorPtr calculator)
Assign/register a WBPn calculation object for a single well.
Definition PAvgCalculatorCollection.cpp:40
Opm::PAvgCalculatorCollection::empty
bool empty() const
Whether or not this collection has any WBPn calculation objects.
Definition PAvgCalculatorCollection.cpp:101
Opm::PAvgCalculatorCollection::operator=
PAvgCalculatorCollection & operator=(const PAvgCalculatorCollection &)=delete
Assignment operator.
Opm::PAvgCalculator
Facility for deriving well-level pressure values from selected block-averaging procedures.
Definition PAvgCalculator.hpp:74
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30