Skip to content

Commit

Permalink
Add more context to errors - constitutive/ files (#2447)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelReyCG authored Sep 20, 2023
1 parent d184d82 commit 74fa386
Show file tree
Hide file tree
Showing 22 changed files with 130 additions and 88 deletions.
8 changes: 6 additions & 2 deletions src/coreComponents/constitutive/ConstitutiveBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ class ConstitutiveBase : public dataRepository::Group

/**
* @brief Get full name of the model.
* @return full name, consisting of XML (catalog) name and actual model name
* @return full name, consisting of XML (catalog) name and actual model name, and if possible
* followed by the xml file and line.
*/
string getFullName() const { return getCatalogName() + " " + getName(); }
string getFullName() const
{
return getCatalogName() + " " + getDataContext().toString();
}

///@}

Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/constitutive/ConstitutiveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ConstitutiveManager::hangConstitutiveRelation( string const & constitutiveRelati
GEOS_FMT( "Error! The constitutive relation {} has already been registered on the subRegion {}. "
"Make sure that the same constitutive model is not listed as a material on a"
" region both as a stand-alone one and as part of a compound constitutive model.",
constitutiveRelationInstanceName, parent->getName() ) );
constitutiveRelationInstanceName, parent->getDataContext().toString() ) );

ConstitutiveBase const & constitutiveRelation = getConstitutiveRelation( constitutiveRelationInstanceName );

Expand All @@ -98,7 +98,7 @@ ConstitutiveManager::hangConstitutiveRelation( string const & constitutiveRelati
GEOS_FMT( "Error! The constitutive relation {} has already been registered on the subRegion {}. "
"Make sure that the same constitutive model is not listed as a material on a"
" region both as a stand-alone one and as part of a compound constitutive model.",
subRelationName, parent->getName() ) );
subRelationName, parent->getDataContext().toString() ) );

ConstitutiveBase const & subRelation = getConstitutiveRelation( subRelationName );

