Skip to content

Commit 0db85be

Browse files
arng40MelReyCGrrsettgast
authored
feat: Log refactor - Output PVT (#3149)
Co-authored-by: MelReyCG <122801580+MelReyCG@users.noreply.github.com> Co-authored-by: Randolph Settgast <settgast1@llnl.gov>
1 parent c225416 commit 0db85be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+527
-214
lines changed

.integrated_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
baselines:
22
bucket: geosx
3-
baseline: integratedTests/baseline_integratedTests-pr3163-7758-9fe3734
3+
baseline: integratedTests/baseline_integratedTests-pr3149-7884-f97a068
44

55
allow_fail:
66
all: ''

BASELINE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ This file is designed to track changes to the integrated test baselines.
66
Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining.
77
These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD).
88

9+
PR #3149( 2024-09-30)
10+
=====================
11+
Added new field "writeCSV"
12+
913
PR #3163 (2024-09-20)
1014
=====================
1115
Added new fields (krylovStrongestTol, adaptiveGamma, adaptiveExponent) to the LinearSolverParameters for adaptive tolerances.

src/coreComponents/common/format/table/TableData.cpp

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,42 @@ std::vector< string > const & TableData::getErrorMsgs() const
5151
return m_errorsMsg;
5252
}
5353

54-
TableData2D::Conversion1D TableData2D::buildTableData( string_view targetUnit,
55-
string_view rowFmt,
56-
string_view columnFmt ) const
54+
void TableData2D::collectTableValues( arraySlice1d< real64 const > rowAxisValues,
55+
arraySlice1d< real64 const > columnAxisValues,
56+
arrayView1d< real64 const > values )
5757
{
58-
TableData2D::Conversion1D tableData1D;
58+
integer const nX = rowAxisValues.size();
59+
integer const nY = columnAxisValues.size();
60+
61+
for( integer i = 0; i < nX; i++ )
62+
{
63+
for( integer y = 0; y < nY; y++ )
64+
{
65+
addCell( rowAxisValues[i], columnAxisValues[y], values[ y*nX + i ] );
66+
}
67+
}
68+
}
69+
70+
TableData2D::TableDataHolder TableData2D::convertTable2D( arrayView1d< real64 const > const values,
71+
units::Unit const valueUnit,
72+
ArrayOfArraysView< real64 const > const coordinates,
73+
string_view rowAxisDescription,
74+
string_view columnAxisDescription )
75+
{
76+
string const rowFmt = GEOS_FMT( "{} = {{}}", rowAxisDescription );
77+
string const columnFmt = GEOS_FMT( "{} = {{}}", columnAxisDescription );
78+
79+
collectTableValues( coordinates[0], coordinates[1], values );
80+
return buildTableData( string( units::getDescription( valueUnit )),
81+
rowFmt,
82+
columnFmt );
83+
}
84+
85+
TableData2D::TableDataHolder TableData2D::buildTableData( string_view targetUnit,
86+
string_view rowFmt,
87+
string_view columnFmt ) const
88+
{
89+
TableData2D::TableDataHolder tableData1D;
5990
std::vector< size_t > rowsLength;
6091

6192
tableData1D.headerNames.push_back( string( targetUnit ) );

src/coreComponents/common/format/table/TableData.hpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef GEOS_COMMON_FORMAT_TABLE_TABLEDATA_HPP
2121
#define GEOS_COMMON_FORMAT_TABLE_TABLEDATA_HPP
2222

23+
#include "common/Units.hpp"
2324
#include "common/DataTypes.hpp"
2425
#include "common/format/Format.hpp"
2526

@@ -85,9 +86,10 @@ class TableData2D
8586
using ColumnType = real64;
8687

8788
/// Struct containing conversion informations
88-
struct Conversion1D
89+
struct TableDataHolder
8990
{
9091
/// Vector containing all columns names
92+
/// A header value is presented as "pressure [K] = {}"
9193
std::vector< string > headerNames;
9294
/// TableData to be built
9395
TableData tableData;
@@ -103,6 +105,30 @@ class TableData2D
103105
template< typename T >
104106
void addCell( RowType rowValue, ColumnType columnValue, T const & value );
105107

108+
/**
109+
* @brief Collects all the values needed to build the table
110+
* @param rowAxisValues Vector containing all row axis values
111+
* @param columnAxisValues Vector containing all column axis values
112+
* @param values Vector containing all table values
113+
*/
114+
void collectTableValues( arraySlice1d< real64 const > rowAxisValues,
115+
arraySlice1d< real64 const > columnAxisValues,
116+
arrayView1d< real64 const > values );
117+
118+
/**
119+
* @param values Vector containing all table values
120+
* @param valueUnit The table unit value
121+
* @param coordinates Array containing row/column axis values
122+
* @param rowAxisDescription The description for a row unit value
123+
* @param columnAxisDescription The description for a column unit value
124+
* @return A struct containing the tableData converted and all header values ;
125+
*/
126+
TableData2D::TableDataHolder convertTable2D( arrayView1d< real64 const > const values,
127+
units::Unit const valueUnit,
128+
ArrayOfArraysView< real64 const > const coordinates,
129+
string_view rowAxisDescription,
130+
string_view columnAxisDescription );
131+
106132
/**
107133
* @return Convert and return a struct containing a 1D Table, the column names list from a TableData2D and any errors related to the table
108134
* @param dataDescription The table dataDescription shown at the top left side
@@ -112,7 +138,8 @@ class TableData2D
112138
* By default it displays the axis value.
113139
* I.E to display a customized axis to show the pressures in y axis, a rowFmt value can be : "pressure [K] = {}"
114140
*/
115-
Conversion1D buildTableData( string_view dataDescription, string_view rowFmt = "{}", string_view columnFmt = "{}" ) const;
141+
TableDataHolder buildTableData( string_view dataDescription,
142+
string_view rowFmt = "{}", string_view columnFmt = "{}" ) const;
116143

117144
private:
118145
/// @brief all cell values by their [ row ][ column ]

src/coreComponents/common/format/table/TableFormatter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* @file TableFormatter.cpp
1818
*/
1919

20+
#include "TableFormatter.hpp"
2021
#include <numeric>
2122
#include "common/format/StringUtilities.hpp"
2223
#include "TableFormatter.hpp"
@@ -67,7 +68,8 @@ string TableCSVFormatter::dataToString( TableData const & tableData ) const
6768
return oss.str();
6869
}
6970

70-
string TableCSVFormatter::toString( TableData const & tableData ) const
71+
template<>
72+
string TableCSVFormatter::toString< TableData >( TableData const & tableData ) const
7173
{
7274
return headerToString() + dataToString( tableData );
7375
}
@@ -155,7 +157,8 @@ string TableTextFormatter::layoutToString() const
155157
return tableOutput.str();
156158
}
157159

