GEOS icon indicating copy to clipboard operation
GEOS copied to clipboard

Log refactor - Table logging features

Open arng40 opened this issue 2 years ago • 3 comments

This PR is the first one of a work in collaboration with @MelReyCG that aim to standardize logs and make them more readable. Today's logs are complicated to read:

  • Data is output in different formats
  • Alignments are random

This PR aim to help to format the logs in a clearer way by providing table drawing :

  • Separation of : the collect, the format and dump.
  • Compile time verification of value added
  • Dynamic table and column size
  • Optional title
  • Optional columns
  • Custom column lignment
  • Margin between columns sides

This feature will be used in a first time for the well data output. According to the well control log level, the column of previous and next element can be displayed.

An example of the refactored Well Log:

Dumping 5 Elements into Log and CSV

1. Data collection

TableData tableData;
loop (over data)
{
tableData.addRow(val1,val42val3,val4,val5);
}

2. Format the data

TableLayout tableLayout( {"Element no.",  "CordX", "CoordY", " CoordZ",  "Prev\nelement", "Next\nelement"} );         

3. Dumping the data

  • Using TableTextFormatter
TableTextFormatter tableText(tableLayout);
  • or dumping to a csv file
std::ofstream os( joinPath( OutputBase::getOutputDirectory(), filename + ".csv" ) );
TableCSVFormatter csvFormat( tableLayout );
os << csvFormat.headerToString();
os << csvFormat.dataToString( tableData );

Log Output

An example of current well log, 3 elements displayed

++++++++++++++++++++++++++
InternalWellGenerator = well_injector1
MPI rank = 0

Number of well elements = 30
Well element #0
Coordinates of the element center: { 9.5, 0.2, 11.9583 }
No next well element
Previous well element #1
First well node: #0
Second well node: #1
Well element #1
Coordinates of the element center: { 9.5, 0.2, 11.875 }
Next well element # = 0
Previous well element #2
First well node: #1
Second well node: #2
Well element #2
Coordinates of the element center: { 9.5, 0.2, 11.7917 }
[...]

With the new log

--------------------------------------------------------------------------------------
|                        Well 'well_injector1' Element Table                         |
--------------------------------------------------------------------------------------
|  Element no.  |  CoordX  |  CoordY  |              CoordZ  |     Prev  |     Next  |
|               |          |          |                      |  Element  |  Element  |
--------------------------------------------------------------------------------------
|            0  |     9.5  |     0.2  |  11.958333333333334  |        1  |           |
|            1  |     9.5  |     0.2  |              11.875  |        2  |        0  |
|            2  |     9.5  |     0.2  |  11.791666666666666  |        3  |        1  |
|            3  |     9.5  |     0.2  |  11.708333333333334  |        4  |        2  |
|            4  |     9.5  |     0.2  |              11.625  |        5  |        3  |
--------------------------------------------------------------------------------------

arng40 avatar Feb 09 '24 15:02 arng40

Codecov Report

Attention: Patch coverage is 83.46883% with 61 lines in your changes missing coverage. Please review.

Project coverage is 53.70%. Comparing base (79856a0) to head (5b46e14). Report is 104 commits behind head on develop.

Files with missing lines Patch % Lines
...reComponents/mesh/generators/WellGeneratorBase.cpp 4.00% 24 Missing :warning:
src/coreComponents/fileIO/Table/TableFormatter.cpp 86.70% 23 Missing :warning:
src/coreComponents/common/DataTypes.hpp 0.00% 4 Missing :warning:
src/coreComponents/fileIO/Table/TableData.cpp 87.09% 4 Missing :warning:
...oreComponents/fileIO/Table/unitTests/testTable.cpp 96.73% 3 Missing :warning:
src/coreComponents/fileIO/Table/TableLayout.cpp 92.00% 2 Missing :warning:
src/coreComponents/fileIO/Table/TableFormatter.hpp 66.66% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2984      +/-   ##
===========================================
+ Coverage    53.56%   53.70%   +0.14%     
===========================================
  Files         1003     1010       +7     
  Lines        85295    85637     +342     
===========================================
+ Hits         45685    45992     +307     
- Misses       39610    39645      +35     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 23 '24 17:02 codecov[bot]

Also, is WellGeneratorBase::debugWellGeometry() well named?

I've split the log into two functions : logInternalWell and logPerforationTable

arng40 avatar Mar 14 '24 14:03 arng40

@TotoGaz Do you agree with the changes / corrections made?

arng40 avatar Apr 22 '24 14:04 arng40