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

[DRAFT] Refactor log & CSV statistics #3406

Draft
wants to merge 285 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
285 commits
Select commit Hold shift + click to select a range
f5251f5
uncrustify + perfo example addded
arng40 Mar 11, 2024
1bec18e
update test + margin correction
arng40 Mar 11, 2024
1e45501
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Mar 11, 2024
288f79e
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Mar 12, 2024
2054bd4
added Formatter function, correction on TableData
arng40 Mar 12, 2024
37e18b4
Delete table..cpp/hpp
arng40 Mar 12, 2024
5ff7c68
small correction
arng40 Mar 12, 2024
b360a16
doc updated
arng40 Mar 13, 2024
dd5f42f
TableData2D small refacto + opti
arng40 Mar 13, 2024
16b4ded
first update for log in table function
arng40 Mar 13, 2024
e8e89c2
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Mar 13, 2024
769beab
uncrustify + small correction
arng40 Mar 13, 2024
5fa478c
csv format / function correction
arng40 Mar 13, 2024
85494c7
remove dataToString with 2D table parameter
arng40 Mar 13, 2024
46e8d23
code opti
arng40 Mar 13, 2024
c1ba824
add 2D table test
arng40 Mar 13, 2024
14ea4f5
uncrustify
arng40 Mar 13, 2024
1271875
Alignment::middle by center and compile time verifcation added
arng40 Mar 14, 2024
d39fa00
PR review
arng40 Mar 14, 2024
c58be1e
2nd wave of pr review
arng40 Mar 14, 2024
1d4bdb4
update compile time verification for table value
arng40 Mar 15, 2024
0bff847
some update
arng40 Mar 15, 2024
8553441
pvt_log updated
arng40 Mar 15, 2024
7005d57
Merge remote-tracking branch 'origin/feature/dudes/table-layout' into…
arng40 Mar 15, 2024
22b16e9
update pvt log
arng40 Mar 15, 2024
429920c
add missing doc + uncrustify
arng40 Mar 15, 2024
965a972
constness update + refacto on text formatter
arng40 Mar 18, 2024
6e49ebc
PR correction
arng40 Mar 18, 2024
c1fb3dd
move has_formatter to format.hpp, doc correction
arng40 Mar 19, 2024
e0c6ca2
log level correction
arng40 Mar 19, 2024
7221c0f
perfo log correctly displayed
arng40 Mar 20, 2024
82098d8
remove ; to scope bracket
arng40 Mar 21, 2024
75ed072
doc correction format.hpp
arng40 Mar 21, 2024
3469920
format.hpp doc
arng40 Mar 21, 2024
052f1fa
last correction
arng40 Mar 21, 2024
fae723e
Merge remote-tracking branch 'origin/develop' into feature/dudes/tabl…
arng40 Mar 21, 2024
838f36e
cmake fix
arng40 Mar 25, 2024
1139117
test return string
arng40 Mar 25, 2024
13a6d09
fix hpp
arng40 Mar 25, 2024
cfeec17
fix error with string_view
arng40 Mar 25, 2024
f735cd1
uncrustify
arng40 Mar 25, 2024
755805a
Correction melvin PR
arng40 Mar 26, 2024
6264d87
correction review PR
arng40 Mar 27, 2024
21021c7
setMargin private
arng40 Mar 27, 2024
3a34e27
uncrustify
arng40 Mar 27, 2024
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
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>
38 changes: 26 additions & 12 deletions src/coreComponents/common/format/table/TableData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,35 @@
*/

#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 > & cells )
{
if( m_rows.size() != 0 && row.size() != m_rows[m_rows.size() - 1].size() )
if( m_rows.size() != 0 && cells.size() != m_rows[m_rows.size() - 1].size() )
{
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 );
}
}
m_rows.push_back( row );

m_rows.push_back( cells );
}

void TableData::addSeparator()
{
if( m_rows.empty())
{
GEOS_ERROR( "You must have filled values in TableData before using addSeparator()" );
}

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

}

void TableData::clear()
Expand All @@ -41,7 +55,7 @@ void TableData::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;
}
Expand All @@ -65,6 +79,7 @@ void TableData2D::collectTableValues( arraySlice1d< real64 const > rowAxisValues
addCell( rowAxisValues[i], columnAxisValues[y], values[ y*nX + i ] );
}
}
std::cout <<" casse pas collectTableValues\n";
}

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

std::cout <<" casse pas convertTable2D\n";
collectTableValues( coordinates[0], coordinates[1], values );
return buildTableData( string( units::getDescription( valueUnit )),
rowFmt,
Expand All @@ -87,7 +102,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,24 +113,24 @@ 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 );
}
std::cout <<" casse pas buildTableData\n";

return tableData1D;
}
Expand Down
50 changes: 39 additions & 11 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,17 @@ namespace geos
class TableData
{
public:

struct CellData
{
CellType type;
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 +53,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 > & 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 +69,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,7 +80,7 @@ class TableData
private:

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

/// store error if there are any inconsistencies related to the table
std::vector< string > m_errorsMsg;
Expand Down Expand Up @@ -98,7 +112,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 +163,31 @@ class TableData2D
std::set< real64 > m_columnValues;
};

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< 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::Merge, " "} );
}
}
else
{
cells.push_back( {CellType::Value, GEOS_FMT( "{}", args )} );
}
} (), ...);

addRow( m_cellsValue );
addRow( cells );
}

template< typename T >
Expand Down
Loading