Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding logLevel documentation #3089

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ CO2BrineFluid< PHASE1, PHASE2, FLASH >::
CO2BrineFluid( string const & name, Group * const parent ):
MultiFluidBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::phasePVTParaFilesString(), &m_phasePVTParaFiles ).
setInputFlag( InputFlags::REQUIRED ).
setRestartFlags( RestartFlags::NO_WRITE ).
Expand All @@ -112,6 +110,8 @@ CO2BrineFluid( string const & name, Group * const parent ):
setPlotLevel( PlotLevel::LEVEL_0 ).
setRestartFlags( RestartFlags::WRITE_AND_READ );
}

appendLogLevelDescription( "logLevel >= 1", "Informations on PVT phase table" );
}

template< typename PHASE1, typename PHASE2, typename FLASH >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ PVTDriver::PVTDriver( const string & name,
Group * const parent ):
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::fluidNameString(), &m_fluidName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand Down Expand Up @@ -90,6 +88,9 @@ PVTDriver::PVTDriver( const string & name,
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( "none" ).
setDescription( "Baseline file" );

appendLogLevelDescription( "logLevel >= 1", "Informations about PVT Driver" );
appendLogLevelDescription( "logLevel >= 1", "Indicate consistency of results" );
}

void PVTDriver::postProcessInput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ ReactiveBrineFluid( string const & name, Group * const parent ):
setPlotLevel( PlotLevel::LEVEL_0 ).
setRestartFlags( RestartFlags::WRITE_AND_READ );
}

appendLogLevelDescription( "logLevel >= 1", "Information on phase PVT Table" );
}

template< typename PHASE >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ ReactiveFluidDriver::ReactiveFluidDriver( const string & name,
Group * const parent ):
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::fluidNameString(), &m_fluidName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand Down Expand Up @@ -66,6 +64,9 @@ ReactiveFluidDriver::ReactiveFluidDriver( const string & name,
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( "none" ).
setDescription( "Baseline file" );

appendLogLevelDescription( "logLevel >= 1", "Information on ReactiveFluidDriver" );
appendLogLevelDescription( "logLevel >= 1", "Indicate at the end if the internal results are consistent" );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
:
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::relpermNameString(), &m_relpermName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand All @@ -52,6 +50,9 @@
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( "none" ).
setDescription( "Baseline file" );

appendLogLevelDescription( "logLevel >= 1", "Information on RelpermDriver" );
appendLogLevelDescription( "logLevel >= 1", "Indicate if the internal results are consistent" );

Check warning on line 55 in src/coreComponents/constitutive/relativePermeability/RelpermDriver.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/constitutive/relativePermeability/RelpermDriver.cpp#L54-L55

Added lines #L54 - L55 were not covered by tests
}


Expand Down
5 changes: 3 additions & 2 deletions src/coreComponents/constitutive/solid/TriaxialDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ TriaxialDriver::TriaxialDriver( const string & name,
Group * const parent ):
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::solidMaterialNameString(), &m_solidMaterialName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand Down Expand Up @@ -67,6 +65,9 @@ TriaxialDriver::TriaxialDriver( const string & name,
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( "none" ).
setDescription( "Baseline file" );

appendLogLevelDescription( "logLevel >= 1", "Information on TriaxialDriver" );
appendLogLevelDescription( "logLevel >= 1", "Indicate if the internal results are consistent" );
}


Expand Down
26 changes: 17 additions & 9 deletions src/coreComponents/dataRepository/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ void Group::deregisterWrapper( string const & name )
m_conduitNode.remove( name );
}

void Group::addLogLevelEntry( string_view level, string_view description )
{
m_logLevelsDescriptions[ string( level ) ].push_back( string( description ) );
}

void Group::appendLogLevelDescription( string_view levelCondition, string_view logDescription )
{
Wrapper< integer > * wrapper = getWrapperPointer< integer >( viewKeyStruct::logLevelString() );
if( wrapper == nullptr )
{
wrapper = &registerWrapper( viewKeyStruct::logLevelString(), &m_logLevel );
wrapper->setApplyDefaultValue( 0 );
wrapper->setInputFlag( InputFlags::OPTIONAL );
}
addLogLevelEntry( levelCondition, logDescription );
wrapper->buildLogLevelDescription( m_logLevelsDescriptions );
}

