Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Refactor log & CSV statistics #3406

Open
wants to merge 330 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
330 commits
Select commit Hold shift + click to select a range
76789ba
remove constructor vector string
arng40 Mar 28, 2024
2d1cded
Table Data logs
arng40 Mar 28, 2024
8fedfd8
move table to common + pr correction
arng40 Mar 29, 2024
e5d2d3a
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Mar 29, 2024
13f975a
correction from merging
arng40 Mar 29, 2024
f7dbdcf
minor correction
arng40 Mar 29, 2024
4f34fc2
gracefully breaking your code :)
MelReyCG Apr 2, 2024
1cb2cc0
improving proposal + added TODOs
MelReyCG Apr 2, 2024
615a16d
Refactor conversion TableData2 => TableData1D
arng40 Apr 3, 2024
0100b33
Merge remote-tracking branch 'origin/feature/rey/transmissibilityOutp…
arng40 Apr 4, 2024
e66074e
Merge remote-tracking branch 'origin/develop' into pvt-logs-cp
arng40 Apr 4, 2024
7375665
refactor method to convert 2Dtable => 1D table
arng40 Apr 4, 2024
d590513
CI correction
arng40 Apr 4, 2024
7f6b79b
move table to fileIO
arng40 Apr 4, 2024
73f8374
update some doc
arng40 Apr 4, 2024
ae4968b
first part test 2D table crash
arng40 Apr 4, 2024
92a1644
add test/warning for table conversion 2D => 1D and warning for fillin…
arng40 Apr 5, 2024
e6b2e6d
ci correction
arng40 Apr 8, 2024
18db533
test ci correction for c++ < 17
arng40 Apr 9, 2024
31126e1
test ci table2D example 1
arng40 Apr 9, 2024
d481454
test ci Table2D test 1 & 2
arng40 Apr 9, 2024
6a7bfe8
test ci Table2D test 1 & 2 & 3
arng40 Apr 9, 2024
e01523b
add virtual destructor TableFormatter + minor variable refacto
arng40 Apr 10, 2024
978674e
bug correction + missing doc + test small refacto
arng40 Apr 10, 2024
da95c91
missig doc ...
arng40 Apr 10, 2024
79acc00
start management logError in table + todo refacto functions in TableF…
arng40 Apr 11, 2024
24f92d9
TableFormatter refacto + clean up
arng40 Apr 12, 2024
5a70c33
uncrustify
arng40 Apr 12, 2024
95f3a9d
small doc update
arng40 Apr 15, 2024
77351b9
some error management update
arng40 Apr 15, 2024
da67c05
renaming & simplifying
arng40 Apr 17, 2024
a9612bb
add case for fill all column in case of table 2D
arng40 Apr 17, 2024
0f1bbe2
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Apr 17, 2024
89f859a
simplification
arng40 Apr 17, 2024
ef5085c
code optimization
arng40 Apr 18, 2024
294db78
remove useless std::move
arng40 Apr 18, 2024
9f23f62
refacto build separator + reviews
arng40 Apr 19, 2024
9809699
final review correction
arng40 Apr 19, 2024
66895d6
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Apr 22, 2024
46a6abe
method display layout added
arng40 Apr 22, 2024
9de9d63
small correction after merge
arng40 Apr 22, 2024
fe80c59
review correction #1
arng40 May 13, 2024
abb994e
variables renamed
arng40 May 17, 2024
c851b38
uncrustify + doc
arng40 May 23, 2024
0ae0c74
doc
arng40 May 23, 2024
86c0130
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 May 23, 2024
e9639ea
remove unused code
arng40 May 24, 2024
a48feb3
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 May 27, 2024
924d955
syntax correction
arng40 May 27, 2024
5b530f0
Merge branch 'pvt-logs-cp' of https://github.com/GEOS-DEV/GEOS into p…
arng40 May 27, 2024
ac0cec8
variable correction
arng40 May 27, 2024
d6415a7
doc + code clarification
arng40 May 30, 2024
eaa8919
more code simplification
arng40 May 31, 2024
138541b
remove addErrorMsg function
arng40 Jun 3, 2024
3f74746
merge
arng40 Jun 3, 2024
d360dcf
Merge branch 'develop' into feature/dudes/table-layout
arng40 Jun 3, 2024
7aaf7b6
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Jun 3, 2024
1f24247
uncrustify
arng40 Jun 3, 2024
709c037
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jun 5, 2024
fb795ba
Merge branch 'feature/dudes/pvt-output' of https://github.com/GEOS-DE…
arng40 Jun 5, 2024
b1ec0d0
begin refacto in table function for more clarity
arng40 Jun 5, 2024
b62161a
continue refato
arng40 Jun 5, 2024
98764af
refacto continuing ( commit works )
arng40 Jun 7, 2024
8091945
missing doxygen
arng40 Jun 7, 2024
1c8d7a9
correction fun name
arng40 Jun 7, 2024
2c17324
missing doc
arng40 Jun 10, 2024
0dddcf5
uncrustify + doc
arng40 Jun 10, 2024
7ee093b
Doxygen check
arng40 Jun 10, 2024
86fe90b
review correction + add pvtOptions struct
arng40 Jun 14, 2024
28b68f0
missing test correction
arng40 Jun 14, 2024
7f1b8ab
pvtOpt struct renaming + fct move to FlashModel
arng40 Jun 14, 2024
3da5e82
xsd/rst generation
arng40 Jun 14, 2024
fd605f7
review pavel
arng40 Jun 17, 2024
5cbaeec
renaming
arng40 Jun 18, 2024
684a405
review update
arng40 Jun 19, 2024
ae86942
revert a modif
arng40 Jun 19, 2024
c69fbee
uncrustify
arng40 Jun 19, 2024
49b52f3
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jun 19, 2024
fa3218c
melvin review
arng40 Jun 26, 2024
5c808f8
fix
arng40 Jun 26, 2024
b39a84a
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jun 27, 2024
76ee4dd
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jul 2, 2024
57c23b2
pr pavel correction
arng40 Jul 4, 2024
4c4a3b8
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jul 4, 2024
83c80b2
missing doxygen
arng40 Jul 4, 2024
5e8d0af
remove unused code
arng40 Jul 4, 2024
547bf9e
review melvin
arng40 Jul 8, 2024
37482aa
doxygen + uncrustify
arng40 Jul 8, 2024
7e7492d
revert space applied
arng40 Jul 8, 2024
d6c3a8a
uncrustify
arng40 Jul 8, 2024
c0c1d6b
nb character lines fix
arng40 Jul 12, 2024
ace4ce9
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jul 12, 2024
44d3e8e
Merge branch 'develop' into feature/dudes/pvt-output
MelReyCG Jul 23, 2024
3c0997a
fix print screen level condition
arng40 Jul 25, 2024
45847cd
Merge branch 'feature/dudes/pvt-output' of https://github.com/GEOS-DE…
arng40 Jul 25, 2024
7278d9c
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Jul 25, 2024
003de35
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Aug 21, 2024
53d4ea0
small fix
arng40 Aug 21, 2024
49c939c
small change in path indaction
arng40 Aug 22, 2024
6d2995e
Merge remote-tracking branch 'origin/develop' into feature/dudes/pvt-…
arng40 Aug 28, 2024
b707111
[DRAFT] column fill with subvalues
arng40 Sep 6, 2024
d486a8a
[DRAFT ] subsection draw
arng40 Sep 6, 2024
a184897
[DRAFT] First table sub version, missing spaces
arng40 Sep 6, 2024
eef11e6
[DRAFT] subVales added
arng40 Sep 9, 2024
4cd35f5
Table well formated + some opti
arng40 Sep 10, 2024
111cb13
fix heade + some simplification
arng40 Sep 11, 2024
50512ae
new version with multiples sub column
arng40 Sep 12, 2024
267d065
some opti
arng40 Sep 13, 2024
985c88c
some refactor
arng40 Sep 13, 2024
59e3134
getter margin adjustment
arng40 Sep 13, 2024
b7bdb04
moving code
arng40 Sep 13, 2024
2d50cda
varaible refactor + unused code
arng40 Sep 16, 2024
f0644cd
test passed + hpp doxygen + uncrustify
arng40 Sep 17, 2024
6fc69e3
update test
arng40 Sep 18, 2024
c369b22
update output pre existing
arng40 Sep 18, 2024
c1c3137
some refacto and adding functions
arng40 Sep 18, 2024
6b33bcc
small fix
arng40 Sep 18, 2024
70400cc
missing doxygen
arng40 Sep 18, 2024
4f8002b
small tweaks
arng40 Sep 18, 2024
349f05c
Merge remote-tracking branch 'origin/develop' into table-subs-division
arng40 Sep 18, 2024
f870e67
const variable
arng40 Sep 19, 2024
41fb6d5
small refactor
arng40 Sep 19, 2024
ed6c14b
doxygen improved
arng40 Sep 19, 2024
eb17f42
fix margin if title largest
arng40 Sep 20, 2024
582e168
add init_list constructor
arng40 Sep 20, 2024
5cfe033
adding setMargin + small cleaning
arng40 Sep 23, 2024
674e271
fix unwanted empty space
arng40 Sep 23, 2024
380da9f
test working + log domainPartiton
arng40 Sep 23, 2024
37c9721
uncrustify + some renaming
arng40 Sep 23, 2024
f9f1111
fix default alignment not defined correctly
arng40 Sep 24, 2024
aa98cf2
xsd
arng40 Sep 25, 2024
d7150b2
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Oct 2, 2024
db50180
fix after merge
arng40 Oct 2, 2024
377eea9
uncrustify
arng40 Oct 2, 2024
6f70e9b
doc small correction + replace layoutTostring -> toString
arng40 Oct 2, 2024
79cbc8e
missing doc + small adjustment
arng40 Oct 2, 2024
a32cedc
minor update
arng40 Oct 3, 2024
8f74418
xsd
arng40 Oct 3, 2024
7d83833
remove todo
arng40 Oct 3, 2024
24ab8fa
small things forgotten
arng40 Oct 3, 2024
1f1d2b5
fix pvt test
arng40 Oct 4, 2024
04a494b
doxygen & failed test
arng40 Oct 7, 2024
88cf2a3
doxygen
arng40 Oct 7, 2024
cd84b82
variable renaming
arng40 Oct 7, 2024
169ffc8
adding a way to set up alignment for header and values
arng40 Oct 7, 2024
16b4e4e
missing doc
arng40 Oct 8, 2024
1cad750
Merge branch 'develop' into table-subs-division
MelReyCG Oct 8, 2024
5ef16fe
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Oct 11, 2024
1262e24
[DRAFT] need table sub div
arng40 Oct 11, 2024
cf3bfd2
Merge remote-tracking branch 'origin/table-subs-division' into featur…
arng40 Oct 11, 2024
4f1a647
TableLayout signature simplification
arng40 Oct 15, 2024
410cd1b
testFlowStatistics field precision in order to print
arng40 Oct 15, 2024
432857a
sourceflux stats output 1st try
arng40 Oct 15, 2024
6b41c4d
source flux : csv with table
arng40 Oct 15, 2024
74cc10d
Merge remote-tracking branch 'origin/develop' into feature/dudes/stat…
arng40 Oct 15, 2024
1d1bc80
[unfinished] doxygen
arng40 Oct 15, 2024
a906453
logLevel for sourceflux stats
arng40 Oct 16, 2024
33e3be1
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Oct 17, 2024
6583325
update layout constructor
arng40 Oct 17, 2024
61ffd56
update tableLayout declaration
arng40 Oct 17, 2024
a2a7273
renaming, doxygen, small simpl
arng40 Oct 17, 2024
adb8dc0
missing doc
arng40 Oct 17, 2024
e8688c4
add table separator
arng40 Oct 17, 2024
6c06d4d
remove unacessary code
arng40 Oct 17, 2024
859f359
[DRAFT] SinglePhase & CompStats
arng40 Oct 17, 2024
e15df11
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Oct 18, 2024
b0d731a
xsd
arng40 Oct 21, 2024
f27c101
Delete src/coreComponents/schema/schema.xsd
arng40 Oct 21, 2024
3acc8a1
xsd regenrate
arng40 Oct 21, 2024
76a022c
test ci fix
arng40 Oct 21, 2024
9c1379f
update output domain partition (fix ci)
arng40 Oct 21, 2024
2fafae3
some renaming
arng40 Oct 21, 2024
cb26312
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Oct 23, 2024
346d8dc
remove unnecessary code
arng40 Oct 23, 2024
cabdbcb
doc
arng40 Oct 28, 2024
e1c88c5
[DRAFT] solidmecanics log
arng40 Oct 29, 2024
c388b42
xsd
arng40 Oct 29, 2024
43f9664
missing const
arng40 Oct 29, 2024
2300686
renaming & signature & const
arng40 Oct 29, 2024
e1af681
improve populate table values
arng40 Oct 30, 2024
b87cee9
renaming, some function refactoring & simplification
arng40 Oct 30, 2024
8ea7e56
cout removed, assert added, doc update
arng40 Oct 31, 2024
e893ac7
move assert
arng40 Oct 31, 2024
e77ea50
add idx...
arng40 Oct 31, 2024
ac61e5d
replace string vector on ColumnStructure
arng40 Nov 5, 2024
d81654c
remove code / doc
arng40 Nov 6, 2024
e56d538
add assert for transporse
arng40 Nov 7, 2024
6332366
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Nov 8, 2024
d8ea06b
.
arng40 Nov 8, 2024
aee27da
Merge remote-tracking branch 'origin/develop' into feature/dudes/stat…
arng40 Nov 8, 2024
8a82f3a
Merge remote-tracking branch 'origin/table-subs-division' into featur…
arng40 Nov 8, 2024
73e741a
[DRAFT] first step for adding special cell
arng40 Nov 13, 2024
b01a8b0
first step refacto ( adding cell structure )
arng40 Nov 15, 2024
9740383
next step of refact
arng40 Nov 15, 2024
a92c84c
[DRAFT] test almost works
arng40 Nov 18, 2024
765b60a
[DRAFT] refacto ( remove method + renaming var + adding Datype file )
arng40 Nov 19, 2024
a27221b
refactor guidelines
MelReyCG Nov 19, 2024
76f4be6
simplify comp
arng40 Nov 20, 2024
754fbc2
Merge branch 'feature/dudes/statistics-log-csv-outpout' of https://gi…
arng40 Nov 20, 2024
c2a3af8
[DRAFT] 1st impact on formatter
arng40 Nov 20, 2024
24cd707
adapting find max string
arng40 Nov 21, 2024
9cd1e36
[DRAFT] refacto
arng40 Nov 21, 2024
0dfe2f7
iterator + update formatter
arng40 Nov 25, 2024
4830935
remove unecessary parameters & some simpl
arng40 Nov 26, 2024
fa1f101
code debug
arng40 Nov 27, 2024
01f447e
Almost all test compile and display correctly
arng40 Dec 2, 2024
8db6a95
doxygen/ renaming
arng40 Dec 2, 2024
27e7b75
1st version with merging
arng40 Dec 4, 2024
2494e7c
continue on merging with example updated
arng40 Dec 4, 2024
3fcb33b
ternary add
arng40 Dec 4, 2024
7f0deeb
revert ternary
arng40 Dec 4, 2024
71e1c59
all merging tests
arng40 Dec 5, 2024
4ce682c
tests fix
arng40 Dec 5, 2024
b5af77b
example updated
arng40 Dec 5, 2024
a0d0785
Merge remote-tracking branch 'origin/develop' into feature/dudes/stat…
arng40 Dec 5, 2024
1002441
improve structure
arng40 Dec 6, 2024
bfce67f
fix merge
arng40 Dec 6, 2024
0a0371e
minor adjust
arng40 Dec 6, 2024
b2394b7
remove func
arng40 Dec 6, 2024
4030629
add const, remove topSeparator, csv opti
arng40 Dec 9, 2024
9d6aab9
merged row updated + multiphase case updated
arng40 Dec 16, 2024
a370232
variable renamed
arng40 Dec 16, 2024
68decb5
add doc, remove unacessary fun/variable
arng40 Dec 16, 2024
c1a2f06
renaming and doc adjustemnt
arng40 Dec 16, 2024
d9cbe2c
update
arng40 Dec 16, 2024
3d16eff
Merge remote-tracking branch 'origin/develop' into feature/dudes/stat…
arng40 Dec 16, 2024
0c6ea97
missing doc
arng40 Dec 16, 2024
b23bcf3
remove error managemennt, correct whitespace
arng40 Dec 16, 2024
6b024b4
fix errormsg
arng40 Dec 17, 2024
e40b0df
test corrections + fix bug, remove line return
arng40 Dec 17, 2024
7d5a2c6
reorganize outputLines function
arng40 Dec 18, 2024
ace83f4
add doc, remove useless code
arng40 Dec 18, 2024
95161a6
tautological-overlap-compare fix
arng40 Dec 18, 2024
c6840ca
missing doc
arng40 Dec 19, 2024
61f5ac7
totalSA -> TE + csv test
arng40 Dec 19, 2024
07d748c
Merge branch 'develop' into feature/dudes/statistics-log-csv-outpout
rrsettgast Dec 19, 2024
26aa062
Correction bug table + renaming
arng40 Dec 20, 2024
9825177
Merge branch 'feature/dudes/statistics-log-csv-outpout' of https://gi…
arng40 Dec 20, 2024
6120818
renaming
arng40 Dec 20, 2024
e5fd8f5
constness
arng40 Dec 23, 2024
6295cbd
rework output comp stats
arng40 Dec 23, 2024
b1f0e35
cosntness & duplicate code
arng40 Jan 6, 2025
cb3cb9b
readonly fix
arng40 Jan 6, 2025
4fbd3c8
sort logLevel in hpp
arng40 Jan 6, 2025
6b4d8fe
remvoe unecessary variable
arng40 Jan 6, 2025
a185765
rename
arng40 Jan 6, 2025
0db66ab
remove unused code
arng40 Jan 7, 2025
c717f05
Merge remote-tracking branch 'origin/develop' into feature/dudes/stat…
arng40 Jan 7, 2025
5c78358
renaming and & improve doc
arng40 Jan 9, 2025
25722b3
remove unused label
arng40 Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
name="statistics"
forceDt="1e6"
target="/Tasks/compflowStatistics"/>
<PeriodicEvent name="timestepStatsEvent"
timeFrequency="4.32e6"
target="/Tasks/testLogStats" />
</Events>

