diff --git a/src/coreComponents/events/EventBase.cpp b/src/coreComponents/events/EventBase.cpp index 12ebd7fda7c..4df6a101093 100644 --- a/src/coreComponents/events/EventBase.cpp +++ b/src/coreComponents/events/EventBase.cpp @@ -144,7 +144,15 @@ void EventBase::getTargetReferences() { if( !m_eventTarget.empty()) { - m_target = &this->getGroupByPath< ExecutableGroup >( m_eventTarget ); + try + { + m_target = &this->getGroupByPath< ExecutableGroup >( m_eventTarget ); + } + catch( std::exception const & e ) + { + throw InputError( e, GEOS_FMT( "Error while reading {}:\n", + getWrapperDataContext( viewKeyStruct::eventTargetString() ) ) ); + } } this->forSubGroups< EventBase >( []( EventBase & subEvent ) diff --git a/src/coreComponents/events/PeriodicEvent.cpp b/src/coreComponents/events/PeriodicEvent.cpp index 2017cb37592..bf1782b9b11 100644 --- a/src/coreComponents/events/PeriodicEvent.cpp +++ b/src/coreComponents/events/PeriodicEvent.cpp @@ -245,15 +245,19 @@ void PeriodicEvent::validate() const GEOS_THROW_IF( m_timeFrequency > 0 && target->getTimesteppingBehavior() == ExecutableGroup::TimesteppingBehavior::DeterminesTimeStepSize, - GEOS_FMT( - "`{}`: This event targets an object that automatically selects the time step size. Therefore, `{}` cannot be used here. However, forcing a constant time step size can still be achived with `{}`.", - getName(), viewKeyStruct::timeFrequencyString(), EventBase::viewKeyStruct::forceDtString() ), + GEOS_FMT( "`{}`: This event targets an object that automatically selects the time " + "step size. Therefore, `{}` cannot be used here. However, forcing a " + "constant time step size can still be achived with `{}`.", + getDataContext(), viewKeyStruct::timeFrequencyString(), + EventBase::viewKeyStruct::forceDtString() ), InputError ); GEOS_THROW_IF( m_cycleFrequency != 1 && target->getTimesteppingBehavior() == ExecutableGroup::TimesteppingBehavior::DeterminesTimeStepSize, - GEOS_FMT( - "`{}`: This event targets an object that automatically selects the time step size. Therefore, `{}` cannot be used here. However, forcing a constant time step size can still be achived with `{}`.", - getName(), viewKeyStruct::cycleFrequencyString(), EventBase::viewKeyStruct::forceDtString() ), + GEOS_FMT( "`{}`: This event targets an object that automatically selects the time " + "step size. Therefore, `{}` cannot be used here. However, forcing a " + "constant time step size can still be achived with `{}`.", + getDataContext(), viewKeyStruct::cycleFrequencyString(), + EventBase::viewKeyStruct::forceDtString() ), InputError ); } diff --git a/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp index 0555c70b6f2..7f8c6916155 100644 --- a/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/AquiferBoundaryCondition.cpp @@ -115,7 +115,8 @@ AquiferBoundaryCondition::AquiferBoundaryCondition( string const & name, Group * void AquiferBoundaryCondition::postProcessInput() { GEOS_THROW_IF_LE_MSG( m_permeability, 0.0, - getCatalogName() << " " << getName() << ": the aquifer permeability cannot be equal to zero or negative", + getCatalogName() << " " << getDataContext() << + ": the aquifer permeability cannot be equal to zero or negative", InputError ); if( m_pressureInfluenceFunctionName.empty() ) @@ -126,13 +127,16 @@ void AquiferBoundaryCondition::postProcessInput() { FunctionManager const & functionManager = FunctionManager::getInstance(); GEOS_THROW_IF( !functionManager.hasGroup( m_pressureInfluenceFunctionName ), - getCatalogName() << " " << getName() << ": the pressure influence table " << m_pressureInfluenceFunctionName << " could not be found", + getCatalogName() << " " << getDataContext() << + ": the pressure influence table " << m_pressureInfluenceFunctionName << " could not be found", InputError ); TableFunction const & pressureInfluenceFunction = functionManager.getGroup< TableFunction >( m_pressureInfluenceFunctionName ); GEOS_THROW_IF( pressureInfluenceFunction.getInterpolationMethod() != TableFunction::InterpolationType::Linear, - getCatalogName() << " " << getName() << ": The interpolation method for the pressure influence function table " - << pressureInfluenceFunction.getName() << " should be TableFunction::InterpolationType::Linear", + getCatalogName() << " " << getDataContext() << + ": The interpolation method for the pressure influence function table " << + pressureInfluenceFunction.getDataContext() << + " should be TableFunction::InterpolationType::Linear", InputError ); } @@ -140,17 +144,19 @@ void AquiferBoundaryCondition::postProcessInput() computeInfluxConstant(); GEOS_THROW_IF_LE_MSG( m_timeConstant, 0.0, - getCatalogName() << " " << getName() << ": the aquifer time constant is equal to zero or negative, the simulation cannot procede", + getCatalogName() << " " << getDataContext() << + ": the aquifer time constant is equal to zero or negative, the simulation cannot procede", InputError ); GEOS_THROW_IF_LE_MSG( m_influxConstant, 0.0, - getCatalogName() << " " << getName() << ": the aquifer influx constant is equal to zero or negative, the simulation cannot procede", + getCatalogName() << " " << getDataContext() << + ": the aquifer influx constant is equal to zero or negative, the simulation cannot procede", InputError ); GEOS_THROW_IF_NE_MSG( m_phaseComponentFraction.size(), m_phaseComponentNames.size(), - getCatalogName() << " " << getName() << ": the sizes of " - << viewKeyStruct::aquiferWaterPhaseComponentFractionString() << " and " << viewKeyStruct::aquiferWaterPhaseComponentNamesString() - << " are inconsistent", + getCatalogName() << " " << getDataContext() << + ": the sizes of " << viewKeyStruct::aquiferWaterPhaseComponentFractionString() << + " and " << viewKeyStruct::aquiferWaterPhaseComponentNamesString() << " are inconsistent", InputError ); } @@ -263,7 +269,7 @@ void AquiferBoundaryCondition::setupDefaultPressureInfluenceFunction() void AquiferBoundaryCondition::setGravityVector( R1Tensor const & gravityVector ) { GEOS_LOG_RANK_0_IF( ( !isZero( gravityVector[0] ) || !isZero( gravityVector[1] ) ), - catalogName() << " " << getName() << + catalogName() << " " << getDataContext() << "The gravity vector specified in this simulation (" << gravityVector[0] << " " << gravityVector[1] << " " << gravityVector[2] << ") is not aligned with the z-axis. \n" << "But, the pressure difference between reservoir and aquifer uses " << viewKeyStruct::aquiferElevationString() << diff --git a/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp b/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp index adb41837e56..3b696e70928 100644 --- a/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp +++ b/src/coreComponents/fieldSpecification/EquilibriumInitialCondition.cpp @@ -89,8 +89,7 @@ void EquilibriumInitialCondition::postProcessInput() { GEOS_THROW_IF( ( m_temperatureVsElevationTableName.empty() != m_componentFractionVsElevationTableNames.empty() ), - getCatalogName() << " " << getName() - << ": both " << + getCatalogName() << " " << getDataContext() << ": both " << viewKeyStruct::componentFractionVsElevationTableNamesString() << " and " << viewKeyStruct::temperatureVsElevationTableNameString() << " must be provided for a multiphase simulation", InputError ); @@ -100,37 +99,38 @@ void EquilibriumInitialCondition::postProcessInput() if( !m_componentFractionVsElevationTableNames.empty() ) { GEOS_THROW_IF( m_componentFractionVsElevationTableNames.size() <= 1, - getCatalogName() << " " << getName() << ": at least two component names must be specified in " - << viewKeyStruct::componentNamesString(), + getCatalogName() << " " << getDataContext() << + ": at least two component names must be specified in " << viewKeyStruct::componentNamesString(), InputError ); GEOS_THROW_IF( m_componentFractionVsElevationTableNames.size() != m_componentNames.size(), - getCatalogName() << " " << getName() << ": mismatch between the size of " - << viewKeyStruct::componentNamesString() << " and " << viewKeyStruct::componentFractionVsElevationTableNamesString(), + getCatalogName() << " " << getDataContext() << ": mismatch between the size of " << + viewKeyStruct::componentNamesString() << + " and " << viewKeyStruct::componentFractionVsElevationTableNamesString(), InputError ); GEOS_THROW_IF( m_componentNames.size() >= 2 && m_initPhaseName.empty(), - getCatalogName() << " " << getName() << ": for now, the keyword: " << viewKeyStruct::initPhaseNameString() - << " must be filled for a multiphase simulation", + getCatalogName() << " " << getDataContext() << ": for now, the keyword: " << + viewKeyStruct::initPhaseNameString() << " must be filled for a multiphase simulation", InputError ); array1d< localIndex > tableSizes( m_componentNames.size() ); for( localIndex ic = 0; ic < m_componentNames.size(); ++ic ) { GEOS_THROW_IF( m_componentFractionVsElevationTableNames[ic].empty(), - getCatalogName() << " " << getName() - << ": the component fraction vs elevation table name is missing for component " << ic, + getCatalogName() << " " << getDataContext() << + ": the component fraction vs elevation table name is missing for component " << ic, InputError ); GEOS_THROW_IF( !m_componentFractionVsElevationTableNames[ic].empty() && !functionManager.hasGroup( m_componentFractionVsElevationTableNames[ic] ), - getCatalogName() << " " << getName() - << ": the component fraction vs elevation table " << m_componentFractionVsElevationTableNames[ic] - << " could not be found" << " for component " << ic, + getCatalogName() << " " << getDataContext() << ": the component fraction vs elevation table " << + m_componentFractionVsElevationTableNames[ic] << " could not be found" << " for component " << ic, InputError ); TableFunction const & compFracTable = functionManager.getGroup< TableFunction >( m_componentFractionVsElevationTableNames[ic] ); GEOS_THROW_IF( compFracTable.getInterpolationMethod() != TableFunction::InterpolationType::Linear, - getCatalogName() << " " << getName() << ": the interpolation method for the component fraction vs elevation table " - << compFracTable.getName() << " should be TableFunction::InterpolationType::Linear", + getCatalogName() << " " << getDataContext() << + ": the interpolation method for the component fraction vs elevation table " << + compFracTable.getName() << " should be TableFunction::InterpolationType::Linear", InputError ); } @@ -140,13 +140,15 @@ void EquilibriumInitialCondition::postProcessInput() { GEOS_THROW_IF( !functionManager.hasGroup( m_temperatureVsElevationTableName ), - getCatalogName() << " " << getName() << ": the temperature vs elevation table " << m_temperatureVsElevationTableName << " could not be found", + getCatalogName() << " " << getDataContext() << ": the temperature vs elevation table " << + m_temperatureVsElevationTableName << " could not be found", InputError ); TableFunction const & tempTable = functionManager.getGroup< TableFunction >( m_temperatureVsElevationTableName ); GEOS_THROW_IF( tempTable.getInterpolationMethod() != TableFunction::InterpolationType::Linear, - getCatalogName() << " " << getName() << ": The interpolation method for the temperature vs elevation table " - << tempTable.getName() << " should be TableFunction::InterpolationType::Linear", + getCatalogName() << " " << getDataContext() << + ": The interpolation method for the temperature vs elevation table " << tempTable.getName() << + " should be TableFunction::InterpolationType::Linear", InputError ); } } @@ -165,16 +167,17 @@ void EquilibriumInitialCondition::initializePreSubGroups() TableFunction const & compFracTable = functionManager.getGroup< TableFunction >( m_componentFractionVsElevationTableNames[ic] ); arrayView1d< real64 const > compFracValues = compFracTable.getValues(); GEOS_THROW_IF( compFracValues.size() <= 1, - getCatalogName() << " " << getName() << ": the component fraction vs elevation table " - << compFracTable.getName() << " must contain at least two values", + getCatalogName() << " " << getDataContext() << + ": the component fraction vs elevation table " << compFracTable.getName() << + " must contain at least two values", InputError ); tableSizes[ic] = compFracValues.size(); if( ic >= 1 ) { GEOS_THROW_IF( tableSizes[ic] != tableSizes[ic-1], - getCatalogName() << " " << getName() - << ": all the component fraction vs elevation tables must contain the same number of values", + getCatalogName() << " " << getDataContext() << + ": all the component fraction vs elevation tables must contain the same number of values", InputError ); } } @@ -195,16 +198,16 @@ void EquilibriumInitialCondition::initializePreSubGroups() if( ic >= 1 ) { GEOS_THROW_IF( !isZero( elevation[ic][i] - elevation[ic-1][i] ), - getCatalogName() << " " << getName() - << ": the elevation values must be the same in all the component vs elevation tables", + getCatalogName() << " " << getDataContext() << + ": the elevation values must be the same in all the component vs elevation tables", InputError ); } if( ic == m_componentNames.size() - 1 ) { GEOS_THROW_IF( !isZero( sumCompFrac[i] - 1 ), - getCatalogName() << " " << getName() - << ": at a given elevation, the component fraction sum must be equal to one", + getCatalogName() << " " << getDataContext() << + ": at a given elevation, the component fraction sum must be equal to one", InputError ); } } diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp index b8499a8d572..49a49f0a081 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationBase.hpp @@ -614,7 +614,18 @@ void FieldSpecificationBase::applyFieldValueKernel( ArrayView< T, N, USD > const } else { - FunctionBase const & function = functionManager.getGroup< FunctionBase >( m_functionName ); + FunctionBase const & function = [&]() -> FunctionBase const & + { + try + { + return functionManager.getGroup< FunctionBase >( m_functionName ); + } + catch( std::exception const & e ) + { + throw InputError( e, GEOS_FMT( "Error while reading {}:\n", + getWrapperDataContext( viewKeyStruct::functionNameString() ) ) ); + } + }(); if( function.isFunctionOfTime()==2 ) { diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp index f9beca48a16..f1b8d2df8d1 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp @@ -172,8 +172,10 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c { missingSetNames.emplace_back( mapEntry.first ); } - GEOS_THROW( GEOS_FMT( "\n{}: there is/are no set(s) named `{}` under the {} `{}`, check the XML input\n", - fs.getName(), fmt::join( missingSetNames, ", " ), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() ), + GEOS_THROW( GEOS_FMT( "\n{}: there is/are no set(s) named `{}` under the {} `{}`.\n", + fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::objectPathString() ), + fmt::join( missingSetNames, ", " ), + FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() ), InputError ); } @@ -182,20 +184,20 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c for( auto const & mapEntry : isTargetSetEmpty ) { GEOS_LOG_RANK_0_IF( ( mapEntry.second == 1 ), // target set is empty - GEOS_FMT( "\nWarning!" - "\n{}: this FieldSpecification targets (an) empty set(s)" + GEOS_FMT( "\nWarning!\n{}: this FieldSpecification targets (an) empty set(s)" "\nIf the simulation does not involve the SurfaceGenerator, check the content of the set `{}` in `{}`. \n", - fs.getName(), mapEntry.first, fs.getObjectPath() ) ); + fs.getDataContext(), mapEntry.first, fs.getObjectPath() ) ); } if( isFieldNameFound == 0 ) { char const fieldNameNotFoundMessage[] = - "\n{}: there is no {} named `{}` under the {} `{}`, check the XML input\n"; + "\n{}: there is no {} named `{}` under the {} `{}`.\n"; string const errorMsg = GEOS_FMT( fieldNameNotFoundMessage, - fs.getName(), FieldSpecificationBase::viewKeyStruct::fieldNameString(), fs.getFieldName(), - FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() ); + fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ), + FieldSpecificationBase::viewKeyStruct::fieldNameString(), + fs.getFieldName(), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() ); if( areAllSetsEmpty ) { GEOS_LOG_RANK_0( errorMsg ); diff --git a/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp b/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp index ae9ffeaaf4a..bdc50920a25 100644 --- a/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp +++ b/src/coreComponents/fieldSpecification/PerfectlyMatchedLayer.cpp @@ -78,45 +78,45 @@ PerfectlyMatchedLayer::PerfectlyMatchedLayer( string const & name, Group * const void PerfectlyMatchedLayer::postProcessInput() { GEOS_THROW_IF( (m_xMax[0]1), - getCatalogName() << " " << getName() << " " + getCatalogName() << " " << getDataContext() << " " << viewKeyStruct::reflectivityString() << " must satisfy 0 < reflectivity <= 1", InputError ); GEOS_LOG_RANK_0_IF( (m_xMin[0]largestXMax || m_xMax[1]>largestXMax || m_xMax[2]>largestXMax), - getCatalogName() << " " << getName() << " " + getCatalogName() << " " << getDataContext() << " " << viewKeyStruct::xMaxString() << " will be computed internally" ); GEOS_LOG_RANK_0_IF( (m_thicknessMinXYZ[0]<0 || m_thicknessMinXYZ[1]<0 || m_thicknessMinXYZ[2]<0), - getCatalogName() << " " << getName() << " " + getCatalogName() << " " << getDataContext() << " " << viewKeyStruct::thicknessMinXYZString() << " will be computed internally" ); GEOS_LOG_RANK_0_IF( (m_thicknessMaxXYZ[0]<0 || m_thicknessMaxXYZ[1]<0 || m_thicknessMaxXYZ[2]<0), - getCatalogName() << " " << getName() << " " + getCatalogName() << " " << getDataContext() << " " << viewKeyStruct::thicknessMaxXYZString() << " will be computed internally" ); GEOS_LOG_RANK_0_IF( (m_waveSpeedMinXYZ[0]<0 || m_waveSpeedMinXYZ[1]<0 || m_waveSpeedMinXYZ[2]<0), - getCatalogName() << " " << getName() << " " + getCatalogName() << " " << getDataContext() << " " << viewKeyStruct::waveSpeedMinXYZString() << " will be computed internally" ); GEOS_LOG_RANK_0_IF( (m_waveSpeedMaxXYZ[0]<0 || m_waveSpeedMaxXYZ[1]<0 || m_waveSpeedMaxXYZ[2]<0), - getCatalogName() << " " << getName() << " " + getCatalogName() << " " << getDataContext() << " " << viewKeyStruct::waveSpeedMaxXYZString() << " will be computed internally" ); } diff --git a/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp b/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp index aed834da49e..5bf74b2d2da 100644 --- a/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp +++ b/src/coreComponents/fieldSpecification/TractionBoundaryCondition.cpp @@ -65,14 +65,14 @@ void TractionBoundaryCondition::postProcessInput() if( m_tractionType == TractionType::vector ) { GEOS_ERROR_IF( LvArray::tensorOps::l2Norm< 3 >( getDirection() ) < 1e-20, - viewKeyStruct::directionString() << " is required for " << + getDataContext() << ": " << viewKeyStruct::directionString() << " is required for " << viewKeyStruct::tractionTypeString() << " = " << TractionType::vector << ", but appears to be unspecified" ); } else { GEOS_LOG_RANK_0_IF( LvArray::tensorOps::l2Norm< 3 >( getDirection() ) > 1e-20, - viewKeyStruct::directionString() << " is not required unless " << + getDataContext() << ": " << viewKeyStruct::directionString() << " is not required unless " << viewKeyStruct::tractionTypeString() << " = " << TractionType::vector << ", but appears to be specified" ); } @@ -80,12 +80,12 @@ void TractionBoundaryCondition::postProcessInput() bool const inputStressRead = getWrapper< R2SymTensor >( viewKeyStruct::inputStressString() ).getSuccessfulReadFromInput(); GEOS_LOG_RANK_0_IF( inputStressRead && m_tractionType != TractionType::stress, - viewKeyStruct::inputStressString() << " is specified, but " << + getDataContext() << ": " << viewKeyStruct::inputStressString() << " is specified, but " << viewKeyStruct::tractionTypeString() << " != " << TractionType::stress << ", so value of " << viewKeyStruct::inputStressString() << " is unused." ); GEOS_ERROR_IF( !inputStressRead && m_tractionType == TractionType::stress, - viewKeyStruct::tractionTypeString() << " = " << TractionType::stress << + getDataContext() << ": " << viewKeyStruct::tractionTypeString() << " = " << TractionType::stress << ", but " << viewKeyStruct::inputStressString() << " is not specified." ); diff --git a/src/coreComponents/fileIO/Outputs/SiloOutput.cpp b/src/coreComponents/fileIO/Outputs/SiloOutput.cpp index 1d3867cf862..ecab64ead55 100644 --- a/src/coreComponents/fileIO/Outputs/SiloOutput.cpp +++ b/src/coreComponents/fileIO/Outputs/SiloOutput.cpp @@ -91,18 +91,23 @@ void SiloOutput::postProcessInput() GEOS_THROW_IF( ( m_onlyPlotSpecifiedFieldNames != 0 ) && m_fieldNames.empty(), GEOS_FMT( "{} `{}`: the flag `{}` is different from zero, but `{}` is empty, which is inconsistent", - catalogName(), getName(), onlyPlotSpecifiedFieldNamesString, fieldNamesString ), + catalogName(), getDataContext(), + onlyPlotSpecifiedFieldNamesString, fieldNamesString ), InputError ); GEOS_LOG_RANK_0_IF( !m_fieldNames.empty() && ( m_onlyPlotSpecifiedFieldNames != 0 ), GEOS_FMT( - "{} `{}`: found {} fields to plot in `{}`. These fields will be output regardless of the `plotLevel` specified by the user. No other field will be output.", - catalogName(), getName(), std::to_string( m_fieldNames.size() ), fieldNamesString ) ); + "{} `{}`: found {} fields to plot in `{}`. These fields will be output regardless" + " of the `plotLevel` specified by the user. No other field will be output.", + catalogName(), getDataContext(), + std::to_string( m_fieldNames.size() ), fieldNamesString ) ); GEOS_LOG_RANK_0_IF( !m_fieldNames.empty() && ( m_onlyPlotSpecifiedFieldNames == 0 ), GEOS_FMT( - "{} `{}`: found {} fields to plot in `{}`, in addition to all fields with `plotLevel` smaller or equal to {}.", - catalogName(), getName(), std::to_string( m_fieldNames.size() ), fieldNamesString, m_plotLevel ) ); + "{} `{}`: found {} fields to plot in `{}`, in addition to all fields with " + "`plotLevel` smaller or equal to {}.", + catalogName(), getDataContext(), std::to_string( m_fieldNames.size() ), + fieldNamesString, m_plotLevel ) ); } diff --git a/src/coreComponents/fileIO/Outputs/TimeHistoryOutput.cpp b/src/coreComponents/fileIO/Outputs/TimeHistoryOutput.cpp index 1e8d5cb8719..1a47c2d864b 100644 --- a/src/coreComponents/fileIO/Outputs/TimeHistoryOutput.cpp +++ b/src/coreComponents/fileIO/Outputs/TimeHistoryOutput.cpp @@ -124,9 +124,17 @@ void TimeHistoryOutput::initializePostInitialConditionsPostSubGroups() DomainPartition & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" ); for( auto collectorPath : m_collectorPaths ) { - HistoryCollection & collector = this->getGroupByPath< HistoryCollection >( collectorPath ); - collector.initializePostSubGroups(); - initCollectorParallel( domain, collector ); + try + { + HistoryCollection & collector = this->getGroupByPath< HistoryCollection >( collectorPath ); + collector.initializePostSubGroups(); + initCollectorParallel( domain, collector ); + } + catch( std::exception const & e ) + { + throw InputError( e, GEOS_FMT( "Error while reading {}:\n", + getWrapperDataContext( viewKeys::timeHistoryOutputTargetString() ) ) ); + } } } diff --git a/src/coreComponents/fileIO/Outputs/VTKOutput.cpp b/src/coreComponents/fileIO/Outputs/VTKOutput.cpp index aca02acc171..b0b2d9493dd 100644 --- a/src/coreComponents/fileIO/Outputs/VTKOutput.cpp +++ b/src/coreComponents/fileIO/Outputs/VTKOutput.cpp @@ -92,18 +92,21 @@ void VTKOutput::postProcessInput() GEOS_THROW_IF( ( m_onlyPlotSpecifiedFieldNames != 0 ) && m_fieldNames.empty(), GEOS_FMT( "{} `{}`: the flag `{}` is different from zero, but `{}` is empty, which is inconsistent", - catalogName(), getName(), onlyPlotSpecifiedFieldNamesString, fieldNamesString ), + catalogName(), getDataContext(), + onlyPlotSpecifiedFieldNamesString, fieldNamesString ), InputError ); GEOS_LOG_RANK_0_IF( !m_fieldNames.empty() && ( m_onlyPlotSpecifiedFieldNames != 0 ), GEOS_FMT( "{} `{}`: found {} fields to plot in `{}`. These fields will be output regardless of the `plotLevel` specified by the user. No other field will be output.", - catalogName(), getName(), std::to_string( m_fieldNames.size() ), fieldNamesString ) ); + catalogName(), getDataContext(), + std::to_string( m_fieldNames.size() ), fieldNamesString ) ); GEOS_LOG_RANK_0_IF( !m_fieldNames.empty() && ( m_onlyPlotSpecifiedFieldNames == 0 ), GEOS_FMT( "{} `{}`: found {} fields to plot in `{}`, in addition to all fields with `plotLevel` smaller or equal to {}.", - catalogName(), getName(), std::to_string( m_fieldNames.size() ), fieldNamesString, m_plotLevel ) ); + catalogName(), getDataContext(), + std::to_string( m_fieldNames.size() ), fieldNamesString, m_plotLevel ) ); } diff --git a/src/coreComponents/fileIO/timeHistory/PackCollection.cpp b/src/coreComponents/fileIO/timeHistory/PackCollection.cpp index 1bf183729ac..70d01c7eb9d 100644 --- a/src/coreComponents/fileIO/timeHistory/PackCollection.cpp +++ b/src/coreComponents/fileIO/timeHistory/PackCollection.cpp @@ -124,8 +124,16 @@ void PackCollection::updateSetsIndices( DomainPartition const & domain ) }; Group const * targetGrp = this->getTargetObject( domain, m_objectPath ); - WrapperBase const & targetField = targetGrp->getWrapperBase( m_fieldName ); - GEOS_ERROR_IF( !targetField.isPackable( false ), "The object targeted for collection must be packable!" ); + try + { + WrapperBase const & targetField = targetGrp->getWrapperBase( m_fieldName ); + GEOS_ERROR_IF( !targetField.isPackable( false ), "The object targeted for collection must be packable!" ); + } + catch( std::exception const & e ) + { + throw InputError( e, getWrapperDataContext( viewKeysStruct::fieldNameString() ).toString() + + ": Target not found !\n" ); + } // If no set or "all" is specified we retrieve the entire field. // If sets are specified we retrieve the field only from those sets. diff --git a/src/coreComponents/finiteElement/FiniteElementDiscretization.cpp b/src/coreComponents/finiteElement/FiniteElementDiscretization.cpp index 7c8beb1d7a1..d8ad2f8ec5f 100644 --- a/src/coreComponents/finiteElement/FiniteElementDiscretization.cpp +++ b/src/coreComponents/finiteElement/FiniteElementDiscretization.cpp @@ -57,8 +57,10 @@ FiniteElementDiscretization::~FiniteElementDiscretization() void FiniteElementDiscretization::postProcessInput() { // GEOS_ERROR_IF_NE_MSG( m_order, 1, "Higher order finite element spaces are currently not supported." ); - GEOS_ERROR_IF( m_formulation != "default" && m_formulation != "SEM", "Only standard element formulations and spectral element formulations are currently supported." ); - GEOS_ERROR_IF_GT_MSG( m_useVem, 1, "The flag useVirtualElements can be either 0 or 1" ); + GEOS_ERROR_IF( m_formulation != "default" && m_formulation != "SEM", + getDataContext() << ": Only standard element formulations and spectral element formulations are currently supported." ); + GEOS_ERROR_IF_GT_MSG( m_useVem, 1, + getDataContext() << ": The flag useVirtualElements can be either 0 or 1" ); } std::unique_ptr< FiniteElementBase > @@ -168,7 +170,7 @@ FiniteElementDiscretization::factory( ElementType const parentElementShape ) con #endif default: { - GEOS_ERROR( "Element type " << parentElementShape << " does not have an associated element formulation." ); + GEOS_ERROR( getDataContext() << ": Element type " << parentElementShape << " does not have an associated element formulation." ); } } return {}; @@ -181,14 +183,16 @@ FiniteElementDiscretization::factory( ElementType const parentElementShape ) con #if !defined( GEOS_USE_HIP ) case ElementType::Hexahedron: GEOS_ERROR_IF( m_formulation != "SEM", - "Element type Hexahedron with order 2 available only when using the Spectral Element Method" ); + getDataContext() << ": Element type Hexahedron with order 2 available" << + " only when using the Spectral Element Method" ); return std::make_unique< Q2_Hexahedron_Lagrange_GaussLobatto >(); #else GEOS_ERROR( "Cannot compile this with HIP active." ); #endif default: { - GEOS_ERROR( "Element type " << parentElementShape << " does not have an associated element formulation." ); + GEOS_ERROR( getDataContext() << ": Element type " << parentElementShape << " does not" << + " have an associated element formulation." ); } } return {}; @@ -201,14 +205,16 @@ FiniteElementDiscretization::factory( ElementType const parentElementShape ) con #if !defined( GEOS_USE_HIP ) case ElementType::Hexahedron: GEOS_ERROR_IF( m_formulation != "SEM", - "Element type Hexahedron with order 3 available only when using the Spectral Element Method" ); + getDataContext() << ": Element type Hexahedron with order 3 available" << + " only when using the Spectral Element Method" ); return std::make_unique< Q3_Hexahedron_Lagrange_GaussLobatto >(); #else GEOS_ERROR( "Cannot compile this with HIP active." ); #endif default: { - GEOS_ERROR( "Element type " << parentElementShape << " does not have an associated element formulation." ); + GEOS_ERROR( getDataContext() << ": Element type " << parentElementShape << " does not" << + " have an associated element formulation." ); } } return {}; @@ -221,14 +227,16 @@ FiniteElementDiscretization::factory( ElementType const parentElementShape ) con #if !defined( GEOS_USE_HIP ) case ElementType::Hexahedron: GEOS_ERROR_IF( m_formulation != "SEM", - "Element type Hexahedron with order 4 available only when using the Spectral Element Method" ); + getDataContext() << ": Element type Hexahedron with order 4 available only" << + " when using the Spectral Element Method" ); return std::make_unique< Q4_Hexahedron_Lagrange_GaussLobatto >(); #else GEOS_ERROR( "Cannot compile this with HIP active." ); #endif default: { - GEOS_ERROR( "Element type " << parentElementShape << " does not have an associated element formulation." ); + GEOS_ERROR( getDataContext() << ": Element type " << parentElementShape << " does not have" << + " an associated element formulation." ); } } return {}; @@ -241,19 +249,22 @@ FiniteElementDiscretization::factory( ElementType const parentElementShape ) con #if !defined( GEOS_USE_HIP ) case ElementType::Hexahedron: GEOS_ERROR_IF( m_formulation != "SEM", - "Element type Hexahedron with order 5 available only when using the Spectral Element Method" ); + getDataContext() << ": Element type Hexahedron with order 5 available only" << + " when using the Spectral Element Method" ); return std::make_unique< Q5_Hexahedron_Lagrange_GaussLobatto >(); #else GEOS_ERROR( "Cannot compile this with HIP active." ); #endif default: { - GEOS_ERROR( "Element type " << parentElementShape << " does not have an associated element formulation." ); + GEOS_ERROR( getDataContext() << ": Element type " << parentElementShape << " does not have" << + " an associated element formulation." ); } } return {}; } - GEOS_ERROR( "Element type " << parentElementShape << " does not have an associated element formulation." ); + GEOS_ERROR( getDataContext() << ": Element type " << parentElementShape << " does not have an" << + " associated element formulation." ); return {}; } diff --git a/src/coreComponents/finiteVolume/HybridMimeticDiscretization.cpp b/src/coreComponents/finiteVolume/HybridMimeticDiscretization.cpp index 515ba6fce6b..35d2149a50a 100644 --- a/src/coreComponents/finiteVolume/HybridMimeticDiscretization.cpp +++ b/src/coreComponents/finiteVolume/HybridMimeticDiscretization.cpp @@ -89,7 +89,7 @@ HybridMimeticDiscretization::factory( string const & mimeticInnerProductType ) c } else { - GEOS_ERROR( "Key value of "<< mimeticInnerProductType <<" does not have an associated mimetic inner product." ); + GEOS_ERROR( getDataContext() << ": Key value of "<< mimeticInnerProductType <<" does not have an associated mimetic inner product." ); } return rval; } diff --git a/src/coreComponents/functions/FunctionBase.hpp b/src/coreComponents/functions/FunctionBase.hpp index ce96b238f7b..7a2aadcef4e 100644 --- a/src/coreComponents/functions/FunctionBase.hpp +++ b/src/coreComponents/functions/FunctionBase.hpp @@ -195,10 +195,12 @@ void FunctionBase::evaluateT( dataRepository::Group const & group, } // Make sure the inputs do not exceed the maximum length - GEOS_ERROR_IF_GT_MSG( totalVarSize, MAX_VARS, "Function input size exceeded" ); + GEOS_ERROR_IF_GT_MSG( totalVarSize, MAX_VARS, + getDataContext() << ": Function input size exceeded" ); // Make sure the result / set size match - GEOS_ERROR_IF_NE_MSG( result.size(), set.size(), "To apply a function to a set, the size of the result and set must match" ); + GEOS_ERROR_IF_NE_MSG( result.size(), set.size(), + getDataContext() << ": To apply a function to a set, the size of the result and set must match" ); forAll< POLICY >( set.size(), [=]( localIndex const i ) { diff --git a/src/coreComponents/functions/MultivariableTableFunction.cpp b/src/coreComponents/functions/MultivariableTableFunction.cpp index bbcaceca856..97136c32f21 100644 --- a/src/coreComponents/functions/MultivariableTableFunction.cpp +++ b/src/coreComponents/functions/MultivariableTableFunction.cpp @@ -34,7 +34,7 @@ MultivariableTableFunction::MultivariableTableFunction( const string & name, void MultivariableTableFunction::initializeFunctionFromFile( string const & filename ) { std::ifstream file( filename.c_str() ); - GEOS_THROW_IF( !file, catalogName() << " " << getName() << ": could not read input file " << filename, InputError ); + GEOS_THROW_IF( !file, catalogName() << " " << getDataContext() << ": could not read input file " << filename, InputError ); integer numDims, numOps; globalIndex numPointsTotal = 1; @@ -50,12 +50,12 @@ void MultivariableTableFunction::initializeFunctionFromFile( string const & file GEOS_THROW_IF( !file, "Can`t read number of interpolatored operators", InputError ); // assume no more than 10 dimensions - GEOS_THROW_IF_LT_MSG( numDims, 1, catalogName() << " " << getName() << ": positive integer value expected", InputError ); - GEOS_THROW_IF_GT_MSG( numDims, 10, catalogName() << " " << getName() << ": maximum 10 dimensions expected", InputError ); + GEOS_THROW_IF_LT_MSG( numDims, 1, catalogName() << " " << getDataContext() << ": positive integer value expected", InputError ); + GEOS_THROW_IF_GT_MSG( numDims, 10, catalogName() << " " << getDataContext() << ": maximum 10 dimensions expected", InputError ); // assume no more than 100 operators - GEOS_THROW_IF_LT_MSG( numOps, 1, catalogName() << " " << getName() << ": positive integer value expected", InputError ); - GEOS_THROW_IF_GT_MSG( numOps, 100, catalogName() << " " << getName() << ": maximum 100 operators expected", InputError ); + GEOS_THROW_IF_LT_MSG( numOps, 1, catalogName() << " " << getDataContext() << ": positive integer value expected", InputError ); + GEOS_THROW_IF_GT_MSG( numOps, 100, catalogName() << " " << getDataContext() << ": maximum 100 operators expected", InputError ); axisMinimums.resize( numDims ); axisMaximums.resize( numDims ); @@ -66,13 +66,13 @@ void MultivariableTableFunction::initializeFunctionFromFile( string const & file for( integer i = 0; i < numDims; i++ ) { file >> axisPoints[i]; - GEOS_THROW_IF( !file, catalogName() << " " << getName() << ": can`t read the number of points for axis " + std::to_string( i ), InputError ); - GEOS_THROW_IF_LE_MSG( axisPoints[i], 1, catalogName() << " " << getName() << ": minimum 2 discretization point per axis are expected", InputError ); + GEOS_THROW_IF( !file, catalogName() << " " << getDataContext() << ": can`t read the number of points for axis " + std::to_string( i ), InputError ); + GEOS_THROW_IF_LE_MSG( axisPoints[i], 1, catalogName() << " " << getDataContext() << ": minimum 2 discretization point per axis are expected", InputError ); file >> axisMinimums[i]; - GEOS_THROW_IF( !file, catalogName() << " " << getName() << ": can`t read minimum value for axis " + std::to_string( i ), InputError ); + GEOS_THROW_IF( !file, catalogName() << " " << getDataContext() << ": can`t read minimum value for axis " + std::to_string( i ), InputError ); file >> axisMaximums[i]; - GEOS_THROW_IF( !file, catalogName() << " " << getName() << ": can`t read maximum value for axis " + std::to_string( i ), InputError ); - GEOS_THROW_IF_LT_MSG( axisMaximums[i], axisMinimums[i], catalogName() << " " << getName() << ": maximum axis value is expected to be larger than minimum", InputError ); + GEOS_THROW_IF( !file, catalogName() << " " << getDataContext() << ": can`t read maximum value for axis " + std::to_string( i ), InputError ); + GEOS_THROW_IF_LT_MSG( axisMaximums[i], axisMinimums[i], catalogName() << " " << getDataContext() << ": maximum axis value is expected to be larger than minimum", InputError ); numPointsTotal *= axisPoints[i]; } @@ -80,7 +80,8 @@ void MultivariableTableFunction::initializeFunctionFromFile( string const & file // lets limit the point storage size with 1 Gb (taking into account that hypercube storage is 2^numDim larger) real64 pointStorageMemoryLimitGB = 1; - GEOS_THROW_IF_GT_MSG( numPointsTotal * numOps, pointStorageMemoryLimitGB * 1024 * 1024 * 1024 / 8, catalogName() << " " << getName() << + GEOS_THROW_IF_GT_MSG( numPointsTotal * numOps, pointStorageMemoryLimitGB * 1024 * 1024 * 1024 / 8, + catalogName() << " " << getDataContext() << ": point storage size exceeds " + std::to_string( pointStorageMemoryLimitGB ) + " Gb, please reduce number of points", InputError ); @@ -93,13 +94,13 @@ void MultivariableTableFunction::initializeFunctionFromFile( string const & file for( auto j = 0; j < numOps; j++ ) { file >> m_pointData[i * numOps + j]; - GEOS_THROW_IF( !file, catalogName() << " " << getName() << ": table file is shorter than expected", InputError ); + GEOS_THROW_IF( !file, catalogName() << " " << getDataContext() << ": table file is shorter than expected", InputError ); } } real64 value; file >> value; - GEOS_THROW_IF( file, catalogName() << " " << getName() << ": table file is longer than expected", InputError ); + GEOS_THROW_IF( file, catalogName() << " " << getDataContext() << ": table file is longer than expected", InputError ); file.close(); @@ -159,13 +160,13 @@ void MultivariableTableFunction::initializeFunction() // check input - GEOS_THROW_IF_NE_MSG( m_numDims, m_axisMinimums.size(), catalogName() << " " << getName() << + GEOS_THROW_IF_NE_MSG( m_numDims, m_axisMinimums.size(), catalogName() << " " << getDataContext() << ": single minimum value is expected for each of " + std::to_string( m_numDims ) + "dimensions", InputError ); - GEOS_THROW_IF_NE_MSG( m_numDims, m_axisMaximums.size(), catalogName() << " " << getName() << + GEOS_THROW_IF_NE_MSG( m_numDims, m_axisMaximums.size(), catalogName() << " " << getDataContext() << ": single maxumum value is expected for each of " + std::to_string( m_numDims ) + "dimensions", InputError ); - GEOS_THROW_IF_NE_MSG( m_numDims, m_axisPoints.size(), catalogName() << " " << getName() << + GEOS_THROW_IF_NE_MSG( m_numDims, m_axisPoints.size(), catalogName() << " " << getDataContext() << "single number is expected for each of " + std::to_string( m_numDims ) + "dimensions", InputError ); @@ -202,13 +203,14 @@ void MultivariableTableFunction::initializeFunction() // check is point data size is correct - GEOS_THROW_IF_NE_MSG( globalIndex( numTablePoints ) * m_numOps, m_pointData.size(), catalogName() << " " << getName() << + GEOS_THROW_IF_NE_MSG( globalIndex( numTablePoints ) * m_numOps, m_pointData.size(), catalogName() << " " << getDataContext() << ": table values array is expected to have length of " + std::to_string( globalIndex( numTablePoints ) * m_numOps ), InputError ); // lets limit the hypercube storage size with 16 Gb real64 hypercubeStorageMemoryLimitGB = 16; - GEOS_THROW_IF_GT_MSG( numTableHypercubes * m_numVerts * m_numOps, hypercubeStorageMemoryLimitGB * 1024 * 1024 * 1024 / 8, catalogName() << " " << getName() << + GEOS_THROW_IF_GT_MSG( numTableHypercubes * m_numVerts * m_numOps, hypercubeStorageMemoryLimitGB * 1024 * 1024 * 1024 / 8, + catalogName() << " " << getDataContext() << ": hypercube storage size exceeds " + std::to_string( hypercubeStorageMemoryLimitGB ) + " Gb, please reduce number of points", InputError ); diff --git a/src/coreComponents/functions/TableFunction.cpp b/src/coreComponents/functions/TableFunction.cpp index 99754907026..9d17158813a 100644 --- a/src/coreComponents/functions/TableFunction.cpp +++ b/src/coreComponents/functions/TableFunction.cpp @@ -66,7 +66,7 @@ void TableFunction::readFile( string const & filename, array1d< real64 > & targe } catch( std::runtime_error const & e ) { - GEOS_THROW( GEOS_FMT( "{} {}: {}", catalogName(), getName(), e.what() ), InputError ); + GEOS_THROW( GEOS_FMT( "{} {}: {}", catalogName(), getDataContext(), e.what() ), InputError ); } } @@ -85,7 +85,7 @@ void TableFunction::setTableCoordinates( array1d< real64_array > const & coordin { GEOS_THROW_IF( coordinates[i][j] - coordinates[i][j-1] <= 0, GEOS_FMT( "{} {}: coordinates must be strictly increasing, but axis {} is not", - catalogName(), getName(), i ), + catalogName(), getDataContext(), i ), InputError ); } m_coordinates.appendArray( coordinates[i].begin(), coordinates[i].end() ); @@ -113,7 +113,7 @@ void TableFunction::initializeFunction() m_coordinates.appendArray( m_tableCoordinates1D.begin(), m_tableCoordinates1D.end() ); GEOS_THROW_IF_NE_MSG( m_tableCoordinates1D.size(), m_values.size(), GEOS_FMT( "{} {}: 1D table function coordinates and values must have the same length", - catalogName(), getName() ), + catalogName(), getDataContext() ), InputError ); } else @@ -146,7 +146,7 @@ void TableFunction::reInitializeFunction() { GEOS_THROW_IF( m_coordinates[ii][j] - m_coordinates[ii][j-1] <= 0, GEOS_FMT( "{} {}: coordinates must be strictly increasing, but axis {} is not", - catalogName(), getName(), ii ), + catalogName(), getDataContext(), ii ), InputError ); } } @@ -154,7 +154,7 @@ void TableFunction::reInitializeFunction() { GEOS_THROW_IF_NE_MSG( increment, m_values.size(), GEOS_FMT( "{} {}: number of values does not match total number of table coordinates", - catalogName(), getName() ), + catalogName(), getDataContext() ), InputError ); }