clang-format : Apply clang-fomat on ApplicationCode

This commit is contained in:
Magne Sjaastad
2019-12-19 11:11:33 +01:00
parent 260ff04b19
commit 4ccbd274b8
12 changed files with 437 additions and 390 deletions

View File

@@ -19,8 +19,8 @@
#include "RigTofWellDistributionCalculator.h"
#include "RiaDefines.h"
#include "RiaPorosityModel.h"
#include "RiaLogging.h"
#include "RiaPorosityModel.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
@@ -35,8 +35,6 @@
#include <map>
//==================================================================================================
//
//
@@ -46,57 +44,77 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigTofWellDistributionCalculator::RigTofWellDistributionCalculator(RimEclipseResultCase* caseToApply, QString targetWellname, size_t timeStepIndex, RiaDefines::PhaseType phase)
RigTofWellDistributionCalculator::RigTofWellDistributionCalculator( RimEclipseResultCase* caseToApply,
QString targetWellname,
size_t timeStepIndex,
RiaDefines::PhaseType phase )
{
CVF_ASSERT(caseToApply);
CVF_ASSERT( caseToApply );
RigEclipseCaseData* eclipseCaseData = caseToApply->eclipseCaseData();
CVF_ASSERT(eclipseCaseData);
CVF_ASSERT( eclipseCaseData );
RimFlowDiagSolution* flowDiagSolution = caseToApply->defaultFlowDiagSolution();
CVF_ASSERT(flowDiagSolution);
CVF_ASSERT( flowDiagSolution );
RigFlowDiagResults* flowDiagResults = flowDiagSolution->flowDiagResults();
CVF_ASSERT(flowDiagResults);
CVF_ASSERT( flowDiagResults );
const std::vector<double>* porvResults = eclipseCaseData->resultValues(RiaDefines::MATRIX_MODEL, RiaDefines::STATIC_NATIVE, "PORV", 0);
if (!porvResults)
const std::vector<double>* porvResults = eclipseCaseData->resultValues( RiaDefines::MATRIX_MODEL,
RiaDefines::STATIC_NATIVE,
"PORV",
0 );
if ( !porvResults )
{
return;
}
QString phaseResultName;
if (phase == RiaDefines::WATER_PHASE) phaseResultName = "SWAT";
else if (phase == RiaDefines::OIL_PHASE) phaseResultName = "SOIL";
else if (phase == RiaDefines::GAS_PHASE) phaseResultName = "SGAS";
const std::vector<double>* phaseResults = eclipseCaseData->resultValues(RiaDefines::MATRIX_MODEL, RiaDefines::DYNAMIC_NATIVE, phaseResultName, timeStepIndex);
if (!phaseResults)
if ( phase == RiaDefines::WATER_PHASE )
phaseResultName = "SWAT";
else if ( phase == RiaDefines::OIL_PHASE )
phaseResultName = "SOIL";
else if ( phase == RiaDefines::GAS_PHASE )
phaseResultName = "SGAS";
const std::vector<double>* phaseResults = eclipseCaseData->resultValues( RiaDefines::MATRIX_MODEL,
RiaDefines::DYNAMIC_NATIVE,
phaseResultName,
timeStepIndex );
if ( !phaseResults )
{
return;
}
const RigFlowDiagResultAddress resultAddrTof("TOF", RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL, targetWellname.toStdString());
const RigFlowDiagResultAddress resultAddrFraction("Fraction", RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL, targetWellname.toStdString());
const std::vector<double>* tofData = flowDiagResults->resultValues(resultAddrTof, timeStepIndex);
const std::vector<double>* targetWellFractionData = flowDiagResults->resultValues(resultAddrFraction, timeStepIndex);
if (!tofData || !targetWellFractionData)
const RigFlowDiagResultAddress resultAddrTof( "TOF",
RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL,
targetWellname.toStdString() );
const RigFlowDiagResultAddress resultAddrFraction( "Fraction",
RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL,
targetWellname.toStdString() );
const std::vector<double>* tofData = flowDiagResults->resultValues( resultAddrTof, timeStepIndex );
const std::vector<double>* targetWellFractionData = flowDiagResults->resultValues( resultAddrFraction, timeStepIndex );
if ( !tofData || !targetWellFractionData )
{
return;
}
const std::map<double, std::vector<size_t>> tofToCellIndicesMap = buildSortedTofToCellIndicesMap( *tofData );
const std::map<double, std::vector<size_t>> tofToCellIndicesMap = buildSortedTofToCellIndicesMap(*tofData);
const std::vector<QString> candidateContributingWellNames = findCandidateContributingWellNames( *flowDiagSolution,
targetWellname,
timeStepIndex );
const size_t numContribWells = candidateContributingWellNames.size();
const std::vector<QString> candidateContributingWellNames = findCandidateContributingWellNames(*flowDiagSolution, targetWellname, timeStepIndex);
const size_t numContribWells = candidateContributingWellNames.size();
for (size_t iContribWell = 0; iContribWell < numContribWells; iContribWell++)
for ( size_t iContribWell = 0; iContribWell < numContribWells; iContribWell++ )
{
const QString contribWellName = candidateContributingWellNames[iContribWell];
const RigFlowDiagResultAddress resultAddrContribWellFraction("Fraction", RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL, contribWellName.toStdString());
const std::vector<double>* contribWellFractionData = flowDiagResults->resultValues(resultAddrContribWellFraction, timeStepIndex);
if (!contribWellFractionData)
const RigFlowDiagResultAddress resultAddrContribWellFraction( "Fraction",
RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL,
contribWellName.toStdString() );
const std::vector<double>* contribWellFractionData = flowDiagResults->resultValues( resultAddrContribWellFraction,
timeStepIndex );
if ( !contribWellFractionData )
{
continue;
}
@@ -106,74 +124,74 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator(RimEclipseRes
ContribWellEntry contribWellEntry;
contribWellEntry.name = contribWellName;
for (auto mapElement : tofToCellIndicesMap)
for ( auto mapElement : tofToCellIndicesMap )
{
const double tofValue = mapElement.first;
const double tofValue = mapElement.first;
const std::vector<size_t>& cellIndicesArr = mapElement.second;
for (size_t cellIndex : cellIndicesArr)
for ( size_t cellIndex : cellIndicesArr )
{
const double porv = porvResults->at(cellIndex);
const double targetWellFractionVal = targetWellFractionData->at(cellIndex);
const double contribWellFractionVal = contribWellFractionData->at(cellIndex);
if (contribWellFractionVal == HUGE_VAL)
const double porv = porvResults->at( cellIndex );
const double targetWellFractionVal = targetWellFractionData->at( cellIndex );
const double contribWellFractionVal = contribWellFractionData->at( cellIndex );
if ( contribWellFractionVal == HUGE_VAL )
{
continue;
}
const double volAllPhasesThisCell = porv * targetWellFractionVal*contribWellFractionVal;
accumulatedVolForSpecifiedPhase += phaseResults->at(cellIndex)*volAllPhasesThisCell;
const double volAllPhasesThisCell = porv * targetWellFractionVal * contribWellFractionVal;
accumulatedVolForSpecifiedPhase += phaseResults->at( cellIndex ) * volAllPhasesThisCell;
}
contribWellEntry.accumulatedVolAlongTof.push_back(accumulatedVolForSpecifiedPhase);
contribWellEntry.accumulatedVolAlongTof.push_back( accumulatedVolForSpecifiedPhase );
}
if (accumulatedVolForSpecifiedPhase > 0)
if ( accumulatedVolForSpecifiedPhase > 0 )
{
m_contributingWells.push_back(contribWellEntry);
m_contributingWells.push_back( contribWellEntry );
}
}
for (auto mapElement : tofToCellIndicesMap)
for ( auto mapElement : tofToCellIndicesMap )
{
const double tofValue = mapElement.first;
m_tofInIncreasingOrder.push_back(tofValue);
m_tofInIncreasingOrder.push_back( tofValue );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigTofWellDistributionCalculator::groupSmallContributions(double smallContribThreshold)
void RigTofWellDistributionCalculator::groupSmallContributions( double smallContribThreshold )
{
if (m_tofInIncreasingOrder.size() == 0)
if ( m_tofInIncreasingOrder.size() == 0 )
{
return;
}
double totalVolAtLastTof = 0;
for (const ContribWellEntry& entry : m_contributingWells)
for ( const ContribWellEntry& entry : m_contributingWells )
{
totalVolAtLastTof += entry.accumulatedVolAlongTof.back();
}
std::vector<ContribWellEntry> sourceEntryArr = std::move(m_contributingWells);
std::vector<ContribWellEntry> sourceEntryArr = std::move( m_contributingWells );
ContribWellEntry groupingEntry;
groupingEntry.name = "Other";
groupingEntry.accumulatedVolAlongTof.resize(m_tofInIncreasingOrder.size(), 0);
groupingEntry.accumulatedVolAlongTof.resize( m_tofInIncreasingOrder.size(), 0 );
bool anySmallContribsDetected = false;
for (const ContribWellEntry& sourceEntry : sourceEntryArr)
for ( const ContribWellEntry& sourceEntry : sourceEntryArr )
{
const double volAtLastTof = sourceEntry.accumulatedVolAlongTof.back();
if (volAtLastTof >= totalVolAtLastTof*smallContribThreshold)
if ( volAtLastTof >= totalVolAtLastTof * smallContribThreshold )
{
m_contributingWells.push_back(sourceEntry);
m_contributingWells.push_back( sourceEntry );
}
else
{
for (size_t i = 0; i < groupingEntry.accumulatedVolAlongTof.size(); i++)
for ( size_t i = 0; i < groupingEntry.accumulatedVolAlongTof.size(); i++ )
{
groupingEntry.accumulatedVolAlongTof[i] += sourceEntry.accumulatedVolAlongTof[i];
}
@@ -181,39 +199,40 @@ void RigTofWellDistributionCalculator::groupSmallContributions(double smallContr
}
}
if (anySmallContribsDetected)
if ( anySmallContribsDetected )
{
m_contributingWells.push_back(groupingEntry);
m_contributingWells.push_back( groupingEntry );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<double, std::vector<size_t>> RigTofWellDistributionCalculator::buildSortedTofToCellIndicesMap(const std::vector<double>& tofData)
std::map<double, std::vector<size_t>>
RigTofWellDistributionCalculator::buildSortedTofToCellIndicesMap( const std::vector<double>& tofData )
{
std::map<double, std::vector<size_t>> tofToCellIndicesMap;
for (size_t i = 0; i < tofData.size(); i++)
for ( size_t i = 0; i < tofData.size(); i++ )
{
const double tofValue = tofData[i];
if (tofValue == HUGE_VAL)
if ( tofValue == HUGE_VAL )
{
continue;
}
// Also filter out special TOF values greater than 73000 days (~200 years)
if (tofValue > 73000.0)
if ( tofValue > 73000.0 )
{
continue;
}
std::vector<size_t> vectorOfIndexes{ i };
auto iteratorBoolFromInsertToMap = tofToCellIndicesMap.insert(std::make_pair(tofValue, vectorOfIndexes));
if (!iteratorBoolFromInsertToMap.second)
std::vector<size_t> vectorOfIndexes{i};
auto iteratorBoolFromInsertToMap = tofToCellIndicesMap.insert( std::make_pair( tofValue, vectorOfIndexes ) );
if ( !iteratorBoolFromInsertToMap.second )
{
// Map element for this tofValue already exist => we must add the cell index ourselves
iteratorBoolFromInsertToMap.first->second.push_back(i);
iteratorBoolFromInsertToMap.first->second.push_back( i );
}
}
@@ -223,33 +242,39 @@ std::map<double, std::vector<size_t>> RigTofWellDistributionCalculator::buildSor
//--------------------------------------------------------------------------------------------------
/// Determine name of the the wells that are candidates for contributing in our calculation
//--------------------------------------------------------------------------------------------------
std::vector<QString> RigTofWellDistributionCalculator::findCandidateContributingWellNames(const RimFlowDiagSolution& flowDiagSolution, QString targetWellname, size_t timeStepIndex)
std::vector<QString>
RigTofWellDistributionCalculator::findCandidateContributingWellNames( const RimFlowDiagSolution& flowDiagSolution,
QString targetWellname,
size_t timeStepIndex )
{
std::vector<QString> candidateWellNames;
const RimFlowDiagSolution::TracerStatusType targetWellStatus = flowDiagSolution.tracerStatusInTimeStep(targetWellname, timeStepIndex);
if (targetWellStatus != RimFlowDiagSolution::INJECTOR &&
targetWellStatus != RimFlowDiagSolution::PRODUCER)
const RimFlowDiagSolution::TracerStatusType targetWellStatus =
flowDiagSolution.tracerStatusInTimeStep( targetWellname, timeStepIndex );
if ( targetWellStatus != RimFlowDiagSolution::INJECTOR && targetWellStatus != RimFlowDiagSolution::PRODUCER )
{
RiaLogging::warning("Status of target well is neither INJECTOR nor PRODUCER");
RiaLogging::warning( "Status of target well is neither INJECTOR nor PRODUCER" );
return candidateWellNames;
}
const RimFlowDiagSolution::TracerStatusType oppositeStatus = (targetWellStatus == RimFlowDiagSolution::INJECTOR) ? RimFlowDiagSolution::PRODUCER : RimFlowDiagSolution::INJECTOR;
const RimFlowDiagSolution::TracerStatusType oppositeStatus = ( targetWellStatus == RimFlowDiagSolution::INJECTOR )
? RimFlowDiagSolution::PRODUCER
: RimFlowDiagSolution::INJECTOR;
const std::vector<QString> allWellNames = flowDiagSolution.tracerNames();
for (QString name : allWellNames)
for ( QString name : allWellNames )
{
const RimFlowDiagSolution::TracerStatusType status = flowDiagSolution.tracerStatusInTimeStep(name, timeStepIndex);
if (status == oppositeStatus)
const RimFlowDiagSolution::TracerStatusType status = flowDiagSolution.tracerStatusInTimeStep( name,
timeStepIndex );
if ( status == oppositeStatus )
{
candidateWellNames.push_back(name);
candidateWellNames.push_back( name );
}
else if (status == targetWellStatus)
else if ( status == targetWellStatus )
{
if (RimFlowDiagSolution::hasCrossFlowEnding(name))
if ( RimFlowDiagSolution::hasCrossFlowEnding( name ) )
{
candidateWellNames.push_back(name);
candidateWellNames.push_back( name );
}
}
}
@@ -276,7 +301,7 @@ size_t RigTofWellDistributionCalculator::contributingWellCount() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QString& RigTofWellDistributionCalculator::contributingWellName(size_t contribWellIndex) const
const QString& RigTofWellDistributionCalculator::contributingWellName( size_t contribWellIndex ) const
{
return m_contributingWells[contribWellIndex].name;
}
@@ -284,10 +309,10 @@ const QString& RigTofWellDistributionCalculator::contributingWellName(size_t con
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RigTofWellDistributionCalculator::accumulatedVolumeForContributingWell(size_t contributingWellIndex) const
const std::vector<double>&
RigTofWellDistributionCalculator::accumulatedVolumeForContributingWell( size_t contributingWellIndex ) const
{
CVF_ASSERT(contributingWellIndex < m_contributingWells.size());
CVF_ASSERT( contributingWellIndex < m_contributingWells.size() );
const ContribWellEntry& entry = m_contributingWells[contributingWellIndex];
return entry.accumulatedVolAlongTof;
}