#1607 Record completion type of completion data and combine after all completions are calculated

This commit is contained in:
Bjørnar Grip Fjær 2017-06-15 09:11:55 +02:00
parent 771a47a287
commit 403bf1890c
4 changed files with 46 additions and 22 deletions

View File

@ -179,7 +179,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
QTextStream stream(&exportFile);
RifEclipseDataTableFormatter formatter(stream);
std::map<IJKCellIndex, RigCompletionData> completionData;
std::map<IJKCellIndex, std::vector<RigCompletionData> > completionData;
for (auto wellPath : wellPaths)
{
@ -207,7 +207,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector
std::vector<RigCompletionData> completions;
for (auto& data : completionData)
{
completions.push_back(data.second);
completions.push_back(RigCompletionData::combine(data.second));
}
// Sort by well name / cell index
std::sort(completions.begin(), completions.end());
@ -525,18 +525,18 @@ void RicWellPathExportCompletionDataFeature::assignBranchAndSegmentNumbers(const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map<IJKCellIndex, RigCompletionData>* completionData, const std::vector<RigCompletionData>& data)
void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map<IJKCellIndex, std::vector<RigCompletionData> >* completionData, const std::vector<RigCompletionData>& data)
{
for (auto& completion : data)
{
auto it = completionData->find(completion.cellIndex());
if (it != completionData->end())
{
it->second = RigCompletionData::combine(it->second, completion);
it->second.push_back(completion);
}
else
{
completionData->insert(std::pair<IJKCellIndex, RigCompletionData>(completion.cellIndex(), completion));
completionData->insert(std::pair<IJKCellIndex, std::vector<RigCompletionData> >(completion.cellIndex(), std::vector<RigCompletionData> {completion}));
}
}
}

View File

@ -150,7 +150,7 @@ private:
static void calculateLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum);
static void assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector<WellSegmentLocation>* locations);
static void appendCompletionData(std::map<IJKCellIndex, RigCompletionData>* completionData, const std::vector<RigCompletionData>& data);
static void appendCompletionData(std::map<IJKCellIndex, std::vector<RigCompletionData> >* completionData, const std::vector<RigCompletionData>& data);
};

View File

@ -21,7 +21,7 @@
#include "RiaLogging.h"
#include <QString>
#include <cmath> // Needed for HUGE_VAL on linux
#include <cmath> // Needed for HUGE_VAL on Linux
//==================================================================================================
///
@ -59,25 +59,35 @@ RigCompletionData::RigCompletionData(const RigCompletionData& other)
//==================================================================================================
///
//==================================================================================================
RigCompletionData RigCompletionData::combine(const RigCompletionData& first, const RigCompletionData& second)
RigCompletionData RigCompletionData::combine(const std::vector<RigCompletionData>& completions)
{
RigCompletionData result(first);
CVF_ASSERT(result.m_wellName == second.m_wellName);
CVF_ASSERT(result.m_cellIndex == second.m_cellIndex);
CVF_ASSERT(!completions.empty());
if (onlyOneIsDefaulted(result.m_transmissibility, second.m_transmissibility))
auto it = completions.cbegin();
RigCompletionData result(*it);
++it;
for (; it != completions.cend(); ++it)
{
RiaLogging::error("Transmissibility defaulted in one but not both, will produce erroneous result");
}
else
{
result.m_transmissibility += second.m_transmissibility;
}
if (it->completionType() != result.completionType())
{
RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.i).arg(result.m_cellIndex.j).arg(result.m_cellIndex.k));
continue;
}
if (onlyOneIsDefaulted(result.m_transmissibility, it->m_transmissibility))
{
RiaLogging::error("Transmissibility defaulted in one but not both, will produce erroneous result");
}
else
{
result.m_transmissibility += it->m_transmissibility;
}
result.m_metadata.reserve(result.m_metadata.size() + second.m_metadata.size());
result.m_metadata.insert(result.m_metadata.end(), second.m_metadata.begin(), second.m_metadata.end());
result.m_metadata.reserve(result.m_metadata.size() + it->m_metadata.size());
result.m_metadata.insert(result.m_metadata.end(), it->m_metadata.begin(), it->m_metadata.end());
result.m_count += second.m_count;
result.m_count += it->m_count;
}
return result;
}
@ -112,6 +122,7 @@ RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other)
//==================================================================================================
void RigCompletionData::setFromFracture(double transmissibility, double skinFactor)
{
m_completionType = FRACTURE;
m_transmissibility = transmissibility;
m_skinFactor = skinFactor;
}
@ -121,6 +132,7 @@ void RigCompletionData::setFromFracture(double transmissibility, double skinFact
//==================================================================================================
void RigCompletionData::setFromFishbone(double diameter, CellDirection direction)
{
m_completionType = FISHBONES;
m_diameter = diameter;
m_direction = direction;
}
@ -130,6 +142,7 @@ void RigCompletionData::setFromFishbone(double diameter, CellDirection direction
//==================================================================================================
void RigCompletionData::setFromFishbone(double transmissibility, double skinFactor)
{
m_completionType = FISHBONES;
m_transmissibility = transmissibility;
m_skinFactor = skinFactor;
}
@ -139,6 +152,7 @@ void RigCompletionData::setFromFishbone(double transmissibility, double skinFact
//==================================================================================================
void RigCompletionData::setFromPerforation(double diameter, CellDirection direction)
{
m_completionType = PERFORATION;
m_diameter = diameter;
m_direction = direction;
}
@ -204,4 +218,5 @@ void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData&
target.m_dFactor = from.m_dFactor;
target.m_direction = from.m_direction;
target.m_count = from.m_count;
target.m_completionType = from.m_completionType;
}

View File

@ -91,11 +91,17 @@ struct RigCompletionMetaData {
class RigCompletionData : public cvf::Object
{
public:
enum CompletionType {
FISHBONES,
FRACTURE,
PERFORATION,
};
RigCompletionData(const QString wellName, const IJKCellIndex& cellIndex);
~RigCompletionData();
RigCompletionData(const RigCompletionData& other);
static RigCompletionData combine(const RigCompletionData& first, const RigCompletionData& second);
static RigCompletionData combine(const std::vector<RigCompletionData>& completions);
bool operator<(const RigCompletionData& other) const;
RigCompletionData& operator=(const RigCompletionData& other);
@ -119,6 +125,7 @@ public:
double dFactor() const { return m_dFactor; }
CellDirection direction() const { return m_direction; }
size_t count() const { return m_count; }
CompletionType completionType() const { return m_completionType; }
private:
std::vector<RigCompletionMetaData> m_metadata;
@ -136,6 +143,8 @@ private:
// Number of parts that have contributed to this completion
size_t m_count;
CompletionType m_completionType;
private:
static bool onlyOneIsDefaulted(double first, double second);
static void copy(RigCompletionData& target, const RigCompletionData& from);