diff --git a/.integrated_tests.yaml b/.integrated_tests.yaml index 7f309b2c34b..2445d111d26 100644 --- a/.integrated_tests.yaml +++ b/.integrated_tests.yaml @@ -1,6 +1,6 @@ baselines: bucket: geosx - baseline: integratedTests/baseline_integratedTests-pr3163-7758-9fe3734 + baseline: integratedTests/baseline_integratedTests-pr3149-7884-f97a068 allow_fail: all: '' diff --git a/BASELINE_NOTES.md b/BASELINE_NOTES.md index 67f0c1c877e..a63ce3f58e4 100644 --- a/BASELINE_NOTES.md +++ b/BASELINE_NOTES.md @@ -6,6 +6,10 @@ This file is designed to track changes to the integrated test baselines. Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining. These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD). +PR #3149( 2024-09-30) +===================== +Added new field "writeCSV" + PR #3163 (2024-09-20) ===================== Added new fields (krylovStrongestTol, adaptiveGamma, adaptiveExponent) to the LinearSolverParameters for adaptive tolerances. diff --git a/src/coreComponents/common/format/table/TableData.cpp b/src/coreComponents/common/format/table/TableData.cpp index 4ff32559385..dcbec10a01a 100644 --- a/src/coreComponents/common/format/table/TableData.cpp +++ b/src/coreComponents/common/format/table/TableData.cpp @@ -51,11 +51,42 @@ std::vector< string > const & TableData::getErrorMsgs() const return m_errorsMsg; } -TableData2D::Conversion1D TableData2D::buildTableData( string_view targetUnit, - string_view rowFmt, - string_view columnFmt ) const +void TableData2D::collectTableValues( arraySlice1d< real64 const > rowAxisValues, + arraySlice1d< real64 const > columnAxisValues, + arrayView1d< real64 const > values ) { - TableData2D::Conversion1D tableData1D; + integer const nX = rowAxisValues.size(); + integer const nY = columnAxisValues.size(); + + for( integer i = 0; i < nX; i++ ) + { + for( integer y = 0; y < nY; y++ ) + { + addCell( rowAxisValues[i], columnAxisValues[y], values[ y*nX + i ] ); + } + } +} + +TableData2D::TableDataHolder TableData2D::convertTable2D( arrayView1d< real64 const > const values, + units::Unit const valueUnit, + ArrayOfArraysView< real64 const > const coordinates, + string_view rowAxisDescription, + string_view columnAxisDescription ) +{ + 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, + columnFmt ); +} + +TableData2D::TableDataHolder TableData2D::buildTableData( string_view targetUnit, + string_view rowFmt, + string_view columnFmt ) const +{ + TableData2D::TableDataHolder tableData1D; std::vector< size_t > rowsLength; tableData1D.headerNames.push_back( string( targetUnit ) ); diff --git a/src/coreComponents/common/format/table/TableData.hpp b/src/coreComponents/common/format/table/TableData.hpp index 316adeda8a3..aa35f06a0f6 100644 --- a/src/coreComponents/common/format/table/TableData.hpp +++ b/src/coreComponents/common/format/table/TableData.hpp @@ -20,6 +20,7 @@ #ifndef GEOS_COMMON_FORMAT_TABLE_TABLEDATA_HPP #define GEOS_COMMON_FORMAT_TABLE_TABLEDATA_HPP +#include "common/Units.hpp" #include "common/DataTypes.hpp" #include "common/format/Format.hpp" @@ -85,9 +86,10 @@ class TableData2D using ColumnType = real64; /// Struct containing conversion informations - struct Conversion1D + struct TableDataHolder { /// Vector containing all columns names + /// A header value is presented as "pressure [K] = {}" std::vector< string > headerNames; /// TableData to be built TableData tableData; @@ -103,6 +105,30 @@ class TableData2D template< typename T > void addCell( RowType rowValue, ColumnType columnValue, T const & value ); + /** + * @brief Collects all the values needed to build the table + * @param rowAxisValues Vector containing all row axis values + * @param columnAxisValues Vector containing all column axis values + * @param values Vector containing all table values + */ + void collectTableValues( arraySlice1d< real64 const > rowAxisValues, + arraySlice1d< real64 const > columnAxisValues, + arrayView1d< real64 const > values ); + + /** + * @param values Vector containing all table values + * @param valueUnit The table unit value + * @param coordinates Array containing row/column axis values + * @param rowAxisDescription The description for a row unit value + * @param columnAxisDescription The description for a column unit value + * @return A struct containing the tableData converted and all header values ; + */ + TableData2D::TableDataHolder convertTable2D( arrayView1d< real64 const > const values, + units::Unit const valueUnit, + ArrayOfArraysView< real64 const > const coordinates, + string_view rowAxisDescription, + string_view columnAxisDescription ); + /** * @return Convert and return a struct containing a 1D Table, the column names list from a TableData2D and any errors related to the table * @param dataDescription The table dataDescription shown at the top left side @@ -112,7 +138,8 @@ class TableData2D * By default it displays the axis value. * I.E to display a customized axis to show the pressures in y axis, a rowFmt value can be : "pressure [K] = {}" */ - Conversion1D buildTableData( string_view dataDescription, string_view rowFmt = "{}", string_view columnFmt = "{}" ) const; + TableDataHolder buildTableData( string_view dataDescription, + string_view rowFmt = "{}", string_view columnFmt = "{}" ) const; private: /// @brief all cell values by their [ row ][ column ] diff --git a/src/coreComponents/common/format/table/TableFormatter.cpp b/src/coreComponents/common/format/table/TableFormatter.cpp index da1f90df986..56f529bdcee 100644 --- a/src/coreComponents/common/format/table/TableFormatter.cpp +++ b/src/coreComponents/common/format/table/TableFormatter.cpp @@ -17,6 +17,7 @@ * @file TableFormatter.cpp */ +#include "TableFormatter.hpp" #include #include "common/format/StringUtilities.hpp" #include "TableFormatter.hpp" @@ -67,7 +68,8 @@ string TableCSVFormatter::dataToString( TableData const & tableData ) const return oss.str(); } -string TableCSVFormatter::toString( TableData const & tableData ) const +template<> +string TableCSVFormatter::toString< TableData >( TableData const & tableData ) const { return headerToString() + dataToString( tableData ); } @@ -155,7 +157,8 @@ string TableTextFormatter::layoutToString() const return tableOutput.str(); } -string TableTextFormatter::toString( TableData const & tableData ) const +template<> +string TableTextFormatter::toString< TableData >( TableData const & tableData ) const { std::ostringstream tableOutput; string sectionSeparatingLine; @@ -403,4 +406,5 @@ void TableTextFormatter::outputSectionRows( std::vector< TableLayout::Column > c tableOutput << GEOS_FMT( "{}\n", sectionSeparatingLine ); } } + } diff --git a/src/coreComponents/common/format/table/TableFormatter.hpp b/src/coreComponents/common/format/table/TableFormatter.hpp index 35410506e07..165533445b6 100644 --- a/src/coreComponents/common/format/table/TableFormatter.hpp +++ b/src/coreComponents/common/format/table/TableFormatter.hpp @@ -37,6 +37,8 @@ class TableFormatter /// Layout for a table TableLayout m_tableLayout; + TableFormatter() = default; + /** * @brief Construct a new Table Formatter from a tableLayout * @param tableLayout Contain all column names and optionnaly the table title @@ -56,6 +58,13 @@ class TableCSVFormatter : public TableFormatter { public: + /** + * @brief Construct a new Table Formatter + */ + TableCSVFormatter(): + TableFormatter( TableLayout() ) + {} + /** * @brief Construct a new Table Formatter from a tableLayout * @param tableLayout Contain all column names and optionnaly the table title @@ -80,28 +89,47 @@ class TableCSVFormatter : public TableFormatter string dataToString( TableData const & tableData ) const; /** - * @brief Convert the TableData to a table string. - * @param tableData The TableData to convert. - * @return The table string representation of the TableData. + * @brief Convert a data source to a CSV string. + * @tparam DATASOURCE The source to convert + * @param tableData The data source to convert + * @return The CSV string representation of a data source. */ - string toString( TableData const & tableData ) const; + template< typename DATASOURCE > + string toString( DATASOURCE const & tableData ) const; }; +/** + * @brief Convert the TableData to a CSV string. + * @param tableData The TableData to convert. + * @return The CSV string representation of the TableData. + */ +template<> +string TableCSVFormatter::toString< TableData >( TableData const & tableData ) const; + + /** * @brief class for log formatting */ class TableTextFormatter : public TableFormatter { - public: + + /** + * @brief Construct a new TableFormatter + */ + TableTextFormatter(): + TableFormatter( TableLayout() ) + {} + /** * @brief Construct a new TableFormatter from a tableLayout * @param tableLayout Contain all column names and optionnaly the table title */ TableTextFormatter( TableLayout const & tableLayout ); + /** * @brief Destroy the Table Text Formatter object */ @@ -113,11 +141,12 @@ class TableTextFormatter : public TableFormatter string layoutToString() const; /** - * @brief Convert the TableData to a table string. - * @param tableData The TableData to convert. + * @brief Convert a data source to a table string. + * @param tableData The data source to convert. * @return The table string representation of the TableData. */ - string toString( TableData const & tableData ) const; + template< typename DATASOURCE > + string toString( DATASOURCE const & tableData ) const; private: @@ -126,7 +155,7 @@ class TableTextFormatter : public TableFormatter /// for the extremity of a row static constexpr char m_horizontalLine = '-'; - /**F + /** * @brief Fill the vector (m_column) in tableData with values from rows stored in tableData. * @param columns Vector of columns to be filled. * @param tableData Vector containing all rows filled with values @@ -217,6 +246,14 @@ class TableTextFormatter : public TableFormatter integer const nbRows, TableLayout::Section const section ) const; }; + +/** + * @brief Convert a TableData to a table string. + * @param tableData The TableData to convert. + * @return The table string representation of the TableData. + */ +template<> +string TableTextFormatter::toString< TableData >( TableData const & tableData ) const; } #endif /* GEOS_COMMON_FORMAT_TABLE_TABLEFORMATTER_HPP */ diff --git a/src/coreComponents/common/format/table/TableLayout.hpp b/src/coreComponents/common/format/table/TableLayout.hpp index 99354e85417..4f24fa5559c 100644 --- a/src/coreComponents/common/format/table/TableLayout.hpp +++ b/src/coreComponents/common/format/table/TableLayout.hpp @@ -97,6 +97,8 @@ class TableLayout string m_maxStringSize; }; + TableLayout() = default; + /** * @brief Construct a new Table object, all values in the table are centered by default * @param columnNames The names of the columns diff --git a/src/coreComponents/common/format/table/unitTests/testTable.cpp b/src/coreComponents/common/format/table/unitTests/testTable.cpp index 35507b94c03..3663b5eae22 100644 --- a/src/coreComponents/common/format/table/unitTests/testTable.cpp +++ b/src/coreComponents/common/format/table/unitTests/testTable.cpp @@ -210,9 +210,9 @@ TEST( testTable, table2DTable ) //convert string const rowFmt = GEOS_FMT( "{} = {{}}", "Temperature" ); string const columnFmt = GEOS_FMT( "{} = {{}}", "Pression" ); - TableData2D::Conversion1D tableconverted = tableData.buildTableData( "Viscosity kg*s", - rowFmt, - columnFmt ); + TableData2D::TableDataHolder tableconverted = tableData.buildTableData( "Viscosity kg*s", + rowFmt, + columnFmt ); //format TableLayout const tableLayout( tableconverted.headerNames ); @@ -248,9 +248,9 @@ TEST( testTable, table2DColumnMismatch ) //convert string const rowFmt = GEOS_FMT( "{} = {{}}", "Temperature" ); string const columnFmt = GEOS_FMT( "{} = {{}}", "Pression" ); - TableData2D::Conversion1D tableConverted = tableData.buildTableData( "Viscosity kg*s", - rowFmt, - columnFmt ); + TableData2D::TableDataHolder tableConverted = tableData.buildTableData( "Viscosity kg*s", + rowFmt, + columnFmt ); //format TableLayout const tableLayout( tableConverted.headerNames ); @@ -274,11 +274,10 @@ TEST( testTable, table2DColumnMismatch ) TEST( testTable, layoutTable ) { string filename = "fluid1_phaseModel1_PhillipsBrineDensity_table"; - //2. format + string log = GEOS_FMT( "The {} PVT table exceeding 500 rows.\nTo visualize the tables, go to the generated csv \n", filename ); TableLayout const tableLayoutInfos( {TableLayout::ColumnParam{{log}, TableLayout::Alignment::left}}, filename ); - //3. log TableTextFormatter const tableLog( tableLayoutInfos ); EXPECT_EQ( tableLog.layoutToString(), "\n-------------------------------------------------------------------------------------\n" diff --git a/src/coreComponents/constitutive/ConstitutiveBase.cpp b/src/coreComponents/constitutive/ConstitutiveBase.cpp index f18138b0e87..2c7334239c3 100644 --- a/src/coreComponents/constitutive/ConstitutiveBase.cpp +++ b/src/coreComponents/constitutive/ConstitutiveBase.cpp @@ -30,7 +30,8 @@ namespace constitutive ConstitutiveBase::ConstitutiveBase( string const & name, Group * const parent ): Group( name, parent ), - m_numQuadraturePoints( 1 ) + m_numQuadraturePoints( 1 ), + m_isClone( false ) { setInputFlags( InputFlags::OPTIONAL_NONUNIQUE ); } @@ -72,6 +73,11 @@ void ConstitutiveBase::allocateConstitutiveData( dataRepository::Group & parent, this->resize( parent.size() ); } +void ConstitutiveBase::setIsClone( bool const newState ) +{ + m_isClone = newState; +} + std::unique_ptr< ConstitutiveBase > ConstitutiveBase::deliverClone( string const & name, Group * const parent ) const @@ -84,6 +90,8 @@ ConstitutiveBase::deliverClone( string const & name, wrapper.copyWrapper( this->getWrapperBase( wrapper.getName() ) ); } ); + newModel->setIsClone( true ); + return newModel; } diff --git a/src/coreComponents/constitutive/ConstitutiveBase.hpp b/src/coreComponents/constitutive/ConstitutiveBase.hpp index 9f39fbbd314..c025a58bb4b 100644 --- a/src/coreComponents/constitutive/ConstitutiveBase.hpp +++ b/src/coreComponents/constitutive/ConstitutiveBase.hpp @@ -113,6 +113,11 @@ class ConstitutiveBase : public dataRepository::Group localIndex numQuadraturePoints() const { return m_numQuadraturePoints; } + /** + * @return true if the instance has been produced with deliverClone() + */ + bool isClone() const { return m_isClone; } + virtual std::vector< string > getSubRelationNames() const { return {}; } /** @@ -162,7 +167,16 @@ class ConstitutiveBase : public dataRepository::Group private: + /** + * @brief Set a isClone state boolean + * @param newState The state of the new constitutive model + */ + void setIsClone( bool const newState ); + localIndex m_numQuadraturePoints; + + /// Indicate if this constitutive model a clone + bool m_isClone; }; } diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.cpp index 7125e3fe6a0..c90b6c296f6 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.cpp @@ -21,6 +21,7 @@ #include "constitutive/fluid/multifluid/MultiFluidFields.hpp" #include "constitutive/fluid/multifluid/CO2Brine/functions/PVTFunctionHelpers.hpp" #include "common/Units.hpp" +#include "functions/TableFunction.hpp" namespace geos { @@ -102,6 +103,12 @@ CO2BrineFluid( string const & name, Group * const parent ): setRestartFlags( RestartFlags::NO_WRITE ). setDescription( "Names of solubility tables for each phase" ); + this->registerWrapper( viewKeyStruct::writeCSVFlagString(), &m_writeCSV ). + setInputFlag( InputFlags::OPTIONAL ). + setRestartFlags( RestartFlags::NO_WRITE ). + setDescription( "Write PVT tables into a CSV file" ). + setDefaultValue( 0 ); + // if this is a thermal model, we need to make sure that the arrays will be properly displayed and saved to restart if( isThermal() ) { @@ -228,14 +235,12 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::postInputInitialization() string const expectedGasPhaseNames[] = { "CO2", "co2", "gas", "Gas" }; m_p2Index = PVTFunctionHelpers::findName( m_phaseNames, expectedGasPhaseNames, viewKeyStruct::phaseNamesString() ); - createPVTModels(); } template< typename PHASE1, typename PHASE2, typename FLASH > void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels() { - // TODO: get rid of these external files and move into XML, this is too error prone // For now, to support the legacy input, we read all the input parameters at once in the arrays below, and then we create the models array1d< array1d< string > > phase1InputParams; @@ -325,10 +330,23 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels() InputError ); // then, we are ready to instantiate the phase models - m_phase1 = std::make_unique< PHASE1 >( getName() + "_phaseModel1", phase1InputParams, m_componentNames, m_componentMolarWeight, - getLogLevel() > 0 && logger::internal::rank==0 ); - m_phase2 = std::make_unique< PHASE2 >( getName() + "_phaseModel2", phase2InputParams, m_componentNames, m_componentMolarWeight, - getLogLevel() > 0 && logger::internal::rank==0 ); + bool const isClone = this->isClone(); + TableFunction::OutputOptions const pvtOutputOpts = { + !isClone && m_writeCSV,// writeCSV + !isClone && (getLogLevel() > 0 && logger::internal::rank==0), // writeInLog + }; + + m_phase1 = std::make_unique< PHASE1 >( getName() + "_phaseModel1", + phase1InputParams, + m_componentNames, + m_componentMolarWeight, + pvtOutputOpts ); + m_phase2 = std::make_unique< PHASE2 >( getName() + "_phaseModel2", + phase2InputParams, + m_componentNames, + m_componentMolarWeight, + pvtOutputOpts ); + // 2) Create the flash model if( !m_flashModelParaFile.empty()) @@ -349,12 +367,16 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels() { if( strs[1] == FLASH::catalogName() ) { + TableFunction::OutputOptions const flashOutputOpts = { + !isClone && m_writeCSV,// writeCSV + !isClone && (getLogLevel() > 0 && logger::internal::rank==0), // writeInLog + }; m_flash = std::make_unique< FLASH >( getName() + '_' + FLASH::catalogName(), strs, m_phaseNames, m_componentNames, m_componentMolarWeight, - getLogLevel() > 0 && logger::internal::rank==0 ); + flashOutputOpts ); } } else @@ -390,12 +412,18 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels() { strs[2] = m_solubilityTables[0]; } + + TableFunction::OutputOptions const flashOutputOpts = { + !isClone && m_writeCSV,// writeCSV + !isClone && (getLogLevel() >= 0 && logger::internal::rank==0), // writeInLog + }; + m_flash = std::make_unique< FLASH >( getName() + '_' + FLASH::catalogName(), strs, m_phaseNames, m_componentNames, m_componentMolarWeight, - getLogLevel() > 0 && logger::internal::rank==0 ); + flashOutputOpts ); } GEOS_THROW_IF( m_flash == nullptr, diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp index fed8e2c8c67..62b6c3a1a15 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp @@ -171,6 +171,7 @@ class CO2BrineFluid : public MultiFluidBase static constexpr char const * flashModelParaFileString() { return "flashModelParaFile"; } static constexpr char const * solubilityTablesString() { return "solubilityTableNames"; } static constexpr char const * phasePVTParaFilesString() { return "phasePVTParaFiles"; } + static constexpr char const * writeCSVFlagString() { return "writeCSV"; } }; protected: @@ -181,6 +182,9 @@ class CO2BrineFluid : public MultiFluidBase private: + /** + * @brief Create a PVT Model and output them + */ void createPVTModels(); /// Names of the files defining the viscosity and density models @@ -198,6 +202,8 @@ class CO2BrineFluid : public MultiFluidBase /// Index of the gas phase integer m_p2Index; + /// Output csv file containing informations about PVT + integer m_writeCSV; /// Brine constitutive models std::unique_ptr< PHASE1 > m_phase1; diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/PhaseModel.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/PhaseModel.hpp index 596d6332457..9c398939b62 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/PhaseModel.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/PhaseModel.hpp @@ -20,6 +20,8 @@ #ifndef GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_CO2BRINE_PHASEMODEL_HPP_ #define GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_CO2BRINE_PHASEMODEL_HPP_ +#include "functions/TableFunction.hpp" + namespace geos { @@ -54,27 +56,28 @@ struct PhaseModel * @param[in] inputParams input parameters read from files * @param[in] componentNames names of the components * @param[in] componentMolarWeight molar weights of the components + * @param[in] pvtOutputOpts A structure containing generated table output options */ PhaseModel( string const & phaseModelName, array1d< array1d< string > > const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ) + TableFunction::OutputOptions const pvtOutputOpts ) : density( phaseModelName + "_" + Density::catalogName(), inputParams[InputParamOrder::DENSITY], componentNames, componentMolarWeight, - printTable ), + pvtOutputOpts ), viscosity( phaseModelName + "_" + Viscosity::catalogName(), inputParams[InputParamOrder::VISCOSITY], componentNames, componentMolarWeight, - printTable ), + pvtOutputOpts ), enthalpy( phaseModelName + "_" + Enthalpy::catalogName(), inputParams[InputParamOrder::ENTHALPY], componentNames, componentMolarWeight, - printTable ) + pvtOutputOpts ) {} /// The phase density model diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/BrineEnthalpy.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/BrineEnthalpy.cpp index 5d8abb34def..5edd296fd51 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/BrineEnthalpy.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/BrineEnthalpy.cpp @@ -192,7 +192,7 @@ BrineEnthalpy::BrineEnthalpy( string const & name, string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): PVTFunctionBase( name, componentNames, componentMolarWeight ) @@ -205,13 +205,12 @@ BrineEnthalpy::BrineEnthalpy( string const & name, m_CO2EnthalpyTable = makeCO2EnthalpyTable( inputParams, m_functionName, FunctionManager::getInstance() ); m_brineEnthalpyTable = makeBrineEnthalpyTable( inputParams, m_functionName, FunctionManager::getInstance() ); - if( printTable ) - { - m_CO2EnthalpyTable->print( m_CO2EnthalpyTable->getName() ); - m_brineEnthalpyTable->print( m_brineEnthalpyTable->getName() ); - } + + m_CO2EnthalpyTable->outputPVTTableData( pvtOutputOpts ); + m_brineEnthalpyTable->outputPVTTableData( pvtOutputOpts ); } + void BrineEnthalpy::checkTablesParameters( real64 const pressure, real64 const temperature ) const { @@ -233,8 +232,6 @@ BrineEnthalpy::createKernelWrapper() const m_waterIndex ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, BrineEnthalpy, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/BrineEnthalpy.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/BrineEnthalpy.hpp index 8a5b6020592..2e000d40f97 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/BrineEnthalpy.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/BrineEnthalpy.hpp @@ -92,7 +92,7 @@ class BrineEnthalpy : public PVTFunctionBase string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); static string catalogName() { return "BrineEnthalpy"; } diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Enthalpy.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Enthalpy.cpp index 6734098364f..01683a9dd64 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Enthalpy.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Enthalpy.cpp @@ -257,7 +257,7 @@ CO2Enthalpy::CO2Enthalpy( string const & name, string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): PVTFunctionBase( name, componentNames, componentMolarWeight ) @@ -266,8 +266,9 @@ CO2Enthalpy::CO2Enthalpy( string const & name, m_CO2Index = PVTFunctionHelpers::findName( componentNames, expectedCO2ComponentNames, "componentNames" ); m_CO2EnthalpyTable = makeCO2EnthalpyTable( inputParams, m_functionName, FunctionManager::getInstance() ); - if( printTable ) - m_CO2EnthalpyTable->print( m_CO2EnthalpyTable->getName() ); + + m_CO2EnthalpyTable->outputPVTTableData( pvtOutputOpts ); + m_CO2EnthalpyTable->outputPVTTableData( pvtOutputOpts ); } @@ -309,8 +310,6 @@ CO2Enthalpy::createKernelWrapper() const m_CO2Index ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, CO2Enthalpy, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Enthalpy.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Enthalpy.hpp index 1c476e09085..034ad20475a 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Enthalpy.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Enthalpy.hpp @@ -80,7 +80,7 @@ class CO2Enthalpy : public PVTFunctionBase string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); static string catalogName() { return "CO2Enthalpy"; } diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Solubility.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Solubility.cpp index 226357aed9c..131fdb60ed9 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Solubility.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Solubility.cpp @@ -221,7 +221,7 @@ CO2Solubility::CO2Solubility( string const & name, string_array const & phaseNames, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): FlashModelBase( name, componentNames, componentMolarWeight ) @@ -257,11 +257,9 @@ CO2Solubility::CO2Solubility( string const & name, std::tie( m_CO2SolubilityTable, m_WaterVapourisationTable ) = makeSolubilityTables( m_modelName, inputParams, solubilityModel ); - if( printTable ) - { - m_CO2SolubilityTable->print( m_CO2SolubilityTable->getName() ); - m_WaterVapourisationTable->print( m_WaterVapourisationTable->getName() ); - } + m_CO2SolubilityTable->outputPVTTableData( pvtOutputOpts ); + m_WaterVapourisationTable->outputPVTTableData( pvtOutputOpts ); + } void CO2Solubility::checkTablesParameters( real64 const pressure, diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Solubility.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Solubility.hpp index ea7143a4443..fe24e1e0270 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Solubility.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/CO2Solubility.hpp @@ -21,10 +21,10 @@ #define GEOS_CONSTITUTIVE_FLUID_MULTIFLUID_CO2BRINE_FUNCTIONS_CO2SOLUBILITY_HPP_ #include "FlashModelBase.hpp" - #include "constitutive/fluid/multifluid/CO2Brine/functions/PVTFunctionHelpers.hpp" #include "constitutive/fluid/multifluid/Layouts.hpp" #include "constitutive/fluid/multifluid/MultiFluidUtils.hpp" +#include "fileIO/Outputs/OutputBase.hpp" #include "functions/TableFunction.hpp" namespace geos @@ -117,7 +117,7 @@ class CO2Solubility : public FlashModelBase string_array const & phaseNames, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); static string catalogName() { return "CO2Solubility"; } diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineDensity.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineDensity.cpp index a35551945e1..7ba7020fa9e 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineDensity.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineDensity.cpp @@ -38,7 +38,7 @@ EzrokhiBrineDensity::EzrokhiBrineDensity( string const & name, string_array const & inputPara, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): PVTFunctionBase( name, componentNames, componentMolarWeight ) @@ -52,11 +52,9 @@ EzrokhiBrineDensity::EzrokhiBrineDensity( string const & name, makeCoefficients( inputPara ); m_waterSatDensityTable = PureWaterProperties::makeSaturationDensityTable( m_functionName, FunctionManager::getInstance() ); m_waterSatPressureTable = PureWaterProperties::makeSaturationPressureTable( m_functionName, FunctionManager::getInstance() ); - if( printTable ) - { - m_waterSatDensityTable->print( m_waterSatDensityTable->getName() ); - m_waterSatPressureTable->print( m_waterSatPressureTable->getName() ); - } + + m_waterSatPressureTable->outputPVTTableData( pvtOutputOpts ); + m_waterSatDensityTable->outputPVTTableData( pvtOutputOpts ); } void EzrokhiBrineDensity::makeCoefficients( string_array const & inputPara ) @@ -103,8 +101,6 @@ EzrokhiBrineDensity::createKernelWrapper() const m_coef2 ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, EzrokhiBrineDensity, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // end namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineDensity.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineDensity.hpp index 8d69675aae6..5942eff4f0a 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineDensity.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineDensity.hpp @@ -109,7 +109,7 @@ class EzrokhiBrineDensity : public PVTFunctionBase string_array const & inputPara, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); virtual ~EzrokhiBrineDensity() override = default; diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineViscosity.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineViscosity.cpp index b8aeccec02a..c300237899a 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineViscosity.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineViscosity.cpp @@ -38,7 +38,7 @@ EzrokhiBrineViscosity::EzrokhiBrineViscosity( string const & name, string_array const & inputPara, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): PVTFunctionBase( name, componentNames, componentMolarWeight ) @@ -51,8 +51,8 @@ EzrokhiBrineViscosity::EzrokhiBrineViscosity( string const & name, makeCoefficients( inputPara ); m_waterViscosityTable = PureWaterProperties::makeSaturationViscosityTable( m_functionName, FunctionManager::getInstance() ); - if( printTable ) - m_waterViscosityTable->print( m_waterViscosityTable->getName() ); + + m_waterViscosityTable->outputPVTTableData( pvtOutputOpts ); } void EzrokhiBrineViscosity::makeCoefficients( string_array const & inputPara ) @@ -94,8 +94,6 @@ EzrokhiBrineViscosity::createKernelWrapper() const m_coef2 ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, EzrokhiBrineViscosity, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // end namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineViscosity.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineViscosity.hpp index dd3202d5ecf..7140a4ca41c 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineViscosity.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/EzrokhiBrineViscosity.hpp @@ -98,7 +98,7 @@ class EzrokhiBrineViscosity : public PVTFunctionBase string_array const & inputPara, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); virtual ~EzrokhiBrineViscosity() override = default; diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FenghourCO2Viscosity.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FenghourCO2Viscosity.cpp index 62d055f1add..11bc6522254 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FenghourCO2Viscosity.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FenghourCO2Viscosity.cpp @@ -142,14 +142,14 @@ FenghourCO2Viscosity::FenghourCO2Viscosity( string const & name, string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ) + TableFunction::OutputOptions const pvtOutputOpts ) : PVTFunctionBase( name, componentNames, componentMolarWeight ) { m_CO2ViscosityTable = makeViscosityTable( inputParams, m_functionName, FunctionManager::getInstance() ); - if( printTable ) - m_CO2ViscosityTable->print( m_CO2ViscosityTable->getName() ); + + m_CO2ViscosityTable->outputPVTTableData( pvtOutputOpts ); } void FenghourCO2Viscosity::checkTablesParameters( real64 const pressure, @@ -166,8 +166,6 @@ FenghourCO2Viscosity::createKernelWrapper() const *m_CO2ViscosityTable ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, FenghourCO2Viscosity, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // end namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FenghourCO2Viscosity.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FenghourCO2Viscosity.hpp index e45d04f312f..ea490882910 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FenghourCO2Viscosity.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FenghourCO2Viscosity.hpp @@ -76,7 +76,7 @@ class FenghourCO2Viscosity : public PVTFunctionBase string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); virtual ~FenghourCO2Viscosity() override = default; diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FlashModelBase.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FlashModelBase.hpp index d6b81cca1fa..acef1ec1ab0 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FlashModelBase.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/FlashModelBase.hpp @@ -78,19 +78,6 @@ class FlashModelBase virtual ~FlashModelBase() = default; - using CatalogInterface = dataRepository::CatalogInterface< FlashModelBase, - string const &, - string_array const &, - string_array const &, - string_array const &, - array1d< real64 > const &, - bool const >; - static typename CatalogInterface::CatalogType & getCatalog() - { - static CatalogInterface::CatalogType catalog; - return catalog; - } - virtual string getCatalogName() const = 0; /** diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/NoOpPVTFunction.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/NoOpPVTFunction.hpp index 7a6af6b075f..c647a071f79 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/NoOpPVTFunction.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/NoOpPVTFunction.hpp @@ -71,12 +71,12 @@ class NoOpPVTFunction : public PVTFunctionBase string_array const & inputPara, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ) + TableFunction::OutputOptions const pvtOutputOpts ) : PVTFunctionBase( name, componentNames, componentMolarWeight ) { - GEOS_UNUSED_VAR( inputPara, printTable ); + GEOS_UNUSED_VAR( inputPara, pvtOutputOpts ); } virtual ~NoOpPVTFunction() override = default; diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PVTFunctionBase.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PVTFunctionBase.hpp index 2778347dd78..135d7c899c4 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PVTFunctionBase.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PVTFunctionBase.hpp @@ -113,17 +113,6 @@ class PVTFunctionBase virtual ~PVTFunctionBase() = default; - using CatalogInterface = dataRepository::CatalogInterface< PVTFunctionBase, - string const &, - array1d< string > const &, - array1d< string > const &, - array1d< real64 > const &, - bool const >; - static typename CatalogInterface::CatalogType & getCatalog() - { - static CatalogInterface::CatalogType catalog; - return catalog; - } virtual string getCatalogName() const = 0; diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineDensity.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineDensity.cpp index 129e723a205..017f5ab92f8 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineDensity.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineDensity.cpp @@ -177,7 +177,7 @@ PhillipsBrineDensity::PhillipsBrineDensity( string const & name, string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): PVTFunctionBase( name, componentNames, componentMolarWeight ) @@ -189,8 +189,8 @@ PhillipsBrineDensity::PhillipsBrineDensity( string const & name, m_waterIndex = PVTFunctionHelpers::findName( componentNames, expectedWaterComponentNames, "componentNames" ); m_brineDensityTable = makeDensityTable( inputParams, m_functionName, FunctionManager::getInstance() ); - if( printTable ) - m_brineDensityTable->print( m_brineDensityTable->getName() ); + + m_brineDensityTable->outputPVTTableData( pvtOutputOpts ); } PhillipsBrineDensity::KernelWrapper @@ -209,8 +209,6 @@ void PhillipsBrineDensity::checkTablesParameters( real64 const pressure, m_brineDensityTable->checkCoord( temperature, 1 ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, PhillipsBrineDensity, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineDensity.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineDensity.hpp index f22a8e945e5..fbfa037be96 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineDensity.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineDensity.hpp @@ -86,7 +86,7 @@ class PhillipsBrineDensity : public PVTFunctionBase string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); static string catalogName() { return "PhillipsBrineDensity"; } diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineViscosity.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineViscosity.cpp index 7107cb15056..8dd96a8a82d 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineViscosity.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineViscosity.cpp @@ -37,15 +37,15 @@ PhillipsBrineViscosity::PhillipsBrineViscosity( string const & name, string_array const & inputPara, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): PVTFunctionBase( name, componentNames, componentMolarWeight ) { m_waterViscosityTable = PureWaterProperties::makeSaturationViscosityTable( m_functionName, FunctionManager::getInstance() ); - if( printTable ) - m_waterViscosityTable->print( m_waterViscosityTable->getName() ); makeCoefficients( inputPara ); + + m_waterViscosityTable->outputPVTTableData( pvtOutputOpts ); } void PhillipsBrineViscosity::makeCoefficients( string_array const & inputPara ) @@ -92,8 +92,6 @@ PhillipsBrineViscosity::createKernelWrapper() const m_coef1 ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, PhillipsBrineViscosity, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // end namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineViscosity.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineViscosity.hpp index 1ff04c0bd91..bdb6bfa0f5a 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineViscosity.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/PhillipsBrineViscosity.hpp @@ -84,7 +84,7 @@ class PhillipsBrineViscosity : public PVTFunctionBase string_array const & inputPara, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); virtual ~PhillipsBrineViscosity() override = default; diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.cpp index ceefb08daf2..0ef520014a0 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.cpp @@ -279,7 +279,7 @@ SpanWagnerCO2Density::SpanWagnerCO2Density( string const & name, string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): PVTFunctionBase( name, componentNames, componentMolarWeight ) @@ -288,8 +288,8 @@ SpanWagnerCO2Density::SpanWagnerCO2Density( string const & name, m_CO2Index = PVTFunctionHelpers::findName( componentNames, expectedCO2ComponentNames, "componentNames" ); m_CO2DensityTable = makeDensityTable( inputParams, m_functionName, FunctionManager::getInstance() ); - if( printTable ) - m_CO2DensityTable->print( m_CO2DensityTable->getName() ); + + m_CO2DensityTable->outputPVTTableData( pvtOutputOpts ); } void SpanWagnerCO2Density::checkTablesParameters( real64 const pressure, @@ -307,8 +307,6 @@ SpanWagnerCO2Density::createKernelWrapper() const m_CO2Index ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, SpanWagnerCO2Density, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.hpp index 1167d615994..f729064fcf0 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/SpanWagnerCO2Density.hpp @@ -81,7 +81,7 @@ class SpanWagnerCO2Density : public PVTFunctionBase string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); static string catalogName() { return "SpanWagnerCO2Density"; } diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/WaterDensity.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/WaterDensity.cpp index 5b3ba0f5a30..41a047c11b5 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/WaterDensity.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/WaterDensity.cpp @@ -37,15 +37,15 @@ WaterDensity::WaterDensity( string const & name, string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ): + TableFunction::OutputOptions const pvtOutputOpts ): PVTFunctionBase( name, componentNames, componentMolarWeight ) { GEOS_UNUSED_VAR( inputParams ); m_waterDensityTable = PureWaterProperties::makeSaturationDensityTable( m_functionName, FunctionManager::getInstance() ); - if( printTable ) - m_waterDensityTable->print( m_waterDensityTable->getName() ); + + m_waterDensityTable->outputPVTTableData( pvtOutputOpts ); } void WaterDensity::checkTablesParameters( real64 const pressure, @@ -62,8 +62,6 @@ WaterDensity::createKernelWrapper() const *m_waterDensityTable ); } -REGISTER_CATALOG_ENTRY( PVTFunctionBase, WaterDensity, string const &, string_array const &, string_array const &, array1d< real64 > const &, bool const ) - } // namespace PVTProps } // namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/WaterDensity.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/WaterDensity.hpp index fc963e7811a..36cd4932661 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/WaterDensity.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/functions/WaterDensity.hpp @@ -76,7 +76,7 @@ class WaterDensity : public PVTFunctionBase string_array const & inputParams, string_array const & componentNames, array1d< real64 > const & componentMolarWeight, - bool const printTable ); + TableFunction::OutputOptions const pvtOutputOpts ); static string catalogName() { return "WaterDensity"; } virtual string getCatalogName() const final { return catalogName(); } diff --git a/src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.cpp b/src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.cpp index 708d4f42d31..fa2dc6eb819 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.cpp @@ -20,6 +20,7 @@ #include "constitutive/fluid/multifluid/MultiFluidFields.hpp" #include "constitutive/fluid/multifluid/CO2Brine/functions/PVTFunctionHelpers.hpp" +#include "constitutive/ConstitutiveManager.hpp" #include "common/Units.hpp" namespace geos @@ -69,6 +70,12 @@ ReactiveBrineFluid( string const & name, Group * const parent ): setRestartFlags( RestartFlags::NO_WRITE ). setDescription( "Names of the files defining the parameters of the viscosity and density models" ); + this->registerWrapper( viewKeyStruct::writeCSVFlagString(), &m_writeCSV ). + setApplyDefaultValue( 0 ). + setInputFlag( InputFlags::OPTIONAL ). + setRestartFlags( RestartFlags::NO_WRITE ). + setDescription( "Write PVT tables into a CSV file" ); + // if this is a thermal model, we need to make sure that the arrays will be properly displayed and saved to restart if( isThermal() ) { @@ -94,6 +101,7 @@ std::unique_ptr< ConstitutiveBase > ReactiveBrineFluid< PHASE > :: deliverClone( string const & name, Group * const parent ) const { + std::unique_ptr< ConstitutiveBase > clone = ReactiveMultiFluid::deliverClone( name, parent ); ReactiveBrineFluid & newConstitutiveRelation = dynamicCast< ReactiveBrineFluid & >( *clone ); @@ -129,7 +137,6 @@ void ReactiveBrineFluid< PHASE > ::postInputInitialization() template< typename PHASE > void ReactiveBrineFluid< PHASE > ::createPVTModels() { - // TODO: get rid of these external files and move into XML, this is too error prone // For now, to support the legacy input, we read all the input parameters at once in the arrays below, and then we create the models array1d< array1d< string > > phase1InputParams; @@ -193,9 +200,15 @@ void ReactiveBrineFluid< PHASE > ::createPVTModels() GEOS_FMT( "{}: PVT model {} not found in input files", getFullName(), PHASE::Enthalpy::catalogName() ), InputError ); + bool const isClone = this->isClone(); + TableFunction::OutputOptions const pvtOutputOpts = { + !isClone && m_writeCSV,// writeCSV + !isClone && (getLogLevel() >= 0 && logger::internal::rank==0), // writeInLog + }; + // then, we are ready to instantiate the phase models m_phase = std::make_unique< PHASE >( getName() + "_phaseModel1", phase1InputParams, m_componentNames, m_componentMolarWeight, - getLogLevel() > 0 && logger::internal::rank==0 ); + pvtOutputOpts ); } template< typename PHASE > diff --git a/src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.hpp index 0ff1ba70c0b..9ba08387cf6 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/reactive/ReactiveBrineFluid.hpp @@ -152,6 +152,7 @@ class ReactiveBrineFluid : public ReactiveMultiFluid struct viewKeyStruct : ReactiveMultiFluid::viewKeyStruct { static constexpr char const * phasePVTParaFilesString() { return "phasePVTParaFiles"; } + static constexpr char const * writeCSVFlagString() { return "writeCSV"; } }; protected: @@ -160,11 +161,17 @@ class ReactiveBrineFluid : public ReactiveMultiFluid private: + /** + * @brief Create a PVT Model and output them + */ void createPVTModels(); /// Names of the files defining the viscosity and density models path_array m_phasePVTParaFiles; + /// Output csv file containing informations about PVT + integer m_writeCSV; + /// Brine constitutive models std::unique_ptr< PHASE > m_phase; diff --git a/src/coreComponents/functions/TableFunction.cpp b/src/coreComponents/functions/TableFunction.cpp index d9f804241fb..2e1897e7629 100644 --- a/src/coreComponents/functions/TableFunction.cpp +++ b/src/coreComponents/functions/TableFunction.cpp @@ -184,77 +184,6 @@ void TableFunction::checkCoord( real64 const coord, localIndex const dim ) const SimulationError ); } -void TableFunction::print( std::string const & filename ) const -{ - std::ofstream os( joinPath( FunctionBase::getOutputDirectory(), filename + ".csv" ) ); - - integer const numDimensions = LvArray::integerConversion< integer >( m_coordinates.size() ); - - if( numDimensions != 2 ) - { - // print header - - for( integer d = 0; d < numDimensions; d++ ) - { - os << units::getDescription( getDimUnit( d )) << ","; - } - os << units::getDescription( m_valueUnit ) << "\n"; - - // print values - - // prepare dividers - std::vector< integer > div( numDimensions ); - div[0] = 1; - for( integer d = 1; d < numDimensions; d++ ) - { - div[d] = div[d-1] * m_coordinates[d-1].size(); - } - // loop through all the values - for( integer v = 0; v < m_values.size(); v++ ) - { - // find coords indices - std::vector< integer > idx( numDimensions ); - integer r = v; - for( integer d = numDimensions-1; d >= 0; d-- ) - { - idx[d] = r / div[d]; - r = r % div[d]; - } - // finally print out in right order - for( integer d = 0; d < numDimensions; d++ ) - { - arraySlice1d< real64 const > const coords = m_coordinates[d]; - os << coords[idx[d]] << ","; - } - os << m_values[v] << "\n"; - } - } - else // numDimensions == 2 - { - arraySlice1d< real64 const > const coordsX = m_coordinates[0]; - arraySlice1d< real64 const > const coordsY = m_coordinates[1]; - integer const nX = coordsX.size(); - integer const nY = coordsY.size(); - os< const coordinates, + arrayView1d< real64 const > const values ) +{ + // prepare dividers + std::vector< integer > div( numDimensions ); + div[0] = 1; + for( integer d = 1; d < numDimensions; d++ ) + { + div[d] = div[d-1] * coordinates[d-1].size(); + } + // loop through all the values + for( integer v = 0; v < values.size(); v++ ) + { + // find coords indices + std::vector< integer > idx( numDimensions ); + integer r = v; + for( integer d = numDimensions-1; d >= 0; d-- ) + { + idx[d] = r / div[d]; + r = r % div[d]; + } + // finally print out in right order + for( integer d = 0; d < numDimensions; d++ ) + { + arraySlice1d< real64 const > const coords = coordinates[d]; + formatterStream << coords[idx[d]] << ","; + } + formatterStream << values[v] << "\n"; + } +} + +void TableFunction::outputPVTTableData( OutputOptions const pvtOutputOpts ) const +{ + if( pvtOutputOpts.writeInLog && this->numDimensions() <= 2 ) + { + TableTextFormatter textFormatter; + GEOS_LOG_RANK_0( textFormatter.toString( *this )); + } + if( pvtOutputOpts.writeCSV || ( pvtOutputOpts.writeInLog && this->numDimensions() >= 3 ) ) + { + string const filename = this->getName(); + std::ofstream logStream( joinPath( FunctionBase::getOutputDirectory(), filename + ".csv" ) ); + GEOS_LOG_RANK_0( GEOS_FMT( "CSV Generated to {}/{}.csv \n", + FunctionBase::getOutputDirectory(), + filename )); + TableCSVFormatter csvFormatter; + logStream << csvFormatter.toString( *this ); + } +} + +template<> +string TableCSVFormatter::toString< TableFunction >( TableFunction const & tableFunction ) const +{ + ArrayOfArraysView< real64 const > const coordinates = tableFunction.getCoordinates(); + arrayView1d< real64 const > const values = tableFunction.getValues(); + units::Unit const valueUnit = tableFunction.getValueUnit(); + std::ostringstream formatterStream; + + integer const numDimensions = LvArray::integerConversion< integer >( coordinates.size() ); + if( numDimensions != 2 ) + { + collectHeaders( formatterStream, tableFunction, numDimensions, valueUnit ); + collectValues( formatterStream, numDimensions, coordinates, values ); + } + else + { + TableData2D tableData2D; + TableData2D::TableDataHolder tableConverted; + tableConverted = tableData2D.convertTable2D( values, + valueUnit, + coordinates, + units::getDescription( tableFunction.getDimUnit( 0 ) ), + units::getDescription( tableFunction.getDimUnit( 1 ) ) ); + + TableLayout tableLayout( tableConverted.headerNames ); + + TableCSVFormatter csvFormat( tableLayout ); + formatterStream << csvFormat.headerToString() << csvFormat.dataToString( tableConverted.tableData ); + } + return formatterStream.str(); +} + +template<> +string TableTextFormatter::toString< TableFunction >( TableFunction const & tableFunction ) const +{ + ArrayOfArraysView< real64 const > coordinates = tableFunction.getCoordinates(); + units::Unit const valueUnit = tableFunction.getValueUnit(); + arrayView1d< real64 const > const values = tableFunction.getValues(); + integer const numDimensions = LvArray::integerConversion< integer >( coordinates.size() ); + string const filename = tableFunction.getName(); + string logOutput; + + GEOS_LOG_RANK_0( GEOS_FMT( "Values in the table are represented by : {}", units::getDescription( valueUnit ))); + + if( numDimensions == 1 ) + { + TableData tableData; + arraySlice1d< real64 const > const coords = coordinates[0]; + for( integer idx = 0; idx < values.size(); idx++ ) + { + tableData.addRow( coords[idx], values[idx] ); + } + + TableLayout const tableLayout( { + string( units::getDescription( tableFunction.getDimUnit( 0 ))), + string( units::getDescription( valueUnit )) + }, filename ); + + TableTextFormatter const logTable( tableLayout ); + logOutput = logTable.toString( tableData ); + } + else if( numDimensions == 2 ) + { + integer const nX = coordinates[0].size(); + integer const nY = coordinates[1].size(); + if( nX * nY <= 500 ) + { + TableData2D tableData2D; + TableData2D::TableDataHolder tableConverted; + tableConverted = tableData2D.convertTable2D( values, + valueUnit, + coordinates, + units::getDescription( tableFunction.getDimUnit( 0 ) ), + units::getDescription( tableFunction.getDimUnit( 1 ) )); + + TableLayout tableLayout( tableConverted.headerNames, filename ); + + TableTextFormatter const table2DLog( tableLayout ); + logOutput = table2DLog.toString( tableConverted.tableData ); + } + else + { + string log = GEOS_FMT( "The {} PVT table exceeding 500 rows.\nTo visualize the tables, go to the generated csv \n", filename ); + TableLayout const tableLayoutInfos( {TableLayout::ColumnParam{{log}, TableLayout::Alignment::left}}, filename ); + TableTextFormatter const tableLog( tableLayoutInfos ); + logOutput = tableLog.layoutToString(); + } + } + return logOutput; +} + REGISTER_CATALOG_ENTRY( FunctionBase, TableFunction, string const &, Group * const ) } // end of namespace geos diff --git a/src/coreComponents/functions/TableFunction.hpp b/src/coreComponents/functions/TableFunction.hpp index 216b29ad91b..676807847a7 100644 --- a/src/coreComponents/functions/TableFunction.hpp +++ b/src/coreComponents/functions/TableFunction.hpp @@ -24,6 +24,7 @@ #include "codingUtilities/EnumStrings.hpp" #include "LvArray/src/tensorOps.hpp" +#include "common/format/table/TableFormatter.hpp" #include "common/Units.hpp" namespace geos @@ -47,6 +48,15 @@ class TableFunction : public FunctionBase Lower }; + /// Struct containing output options + struct OutputOptions + { + /// Output PVT in CSV file + bool writeCSV; + /// Output PVT in log + bool writeInLog; + }; + /// maximum dimensions for the coordinates in the table static constexpr integer maxDimensions = 4; @@ -277,7 +287,9 @@ class TableFunction : public FunctionBase * @return The unit of a coordinate dimension, or units::Unknown if no units has been specified. */ units::Unit getDimUnit( localIndex const dim ) const - { return size_t(dim) < m_dimUnits.size() ? m_dimUnits[dim] : units::Unknown; } + { + return size_t(dim) < m_dimUnits.size() ? m_dimUnits[dim] : units::Unknown; + } /** * @brief Set the interpolation method @@ -318,11 +330,17 @@ class TableFunction : public FunctionBase m_valueUnit = unit; } +/** + * @return The table unit + */ + units::Unit getValueUnit() const { return m_valueUnit; } + + /** - * @brief Print table into a CSV file (only 1d and 2d tables are supported) - * @param filename Filename for output + * @brief Print the table(s) in the log and/or CSV files when requested by the user. + * @param pvtOutputOpts Struct containing output options */ - void print( std::string const & filename ) const; + void outputPVTTableData( OutputOptions const pvtOutputOpts ) const; /** * @brief Create an instance of the kernel wrapper @@ -355,6 +373,7 @@ class TableFunction : public FunctionBase */ void readFile( string const & filename, array1d< real64 > & target ); + /// Coordinates for 1D table array1d< real64 > m_tableCoordinates1D; @@ -674,6 +693,22 @@ ENUM_STRINGS( TableFunction::InterpolationType, "upper", "lower" ); +/** + * @brief Template specialisation to convert a TableFunction to a CSV string. + * @param tableData The TableFunction object to convert. + * @return The CSV string representation of the TableFunction. + */ +template<> +string TableTextFormatter::toString< TableFunction >( TableFunction const & tableData ) const; + +/** + * @brief Template specialisation to convert a TableFunction to a table string. + * @param tableData The TableFunction object to convert. + * @return The table string representation of the TableFunction. + */ +template<> +string TableCSVFormatter::toString< TableFunction >( TableFunction const & tableData ) const; + } /* namespace geos */ #endif /* GEOS_FUNCTIONS_TABLEFUNCTION_HPP_ */ diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 2930e0f6b9e..a8430b98131 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -4374,6 +4374,8 @@ The expected format is "{ waterMax, oilMax }", in that order--> + + @@ -4394,6 +4396,8 @@ The expected format is "{ waterMax, oilMax }", in that order--> + + @@ -4414,6 +4418,8 @@ The expected format is "{ waterMax, oilMax }", in that order--> + + @@ -4434,6 +4440,8 @@ The expected format is "{ waterMax, oilMax }", in that order--> + + @@ -5445,6 +5453,8 @@ If you want to do a three-phase simulation, please use instead wettingIntermedia + + @@ -5459,6 +5469,8 @@ If you want to do a three-phase simulation, please use instead wettingIntermedia + + diff --git a/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp b/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp index 9b8a69cf84d..20df8c70fe5 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp @@ -361,13 +361,18 @@ std::unique_ptr< MODEL > makePVTFunction( string const & filename, { array1d< string > const strs = stringutilities::tokenizeBySpaces< array1d >( str ); + TableFunction::OutputOptions const pvtOutputOpts = { + true,// writeCSV + true, // writeInLog + }; + if( strs.size()>1 && strs[0] == key ) { pvtFunction = std::make_unique< MODEL >( strs[1], strs, componentNames, componentMolarWeight, - true ); // print PVT tables + pvtOutputOpts ); } } GEOS_ERROR_IF( pvtFunction == nullptr, @@ -401,7 +406,10 @@ std::unique_ptr< MODEL > makeFlashModel( string const & filename, while( std::getline( is, str ) ) { array1d< string > const strs = stringutilities::tokenizeBySpaces< array1d >( str ); - + TableFunction::OutputOptions const flashOutputOpts = { + true, // writeCSV + true, // writeInLog + }; if( strs.size()>1 && strs[0] == key ) { flashModel = std::make_unique< MODEL >( strs[1], @@ -409,7 +417,7 @@ std::unique_ptr< MODEL > makeFlashModel( string const & filename, phaseNames, componentNames, componentMolarWeight, - true ); // print PVT tables + flashOutputOpts ); } } GEOS_ERROR_IF( flashModel == nullptr, diff --git a/src/coreComponents/unitTests/constitutiveTests/testCO2SpycherPruessModels.cpp b/src/coreComponents/unitTests/constitutiveTests/testCO2SpycherPruessModels.cpp index e7cf917857e..a8160dc51f9 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testCO2SpycherPruessModels.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testCO2SpycherPruessModels.cpp @@ -83,12 +83,17 @@ CO2SolubilitySpycherPruessTestFixture::makeFlashModel( string const & fileConten // Read file parameters array1d< string > const strs = stringutilities::tokenizeBySpaces< array1d >( fileContent ); + TableFunction::OutputOptions const flashOutputOpts = { + false, // writeCSV + false, // writeInLog + }; + return std::make_unique< CO2Solubility >( strs[1], strs, phaseNames, componentNames, componentMolarWeight, - false ); + flashOutputOpts ); } TEST_P( CO2SolubilitySpycherPruessTestFixture, testExpectedValues ) diff --git a/src/docs/sphinx/developerGuide/Contributing/Sphinx.rst b/src/docs/sphinx/developerGuide/Contributing/Sphinx.rst index 1a273cce07a..2b09f25e2e4 100644 --- a/src/docs/sphinx/developerGuide/Contributing/Sphinx.rst +++ b/src/docs/sphinx/developerGuide/Contributing/Sphinx.rst @@ -35,3 +35,21 @@ like those describing a specific class, can instead be found in ``docs`` subdire in the folder containing the source code. Information about how to write ``rst`` files can be found `here `_ . + +Fixing errors the documentation +=============================== +As part of the Continuous Integration process, the documentation is built on readthedocs, and any warnings or errors result in a failure test failure. +What follows is a brief guide on how to fix the most common errors. + +#. Navigate to the readthedocs build logs. This can be done by clicking on the failed test in the github test summary. + +.. image:: githubtestsummary.png + :width: 600 + +#. Download the logs from the failed test on readthedocs through the "view raw" button. + +.. image:: readthedocsbuildsummary.png + :width: 600 + +#. Perform a case sensitive search for "WARNING:" or "ERROR" to locate the sphinx issues. +Note that there will be numerous doxygen warnings that should be ignored. \ No newline at end of file diff --git a/src/docs/sphinx/developerGuide/Contributing/githubtestsummary.png b/src/docs/sphinx/developerGuide/Contributing/githubtestsummary.png new file mode 100644 index 00000000000..87d77dd9a22 Binary files /dev/null and b/src/docs/sphinx/developerGuide/Contributing/githubtestsummary.png differ diff --git a/src/docs/sphinx/developerGuide/Contributing/readthedocsbuildsummary.png b/src/docs/sphinx/developerGuide/Contributing/readthedocsbuildsummary.png new file mode 100644 index 00000000000..fc6a42e6a0c Binary files /dev/null and b/src/docs/sphinx/developerGuide/Contributing/readthedocsbuildsummary.png differ