Skip to content

Commit

Permalink
missing doc
Browse files Browse the repository at this point in the history
  • Loading branch information
arng40 committed Dec 16, 2024
1 parent 3d16eff commit 0c6ea97
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 21 deletions.
9 changes: 9 additions & 0 deletions src/coreComponents/common/format/table/TableData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ class TableData
{
public:

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

Expand Down Expand Up @@ -163,6 +168,10 @@ 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 >;

Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/common/format/table/TableFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2024 TotalEnergies
* Copyright (c) 2018-2024 Total, S.A
* Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2023-2024 Chevron
* Copyright (c) 2019- GEOS/GEOSX Contributors
Expand Down Expand Up @@ -237,8 +237,8 @@ void TableTextFormatter::setLinks( std::vector< TableLayout::Column > & columns
void TableTextFormatter::populateHeaderCellsLayout( TableLayout & tableLayout,
CellLayoutRows & cellsHeaderLayout ) const
{
cellsHeaderLayout.resize( tableLayout.getMaxHeaderRow() );
size_t const headerLayersCount = tableLayout.getMaxHeaderRow();
cellsHeaderLayout.resize( tableLayout.getMaxDepth() );
size_t const headerLayersCount = tableLayout.getMaxDepth();
std::vector< size_t > & sublineHeaderCounts = tableLayout.getSublineInHeaderCounts();
sublineHeaderCounts.resize( headerLayersCount, 1 );

Expand Down
3 changes: 3 additions & 0 deletions src/coreComponents/common/format/table/TableFormatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class TableFormatter
{

public:
/// Represent the TableData values
using RowsCellInput = std::vector< std::vector< TableData::CellData > >;
/// Represent the Table (header or values) structured
using CellLayoutRows = std::vector< std::vector< TableLayout::CellLayout > >;


Expand Down Expand Up @@ -79,6 +81,7 @@ class TableCSVFormatter : public TableFormatter

/**
* @brief Convert the table data to a CSV string..
* @param tableData The table data
* @return The CSV string representation of the table data.
*/
string dataToString( TableData const & tableData ) const;
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/common/format/table/TableLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ TableLayout & TableLayout::setMargin( MarginValue marginValue )
bool TableLayout::isLineBreakEnabled() const
{ return m_wrapLine; }

size_t TableLayout::getMaxHeaderRow() const
size_t TableLayout::getMaxDepth() const
{
size_t depthMax = 1;
size_t currDepth = 1;
Expand Down
36 changes: 25 additions & 11 deletions src/coreComponents/common/format/table/TableLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,36 @@ class TableLayout

/**
* @brief Constructor to initialize a column with a specific `CellLayout`.
* @param cell The `CellLayout` object to initialize the column.
* @param cellLayout The `CellLayout` object to initialize the column.
*
*/
Column( TableLayout::CellLayout cellLayout );

/**
* @brief Get the parent column.
* @return Pointer to the parent column, or `nullptr` if no parent is set.
*/
Column * getParent()
{ return m_parent; }

/**
* @brief Set the parent column.
* @param parent Pointer to the parent column to set.
*/
void setParent( Column * parent )
{ m_parent = parent; }

/**
* @brief GGet the next column in the layout.
* @return Pointer to the next column or `nullptr` if no next column exists.
*/
Column * getNextCell()
{ return m_next; }

/**
* @brief Set the next column in the layout.
* @param nextCell The next column in the table layout.
*/
void setNextCell( Column * nextCell )
{ m_next = nextCell; }

Expand All @@ -142,13 +158,14 @@ class TableLayout

/**
* @brief Set the column visibility.
* @param CellType Cell type to apply to hide the colmun
* @return The current column .
*/
Column & setVisibility( CellType celltype );

/**
* @brief Adds multiple sub-columns to the column.
* @param subColName A list of sub-column names to add.
* @param subCol A list of sub-column names to add.
* @return The current column object
*/
TableLayout::Column & addSubColumns( std::initializer_list< TableLayout::Column > subCol );
Expand Down Expand Up @@ -237,7 +254,7 @@ class TableLayout

/**
* @brief Copy assignment operator
* @param[in] source Coulmn to copy
* @param[in] columnPtr Coulmn to copy
* @return Leaf iterator
*/
LeafIterator & operator=( Column * columnPtr )
Expand Down Expand Up @@ -357,12 +374,6 @@ class TableLayout
return LeafIterator( nullptr, 0 );
}

struct Row
{
// maximum number of lines among the cells of a given row
size_t maxLineCount; // TODO : Assigner cette stat
};

/// Alias for an initializer list of variants that can contain either a string or a layout column.
using TableLayoutArgs = std::initializer_list< std::variant< string_view, TableLayout::Column > >;

Expand Down Expand Up @@ -421,7 +432,11 @@ class TableLayout
addToColumns( args );
}

size_t getMaxHeaderRow() const;
/**
* @brief Get the max depth of a column
* @return The max column depth
*/
size_t getMaxDepth() const;

/**
* @return The columns vector
Expand Down Expand Up @@ -552,7 +567,6 @@ class TableLayout
/// Contains the subdivision (line) counts for each line in data.
std::vector< size_t > m_sublineDataCounts;
bool m_wrapLine = true;
bool m_containSubColumn = false;

string m_tableTitle;

Expand Down
3 changes: 3 additions & 0 deletions src/coreComponents/common/format/table/TableTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
namespace geos
{

/**
* @brief The different type a cell can handle
*/
enum class CellType : integer
{
Header,
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/mesh/DomainPartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void DomainPartition::outputPartitionInformation() const
TableLayout::Column()
.setName( "Elems" )
.addSubColumns( { "Locales", "Ghost" } )} );
// layoutPartition.setMargin( TableLayout::MarginValue::large ).disableLineBreak();
// layoutPartition.setMargin( TableLayout::MarginValue::large ).disableLineBreak();

TableData dataPartition;
dataPartition.addRow( "min",
Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/physicsSolvers/fluidFlow/LogLevelsInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ struct Statistics

struct sourceFluxRegionsStatistics
{
static constexpr int getMinLogLevel() { return 3; }
static constexpr int getMinLogLevel() { return 3; }
static constexpr std::string_view getDescription() { return "Print source flux statistics for each regions "; }
};

struct sourceFluxStatistics
{
static constexpr int getMinLogLevel() { return 2; }
static constexpr int getMinLogLevel() { return 2; }
static constexpr std::string_view getDescription() { return "Print source flux statistics for each flux in a mesh"; }
};

struct sourceFluxMeshStatistics
{
static constexpr int getMinLogLevel() { return 1; }
static constexpr int getMinLogLevel() { return 1; }
static constexpr std::string_view getDescription() { return "Print source flux statistics resulting from all flux in a mesh"; }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void SinglePhaseStatistics::computeRegionStatistics( real64 const time,

singPhaseStatsData.addRow( "Total dynamic pore volume [rm^3]", "all", CellType::MergeNext, stats.totalPoreVolume );
singPhaseStatsData.addSeparator();
singPhaseStatsData.addRow( GEOS_FMT("Total fluid mass [{}]", massUnit), "all", CellType::MergeNext, stats.totalMass );
singPhaseStatsData.addRow( GEOS_FMT( "Total fluid mass [{}]", massUnit ), "all", CellType::MergeNext, stats.totalMass );

string const title = GEOS_FMT( "{}, {} (time {} s):", getName(), regionNames[i], time );
TableLayout const singPhaseStatsLayout( title, { "statistics", "min", "average", "max" } );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void SourceFluxStatsAggregator::outputStatsToLog( bool logLevelActive, string_vi
{
m_logLayout.setTitle( GEOS_FMT( "Source flux statistics in {}", elementSetName ));
TableTextFormatter const tableStatFormatter( m_logLayout );
GEOS_LOG_RANK( tableStatFormatter.toString( tableMeshData ) );
GEOS_LOG_RANK( tableStatFormatter.toString( tableMeshData ) );
}
}
void SourceFluxStatsAggregator::outputStatsToCSV( string_array const & filenames, TableData & csvData )
Expand Down

0 comments on commit 0c6ea97

Please sign in to comment.