Merge pull request #504 from akva2/restart_fixups

Fixups after restart merge
This commit is contained in:
Arne Morten Kvarving
2018-09-25 10:58:21 +02:00
committed by GitHub
5 changed files with 18 additions and 145 deletions

View File

@@ -42,29 +42,8 @@
namespace {
int nigrpz(const std::vector<int>& inteHead)
{
// INTEHEAD(36) = NIGRPZ
return inteHead[36];
}
int nsgrpz(const std::vector<int>& inteHead)
{
return inteHead[37];
}
int nxgrpz(const std::vector<int>& inteHead)
{
return inteHead[38];
}
int nzgrpz(const std::vector<int>& inteHead)
{
return inteHead[39];
}
// maximum number of groups
int ngmaxz(const std::vector<int>& inteHead)
std::size_t ngmaxz(const std::vector<int>& inteHead)
{
return inteHead[20];
}
@@ -75,37 +54,6 @@ namespace {
return inteHead[19];
}
std::string trim(const std::string& s)
{
const auto b = s.find_first_not_of(" \t");
if (b == std::string::npos) {
// No blanks. Return unchanged.
return s;
}
auto e = s.find_last_not_of(" \t");
if (e == std::string::npos) {
// No trailing blanks. Return [b, end)
return s.substr(b, std::string::npos);
}
// Remove leading/trailing blanks.
return s.substr(b, e - b + 1);
}
std::vector<std::string>
groupNames(const std::vector<const Opm::Group*>& groups)
{
auto gnms = std::vector<std::string>{};
gnms.reserve(groups.size());
for (const auto* group : groups) {
gnms.push_back(trim(group->name()));
}
return gnms;
}
const int groupType(const Opm::Schedule& sched,
const Opm::Group& group,
const std::size_t simStep)
@@ -171,18 +119,6 @@ namespace {
return groupIndexMap;
}
const std::map <std::string, size_t> currentWellIndex(const Opm::Schedule& sched, const size_t simStep)
{
const auto& wells = sched.getWells(simStep);
// make group index for current report step
std::map <std::string, size_t> wellIndexMap;
for (const auto* well : wells) {
std::pair<std::string, size_t> wellPair = std::make_pair(well->name(), well->seqIndex());
wellIndexMap.insert(wellPair);
}
return wellIndexMap;
}
const int currentGroupLevel(const Opm::Schedule& sched, const Opm::Group& group, const size_t simStep)
{
int level = 0;
@@ -203,7 +139,9 @@ namespace {
return level;
}
else {
throw std::invalid_argument("actual group has not been defined at report time: " + simStep );
std::stringstream str;
str << "actual group has not been defined at report time: " << simStep;
throw std::invalid_argument(str.str());
}
}
return level;
@@ -521,9 +459,7 @@ currentGrpTreeNameSeqIndMap(const Opm::Schedule& sched,
const std::map<size_t, const Opm::Group*>& IGMap)
{
const auto& grpTreeNSIMap = (sched.getGroupTree(simStep)).nameSeqIndMap();
const auto& grpTreeSINMap = (sched.getGroupTree(simStep)).seqIndNameMap();
// make group index for current report step
size_t index = 0;
for (auto itr = IGMap.begin(); itr != IGMap.end(); itr++) {
auto name = (itr->second)->name();
auto srchGN = grpTreeNSIMap.find(name);
@@ -581,11 +517,7 @@ captureDeclaredGroupData(const Opm::Schedule& sched,
const auto indexGroupMap = currentGroupMapIndexGroup(sched, simStep, inteHead);
const auto nameIndexMap = currentGroupMapNameIndex(sched, simStep, inteHead);
std::vector<const Opm::Group*> curGroups;
curGroups.resize(ngmaxz(inteHead));
//
//initialize curgroups
for (auto* cg : curGroups) cg = nullptr;
std::vector<const Opm::Group*> curGroups(ngmaxz(inteHead), nullptr);
auto it = indexGroupMap.begin();
while (it != indexGroupMap.end())

View File

@@ -46,12 +46,6 @@
namespace {
std::size_t nummsw(const std::vector<int>& inteHead)
{
// inteHead(174) = NSEGWL
return inteHead[174];
}
std::size_t nswlmx(const std::vector<int>& inteHead)
{
// inteHead(175) = NSWLMX
@@ -83,7 +77,7 @@ namespace {
int firstSeg = -1;
int lastSeg = -1;
int outletS = 0;
for (std::size_t segNo = 1; segNo <= segSet.size(); segNo++) {
for (int segNo = 1; segNo <= segSet.size(); segNo++) {
auto segInd = segSet.segmentNumberToIndex(segNo);
auto i_branch = segSet[segInd].branchNumber();
auto i_outS = segSet[segInd].outletSegment();
@@ -108,7 +102,7 @@ namespace {
std::vector<std::size_t> SegmentSetBranches(const Opm::WellSegments& segSet) {
std::vector<std::size_t> branches;
for (std::size_t segNo = 1; segNo <= segSet.size(); segNo++) {
for (int segNo = 1; segNo <= segSet.size(); segNo++) {
auto segInd = segSet.segmentNumberToIndex(segNo);
auto i_branch = segSet[segInd].branchNumber();
if (std::find(branches.begin(), branches.end(), i_branch) == branches.end()) {
@@ -120,7 +114,7 @@ namespace {
int firstSegmentInBranch(const Opm::WellSegments& segSet, const int branch) {
int firstSegNo = 0;
std::size_t segNo = 0;
int segNo = 0;
while ((segNo <= segSet.size()) && (firstSegNo == 0)) {
segNo+=1;
auto segInd = segSet.segmentNumberToIndex(segNo);
@@ -159,7 +153,7 @@ namespace {
if (noConnectionsSegment(compSet, segSet, segIndex) > 0) {
// add up the number of connections for å segments with lower segment index than current segment
auto segNumber = segSet[segIndex].segmentNumber();
for (std::size_t i_seg = 1; i_seg <= segNumber; i_seg++) {
for (int i_seg = 1; i_seg <= segNumber; i_seg++) {
auto ind = segSet.segmentNumberToIndex(i_seg);
int addCon = (ind == static_cast<int>(segIndex)) ? 1 : noConnectionsSegment(compSet, segSet, ind);
sumConn += addCon;
@@ -173,7 +167,7 @@ namespace {
inflowSegmentsIndex(const Opm::WellSegments& segSet, std::size_t segIndex) {
auto segNumber = segSet[segIndex].segmentNumber();
std::vector<std::size_t> inFlowSegNum;
for (std::size_t ind = 0; ind < segSet.size(); ind++) {
for (int ind = 0; ind < segSet.size(); ind++) {
auto i_outletSeg = segSet[ind].outletSegment();
if (segNumber == i_outletSeg) {
inFlowSegNum.push_back(ind);
@@ -186,7 +180,7 @@ namespace {
auto segNumber = segSet[segIndex].segmentNumber();
auto branch = segSet[segIndex].branchNumber();
int noIFBr = 0;
for (std::size_t ind = 0; ind < segSet.size(); ind++) {
for (int ind = 0; ind < segSet.size(); ind++) {
auto o_segNum = segSet[ind].outletSegment();
auto i_branch = segSet[ind].branchNumber();
if ((segNumber == o_segNum) && (branch != i_branch)){
@@ -219,8 +213,7 @@ namespace {
std::vector<std::size_t> segIndCB;
// Store "heel" segment since that will not always be at the end of the list
segIndCB.push_back(segIndex);
std::size_t sInd = segIndex;
std::size_t newSInd = segIndex;
int newSInd = segIndex;
auto origBranchNo = segSet[segIndex].branchNumber();
bool endOrigBranch = true;
//std::cout << "SegmentOrder-segIndex:" << segIndex << " origBranchno: " << origBranchNo << std::endl;
@@ -294,7 +287,7 @@ namespace {
auto branch = segSet[segIndex].branchNumber();
auto segNumber = segSet[segIndex].segmentNumber();
int inFlowSegNum = 0;
for (std::size_t ind = 0; ind < segSet.size(); ind++) {
for (int ind = 0; ind < segSet.size(); ind++) {
auto i_segNum = segSet[ind].segmentNumber();
auto i_branch = segSet[ind].branchNumber();
auto i_outFlowSeg = segSet[ind].outletSegment();
@@ -363,7 +356,7 @@ namespace {
auto noElmSeg = nisegz(inteHead);
std::size_t segmentInd = 0;
auto orderedSegmentNo = segmentOrder(welSegSet, segmentInd);
for (std::size_t ind_seg = 1; ind_seg <= welSegSet.size(); ind_seg++) {
for (int ind_seg = 1; ind_seg <= welSegSet.size(); ind_seg++) {
auto ind = welSegSet.segmentNumberToIndex(ind_seg);
auto iS = (ind_seg-1)*noElmSeg;
iSeg[iS + 0] = orderedSegmentNo[ind];
@@ -416,8 +409,6 @@ namespace {
auto completionSet = well.getCompletions(rptStep);
auto noElmSeg = nrsegz(inteHead);
//treat the top segment individually
int ind_seg = 1;
auto ind = welSegSet.segmentNumberToIndex(ind_seg);
rSeg[0] = units.from_si(M::length, welSegSet.lengthTopSegment());
rSeg[1] = units.from_si(M::length, welSegSet.depthTopSegment());
rSeg[5] = units.from_si(M::volume, welSegSet.volumeTopSegment());
@@ -440,7 +431,7 @@ namespace {
rSeg[110] = 1.0;
//Treat subsequent segments
for (std::size_t ind_seg = 2; ind_seg <= welSegSet.size(); ind_seg++) {
for (int ind_seg = 2; ind_seg <= welSegSet.size(); ind_seg++) {
// set the elements of the rSeg array
auto ind = welSegSet.segmentNumberToIndex(ind_seg);
auto outSeg = welSegSet[ind].outletSegment();

View File

@@ -75,19 +75,6 @@ namespace {
return s.substr(b, e - b + 1);
}
std::vector<std::string>
groupNames(const std::vector<const Opm::Group*>& groups)
{
auto gnms = std::vector<std::string>{};
gnms.reserve(groups.size());
for (const auto* group : groups) {
gnms.push_back(trim(group->name()));
}
return gnms;
}
template <typename WellOp>
void wellLoop(const std::vector<const Opm::Well*>& wells,
WellOp&& wellOp)

View File

@@ -145,7 +145,6 @@ namespace {
const ::Opm::Schedule& sched,
const std::size_t lookup_step)
{
const auto& wd = rspec.wellDimensions();
const auto& wsd = rspec.wellSegmentDimensions();
const auto& sched_wells = sched.getWells(lookup_step);
@@ -202,7 +201,7 @@ namespace {
const auto ngroups = sched.numGroups(step)-1;
return {
ngroups
int(ngroups)
};
}
} // Anonymous

View File

@@ -1064,12 +1064,6 @@ bool ecl_kw_fread_realloc_data(::Opm::RestartIO::ecl_kw_type *ecl_kw, fortio_typ
}
static void ecl_kw_endian_convert_data(::Opm::RestartIO::ecl_kw_type *ecl_kw) {
if (::Opm::RestartIO::ecl_type_is_numeric(ecl_kw->data_type) || ::Opm::RestartIO::ecl_type_is_bool(ecl_kw->data_type))
::Opm::RestartIO::util_endian_flip_vector(ecl_kw->data , ::Opm::RestartIO::ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->size);
}
char * util_alloc_sprintf(const char * fmt , ...) {
char * s;
va_list ap;
@@ -1276,7 +1270,6 @@ int ecl_type_get_sizeof_iotype(const ::Opm::RestartIO::ecl_data_type ecl_type) {
static void ecl_kw_load_from_input_buffer(::Opm::RestartIO::ecl_kw_type * ecl_kw, char * buffer) {
size_t sizeof_iotype = ::Opm::RestartIO::ecl_type_get_sizeof_iotype(ecl_kw->data_type);
size_t sizeof_ctype = ::Opm::RestartIO::ecl_type_get_sizeof_ctype(ecl_kw->data_type);
size_t buffer_size = ecl_kw->size * sizeof_iotype;
if (ECL_ENDIAN_FLIP) {
if (::Opm::RestartIO::ecl_type_is_numeric(ecl_kw->data_type) || ::Opm::RestartIO::ecl_type_is_bool(ecl_kw->data_type))
@@ -2561,7 +2554,7 @@ static int vector_append_node(::Opm::RestartIO::vector_type * vector , ::Opm::Re
*/
static void vector_iset__(::Opm::RestartIO::vector_type * vector , int index , ::Opm::RestartIO::node_data_type * node) {
if (index > vector->size)
if (vector->size <= index)
::Opm::RestartIO::vector_grow_NULL( vector , index );
if (index == vector->size)
@@ -2682,35 +2675,6 @@ static time_t timegm(struct tm * a_tm)
return utc;
}
static time_t _mkgmtime(const struct tm *tm)
{
// Month-to-day offset for non-leap-years.
static const int month_day[12] =
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
// Most of the calculation is easy; leap years are the main difficulty.
int month = tm->tm_mon % 12;
int year = tm->tm_year + tm->tm_mon / 12;
if (month < 0) { // Negative values % 12 are still negative.
month += 12;
--year;
}
// This is the number of Februaries since 1900.
const int year_for_leap = (month > 1) ? year + 1 : year;
time_t rt = tm->tm_sec // Seconds
+ 60 * (tm->tm_min // Minute = 60 seconds
+ 60 * (tm->tm_hour // Hour = 60 minutes
+ 24 * (month_day[month] + tm->tm_mday - 1 // Day = 24 hours
+ 365 * (year - 70) // Year = 365 days
+ (year_for_leap - 69) / 4 // Every 4 years is leap...
- (year_for_leap - 1) / 100 // Except centuries...
+ (year_for_leap + 299) / 400))); // Except 400s.
return rt < 0 ? -1 : rt;
}
static bool util_make_datetime_utc__(int sec, int min, int hour , int mday , int month , int year, bool force_set, time_t * t) {
bool valid = false;
struct tm ts;
@@ -4647,7 +4611,7 @@ static size_t get_ecl_string_length(const char * type_name) {
return ECL_KW_READ_FAIL;
memcpy( header , &buffer[0] , ECL_STRING8_LENGTH);
size = * ( (int *) &buffer[ECL_STRING8_LENGTH] );
memcpy(&size, buffer+ECL_STRING8_LENGTH, sizeof(size));
memcpy( ecl_type_str , &buffer[ECL_STRING8_LENGTH + sizeof(size)] , ECL_TYPE_LENGTH);
if(!fortio_complete_read(fortio , record_size))