#3853 Add line shift to compdat export table rows if the line exceeds 132 characters

This commit is contained in:
Gaute Lindkvist
2018-12-18 10:22:22 +01:00
parent a9f70a13b3
commit 9851a2d938
3 changed files with 80 additions and 56 deletions

View File

@@ -680,10 +680,9 @@ void RicWellPathExportMswCompletionsImpl::generateWsegvalvTable(RifEclipseDataTa
void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTableFormatter& formatter, void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo) const RicMswExportInfo& exportInfo)
{ {
int existingColSpacing = formatter.columnSpacing(); RifEclipseDataTableFormatter tighterFormatter(formatter);
formatter.setColumnSpacing(1); tighterFormatter.setColumnSpacing(1);
QString existingPrependText = formatter.tableRowPrependText(); tighterFormatter.setTableRowPrependText(" ");
formatter.setTableRowPrependText("");
bool foundValve = false; bool foundValve = false;
@@ -726,11 +725,11 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTa
"Exponent of the water flowing fraction in the density viscosity calculation", "Exponent of the water flowing fraction in the density viscosity calculation",
"Exponent of the gas flowing fraction in the density viscosity calculation"}; "Exponent of the gas flowing fraction in the density viscosity calculation"};
formatter.keyword("WSEGAICD"); tighterFormatter.keyword("WSEGAICD");
formatter.comment("Column Overview:"); tighterFormatter.comment("Column Overview:");
for (size_t i = 0; i < columnDescriptions.size(); ++i) for (size_t i = 0; i < columnDescriptions.size(); ++i)
{ {
formatter.comment(QString("%1: %2").arg(i + 1, 2, 10, QChar('0')).arg(columnDescriptions[i])); tighterFormatter.comment(QString("%1: %2").arg(i + 1, 2, 10, QChar('0')).arg(columnDescriptions[i]));
} }
std::vector<RifEclipseOutputTableColumn> header; std::vector<RifEclipseOutputTableColumn> header;
@@ -741,55 +740,53 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTa
cName, RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_CONSISE), RIGHT); cName, RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_CONSISE), RIGHT);
header.push_back(col); header.push_back(col);
} }
formatter.header(header); tighterFormatter.header(header);
foundValve = true; foundValve = true;
} }
if (!aicd->subSegments().empty()) if (!aicd->subSegments().empty())
{ {
CVF_ASSERT(aicd->subSegments().size() == 1u); CVF_ASSERT(aicd->subSegments().size() == 1u);
formatter.comment(aicd->label()); tighterFormatter.comment(aicd->label());
formatter.add(exportInfo.wellPath()->completions()->wellNameForExport()); // 1 tighterFormatter.add(exportInfo.wellPath()->completions()->wellNameForExport()); // 1
formatter.add(aicd->subSegments().front()->segmentNumber()); tighterFormatter.add(aicd->subSegments().front()->segmentNumber());
formatter.add(aicd->subSegments().front()->segmentNumber()); tighterFormatter.add(aicd->subSegments().front()->segmentNumber());
std::array<double, AICD_NUM_PARAMS> values = aicd->values(); std::array<double, AICD_NUM_PARAMS> values = aicd->values();
formatter.add(values[AICD_STRENGTH]); tighterFormatter.add(values[AICD_STRENGTH]);
formatter.add(aicd->length()); // 5 tighterFormatter.add(aicd->length()); // 5
formatter.add(values[AICD_DENSITY_CALIB_FLUID]); tighterFormatter.add(values[AICD_DENSITY_CALIB_FLUID]);
formatter.add(values[AICD_VISCOSITY_CALIB_FLUID]); tighterFormatter.add(values[AICD_VISCOSITY_CALIB_FLUID]);
formatter.addValueOrDefaultMarker(values[AICD_CRITICAL_WATER_IN_LIQUID_FRAC], tighterFormatter.addValueOrDefaultMarker(values[AICD_CRITICAL_WATER_IN_LIQUID_FRAC],
RicMswExportInfo::defaultDoubleValue()); RicMswExportInfo::defaultDoubleValue());
formatter.addValueOrDefaultMarker(values[AICD_EMULSION_VISC_TRANS_REGION], tighterFormatter.addValueOrDefaultMarker(values[AICD_EMULSION_VISC_TRANS_REGION],
RicMswExportInfo::defaultDoubleValue()); RicMswExportInfo::defaultDoubleValue());
formatter.addValueOrDefaultMarker(values[AICD_MAX_RATIO_EMULSION_VISC], tighterFormatter.addValueOrDefaultMarker(values[AICD_MAX_RATIO_EMULSION_VISC],
RicMswExportInfo::defaultDoubleValue()); // 10 RicMswExportInfo::defaultDoubleValue()); // 10
formatter.add(1); tighterFormatter.add(1);
formatter.addValueOrDefaultMarker(values[AICD_MAX_FLOW_RATE], RicMswExportInfo::defaultDoubleValue()); tighterFormatter.addValueOrDefaultMarker(values[AICD_MAX_FLOW_RATE], RicMswExportInfo::defaultDoubleValue());
formatter.add(values[AICD_VOL_FLOW_EXP]); tighterFormatter.add(values[AICD_VOL_FLOW_EXP]);
formatter.add(values[AICD_VISOSITY_FUNC_EXP]); tighterFormatter.add(values[AICD_VISOSITY_FUNC_EXP]);
formatter.add(aicd->isOpen() ? "OPEN" : "SHUT"); // 15 tighterFormatter.add(aicd->isOpen() ? "OPEN" : "SHUT"); // 15
formatter.addValueOrDefaultMarker(values[AICD_EXP_OIL_FRAC_DENSITY], RicMswExportInfo::defaultDoubleValue()); tighterFormatter.addValueOrDefaultMarker(values[AICD_EXP_OIL_FRAC_DENSITY], RicMswExportInfo::defaultDoubleValue());
formatter.addValueOrDefaultMarker(values[AICD_EXP_WATER_FRAC_DENSITY], tighterFormatter.addValueOrDefaultMarker(values[AICD_EXP_WATER_FRAC_DENSITY],
RicMswExportInfo::defaultDoubleValue()); RicMswExportInfo::defaultDoubleValue());
formatter.addValueOrDefaultMarker(values[AICD_EXP_GAS_FRAC_DENSITY], RicMswExportInfo::defaultDoubleValue()); tighterFormatter.addValueOrDefaultMarker(values[AICD_EXP_GAS_FRAC_DENSITY], RicMswExportInfo::defaultDoubleValue());
formatter.addValueOrDefaultMarker(values[AICD_EXP_OIL_FRAC_VISCOSITY], tighterFormatter.addValueOrDefaultMarker(values[AICD_EXP_OIL_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue()); RicMswExportInfo::defaultDoubleValue());
formatter.addValueOrDefaultMarker(values[AICD_EXP_WATER_FRAC_VISCOSITY], tighterFormatter.addValueOrDefaultMarker(values[AICD_EXP_WATER_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue()); // 20 RicMswExportInfo::defaultDoubleValue()); // 20
formatter.addValueOrDefaultMarker(values[AICD_EXP_GAS_FRAC_VISCOSITY], tighterFormatter.addValueOrDefaultMarker(values[AICD_EXP_GAS_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue()); RicMswExportInfo::defaultDoubleValue());
formatter.rowCompleted(); tighterFormatter.rowCompleted();
} }
} }
} }
} }
if (foundValve) if (foundValve)
{ {
formatter.tableCompleted(); tighterFormatter.tableCompleted();
} }
formatter.setColumnSpacing(existingColSpacing);
formatter.setTableRowPrependText(existingPrependText);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -32,6 +32,18 @@ RifEclipseDataTableFormatter::RifEclipseDataTableFormatter(QTextStream& out)
{ {
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter::RifEclipseDataTableFormatter(const RifEclipseDataTableFormatter& rhs)
: m_out(rhs.m_out)
, m_colSpacing(rhs.m_colSpacing)
, m_tableRowPrependText(rhs.m_tableRowPrependText)
, m_tableRowAppendText(rhs.m_tableRowAppendText)
, m_commentPrefix(rhs.m_commentPrefix)
{
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -96,14 +108,10 @@ void RifEclipseDataTableFormatter::outputBuffer()
{ {
if (!m_columns.empty() && !isAllHeadersEmpty(m_columns)) if (!m_columns.empty() && !isAllHeadersEmpty(m_columns))
{ {
m_out << m_commentPrefix << " ";
for (size_t i = 0u; i < m_columns.size(); ++i) for (size_t i = 0u; i < m_columns.size(); ++i)
{ {
QString colTitle = m_columns[i].title; m_out << formatColumn(m_columns[i].title, i);
if (i == 0u)
{
colTitle = m_commentPrefix + " " + colTitle;
}
m_out << formatColumn(colTitle, i);
} }
m_out << "\n"; m_out << "\n";
} }
@@ -120,14 +128,26 @@ void RifEclipseDataTableFormatter::outputBuffer()
} }
else if (line.lineType == CONTENTS) else if (line.lineType == CONTENTS)
{ {
m_out << m_tableRowPrependText; QString lineText = m_tableRowPrependText;
QString appendText = (line.appendTextSet ? line.appendText : m_tableRowAppendText) + "\n";
for (size_t i = 0; i < line.data.size(); ++i) for (size_t i = 0; i < line.data.size(); ++i)
{ {
m_out << formatColumn(line.data[i], i); QString column = formatColumn(line.data[i], i);
QString newLineText = lineText + column;
if (i == line.data.size() - 1)
{
newLineText += appendText;
}
if (newLineText.length() > maxEclipseRowWidth())
{
m_out << lineText << "\n";
lineText = m_tableRowPrependText;
}
lineText += column;
} }
m_out << (line.appendTextSet ? line.appendText : m_tableRowAppendText) << "\n"; m_out << lineText << appendText;
} }
} }
m_columns.clear(); m_columns.clear();
@@ -249,12 +269,7 @@ RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::header(const std::ve
for (size_t colNumber = 0u; colNumber < m_columns.size(); ++colNumber) for (size_t colNumber = 0u; colNumber < m_columns.size(); ++colNumber)
{ {
QString colTitle = m_columns[colNumber].title; m_columns[colNumber].width = measure(m_columns[colNumber].title);
if (colNumber == 0u)
{
colTitle = m_commentPrefix + " " + colTitle;
}
m_columns[colNumber].width = measure(colTitle);
} }
return *this; return *this;
} }
@@ -451,6 +466,14 @@ int RifEclipseDataTableFormatter::tableWidth() const
return characterCount; return characterCount;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseDataTableFormatter::maxEclipseRowWidth()
{
return 132;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -459,11 +482,11 @@ QString RifEclipseDataTableFormatter::format(double num, RifEclipseOutputTableDo
switch (doubleFormat.format) switch (doubleFormat.format)
{ {
case RifEclipseOutputTableDoubleFormat::RIF_FLOAT: case RifEclipseOutputTableDoubleFormat::RIF_FLOAT:
return QString("%1").arg(num, 0, 'f', doubleFormat.width); return QString("%1").arg(num, 0, 'f', doubleFormat.precision);
case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC: case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC:
return QString("%1").arg(num, 0, 'E'); return QString("%1").arg(num, 0, 'E');
case RifEclipseOutputTableDoubleFormat::RIF_CONSISE: case RifEclipseOutputTableDoubleFormat::RIF_CONSISE:
return QString("%1").arg(num, doubleFormat.width, 'g'); return QString::number(num, 'g', doubleFormat.precision);
default: default:
return QString("%1"); return QString("%1");
} }

View File

@@ -68,14 +68,14 @@ struct RifEclipseOutputTableLine
//================================================================================================== //==================================================================================================
struct RifEclipseOutputTableDoubleFormatting struct RifEclipseOutputTableDoubleFormatting
{ {
RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat format = RIF_FLOAT, int width = 5) RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat format = RIF_FLOAT, int precision = 5)
: format(format) : format(format)
, width(width) , precision(precision)
{ {
} }
RifEclipseOutputTableDoubleFormat format; RifEclipseOutputTableDoubleFormat format;
int width; int precision;
}; };
//================================================================================================== //==================================================================================================
@@ -107,6 +107,8 @@ class RifEclipseDataTableFormatter
{ {
public: public:
RifEclipseDataTableFormatter(QTextStream& out); RifEclipseDataTableFormatter(QTextStream& out);
RifEclipseDataTableFormatter(const RifEclipseDataTableFormatter& rhs);
virtual ~RifEclipseDataTableFormatter(); virtual ~RifEclipseDataTableFormatter();
int columnSpacing() const; int columnSpacing() const;
@@ -133,6 +135,7 @@ public:
static void addValueTable(QTextStream& stream, const QString& keyword, size_t columns, const std::vector<double>& values); static void addValueTable(QTextStream& stream, const QString& keyword, size_t columns, const std::vector<double>& values);
private: private:
int measure(const QString str); int measure(const QString str);
int measure(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); int measure(double num, RifEclipseOutputTableDoubleFormatting doubleFormat);
@@ -140,6 +143,7 @@ private:
int measure(size_t num); int measure(size_t num);
int tableWidth() const; int tableWidth() const;
static int maxEclipseRowWidth();
QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat);
QString format(int num); QString format(int num);