158-
string TableTextFormatter::toString( TableData const & tableData ) const
160+
template<>
161+
string TableTextFormatter::toString< TableData >( TableData const & tableData ) const
159162
{
160163
std::ostringstream tableOutput;
161164
string sectionSeparatingLine;
@@ -403,4 +406,5 @@ void TableTextFormatter::outputSectionRows( std::vector< TableLayout::Column > c
403406
tableOutput << GEOS_FMT( "{}\n", sectionSeparatingLine );
404407
}
405408
}
409+
406410
}

src/coreComponents/common/format/table/TableFormatter.hpp

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class TableFormatter
3737
/// Layout for a table
3838
TableLayout m_tableLayout;
3939

40+
TableFormatter() = default;
41+
4042
/**
4143
* @brief Construct a new Table Formatter from a tableLayout
4244
* @param tableLayout Contain all column names and optionnaly the table title
@@ -56,6 +58,13 @@ class TableCSVFormatter : public TableFormatter
5658
{
5759
public:
5860

61+
/**
62+
* @brief Construct a new Table Formatter
63+
*/
64+
TableCSVFormatter():
65+
TableFormatter( TableLayout() )
66+
{}
67+
5968
/**
6069
* @brief Construct a new Table Formatter from a tableLayout
6170
* @param tableLayout Contain all column names and optionnaly the table title
@@ -80,28 +89,47 @@ class TableCSVFormatter : public TableFormatter
8089
string dataToString( TableData const & tableData ) const;
8190

8291
/**
83-
* @brief Convert the TableData to a table string.
84-
* @param tableData The TableData to convert.
85-
* @return The table string representation of the TableData.
92+
* @brief Convert a data source to a CSV string.
93+
* @tparam DATASOURCE The source to convert
94+
* @param tableData The data source to convert
95+
* @return The CSV string representation of a data source.
8696
*/
87-
string toString( TableData const & tableData ) const;
97+
template< typename DATASOURCE >
98+
string toString( DATASOURCE const & tableData ) const;
8899

