Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/coreComponents/codingUtilities/tests/testParsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ParsingTest : public ::testing::TestWithParam< T >
{
protected:

static constexpr std::array< char, 4 > const separators = { ' ', ',', '\n', ';' };
static constexpr geos::stdArray< char, 4 > const separators = { ' ', ',', '\n', ';' };

static bool issep( char const c )
{
Expand Down Expand Up @@ -147,7 +147,7 @@ class ParsingTest : public ::testing::TestWithParam< T >
};

template< typename T >
std::array< char, 4 > const ParsingTest< T >::separators;
geos::stdArray< char, 4 > const ParsingTest< T >::separators;

using Types = ::testing::Types<
float,
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/common/MemoryInfos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void MemoryLogging::memoryStatsReport() const
MPI_Comm_size( MPI_COMM_WORLD, &size );
size_t nbRank = (std::size_t)size;
// Get a list of all the allocators and sort it so that it's in the same order on each rank.
std::vector< string > allocatorNames = rm.getAllocatorNames();
stdVector< string > allocatorNames = rm.getAllocatorNames();
std::sort( allocatorNames.begin(), allocatorNames.end() );

// If each rank doesn't have the same number of allocators you can't aggregate them.
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/common/MpiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ int MpiWrapper::nodeCommSize()
return 1;

int len;
std::array< char, MPI_MAX_PROCESSOR_NAME + 1 > hostname;
stdArray< char, MPI_MAX_PROCESSOR_NAME + 1 > hostname;
MPI_Get_processor_name( hostname.data(), &len );
hostname[len] = '\0';
hostname.at(len) = '\0';
int color = (int)std::hash< string >{} (hostname.data());
if( color < 0 )
color *= -1;
Expand Down
50 changes: 50 additions & 0 deletions src/coreComponents/common/StdContainerWrappers.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef GEOS_COMMON_STD_CONTAINER_WRAPPERS_HPP
#define GEOS_COMMON_STD_CONTAINER_WRAPPERS_HPP

#include <array>
#include <cstddef>
#include <array>
#include <cstddef>
#include <vector>
Expand Down Expand Up @@ -462,4 +464,52 @@ constexpr stdArray< T, N > to_stdArray( std::array< T, N > const & arr )

} // namespace geos

/**
* @namespace std
* @brief Partial specialization for stdArray.
* Those specialization serve to use geos::stdArray as tuples.
*/
namespace std
{

/**
* @brief Provides access to the number of elements in a tuple as a compile-time constant expression.
* @tparam T Type of elements in stdArray
* @tparam N The number of fixed element in the array
*/
template< typename T, size_t N >
struct tuple_size< geos::stdArray< T, N > >
: public integral_constant< size_t, N > { };

/**
* @brief Provides compile-time indexed access to the types of the elements of the tuple.
* @tparam Ind The index element of the tuple to access
* @tparam Tp Type of elements in stdArray
* @tparam Nm The number of fixed element in the array
*/
template< size_t Ind, typename Tp, size_t Nm >
struct tuple_element< Ind, geos::stdArray< Tp, Nm > >
{
static_assert( Ind < Nm, "array index is in range" );
using type = Tp;
};

#if __cplusplus >= 201703L
/**
* @brief Helper variable template
* @tparam Tp Type of elements in stdArray
* @tparam Nm The number of fixed element in the array
*/
template< typename Tp, size_t Nm >
inline constexpr size_t tuple_size_v< geos::stdArray< Tp, Nm > > = Nm;

template< typename Tp, size_t Nm >
inline constexpr size_t tuple_size_v< const geos::stdArray< Tp, Nm > > = Nm;
#endif

template< typename Tp, size_t Nm >
struct __is_tuple_like_impl< geos::stdArray< Tp, Nm > > : true_type
{ };
}

