Skip to content

Commit

Permalink
PVT & TPL error message rewrite (#2929)
Browse files Browse the repository at this point in the history
Co-authored-by: Randolph Settgast <[email protected]>
  • Loading branch information
MelReyCG and rrsettgast authored Apr 9, 2024
1 parent 45725d5 commit 344c9d9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
8 changes: 8 additions & 0 deletions host-configs/tpls.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
#
message("in tpls.cmake GEOSX_TPL_DIR=${GEOSX_TPL_DIR}")

#
# General TPL Folder verifications
#
if(NOT EXISTS ${GEOSX_TPL_DIR})
message(WARNING "'GEOSX_TPL_DIR' does not exist.\n")
endif()


if(EXISTS ${GEOSX_TPL_DIR}/raja)
set(RAJA_DIR ${GEOSX_TPL_DIR}/raja CACHE PATH "" FORCE)
endif()
Expand Down
37 changes: 30 additions & 7 deletions src/cmake/thirdparty/SetupGeosxThirdParty.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
####################################
#
# 3rd Party Dependencies
#
# Setup all GEOS TPL
#
####################################


################################
# Helper macros & functions
################################

macro(find_and_import)
set(singleValueArgs NAME HEADER)
set(multiValueArgs INCLUDE_DIRECTORIES
Expand Down Expand Up @@ -101,8 +110,22 @@ macro(extract_version_from_header)

endmacro( extract_version_from_header)


macro(mandatory_tpl_doesnt_exist
CURRENT_TPL_NAME
CURRENT_TPL_DIR_VAR)

message(FATAL_ERROR
"GEOSX requires ${CURRENT_TPL_NAME}, either :\n"
" - Verify that you provided a valid TPL installation directory (GEOSX_TPL_DIR = \"${GEOSX_TPL_DIR}\"),\n"
" - Or set ${CURRENT_TPL_DIR_VAR} to the ${CURRENT_TPL_NAME} installation directory (${CURRENT_TPL_DIR_VAR} = \"${${CURRENT_TPL_DIR_VAR}}\").\n")

endmacro(mandatory_tpl_doesnt_exist)


set(thirdPartyLibs "")


################################
# BLAS/LAPACK
################################
Expand Down Expand Up @@ -184,7 +207,7 @@ if(DEFINED CONDUIT_DIR)

set(thirdPartyLibs ${thirdPartyLibs} conduit::conduit)
else()
message(FATAL_ERROR "GEOSX requires conduit, set CONDUIT_DIR to the conduit installation directory.")
mandatory_tpl_doesnt_exist("Conduit" CONDUIT_DIR)
endif()

################################
Expand Down Expand Up @@ -215,7 +238,7 @@ if(DEFINED HDF5_DIR)
set(ENABLE_HDF5 ON CACHE BOOL "")
set(thirdPartyLibs ${thirdPartyLibs} hdf5)
else()
message(FATAL_ERROR "GEOSX requires hdf5, set HDF5_DIR to the hdf5 installation directory.")
mandatory_tpl_doesnt_exist("hdf5" HDF5_DIR)
endif()

################################
Expand Down Expand Up @@ -259,7 +282,7 @@ if(DEFINED PUGIXML_DIR)
set(thirdPartyLibs ${thirdPartyLibs} pugixml)
endif()
else()
message(FATAL_ERROR "GEOSX requires pugixml, set PUGIXML_DIR to the pugixml installation directory.")
mandatory_tpl_doesnt_exist("pugixml" PUGIXML_DIR)
endif()

################################
Expand Down Expand Up @@ -291,7 +314,7 @@ if(DEFINED RAJA_DIR)
set(ENABLE_RAJA ON CACHE BOOL "")
set(thirdPartyLibs ${thirdPartyLibs} RAJA )
else()
message(FATAL_ERROR "GEOSX requires RAJA, set RAJA_DIR to the RAJA installation directory.")
mandatory_tpl_doesnt_exist("RAJA" RAJA_DIR)
endif()

################################
Expand Down Expand Up @@ -322,7 +345,7 @@ if(DEFINED UMPIRE_DIR)
set(ENABLE_UMPIRE ON CACHE BOOL "")
set(thirdPartyLibs ${thirdPartyLibs} umpire)
else()
message(FATAL_ERROR "GEOSX requires Umpire, set UMPIRE_DIR to the Umpire installation directory.")
mandatory_tpl_doesnt_exist("Umpire" UMPIRE_DIR)
endif()


Expand All @@ -345,7 +368,7 @@ if(DEFINED CHAI_DIR)
set(ENABLE_CHAI ON CACHE BOOL "")
set(thirdPartyLibs ${thirdPartyLibs} chai)
else()
message(FATAL_ERROR "GEOSX requires CHAI, set CHAI_DIR to the CHAI installation directory.")
mandatory_tpl_doesnt_exist("CHAI" CHAI_DIR)
endif()

################################
Expand Down Expand Up @@ -800,7 +823,7 @@ if(DEFINED FMT_DIR)

set(thirdPartyLibs ${thirdPartyLibs} fmt::fmt )
else()
message(FATAL_ERROR "GEOSX requires {fmt}, set FMT_DIR to the {fmt} installation directory.")
mandatory_tpl_doesnt_exist("{fmt}" FMT_DIR)
endif()

################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::checkTablesParameters( real64 const
m_phase1->enthalpy.checkTablesParameters( pressure, temperatureInCelsius );
} catch( SimulationError const & ex )
{
string const errorMsg = GEOS_FMT( "{}: Table input error for phase no. 1.\n", getDataContext() );
string const errorMsg = GEOS_FMT( "Table input error for {} phase (in table from \"{}\").\n",
m_phaseNames[m_p1Index], m_phasePVTParaFiles[m_p1Index] );
throw SimulationError( ex, errorMsg );
}

Expand All @@ -173,7 +174,8 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::checkTablesParameters( real64 const
m_phase2->enthalpy.checkTablesParameters( pressure, temperatureInCelsius );
} catch( SimulationError const & ex )
{
string const errorMsg = GEOS_FMT( "{}: Table input error for phase no. 2.\n", getDataContext() );
string const errorMsg = GEOS_FMT( "Table input error for {} phase (in table from \"{}\").\n",
m_phaseNames[m_p2Index], m_phasePVTParaFiles[m_p2Index] );
throw SimulationError( ex, errorMsg );
}

Expand All @@ -182,7 +184,8 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::checkTablesParameters( real64 const
m_flash->checkTablesParameters( pressure, temperatureInCelsius );
} catch( SimulationError const & ex )
{
string const errorMsg = GEOS_FMT( "{}: Table input error for flash phase.\n", getDataContext() );
string const errorMsg = GEOS_FMT( "Table input error for flash phase (in table from \"{}\").\n",
m_flashModelParaFile );
throw SimulationError( ex, errorMsg );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ void ReactiveBrineFluid< PHASE >::checkTablesParameters( real64 const pressure,
m_phase->enthalpy.checkTablesParameters( pressure, temperatureInCelsius );
} catch( SimulationError const & ex )
{
string const errorMsg = GEOS_FMT( "{}: Table input error.\n", getDataContext() );
string const errorMsg = GEOS_FMT( "Table input error (in table from {}).\n",
stringutilities::join( m_phasePVTParaFiles ) );
throw SimulationError( ex, errorMsg );
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/coreComponents/functions/TableFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ void TableFunction::checkCoord( real64 const coord, localIndex const dim ) const
real64 const upperBound = m_coordinates[dim][m_coordinates.sizeOfArray( dim ) - 1];
GEOS_THROW_IF( coord > upperBound || coord < lowerBound,
GEOS_FMT( "{}: Requested {} is out of the table bounds ( lower bound: {} -> upper bound: {} ).",
getDataContext(), units::formatValue( coord, getDimUnit( dim ) ), lowerBound, upperBound ),
getDataContext(),
units::formatValue( coord, getDimUnit( dim ) ),
units::formatValue( lowerBound, getDimUnit( dim ) ),
units::formatValue( upperBound, getDimUnit( dim ) ) ),
SimulationError );
}

Expand Down

0 comments on commit 344c9d9

Please sign in to comment.