89100
};
90101

102+
/**
103+
* @brief Convert the TableData to a CSV string.
104+
* @param tableData The TableData to convert.
105+
* @return The CSV string representation of the TableData.
106+
*/
107+
template<>
108+
string TableCSVFormatter::toString< TableData >( TableData const & tableData ) const;
109+
110+
91111
/**
92112
* @brief class for log formatting
93113
*/
94114
class TableTextFormatter : public TableFormatter
95115
{
96-
97116
public:
98117

118+
119+
/**
120+
* @brief Construct a new TableFormatter
121+
*/
122+
TableTextFormatter():
123+
TableFormatter( TableLayout() )
124+
{}
125+
99126
/**
100127
* @brief Construct a new TableFormatter from a tableLayout
101128
* @param tableLayout Contain all column names and optionnaly the table title
102129
*/
103130
TableTextFormatter( TableLayout const & tableLayout );
104131

132+
105133
/**
106134
* @brief Destroy the Table Text Formatter object
107135
*/
@@ -113,11 +141,12 @@ class TableTextFormatter : public TableFormatter
113141
string layoutToString() const;
114142

115143
/**
116-
* @brief Convert the TableData to a table string.
117-
* @param tableData The TableData to convert.
144+
* @brief Convert a data source to a table string.
145+
* @param tableData The data source to convert.
118146
* @return The table string representation of the TableData.
119147
*/
120-
string toString( TableData const & tableData ) const;
148+
template< typename DATASOURCE >
149+
string toString( DATASOURCE const & tableData ) const;
121150

122151
private:
123152

@@ -126,7 +155,7 @@ class TableTextFormatter : public TableFormatter
126155
/// for the extremity of a row
127156
static constexpr char m_horizontalLine = '-';
128157

129-
/**F
158+
/**
130159
* @brief Fill the vector (m_column) in tableData with values from rows stored in tableData.
131160
* @param columns Vector of columns to be filled.
132161
* @param tableData Vector containing all rows filled with values
@@ -217,6 +246,14 @@ class TableTextFormatter : public TableFormatter
217246
integer const nbRows,
218247
TableLayout::Section const section ) const;
219248
};
249+
250+
/**
251+
* @brief Convert a TableData to a table string.
252+
* @param tableData The TableData to convert.
253+
* @return The table string representation of the TableData.
254+
*/
255+
template<>
256+
string TableTextFormatter::toString< TableData >( TableData const & tableData ) const;
220257
}
221258

222259
#endif /* GEOS_COMMON_FORMAT_TABLE_TABLEFORMATTER_HPP */

src/coreComponents/common/format/table/TableLayout.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class TableLayout
9797
string m_maxStringSize;
9898
};
9999