Expand Down
12 changes: 6 additions & 6 deletions src/coreComponents/constitutive/ConstitutivePassThru.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ struct ConstitutivePassThru< NullModel >
}
else
{
GEOS_ERROR( "ConstitutivePassThru< NullModel >::execute failed. The constitutive relation is named "
<< constitutiveRelation.getName() << " with type "
GEOS_ERROR( "ConstitutivePassThru< NullModel >::execute failed on constitutive relation "
<< constitutiveRelation.getDataContext() << " with type "
<< LvArray::system::demangleType( constitutiveRelation ) );
}
}
Expand All @@ -194,8 +194,8 @@ struct ConstitutivePassThru< PorousSolid< ElasticIsotropic > >
}
else
{
GEOS_ERROR( "ConstitutivePassThru< PorousSolid< ElasticIsotropic > >::execute failed. The constitutive relation is named "
<< constitutiveRelation.getName() << " with type "
GEOS_ERROR( "ConstitutivePassThru< PorousSolid< ElasticIsotropic > >::execute failed on constitutive relation "
<< constitutiveRelation.getDataContext() << " with type "
<< LvArray::system::demangleType( constitutiveRelation ) );
}
}
Expand Down Expand Up @@ -293,8 +293,8 @@ struct ConstitutivePassThru< ProppantSolid< ProppantPorosity, ProppantPermeabili
}
else
{
GEOS_ERROR( "ConstitutivePassThru< ProppantSolid >::execute failed. The constitutive relation is named "
<< constitutiveRelation.getName() << " with type "
GEOS_ERROR( "ConstitutivePassThru< ProppantSolid >::execute failed on constitutive relation "
<< constitutiveRelation.getDataContext() << " with type "
<< LvArray::system::demangleType( constitutiveRelation ) );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ConstitutivePassThruHandler<>
static void execute( BASE & relation, LAMBDA lambda )
{
GEOS_UNUSED_VAR( relation, lambda );
GEOS_ERROR( "The constitutive model " << relation.getName() << " was not dispatched." <<
GEOS_ERROR( "The constitutive model " << relation.getDataContext() << " was not dispatched. " <<
"The model type does not match the list of supported types." );
}
};
Expand Down
12 changes: 6 additions & 6 deletions src/coreComponents/constitutive/contact/ContactBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void ContactBase::postProcessInput()
{

GEOS_THROW_IF( m_apertureTableName.empty(),
getCatalogName() << " " << getName() << ": the aperture table name " << m_apertureTableName << " is empty", InputError );
getFullName() << ": the aperture table name " << m_apertureTableName << " is empty", InputError );

}

Expand All @@ -86,7 +86,7 @@ void ContactBase::allocateConstitutiveData( Group & parent,
FunctionManager & functionManager = FunctionManager::getInstance();

GEOS_THROW_IF( !functionManager.hasGroup( m_apertureTableName ),
getCatalogName() << " " << getName() << ": the aperture table named " << m_apertureTableName << " could not be found",
getFullName() << ": the aperture table named " << m_apertureTableName << " could not be found",
InputError );

TableFunction & apertureTable = functionManager.getGroup< TableFunction >( m_apertureTableName );
Expand Down Expand Up @@ -126,25 +126,25 @@ void ContactBase::validateApertureTable( TableFunction const & apertureTable ) c
arrayView1d< real64 const > const & hydraulicApertureValues = apertureTable.getValues();

GEOS_THROW_IF( coords.size() > 1,
getCatalogName() << " " << getName() << ": Aperture limiter table cannot be greater than a 1D table.",
getFullName() << ": Aperture limiter table cannot be greater than a 1D table.",
InputError );

arraySlice1d< real64 const > apertureValues = coords[0];
localIndex const size = apertureValues.size();

GEOS_THROW_IF( coords( 0, size-1 ) > 0.0 || coords( 0, size-1 ) < 0.0,
getCatalogName() << " " << getName() << ": Invalid aperture limiter table. Last coordinate must be zero!",
getFullName() << ": Invalid aperture limiter table. Last coordinate must be zero!",
InputError );

GEOS_THROW_IF( apertureValues.size() < 2,
getCatalogName() << " " << getName() << ": Invalid aperture limiter table. Must have more than two points specified",
getFullName() << ": Invalid aperture limiter table. Must have more than two points specified",
InputError );

localIndex const n = apertureValues.size()-1;
real64 const slope = ( hydraulicApertureValues[n] - hydraulicApertureValues[n-1] ) / ( apertureValues[n] - apertureValues[n-1] );

GEOS_THROW_IF( slope >= 1.0,
getCatalogName() << " " << getName() << ": Invalid aperture table. The slope of the last two points >= 1 is invalid.",
getFullName() << ": Invalid aperture table. The slope of the last two points >= 1 is invalid.",
InputError );
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/constitutive/contact/CoulombContact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CoulombContact::~CoulombContact()
void CoulombContact::postProcessInput()
{
GEOS_THROW_IF( m_frictionCoefficient < 0.0,
getCatalogName() << " " << getName() << ": The provided friction coefficient is less than zero. Value: " << m_frictionCoefficient,
getFullName() << ": The provided friction coefficient is less than zero. Value: " << m_frictionCoefficient,
InputError );

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ void ApertureTableContact::postProcessInput()
FunctionManager const & functionManager = FunctionManager::getInstance();

GEOS_THROW_IF( m_apertureTableName.empty(),
getCatalogName() << " " << getName() << ": the aperture table name " << m_apertureTableName << " is empty",
getFullName() << ": the aperture table name " << m_apertureTableName << " is empty",
InputError );

GEOS_THROW_IF( !functionManager.hasGroup( m_apertureTableName ),
getCatalogName() << " " << getName() << ": the aperture table named " << m_apertureTableName << " could not be found",
getFullName() << ": the aperture table named " << m_apertureTableName << " could not be found",
InputError );
}

Expand Down Expand Up @@ -95,25 +95,25 @@ void ApertureTableContact::validateApertureTable( TableFunction const & aperture
arrayView1d< real64 const > const & effectiveApertureValues = apertureTable.getValues();

GEOS_THROW_IF( coords.size() > 1,
getCatalogName() << " " << getName() << ": Aperture limiter table cannot be greater than a 1D table.",
getFullName() << ": Aperture limiter table cannot be greater than a 1D table.",
InputError );

arraySlice1d< real64 const > apertureValues = coords[0];
localIndex const size = apertureValues.size();

GEOS_THROW_IF( coords( 0, size-1 ) > 0.0 || coords( 0, size-1 ) < 0.0,
getCatalogName() << " " << getName() << ": Invalid aperture limiter table. Last coordinate must be zero!",
getFullName() << ": Invalid aperture limiter table. Last coordinate must be zero!",
InputError );

GEOS_THROW_IF( apertureValues.size() < 2,
getCatalogName() << " " << getName() << ": Invalid aperture limiter table. Must have more than two points specified",
getFullName() << ": Invalid aperture limiter table. Must have more than two points specified",
InputError );

localIndex const n = apertureValues.size()-1;
real64 const slope = ( effectiveApertureValues[n] - effectiveApertureValues[n-1] ) / ( apertureValues[n] - apertureValues[n-1] );

GEOS_THROW_IF( slope >= 1.0,
getCatalogName() << " " << getName() << ": Invalid aperture table. The slope of the last two points >= 1 is invalid.",
getFullName() << ": Invalid aperture table. The slope of the last two points >= 1 is invalid.",
InputError );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,28 @@ void ParticleFluid::postProcessInput()
ParticleFluidBase::postProcessInput();

GEOS_ERROR_IF( m_proppantDensity < 500.0,
"Invalid proppantDensity in ParticleFluid, which must >= 500.0 " );
"Invalid proppantDensity in ParticleFluid "
<< getDataContext() << ", which must >= 500.0 " );

GEOS_ERROR_IF( m_proppantDiameter < 10e-6,
"Invalid proppantDiameter in ParticleFluid, which must >= 10e-6 " );
"Invalid proppantDiameter in ParticleFluid "
<< getDataContext() << ", which must >= 10e-6 " );

GEOS_ERROR_IF( m_hinderedSettlingCoefficient< 0.0 || m_hinderedSettlingCoefficient > 10.0,
"Invalid hinderedSettlingCoefficient in ParticleFluid, which must between 0 and 10 " );
"Invalid hinderedSettlingCoefficient in ParticleFluid "
<< getDataContext() << ", which must between 0 and 10 " );