#endif /* GEOS_COMMON_STD_CONTAINER_WRAPPERS_HPP */
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 @@ -200,7 +200,7 @@ string TableCSVFormatter::toString< TableData >( TableData const & tableData ) c
{
if( tableData.getErrorsList().hasErrors() )
{
std::vector< string > cpyErrors = tableData.getErrorsList().getErrors();
stdVector< string > cpyErrors = tableData.getErrorsList().getErrors();
getErrorsList().appendErrors( cpyErrors );
}

Expand Down Expand Up @@ -518,7 +518,7 @@ void TableTextFormatter::populateErrorCellsLayout( PreparedTableLayout const & t
{
errorCellsLayout.push_back(
{
std::vector< TableLayout::CellLayout >( nbCells,
stdVector< TableLayout::CellLayout >( nbCells,
TableLayout::CellLayout( CellType::MergeNext ) ),
1 // subLines count
} );
Expand All @@ -531,7 +531,7 @@ void TableTextFormatter::populateErrorCellsLayout( PreparedTableLayout const & t

errorCellsLayout.push_back(
{
std::vector< TableLayout::CellLayout >( nbCells,
stdVector< TableLayout::CellLayout >( nbCells,
TableLayout::CellLayout( CellType::Separator ) ),
1 // subLines count
} );
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/common/format/table/TableLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class TableLayout
/**
* @return The view on each cell line.
*/
std::vector< string_view > & getLines()
stdVector< string_view > & getLines()
{ return m_lines; }

/**
Expand Down
10 changes: 5 additions & 5 deletions src/coreComponents/common/format/table/TableTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TableErrorListing
void clear();

/// The iterator alias for the errors vector of string
using Iterator = std::vector< string >::const_iterator;
using Iterator = stdVector< string >::const_iterator;

/**
* @return An Iterator pointing to the first element of the errors vector
Expand All @@ -80,24 +80,24 @@ class TableErrorListing
* @brief Append a vector of string to the errors vector.
* @param errors A vector of string to append
*/
void appendErrors( std::vector< string > & errors )
void appendErrors( stdVector< string > & errors )
{ m_errorList.insert( m_errorList.end(), errors.begin(), errors.end() );}

/**
* @return A const reference to the errors vector.
*/
std::vector< string > const & getErrors() const
stdVector< string > const & getErrors() const
{ return m_errorList; }

/**
* @return A reference to the errors vector.
*/
std::vector< string > & getErrors()
stdVector< string > & getErrors()
{ return m_errorList; }

private:
/// Contain all the errors to display at the end of the table
std::vector< string > m_errorList;
stdVector< string > m_errorList;
};

inline void TableErrorListing::addError( string_view text )
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/constitutive/ConstitutiveBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class ConstitutiveBase : public dataRepository::Group
/**
* @return A const vector containing all fields
*/
std::vector< std::string > const & getUserFields() const
stdVector< std::string > const & getUserFields() const
{
return m_userFields;
}
Expand All @@ -189,7 +189,7 @@ class ConstitutiveBase : public dataRepository::Group
bool m_isClone;

// Vector containing all fields registered with `registerField()`
std::vector< std::string > m_userFields;
stdVector< std::string > m_userFields;
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ bool KValueFlashParameters< NUM_PHASE >::validateKValues( MultiFluidBase const *

if( !tableData.getTableDataRows().empty())
{
std::vector< TableLayout::Column > columns;
stdVector< TableLayout::Column > columns;
columns.emplace_back( TableLayout::Column().setName( "Phase" ).setValuesAlignment( TableLayout::Alignment::left ) );
columns.emplace_back( TableLayout::Column().setName( "Pressure" ).setValuesAlignment( TableLayout::Alignment::right ) );
columns.emplace_back( TableLayout::Column().setName( "Temperature" ).setValuesAlignment( TableLayout::Alignment::right ) );
Expand Down
6 changes: 3 additions & 3 deletions src/coreComponents/constitutive/unitTests/TestFluid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct Fluid

static constexpr integer NP = 6; // Number of properties

static constexpr std::array<real64,84> data = {
static constexpr stdArray<real64,84> data = {
// Mw Pc Tc Vc Ac Pr Name
1.80153e-02, 2.20640e+07, 6.47096e+02, 5.59480e-05, 3.44300e-01, 9.36563e-06, // H2O (water)
4.40095e-02, 7.37730e+06, 3.04128e+02, 9.41185e-05, 2.23940e-01, 7.37268e-06, // CO2 (carbon dioxide)
Expand All @@ -83,15 +83,15 @@ struct Fluid
};

template< int NC >
using Feed = std::array< real64, NC >;
using Feed = stdArray< real64, NC >;

template< int NC >
class TestFluid
{
public:
~TestFluid() = default;

static std::unique_ptr< TestFluid< NC > > create( std::array< integer, NC > const & components )
static std::unique_ptr< TestFluid< NC > > create( stdArray< integer, NC > const & components )
{
std::unique_ptr< TestFluid< NC > > testFluid( new TestFluid() );
for( integer const ic : components )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct FluidData< 9 >
static std::unique_ptr< TestFluid< 9 > > createFluid()
{
auto fluid = TestFluid< 9 >::create( {Fluid::H2O, Fluid::CO2, Fluid::N2, Fluid::CH4, Fluid::C2H6, Fluid::C3H8, Fluid::C4H10, Fluid::C5H12, Fluid::C10H22} );
const std::array< real64 const, 36 > bics = {
const stdArray< real64 const, 36 > bics = {
0.01, 0, 0.003732, 0, 0.01, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0.01, 0, 0.028, 0.01, 0.01, 0, 0, 0.01, 0, 0.04532, 0.01, 0.01, 0, 0, 0
};
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/constitutive/unitTests/testCubicEOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct FluidData< 2 >
return fluid;
}

static std::array< Feed< 2 >, 3 > constexpr feeds = {
static stdArray< Feed< 2 >, 3 > constexpr feeds = {
Feed< 2 >{0.995, 0.005},
Feed< 2 >{0.990, 0.010},
Feed< 2 >{0.100, 0.900}
Expand All @@ -57,7 +57,7 @@ struct FluidData< 4 >
return fluid;
}

static std::array< Feed< 4 >, 4 > constexpr feeds = {
static stdArray< Feed< 4 >, 4 > constexpr feeds = {
Feed< 4 >{0.030933, 0.319683, 0.637861, 0.011523},
Feed< 4 >{0.000000, 0.349686, 0.637891, 0.012423},
Feed< 4 >{0.000000, 0.349686, 0.650314, 0.000000},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct FluidData< 3 >
static std::unique_ptr< TestFluid< 3 > > createFluid()
{
auto fluid = TestFluid< 3 >::create( {Fluid::CH4, Fluid::C10H22, Fluid::H2O} );
const std::array< real64 const, 3 > bics = { 0.25, 0.0, 0.0 };
const stdArray< real64 const, 3 > bics = { 0.25, 0.0, 0.0 };
fluid->setBinaryCoefficients( bics );
return fluid;
}
Expand All @@ -69,9 +69,9 @@ struct FluidData< 9 >
static std::unique_ptr< TestFluid< 9 > > createFluid()
{
auto fluid = TestFluid< 9 >::create( {Fluid::H2O, Fluid::CO2, Fluid::N2, Fluid::C5H12, Fluid::C2H6, Fluid::C3H8, Fluid::C4H10, Fluid::C5H12, Fluid::C10H22} );
const std::array< real64 const, 36 > bics = {
const stdArray< real64, 36 > bics = {
0.01, 0, 0.003732, 0, 0.01, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0.01, 0, 0.028, 0.01, 0.01, 0, 0, 0.01, 0, 0.04532, 0.01, 0.01, 0, 0, 0
0, 0, 0, 0.01, 0, 0.028, 0.01, 0.01, 0, 0, 0.01, 0, 0.04532, 0.01, 0.01, 0, 0, 0
};
fluid->setBinaryCoefficients( bics );
return fluid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct FluidData< 3 >
static std::unique_ptr< TestFluid< 3 > > createFluid()
{
auto fluid = TestFluid< 3 >::create( {Fluid::CH4, Fluid::C10H22, Fluid::H2O} );
std::array< real64, 3 > const bics = {0.25, 0.0, 0.0};
stdArray< real64, 3 > const bics = {0.25, 0.0, 0.0};
fluid->setBinaryCoefficients( bics );
return fluid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct TestData< 9 >
static std::unique_ptr< TestFluid< 9 > > createFluid()
{
auto fluid = TestFluid< 9 >::create( {Fluid::H2O, Fluid::CO2, Fluid::N2, Fluid::CH4, Fluid::C2H6, Fluid::C3H8, Fluid::C4H10, Fluid::C5H12, Fluid::C10H22} );
const std::array< real64 const, 36 > bics = {
const stdArray< real64 const, 36 > bics = {
0.01, 0, 0.003732, 0, 0.01, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0.01, 0, 0.028, 0.01, 0.01, 0, 0, 0.01, 0, 0.04532, 0.01, 0.01, 0, 0, 0
};
Expand Down Expand Up @@ -113,7 +113,7 @@ class KValueFlashTestFixture< numPhases, numComps >::MockFluid : public MultiFlu
void setProperties( ComponentProperties const & componentProperties )
{
string_array & phaseNames = getReference< string_array >( MultiFluidBase::viewKeyStruct::phaseNamesString() );
TestFluid< numPhases >::createArray( phaseNames, std::array< string, 2 >{"oil", "gas"} );
TestFluid< numPhases >::createArray( phaseNames, stdArray< string, 2 >{"oil", "gas"} );
string_array & componentNames = getReference< string_array >( MultiFluidBase::viewKeyStruct::componentNamesString() );
TestFluid< numPhases >::createArray( componentNames, componentProperties.getComponentName());
}
Expand Down Expand Up @@ -163,7 +163,7 @@ real64 getKValue( integer const phaseIndex, integer const compIndex, real64 cons
{
GEOS_UNUSED_VAR( phaseIndex );

static std::array< real64, 5 > constexpr crookstonCoefficients[9] = {
static stdArray< real64, 5 > constexpr crookstonCoefficients[9] = {
{3.0620e+00, 8.9414e+02, 1.1912e-02, 5.3659e+02, 1.1951e+02},
{-1.8141e+00, 6.2655e+02, 6.7489e-03, 5.0732e+00, 2.5249e+02},
{-3.5742e-01, 4.8660e+02, 5.7887e-03, 9.1910e+01, 1.8027e+02},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct FluidData< 9 >
static std::unique_ptr< TestFluid< 9 > > createFluid()
{
auto fluid = TestFluid< 9 >::create( {Fluid::H2O, Fluid::CO2, Fluid::N2, Fluid::CH4, Fluid::C2H6, Fluid::C3H8, Fluid::C4H10, Fluid::C5H12, Fluid::C10H22} );
const std::array< real64 const, 36 > bics = {
const stdArray< real64 const, 36 > bics = {
0.01, 0, 0.003732, 0, 0.01, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0.01, 0, 0.028, 0.01, 0.01, 0, 0, 0.01, 0, 0.04532, 0.01, 0.01, 0, 0, 0
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ string MultiFluidCompositionalMultiphaseTestFixture< TEST_TYPE >::getFluidName()
}

template< integer NUM_COMP >
static void fillBinaryCoeffs( array2d< real64 > & binaryCoeff, std::array< real64 const, NUM_COMP *(NUM_COMP-1)/2 > const data )
static void fillBinaryCoeffs( array2d< real64 > & binaryCoeff, stdArray< real64 const, NUM_COMP *(NUM_COMP-1)/2 > const data )
{
auto bic = data.begin();
binaryCoeff.resize( NUM_COMP, NUM_COMP );
Expand All @@ -117,7 +117,7 @@ static void fillBinaryCoeffs( array2d< real64 > & binaryCoeff, std::array< real6
}

template< integer NUM_COMP >
static void populateArray( arraySlice1d< real64 > array, std::array< real64 const, NUM_COMP > const data )
static void populateArray( arraySlice1d< real64 > array, stdArray< real64 const, NUM_COMP > const data )
{
for( integer i = 0; i < NUM_COMP; ++i )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ string MultiFluidCompositionalMultiphaseTestFixture< TEST_TYPE >::getFluidName()
}

template< integer NUM_COMP >
static void fillBinaryCoeffs( array2d< real64 > & binaryCoeff, std::array< real64 const, NUM_COMP *(NUM_COMP-1)/2 > const data )
static void fillBinaryCoeffs( array2d< real64 > & binaryCoeff, stdArray< real64 const, NUM_COMP *(NUM_COMP-1)/2 > const data )
{
auto bic = data.begin();
binaryCoeff.resize( NUM_COMP, NUM_COMP );
Expand All @@ -138,7 +138,7 @@ static void fillBinaryCoeffs( array2d< real64 > & binaryCoeff, std::array< real6
}

template< integer NUM_COMP >
static void populateArray( arraySlice1d< real64 > array, std::array< real64 const, NUM_COMP > const data )
static void populateArray( arraySlice1d< real64 > array, stdArray< real64 const, NUM_COMP > const data )
{
for( integer i = 0; i < NUM_COMP; ++i )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct FluidData< 2 >
static std::unique_ptr< TestFluid< 2 > > createFluid()
{
auto fluid = TestFluid< 2 >::create( {Fluid::CH4, Fluid::C5H12} );
const std::array< real64 const, 2 > bics = { 0.5 };
const stdArray< real64 const, 2 > bics = { 0.5 };
fluid->setBinaryCoefficients( bics );
return fluid;
}
Expand All @@ -68,7 +68,7 @@ struct FluidData< 4 >
static std::unique_ptr< TestFluid< 4 > > createFluid()
{
auto fluid = TestFluid< 4 >::create( {Fluid::CH4, Fluid::CO2, Fluid::H2S, Fluid::H2O} );
const std::array< real64 const, 6 > bics = { 0.0, 0.0, 0.0, 0.4850, 0.1896, 0.1353 };
const stdArray< real64 const, 6 > bics = { 0.0, 0.0, 0.0, 0.4850, 0.1896, 0.1353 };
fluid->setBinaryCoefficients( bics );
return fluid;
}
Expand All @@ -81,7 +81,7 @@ struct FluidData< 9 >
static std::unique_ptr< TestFluid< 9 > > createFluid()
{
auto fluid = TestFluid< 9 >::create( {Fluid::H2O, Fluid::CO2, Fluid::N2, Fluid::CH4, Fluid::C2H6, Fluid::C3H8, Fluid::C4H10, Fluid::C5H12, Fluid::C8H18} );
const std::array< real64 const, 36 > bics = {
const stdArray< real64 const, 36 > bics = {
0.01, 0, 0.003732, 0, 0.01, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0.01, 0, 0.028, 0.01, 0.01, 0, 0, 0.01, 0, 0.04532, 0.01, 0.01, 0, 0, 0
};
Expand Down
Loading
Loading