100+
TableLayout() = default;
101+
100102
/**
101103
* @brief Construct a new Table object, all values in the table are centered by default
102104
* @param columnNames The names of the columns

src/coreComponents/common/format/table/unitTests/testTable.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ TEST( testTable, table2DTable )
210210
//convert
211211
string const rowFmt = GEOS_FMT( "{} = {{}}", "Temperature" );
212212
string const columnFmt = GEOS_FMT( "{} = {{}}", "Pression" );
213-
TableData2D::Conversion1D tableconverted = tableData.buildTableData( "Viscosity kg*s",
214-
rowFmt,
215-
columnFmt );
213+
TableData2D::TableDataHolder tableconverted = tableData.buildTableData( "Viscosity kg*s",
214+
rowFmt,
215+
columnFmt );
216216

217217
//format
218218
TableLayout const tableLayout( tableconverted.headerNames );
@@ -248,9 +248,9 @@ TEST( testTable, table2DColumnMismatch )
248248
//convert
249249
string const rowFmt = GEOS_FMT( "{} = {{}}", "Temperature" );
250250
string const columnFmt = GEOS_FMT( "{} = {{}}", "Pression" );
251-
TableData2D::Conversion1D tableConverted = tableData.buildTableData( "Viscosity kg*s",
252-
rowFmt,
253-
columnFmt );
251+
TableData2D::TableDataHolder tableConverted = tableData.buildTableData( "Viscosity kg*s",
252+
rowFmt,
253+
columnFmt );
254254

255255
//format
256256
TableLayout const tableLayout( tableConverted.headerNames );
@@ -274,11 +274,10 @@ TEST( testTable, table2DColumnMismatch )
274274
TEST( testTable, layoutTable )
275275
{
276276
string filename = "fluid1_phaseModel1_PhillipsBrineDensity_table";
277-
//2. format
277+
278278
string log = GEOS_FMT( "The {} PVT table exceeding 500 rows.\nTo visualize the tables, go to the generated csv \n", filename );
279279
TableLayout const tableLayoutInfos( {TableLayout::ColumnParam{{log}, TableLayout::Alignment::left}}, filename );
280280

281-
//3. log
282281
TableTextFormatter const tableLog( tableLayoutInfos );
283282
EXPECT_EQ( tableLog.layoutToString(),
284283
"\n-------------------------------------------------------------------------------------\n"

src/coreComponents/constitutive/ConstitutiveBase.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ namespace constitutive
3030
ConstitutiveBase::ConstitutiveBase( string const & name,
3131
Group * const parent ):
3232
Group( name, parent ),
33-
m_numQuadraturePoints( 1 )
33+
m_numQuadraturePoints( 1 ),
34+
m_isClone( false )
3435
{
3536
setInputFlags( InputFlags::OPTIONAL_NONUNIQUE );
3637
}
@@ -72,6 +73,11 @@ void ConstitutiveBase::allocateConstitutiveData( dataRepository::Group & parent,
7273
this->resize( parent.size() );
7374
}
7475

76+
void ConstitutiveBase::setIsClone( bool const newState )
77+
{
78+
m_isClone = newState;
79+
}
80+
7581
std::unique_ptr< ConstitutiveBase >
7682
ConstitutiveBase::deliverClone( string const & name,
7783
Group * const parent ) const
@@ -84,6 +90,8 @@ ConstitutiveBase::deliverClone( string const & name,
8490
wrapper.copyWrapper( this->getWrapperBase( wrapper.getName() ) );
8591
} );
8692

93+
newModel->setIsClone( true );
94+
8795
return newModel;
8896
}
8997

src/coreComponents/constitutive/ConstitutiveBase.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ class ConstitutiveBase : public dataRepository::Group
113113

114114
localIndex numQuadraturePoints() const { return m_numQuadraturePoints; }
115115

116+
/**
117+
* @return true if the instance has been produced with deliverClone()
118+
*/
119+
bool isClone() const { return m_isClone; }
120+
116121
virtual std::vector< string > getSubRelationNames() const { return {}; }
117122

118123
/**
@@ -162,7 +167,16 @@ class ConstitutiveBase : public dataRepository::Group
162167

163168
private:
164169

170+
/**
171+
* @brief Set a isClone state boolean
172+
* @param newState The state of the new constitutive model
173+
*/
174+
void setIsClone( bool const newState );
175+
165176
localIndex m_numQuadraturePoints;
177+
178+
/// Indicate if this constitutive model a clone
179+
bool m_isClone;
166180
};
167181

168182
}

0 commit comments

Comments
 (0)