GEOS_ERROR_IF( m_collisionAlpha < 1.0,
"Invalid collisionAlpha in ParticleFluid, which must >= 1 " );
"Invalid collisionAlpha in ParticleFluid "
<< getDataContext() << ", which must >= 1 " );

GEOS_ERROR_IF( m_collisionBeta < 0.0,
"Invalid collisionBeta in ParticleFluid, which must >= 0" );
"Invalid collisionBeta in ParticleFluid "
<< getDataContext() << ", which must >= 0" );

GEOS_ERROR_IF( m_slipConcentration > 0.3,
"Invalid slipConcentration in ParticleFluid, which must <= 0.3" );
"Invalid slipConcentration in ParticleFluid "
<< getDataContext() << ", which must <= 0.3" );

m_packPermeabilityCoef = pow( m_sphericity * m_proppantDiameter, 2.0 ) / 180.0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ void ProppantSlurryFluid::postProcessInput()
SlurryFluidBase::postProcessInput();

GEOS_ERROR_IF_LT_MSG( m_compressibility, 0.0,
getName() << ": invalid value of " << viewKeyStruct::compressibilityString() );
getFullName() << ": invalid value of " << viewKeyStruct::compressibilityString() );

GEOS_ERROR_IF_LE_MSG( m_referenceDensity, 0.0,
getName() << ": invalid value of " << viewKeyStruct::referenceDensityString() );
getFullName() << ": invalid value of " << viewKeyStruct::referenceDensityString() );

GEOS_ERROR_IF_LT_MSG( m_referenceViscosity, 0.0,
getName() << ": invalid value of " << viewKeyStruct::referenceViscosityString() );
getFullName() << ": invalid value of " << viewKeyStruct::referenceViscosityString() );

GEOS_ERROR_IF_LE_MSG( m_maxProppantConcentration, 0.0,
getName() << ": invalid value of " << viewKeyStruct::maxProppantConcentrationString() );
getFullName() << ": invalid value of " << viewKeyStruct::maxProppantConcentrationString() );

GEOS_ERROR_IF_GT_MSG( m_maxProppantConcentration, 1.0,
getName() << ": invalid value of " << viewKeyStruct::maxProppantConcentrationString() );
getFullName() << ": invalid value of " << viewKeyStruct::maxProppantConcentrationString() );
}

ProppantSlurryFluid::KernelWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ void SlurryFluidBase::postProcessInput()
localIndex const NC = numFluidComponents();

GEOS_ERROR_IF( m_defaultComponentDensity.size() != NC,
"The number of default density values is not the same as the component number" );
getFullName() << ": The number of default density values is not the same as the component number" );

GEOS_ERROR_IF( m_defaultComponentCompressibility.size() != NC,
"The number of default compressibility values is not the same as the component number" );
getFullName() << ": The number of default compressibility values is not the same as the component number" );

