Skip to content

Commit

Permalink
Merge branch '2018.11.01-patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Dec 21, 2018
2 parents bd44ec8 + 92aed7b commit 329d2f7
Show file tree
Hide file tree
Showing 71 changed files with 2,102 additions and 330 deletions.
12 changes: 12 additions & 0 deletions ApplicationCode/Application/Tools/RiaStdStringTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ bool RiaStdStringTools::startsWithAlphabetic(const std::string& s)
return isalpha(s[0]) != 0;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaStdStringTools::endsWith(const std::string& mainStr, const std::string& toMatch)
{
if (mainStr.size() >= toMatch.size() && mainStr.compare(mainStr.size() - toMatch.size(), toMatch.size(), toMatch) == 0)
return true;
else
return false;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -127,3 +138,4 @@ size_t RiaStdStringTools::findCharMatchCount(const std::string& s, char c)
}
return count;
}

3 changes: 3 additions & 0 deletions ApplicationCode/Application/Tools/RiaStdStringTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class RiaStdStringTools
static bool containsAlphabetic(const std::string& s);
static bool startsWithAlphabetic(const std::string& s);

static bool endsWith(const std::string& mainStr, const std::string& toMatch);


static std::vector<std::string> splitStringBySpace(const std::string& s);

private:
Expand Down
106 changes: 105 additions & 1 deletion ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////

#include "RiaSummaryCurveAnalyzer.h"
#include "RiaStdStringTools.h"

#include "RiaSummaryCurveDefinition.h"

