mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add support for region = 0 i.e. field
This commit is contained in:
parent
f9832d8830
commit
f497fa0fd7
@ -140,6 +140,27 @@ namespace Opm {
|
|||||||
typename Select::RegionIDParameter
|
typename Select::RegionIDParameter
|
||||||
<RegionId, std::is_integral<RegionId>::value>::type;
|
<RegionId, std::is_integral<RegionId>::value>::type;
|
||||||
|
|
||||||
|
using ID =
|
||||||
|
typename std::remove_reference<RegionId>::type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aggregate per-region attributes along with region's
|
||||||
|
* representative cell.
|
||||||
|
*/
|
||||||
|
struct Value {
|
||||||
|
Value(const Attributes& attr)
|
||||||
|
: attr_(attr)
|
||||||
|
, cell_(-1)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Attributes attr_;
|
||||||
|
int cell_;
|
||||||
|
};
|
||||||
|
|
||||||
|
using AttributeMap =
|
||||||
|
std::unordered_map<ID, std::unique_ptr<Value>>;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -213,6 +234,17 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request read-only access to region's attributes.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \return Read-only access to all regions attributes.
|
||||||
|
*/
|
||||||
|
const AttributeMap& attributes() const
|
||||||
|
{
|
||||||
|
return attr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request read-only access to region's attributes.
|
* Request read-only access to region's attributes.
|
||||||
@ -241,25 +273,6 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
|
||||||
* Aggregate per-region attributes along with region's
|
|
||||||
* representative cell.
|
|
||||||
*/
|
|
||||||
struct Value {
|
|
||||||
Value(const Attributes& attr)
|
|
||||||
: attr_(attr)
|
|
||||||
, cell_(-1)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Attributes attr_;
|
|
||||||
int cell_;
|
|
||||||
};
|
|
||||||
|
|
||||||
using ID =
|
|
||||||
typename std::remove_reference<RegionId>::type;
|
|
||||||
|
|
||||||
using AttributeMap =
|
|
||||||
std::unordered_map<ID, std::unique_ptr<Value>>;
|
|
||||||
|
|
||||||
AttributeMap attr_;
|
AttributeMap attr_;
|
||||||
|
|
||||||
|
@ -218,6 +218,19 @@ namespace Opm {
|
|||||||
double
|
double
|
||||||
pressure(const RegionId r) const
|
pressure(const RegionId r) const
|
||||||
{
|
{
|
||||||
|
if (r == 0 ) // region 0 is the whole field
|
||||||
|
{
|
||||||
|
double pressure = 0.0;
|
||||||
|
int num_active_regions = 0;
|
||||||
|
for (const auto& attr : attr_.attributes()) {
|
||||||
|
const auto& value = *attr.second;
|
||||||
|
const auto& ra = value.attr_;
|
||||||
|
pressure += ra.pressure;
|
||||||
|
num_active_regions ++;
|
||||||
|
}
|
||||||
|
return pressure / num_active_regions;
|
||||||
|
}
|
||||||
|
|
||||||
const auto& ra = attr_.attributes(r);
|
const auto& ra = attr_.attributes(r);
|
||||||
return ra.pressure;
|
return ra.pressure;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user