GEOS_ERROR_IF( m_defaultComponentViscosity.size() != NC,
"The number of default viscosity values is not the same as the component number" );
getFullName() << ": The number of default viscosity values is not the same as the component number" );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ TableRelativePermeabilityHelpers::validateRelativePermeabilityTable( TableFuncti
ArrayOfArraysView< real64 const > coords = relPermTable.getCoordinates();

GEOS_THROW_IF_NE_MSG( relPermTable.getInterpolationMethod(), TableFunction::InterpolationType::Linear,
GEOS_FMT( "{}: in table '{}' interpolation method must be linear", fullConstitutiveName, relPermTable.getName() ),
GEOS_FMT( "{}: TableFunction '{}' interpolation method must be linear",
fullConstitutiveName, relPermTable.getDataContext() ),
InputError );
GEOS_THROW_IF_NE_MSG( relPermTable.numDimensions(), 1,
GEOS_FMT( "{}: table '{}' must have a single independent coordinate", fullConstitutiveName, relPermTable.getName() ),
GEOS_FMT( "{}: TableFunction '{}' must have a single independent coordinate",
fullConstitutiveName, relPermTable.getDataContext() ),
InputError );
GEOS_THROW_IF_LT_MSG( coords.sizeOfArray( 0 ), 2,
GEOS_FMT( "{}: table `{}` must contain at least two values", fullConstitutiveName, relPermTable.getName() ),
GEOS_FMT( "{}: TableFunction `{}` must contain at least two values",
fullConstitutiveName, relPermTable.getDataContext() ),
InputError );

arraySlice1d< real64 const > phaseVolFrac = coords[0];
Expand All @@ -53,21 +56,23 @@ TableRelativePermeabilityHelpers::validateRelativePermeabilityTable( TableFuncti

// note that the TableFunction class has already checked that coords.sizeOfArray( 0 ) == relPerm.size()
GEOS_THROW_IF( !isZero( relPerm[0] ),
GEOS_FMT( "{}: in table '{}' the first value must be equal to 0", fullConstitutiveName, relPermTable.getName() ),
GEOS_FMT( "{}: TableFunction '{}' first value must be equal to 0",
fullConstitutiveName, relPermTable.getDataContext() ),
InputError );
for( localIndex i = 1; i < coords.sizeOfArray( 0 ); ++i )
{
// check phase volume fraction
GEOS_THROW_IF( phaseVolFrac[i] < 0 || phaseVolFrac[i] > 1,
GEOS_FMT( "{}: in table '{}' values must be between 0 and 1", fullConstitutiveName, relPermTable.getName() ),
GEOS_FMT( "{}: TableFunction '{}' values must be between 0 and 1",
fullConstitutiveName, relPermTable.getDataContext() ),
InputError );

// note that the TableFunction class has already checked that the coordinates are monotone

// check phase relative permeability
GEOS_THROW_IF( !isZero( relPerm[i] ) && (relPerm[i] - relPerm[i-1]) < 1e-15,
GEOS_FMT( "{}: in table '{}' values must be strictly increasing (|Delta kr| > 1e-15 between two non-zero values)",
fullConstitutiveName, relPermTable.getName() ),
GEOS_FMT( "{}: TableFunction '{}' values must be strictly increasing (|Delta kr| > 1e-15 between two non-zero values)",
fullConstitutiveName, relPermTable.getDataContext() ),
InputError );

if( isZero( relPerm[i-1] ) && !isZero( relPerm[i] ) )
Expand Down
18 changes: 9 additions & 9 deletions src/coreComponents/constitutive/solid/CoupledSolid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,23 @@ void CoupledSolid< SOLID_TYPE, PORO_TYPE, PERM_TYPE >::initializePreSubGroups()
{
if( PORO_TYPE::catalogName() != getPorosityModel().getCatalogName() )
{
GEOS_ERROR( " The coupled solid "<< this->getName()<<
" expects a porosity model of type "<<PORO_TYPE::catalogName()<<
" but the specified porosity model \""<<m_porosityModelName<<
GEOS_ERROR( " The coupled solid " << getDataContext() <<
" expects a porosity model of type " << PORO_TYPE::catalogName() <<
" but the specified porosity model \"" << m_porosityModelName <<
"\" is of type " << getPorosityModel().getCatalogName() );
}
if( PERM_TYPE::catalogName() != getPermModel().getCatalogName() )
{
GEOS_ERROR( " The coupled solid "<<this->getName()<<
" expects a permeability model of type "<<PERM_TYPE::catalogName()<<
" but the specified permeability model \""<<m_permeabilityModelName<<
GEOS_ERROR( " The coupled solid " << getDataContext() <<
" expects a permeability model of type " << PERM_TYPE::catalogName() <<
" but the specified permeability model \"" << m_permeabilityModelName <<
"\" is of type " << getPermModel().getCatalogName() );
}
if( SOLID_TYPE::catalogName() != getSolidModel().getCatalogName() )
{
GEOS_ERROR( " The coupled solid "<<this->getName()<<
" expects a solid model of type "<<SOLID_TYPE::catalogName()<<
" but the specified solid model \""<<this->m_solidModelName<<
GEOS_ERROR( " The coupled solid " << getDataContext() <<
" expects a solid model of type " << SOLID_TYPE::catalogName() <<
" but the specified solid model \"" << m_solidModelName <<
"\" is of type" << getSolidModel().getCatalogName() );
}
}
Expand Down
Loading

0 comments on commit 74fa386

Please sign in to comment.