Expand Down Expand Up @@ -62,6 +63,44 @@ std::set<std::string> RiaSummaryCurveAnalyzer::quantities() const
return m_quantities;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<std::string> RiaSummaryCurveAnalyzer::quantityNamesWithHistory() const
{
assignCategoryToQuantities();

return m_quantitiesWithMatchingHistory;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<std::string> RiaSummaryCurveAnalyzer::quantityNamesNoHistory() const
{
assignCategoryToQuantities();

return m_quantitiesNoMatchingHistory;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaSummaryCurveAnalyzer::quantityNameForTitle() const
{
if (quantityNamesWithHistory().size() == 1 && quantityNamesNoHistory().empty())
{
return *quantityNamesWithHistory().begin();
}

if (quantityNamesNoHistory().size() == 1 && quantityNamesWithHistory().empty())
{
return *quantityNamesNoHistory().begin();
}

return std::string();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -130,7 +169,7 @@ std::vector<QString> RiaSummaryCurveAnalyzer::identifierTexts(RifEclipseSummaryA
///
//--------------------------------------------------------------------------------------------------
std::vector<RifEclipseSummaryAddress>
RiaSummaryCurveAnalyzer::addressesForCategory(const std::set<RifEclipseSummaryAddress>& addresses,
RiaSummaryCurveAnalyzer::addressesForCategory(const std::set<RifEclipseSummaryAddress>& addresses,
RifEclipseSummaryAddress::SummaryVarCategory category)
{
std::vector<RifEclipseSummaryAddress> filteredAddresses;
Expand All @@ -146,6 +185,24 @@ std::vector<RifEclipseSummaryAddress>
return filteredAddresses;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaSummaryCurveAnalyzer::correspondingHistorySummaryCurveName(const std::string& curveName)
{
static std::string historyIdentifier = "H";

if (RiaStdStringTools::endsWith(curveName, historyIdentifier))
{
std::string candidate = curveName.substr(0, curveName.size() - 1);
return candidate;
}
else
{
return curveName + historyIdentifier;
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -158,6 +215,53 @@ void RiaSummaryCurveAnalyzer::clear()
m_categories.clear();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveAnalyzer::assignCategoryToQuantities() const
{
if (!m_quantities.empty())
{
if (m_quantitiesWithMatchingHistory.empty() && m_quantitiesNoMatchingHistory.empty())
{
computeQuantityNamesWithHistory();
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveAnalyzer::computeQuantityNamesWithHistory() const
{
m_quantitiesNoMatchingHistory.clear();
m_quantitiesWithMatchingHistory.clear();

const std::string historyIdentifier("H");

for (const auto& s : m_quantities)
{
std::string correspondingHistoryCurve = correspondingHistorySummaryCurveName(s);

if (m_quantities.find(correspondingHistoryCurve) != m_quantities.end())
{
// Insert the curve name without H
if (RiaStdStringTools::endsWith(s, historyIdentifier))
{
m_quantitiesWithMatchingHistory.insert(correspondingHistoryCurve);
}
else
{
m_quantitiesWithMatchingHistory.insert(s);
}
}
else
{
m_quantitiesNoMatchingHistory.insert(s);
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class RiaSummaryCurveAnalyzer
void clear();

std::set<std::string> quantities() const;
std::set<std::string> quantityNamesWithHistory() const;
std::set<std::string> quantityNamesNoHistory() const;

std::string quantityNameForTitle() const;

std::set<std::string> wellNames() const;
std::set<std::string> wellGroupNames() const;
std::set<int> regionNumbers() const;
Expand All @@ -53,11 +58,19 @@ class RiaSummaryCurveAnalyzer
static std::vector<RifEclipseSummaryAddress> addressesForCategory(const std::set<RifEclipseSummaryAddress>& addresses,
RifEclipseSummaryAddress::SummaryVarCategory category);

static std::string correspondingHistorySummaryCurveName(const std::string& curveName);

private:
void assignCategoryToQuantities() const;
void computeQuantityNamesWithHistory() const;

void analyzeSingleAddress(const RifEclipseSummaryAddress& address);

private:
std::set<std::string> m_quantities;
mutable std::set<std::string> m_quantitiesWithMatchingHistory;
mutable std::set<std::string> m_quantitiesNoMatchingHistory;

std::set<std::string> m_wellNames;
std::set<std::string> m_wellGroupNames;
std::set<int> m_regionNumbers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked)
QString subIndexText = QString("%1").arg(sub.subIndex, 2, 10, QChar('0'));
QString lateralName = QString("%1_%2_Sub%3_Lat%4").arg(wellPath->name()).arg(fishboneName).arg(subIndexText).arg(lateralIndex);

EXP::writeWellPathGeometryToStream(*stream, wellPath, lateralName, mdStepSize);
EXP::writeWellPathGeometryToStream(*stream, &geometry, lateralName, mdStepSize, false, 0.0, false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve
std::vector<RigCompletionData> completionsForWell;
for (const auto& completion : completions)
{
if (completion.wellName() == wellPath->completions()->wellNameForExport())
if (RicWellPathExportCompletionDataFeatureImpl::isCompletionWellPathEqual(completion, wellPath))
{
completionsForWell.push_back(completion);
}
Expand Down Expand Up @@ -369,10 +369,12 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve
std::vector<RigCompletionData> completionsForWell;
for (const auto& completion : completions)
{
if (completion.wellName() == wellPath->completions()->wellNameForExport() &&
completionType == completion.completionType())
if (completionType == completion.completionType())
{
completionsForWell.push_back(completion);
if (RicWellPathExportCompletionDataFeatureImpl::isCompletionWellPathEqual(completion, wellPath))
{
completionsForWell.push_back(completion);
}
}
}

Expand Down Expand Up @@ -616,7 +618,7 @@ void RicWellPathExportCompletionDataFeatureImpl::generateWelsegsTable(RifEclipse
formatter.add(startMD);
formatter.addValueOrDefaultMarker(exportInfo.topWellBoreVolume(), RicMswExportInfo::defaultDoubleValue());
formatter.add(exportInfo.lengthAndDepthText());
formatter.add(exportInfo.pressureDropText());
formatter.add(QString("'%1'").arg(exportInfo.pressureDropText()));

formatter.rowCompleted();
}
Expand Down Expand Up @@ -998,6 +1000,7 @@ RigCompletionData

RigCompletionData resultCompletion(wellName, cellIndexIJK, firstCompletion.firstOrderingValue());
resultCompletion.setSecondOrderingValue(firstCompletion.secondOrderingValue());
resultCompletion.setSourcePdmObject(firstCompletion.sourcePdmObject());

bool anyNonDarcyFlowPresent = false;
for (const auto& c : completions)
Expand Down Expand Up @@ -1125,7 +1128,9 @@ QFilePtr RicWellPathExportCompletionDataFeatureImpl::openFileForExport(const QSt
}
}

QString filePath = exportFolder.filePath(fileName);
QString validFileName = caf::Utils::makeValidFileBasename(fileName);

QString filePath = exportFolder.filePath(validFileName);
QFilePtr exportFile(new QFile(filePath));
if (!exportFile->open(QIODevice::WriteOnly | QIODevice::Text))
{
Expand Down Expand Up @@ -2669,6 +2674,23 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCarfinForTemporaryLgrs(co
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathExportCompletionDataFeatureImpl::isCompletionWellPathEqual(const RigCompletionData& completion,
const RimWellPath* wellPath)
{
if (!wellPath) return false;

RimWellPath* parentWellPath = nullptr;
if (completion.sourcePdmObject())
{
completion.sourcePdmObject()->firstAncestorOrThisOfType(parentWellPath);
}

return (parentWellPath == wellPath);
}

//--------------------------------------------------------------------------------------------------
/// Internal function
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,5 @@ class RicWellPathExportCompletionDataFeatureImpl

static void exportCarfinForTemporaryLgrs(const RimEclipseCase* sourceCase, const QString& folder);

static bool isCompletionWellPathEqual(const RigCompletionData& completion, const RimWellPath* wellPath);
};
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ void RicExportLgrFeature::writeLgrs(QTextStream& stream, const std::vector<LgrIn
formatter.addOneBasedCellIndex(lgrInfo.mainGridEndCell.j());
formatter.addOneBasedCellIndex(lgrInfo.mainGridStartCell.k());
formatter.addOneBasedCellIndex(lgrInfo.mainGridEndCell.k());
formatter.add(lgrInfo.sizesPerMainGridCell().i());
formatter.add(lgrInfo.sizesPerMainGridCell().j());
formatter.add(lgrInfo.sizesPerMainGridCell().k());
formatter.add(lgrInfo.sizes.i());
formatter.add(lgrInfo.sizes.j());
formatter.add(lgrInfo.sizes.k());
formatter.rowCompleted();
formatter.tableCompleted("", false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,33 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream(QTextStrea
auto wellPathGeom = wellPath->wellPathGeometry();
if (!wellPathGeom) return;

bool useMdRkb = false;
double rkb = 0.0;
{
const RimModeledWellPath* modeledWellPath = dynamic_cast<const RimModeledWellPath*>(wellPath);
if (modeledWellPath)
{
useMdRkb = true;
rkb = modeledWellPath->geometryDefinition()->mdrkbAtFirstTarget();
}
}

writeWellPathGeometryToStream(stream, wellPathGeom, exportName, mdStepSize, useMdRkb, rkb, writeProjectInfo);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream(QTextStream& stream,
const RigWellPath* wellPathGeom,
const QString& exportName,
double mdStepSize,
bool useMdRkb,
double rkbOffset,
bool writeProjectInfo)
{
if (!wellPathGeom) return;

double currMd = wellPathGeom->measureDepths().front() - mdStepSize;
double endMd = wellPathGeom->measureDepths().back();

Expand All @@ -88,27 +115,16 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream(QTextStrea
stream << endl;
}

bool useMdRkb = false;
double rkb = 0.0;
{
const RimModeledWellPath* modeledWellPath = dynamic_cast<const RimModeledWellPath*>(wellPath);
if (modeledWellPath)
{
useMdRkb = true;
rkb = modeledWellPath->geometryDefinition()->mdrkbAtFirstTarget();
}
}

stream << "WELLNAME: '" << caf::Utils::makeValidFileBasename(exportName) << "'" << endl;

auto numberFormat = RifEclipseOutputTableDoubleFormatting(RIF_FLOAT, 2);
formatter.header(
{
{"X", numberFormat, RIGHT},
{"Y", numberFormat, RIGHT},
{"TVDMSL", numberFormat, RIGHT},
{useMdRkb ? "MDRKB" : "MDMSL", numberFormat, RIGHT}
});
{
{"X", numberFormat, RIGHT},
{"Y", numberFormat, RIGHT},
{"TVDMSL", numberFormat, RIGHT},
{useMdRkb ? "MDRKB" : "MDMSL", numberFormat, RIGHT}
});

while (currMd < endMd)
{
Expand All @@ -122,7 +138,7 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream(QTextStrea
formatter.add(pt.x());
formatter.add(pt.y());
formatter.add(tvd);
formatter.add(currMd + rkb);
formatter.add(currMd + rkbOffset);
formatter.rowCompleted("");
}
formatter.tableCompleted("", false);
Expand Down
Loading

0 comments on commit 329d2f7

Please sign in to comment.