void Group::resize( indexType const newSize )
{
Expand Down Expand Up @@ -642,15 +659,6 @@ void Group::postRestartInitializationRecursive()
postRestartInitialization();
}

void Group::enableLogLevelInput()
{
// TODO : Improve the Log Level description to clearly assign a usecase per log level (incoming PR).
registerWrapper( viewKeyStruct::logLevelString(), &m_logLevel ).
setApplyDefaultValue( 0 ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "Log level" );
}

Group const & Group::getBaseGroupByPath( string const & path ) const
{
Group const * currentGroup = this;
Expand Down
22 changes: 19 additions & 3 deletions src/coreComponents/dataRepository/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,13 @@ class Group
///@}
//END_SPHINX_INCLUDE_REGISTER_WRAPPER

/**
* @brief Append a levelCondition and a log description to the description of the wrapped object
* @param levelCondition The level condition to append
* @param logDescription The log description to append
*/
void appendLogLevelDescription( string_view levelCondition, string_view logDescription );
Copy link
Contributor

@TotoGaz TotoGaz Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way, instead of having now 4 public member functions and 2 attributes directly related to logs (and a entry in the viewKeysStruct) to gather all the behaviors related to the log into a dedicated class?
I personally do not want to add more and more stuff into Group which is already big enough (+/- 120 public member functions IIRC).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit off-topic comment : I don't know if it would help, but in a long-term effort. I would say that if we use a similar approach with the group's wrappers with a WrapperContainers, we could remove around 36 members (including const/non-const), allowing to clarify that methods like "size()" are related to Wrappers.


/**
* @name Schema generation methods
*/
Expand Down Expand Up @@ -1469,9 +1476,6 @@ class Group
*/
void loadFromConduit();

/// Enable verbosity input for object
void enableLogLevelInput();

/**
* @brief Set verbosity level
* @param logLevel new verbosity level value
Expand All @@ -1482,6 +1486,13 @@ class Group
integer getLogLevel() const { return m_logLevel; }
///@}

/**
* @brief Add an entry to the description map
* @param level The log level key
* @param description The log description value
*/
void addLogLevelEntry( string_view level, string_view description );

/**
* @brief Performs re-initialization of certain variable depending on the solver being used.
*/
Expand Down Expand Up @@ -1606,6 +1617,11 @@ class Group

/// Verbosity flag for group logs
integer m_logLevel;

/// Map for building the log level string for each wrapper
/// key : a logLevel condition, values : a set of description for a corresponding loglevel
std::map< std::string, std::vector< std::string > > m_logLevelsDescriptions;

//END_SPHINX_INCLUDE_02

/// Restart flag for this group... and subsequently all wrappers in this group.
Expand Down
27 changes: 25 additions & 2 deletions src/coreComponents/dataRepository/WrapperBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,33 @@ class WrapperBase
*/
WrapperBase & appendDescription( string const & description )
{
m_description += description;
m_description = description;
return *this;
}

/**
* @brief Construct the log level string description for a wrapper
*/
void buildLogLevelDescription( std::map< std::string, std::vector< std::string > > const & logLevelsDescriptions )
{
string descriptionToBuild;
descriptionToBuild.append( "Sets the level of information to write in the standard output (the console typically).\n"
"A level of 0 outputs minimal information, higher levels require more." );
for( auto const & [logLevel, logDescriptions] : logLevelsDescriptions )
{
descriptionToBuild.append( GEOS_FMT( "\n{}\n", logLevel ) );
size_t idxDescription = 0;
for( const auto & description : logDescriptions )
{
idxDescription == logDescriptions.size() - 1 ? descriptionToBuild.append( " - " + description )
: descriptionToBuild.append( GEOS_FMT( " - {}\n", description ) );
idxDescription++;
}
}
appendDescription( descriptionToBuild );
}


/**
* @brief Get the description string of the wrapper.
* @return this wrapper's description string
Expand Down Expand Up @@ -782,7 +805,7 @@ class WrapperBase
parallelDeviceEvents & events ) const = 0;
};

} /// namespace dataRepository
} /// namespace dataRepository
} /// namespace geos

#endif /* GEOS_DATAREPOSITORY_WRAPPERBASE_HPP_ */
5 changes: 2 additions & 3 deletions src/coreComponents/events/EventBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ EventBase::EventBase( const string & name,
{
setInputFlags( InputFlags::OPTIONAL_NONUNIQUE );

// This enables logLevel filtering
enableLogLevelInput();

registerWrapper( viewKeyStruct::eventTargetString(), &m_eventTarget ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::OPTIONAL ).
Expand Down Expand Up @@ -106,6 +103,8 @@ EventBase::EventBase( const string & name,

registerWrapper( viewKeyStruct::isTargetExecutingString(), &m_targetExecFlag ).
setDescription( "Index of the current subevent" );

appendLogLevelDescription( "logLevel >= 1", "Information about sub-event" );
}


Expand Down
5 changes: 2 additions & 3 deletions src/coreComponents/events/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ EventManager::EventManager( string const & name,
{
setInputFlags( InputFlags::REQUIRED );

// This enables logLevel filtering
enableLogLevelInput();

registerWrapper( viewKeyStruct::minTimeString(), &m_minTime ).
setApplyDefaultValue( 0 ).
setInputFlag( InputFlags::OPTIONAL ).
Expand Down Expand Up @@ -82,6 +79,8 @@ EventManager::EventManager( string const & name,
setInputFlag( InputFlags::OPTIONAL ).
setRestartFlags( RestartFlags::NO_WRITE ).
setDescription( "Format of the time in the GEOS log." );

appendLogLevelDescription( "logLevel >= 1", "Information about current sub-event" );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ AquiferBoundaryCondition::AquiferBoundaryCondition( string const & name, Group *
getWrapper< int >( FieldSpecificationBase::viewKeyStruct::componentString() ).
setInputFlag( InputFlags::FALSE );

appendLogLevelDescription( "logLevel >= 1", "Information on boundary conditions" );
}

void AquiferBoundaryCondition::postProcessInput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * par
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "Time at which the boundary condition will stop being applied." );

enableLogLevelInput();
appendLogLevelDescription( "logLevel >= 1 and regions with no dof", "Warning about non simulated region" );
appendLogLevelDescription( "logLevel >= 1 first nonlinear iteration", "Print boundary conditions log messages" );
appendLogLevelDescription( "logLevel >= 1 and first nonlinear iteration", "Information on the face boundary condition defined with pressure and temperature" );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@ SourceFluxBoundaryCondition::SourceFluxBoundaryCondition( string const & name, G
setInputFlag( InputFlags::FALSE );
setFieldName( catalogName() );

getWrapper< string >( FieldSpecificationBase::viewKeyStruct::functionNameString() ).
setDescription( GEOS_FMT( "Name of a function that specifies the variation of the production rate variations of this {}."
"Multiplied by {}. If no function is provided, a constant value of 1 is used."
"The producted fluid rate unit is in kg by default, or in mole if the flow solver has a {} of 0.",
catalogName(),
FieldSpecificationBase::viewKeyStruct::scaleString(),
CompositionalMultiphaseBase::viewKeyStruct::useMassFlagString() ) );

getWrapper< real64 >( FieldSpecificationBase::viewKeyStruct::scaleString() ).
setDescription( GEOS_FMT( "Multiplier of the {0} value. If no {0} is provided, this value is used directly.",
FieldSpecificationBase::viewKeyStruct::functionNameString() ) );
appendLogLevelDescription( "logLevel >= 1 and first newton iteration", "Print the log message issued by the solver if the boundary condition is called" );
appendLogLevelDescription( "logLevel >= 1 and regions with no dof", "Warnings about non-simulated region intersecting, that can cancel sourceFlux effects" );
appendLogLevelDescription( "logLevel >= 1 and first nonlinear iteration", "Information abonout the Dirichlet pressure, temperature boundary conditions" );
appendLogLevelDescription( "logLevel >= 1 and first nonlinear iteration and this is a thermal simulation", "Information on single phase thermal simulation" );
}

REGISTER_CATALOG_ENTRY( FieldSpecificationBase, SourceFluxBoundaryCondition, string const &, Group * const )
Expand Down
2 changes: 2 additions & 0 deletions src/coreComponents/fileIO/Outputs/ChomboIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
setInputFlag( InputFlags::OPTIONAL ).
setDefaultValue( 0 ).
setDescription( "True iff geosx should use the pressures chombo writes out." );

appendLogLevelDescription( "logLevel == 1", "Indicate chombo initializing" );

Check warning on line 64 in src/coreComponents/fileIO/Outputs/ChomboIO.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/fileIO/Outputs/ChomboIO.cpp#L64

Added line #L64 was not covered by tests
}

ChomboIO::~ChomboIO()
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/fileIO/Outputs/VTKOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
m_levelNames(),
m_writer( getOutputDirectory() + '/' + m_plotFileRoot )
{
enableLogLevelInput();

registerWrapper( viewKeysStruct::plotFileRoot, &m_plotFileRoot ).
setDefaultValue( m_plotFileRoot ).
setInputFlag( InputFlags::OPTIONAL ).
Expand Down Expand Up @@ -122,6 +120,8 @@
catalogName(), getDataContext(),
std::to_string( m_fieldNames.size() ), fieldNamesString, m_plotLevel ) );

appendLogLevelDescription( "logLevel >= 1", "Print field name and cycle number during execution" );

Check warning on line 123 in src/coreComponents/fileIO/Outputs/VTKOutput.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/fileIO/Outputs/VTKOutput.cpp#L123

Added line #L123 was not covered by tests

GEOS_ERROR_IF( m_writeFaceElementsAs3D, GEOS_FMT( "{} `{}`: 3D vtk plot of faceElements is not yet supported.",
catalogName(), getDataContext() ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void SuperLUDist< LAI >::setOptions()
m_data->options.ParSymbFact = m_params.direct.colPerm == LinearSolverParameters::Direct::ColPerm::parmetis ? YES : NO;
m_data->options.ReplaceTinyPivot = m_params.direct.replaceTinyPivot ? YES : NO;
m_data->options.IterRefine = m_params.direct.iterativeRefine ? SLU_DOUBLE : NOREFINE;

if( m_params.logLevel > 0 )
{
print_sp_ienv_dist( &m_data->options );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
{
GEOS_LOG_RANK_0( GEOS_FMT( " MGR preconditioner: numComponentsPerField = {}", numComponentsPerField ) );
}
if( params.logLevel >= 1024 )
if( params.logLevel >= 1 )

Check warning on line 77 in src/coreComponents/linearAlgebra/interfaces/hypre/HypreMGR.cpp

View check run for this annotation

Codecov / codecov/patch

src/coreComponents/linearAlgebra/interfaces/hypre/HypreMGR.cpp#L77

Added line #L77 was not covered by tests
{
GEOS_LOG_RANK( GEOS_FMT( " MGR preconditioner: pointMarkers = {}", mgrData.pointMarkers ) );
}
Expand Down
2 changes: 2 additions & 0 deletions src/coreComponents/mesh/DomainPartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ DomainPartition::DomainPartition( string const & name,

registerGroup( groupKeys.meshBodies );
registerGroup< constitutive::ConstitutiveManager >( groupKeys.constitutiveManager );

appendLogLevelDescription( "logLevel >= 3", "Indication about setup communication" );
}


Expand Down
3 changes: 3 additions & 0 deletions src/coreComponents/mesh/MeshManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ MeshManager::MeshManager( string const & name,
Group * const parent ):
Group( name, parent )
{

setInputFlags( InputFlags::REQUIRED );

appendLogLevelDescription( "logLevel >= 1", "Information on imported field name on region/subRegion" );
}

MeshManager::~MeshManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ ExternalMeshGeneratorBase::ExternalMeshGeneratorBase( string const & name,
dataRepository::Group * const parent )
: MeshGeneratorBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::filePathString(), &m_filePath ).
setInputFlag( InputFlags::REQUIRED ).
setRestartFlags( RestartFlags::NO_WRITE ).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ using namespace dataRepository;
InternalWellGenerator::InternalWellGenerator( string const & name, Group * const parent ):
WellGeneratorBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::polylineNodeCoordsString(), &m_polyNodeCoords ).
setInputFlag( InputFlags::REQUIRED ).
setSizedFromParent( 0 ).
Expand Down
Loading
Loading