<NumericalMethods>
Expand Down Expand Up @@ -173,7 +176,10 @@
objectPath="ElementRegions/injectionWell"
component="0"
scale="-0.0887"
setNames="{ source }"/>
setNames="{ source }"
/>


<!-- SPHINX_SOURCE_BC_END -->

<!-- SPHINX_DIRICHLET_BC -->
Expand Down Expand Up @@ -361,6 +367,11 @@
logLevel="1"
computeCFLNumbers="1"
computeRegionStatistics="1"/>
<SourceFluxStatistics
name="testLogStats"
flowSolverName="compflow"
logLevel="1"
/>
</Tasks>

</Problem>
42 changes: 19 additions & 23 deletions src/coreComponents/common/format/table/TableData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,38 @@
*/

#include "TableData.hpp"
#include "common/logger/Logger.hpp"

namespace geos
{

void TableData::addRow( std::vector< string > const & row )
void TableData::addRow( std::vector< TableData::CellData > const & row )
{
if( m_rows.size() != 0 && row.size() != m_rows[m_rows.size() - 1].size() )
m_rows.push_back( row );
}

void TableData::addSeparator()
{
if( m_rows.empty())
{
string msg = "Remarks : some cells may be missing";
if( std::find( m_errorsMsg.begin(), m_errorsMsg.end(), msg ) == m_errorsMsg.end())
{
m_errorsMsg.push_back( msg );
}
GEOS_ERROR( "You must have filled values in TableData before using addSeparator()" );
}
m_rows.push_back( row );

integer rowSize = m_rows[0].size();
m_rows.emplace_back( std::vector< TableData::CellData >( rowSize, { CellType::Separator, "-" } ));

}

void TableData::clear()
{
m_rows.clear();
m_errorsMsg.clear();
}

std::vector< std::vector< string > > const & TableData::getTableDataRows() const
std::vector< std::vector< TableData::CellData > > const & TableData::getTableDataRows() const
{
return m_rows;
}

std::vector< string > const & TableData::getErrorMsgs() const
{
return m_errorsMsg;
}

void TableData2D::collectTableValues( arraySlice1d< real64 const > rowAxisValues,
arraySlice1d< real64 const > columnAxisValues,
arrayView1d< real64 const > values )
Expand All @@ -75,7 +74,6 @@ TableData2D::TableDataHolder TableData2D::convertTable2D( arrayView1d< real64 co
{
string const rowFmt = GEOS_FMT( "{} = {{}}", rowAxisDescription );
string const columnFmt = GEOS_FMT( "{} = {{}}", columnAxisDescription );

collectTableValues( coordinates[0], coordinates[1], values );
return buildTableData( string( units::getDescription( valueUnit )),
rowFmt,
Expand All @@ -87,7 +85,6 @@ TableData2D::TableDataHolder TableData2D::buildTableData( string_view targetUnit
string_view columnFmt ) const
{
TableData2D::TableDataHolder tableData1D;
std::vector< size_t > rowsLength;

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

Expand All @@ -99,23 +96,22 @@ TableData2D::TableDataHolder TableData2D::buildTableData( string_view targetUnit
// insert row value and row cell values
for( auto const & [rowValue, rowMap] : m_data )
{
std::vector< string > currentRowValues;
std::vector< TableData::CellData > currentRowValues;
currentRowValues.reserve( rowMap.size() );
currentRowValues.push_back( GEOS_FMT( rowFmt, rowValue ) );
currentRowValues.push_back( {CellType::Value, GEOS_FMT( rowFmt, rowValue )} );

std::set< real64 >::const_iterator columnIt = m_columnValues.begin();
for( auto const & [columnValue, cellValue] : rowMap )
{
// if a column value(s) is/are missing, insert empty entry(ies)
while( columnValue > *( columnIt++ ) && columnIt != m_columnValues.end() )
{
currentRowValues.push_back( "" );
currentRowValues.push_back( {CellType::Value, ""} );
}
currentRowValues.push_back( GEOS_FMT( "{}", cellValue ) );
currentRowValues.push_back( {CellType::Value, GEOS_FMT( "{}", cellValue )} );
}

tableData1D.tableData.addRow( std::move( currentRowValues ) );
rowsLength.push_back( currentRowValues.size() );
tableData1D.tableData.addRow( currentRowValues );
}

return tableData1D;
Expand Down
62 changes: 48 additions & 14 deletions src/coreComponents/common/format/table/TableData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "common/Units.hpp"
#include "common/DataTypes.hpp"
#include "common/format/Format.hpp"
#include "TableTypes.hpp"

namespace geos
{
Expand All @@ -33,10 +34,22 @@ namespace geos
class TableData
{
public:

/**
* @brief Representing a data in TableData
*/
struct CellData
{
/// The cell type
CellType type;
/// The cell value
string value = "";
};

/**
* @brief Add a row to the table.
* The values passed to addRow (can be any type).
* @param args Cell values to be added to the row.
* @param args CellData values to be added to the row.
*/
template< typename ... Args >
void addRow( Args const & ... args );
Expand All @@ -45,7 +58,13 @@ class TableData
* @brief Add a row to the table
* @param row A vector of string representing a row
*/
void addRow( std::vector< string > const & row );
void addRow( std::vector< CellData > const & row );

/**
* @brief Add a line separator to the table
* You must have filled values in TableData before using it
*/
void addSeparator();

/**
* @brief Reset data in the table
Expand All @@ -55,7 +74,7 @@ class TableData
/**
* @return The rows of the table
*/
std::vector< std::vector< string > > const & getTableDataRows() const;
std::vector< std::vector< CellData > > const & getTableDataRows() const;

/**
* @brief Get all error messages
Expand All @@ -66,10 +85,7 @@ class TableData
private:

/// vector containing all rows with cell values
std::vector< std::vector< string > > m_rows;

/// store error if there are any inconsistencies related to the table
std::vector< string > m_errorsMsg;
std::vector< std::vector< CellData > > m_rows;

};

Expand Down Expand Up @@ -98,7 +114,7 @@ class TableData2D
/**
* @brief Add a cell to the table. If necessary, create automatically the containing column & row.
* @tparam T The value passed to addCell (can be any type).
* @param value Cell value to be added.
* @param value CellData value to be added.
* @param rowValue The value of the row containing the cell.
* @param columnValue The value of the column containing the cell.
*/
Expand Down Expand Up @@ -149,17 +165,35 @@ class TableData2D
std::set< real64 > m_columnValues;
};

/**
* @brief Trait to check is the args is a special type of cell
* @tparam T The type of a cell
*/
template< typename T >
constexpr bool isCellType = std::is_same_v< T, CellType >;

template< typename ... Args >
void TableData::addRow( Args const &... args )
{
std::vector< string > m_cellsValue;
std::vector< CellData > cells;
( [&] {
static_assert( has_formatter_v< decltype(args) >, "Argument passed in addRow cannot be converted to string" );
string const cellValue = GEOS_FMT( "{}", args );
m_cellsValue.push_back( cellValue );
static_assert( has_formatter_v< decltype(args) > || isCellType< std::decay_t< decltype(args) > >, "Argument passed in addRow cannot be converted to string nor a CellType" );
if constexpr (std::is_same_v< Args, CellType >) {
if( args == CellType::Separator )
{
cells.push_back( {CellType::Separator} );
}
else
{
cells.push_back( {CellType::MergeNext} );
}
}
else
{
cells.push_back( {CellType::Value, GEOS_FMT( "{}", args )} );
}
} (), ...);

addRow( m_cellsValue );
addRow( cells );
}

template< typename T >
Expand Down
Loading
Loading