Skip to content

fix: FieldSpeciaficationManager log corrections #3749

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

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Changes from all 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 @@ -192,15 +192,6 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c
{
mapEntry.second = MpiWrapper::min( mapEntry.second );
}
bool areAllSetsEmpty = true;
for( std::pair< string const, localIndex > & mapEntry : isTargetSetEmpty )
{
if( mapEntry.second == 0 ) // target set is not empty
{
areAllSetsEmpty = false;
break;
}
}

for( std::pair< string const, localIndex > & mapEntry : isTargetSetCreated )
{
Expand All @@ -227,7 +218,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c
missingSetNames.emplace_back( mapEntry.first );
}

string setNamesError = GEOS_FMT( "\n{}: there is/are no set(s) named `{}` under the {} `{}`.\n",
string setNamesError = GEOS_FMT( "\n{}: there are no set(s) named `{}` under the {} `{}`.\n",
fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::objectPathString() ),
fmt::join( missingSetNames, ", " ),
FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath() );
Expand All @@ -249,25 +240,48 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c

if( isFieldNameFound == 0 )
{
std::ostringstream fieldNameNotFoundMessage;
std::string fieldNamePath =
GEOS_FMT( "\n{}: there is no {} named `{}` under the region `{}`.\n",
fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ),
FieldSpecificationBase::viewKeyStruct::fieldNameString(),
fs.getFieldName(), fs.getObjectPath() );

fieldNameNotFoundMessage << fieldNamePath;
if( areAllSetsEmpty )
std::ostringstream errorMessageBuilder;
errorMessageBuilder << GEOS_FMT( "\n{}: there are no {} named `{}` under the region `{}`.\n",
fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ),
FieldSpecificationBase::viewKeyStruct::fieldNameString(),
fs.getFieldName(), fs.getObjectPath() );;

string_array const splitPath = stringutilities::tokenize( fs.getObjectPath(), "/" );
string const targetRegion = splitPath.size() > 1 ? splitPath.at( 1 ) : splitPath.at( 0 );

string_array availableRegions;
bool foundMaterialInTargetRegion = false;
mesh.getElemManager().forElementRegions< ElementRegionBase >( [&]( ElementRegionBase const & elemRegion )
{
availableRegions.push_back( elemRegion.getName());
if( targetRegion == elemRegion.getName() && !elemRegion.getMaterialList().empty())
{
errorMessageBuilder << GEOS_FMT( "Available fieldname in {} are:\n{{ {} }}", fs.getObjectPath(),
stringutilities::join( allPresentFieldsName[invalidRegion], ", " ));
foundMaterialInTargetRegion = true;
}
} );

if( splitPath.size()==1 )
{
GEOS_LOG_RANK_0( fieldNameNotFoundMessage.str() );
std::set< std::string > uniqueFields;
for( const auto & pair : allPresentFieldsName )
{
const auto & vec = pair.second;
uniqueFields.insert( vec.begin(), vec.end());
}
errorMessageBuilder << GEOS_FMT( "{} contain the following fields :\n{{ {} }}\n", fs.getObjectPath(),
stringutilities::join( uniqueFields, ", " ) );
errorMessageBuilder << GEOS_FMT( "There are also {} CellElementsRegions that can be appended under {} : [{}].",
availableRegions.size(), fs.getObjectPath(),
stringutilities::join( availableRegions, ", " ) );
}
else
else if( !foundMaterialInTargetRegion )
{
fieldNameNotFoundMessage << GEOS_FMT( "Available fields in {} are:\n", fs.getObjectPath() );
fieldNameNotFoundMessage << stringutilities::join( allPresentFieldsName[invalidRegion], ", " );
errorMessageBuilder << GEOS_FMT( "No material found under {}.\n", fs.getObjectPath() );
}

GEOS_THROW( fieldNameNotFoundMessage.str(), InputError );
};
GEOS_THROW( errorMessageBuilder.str(), InputError );
}
} );
}
Expand Down
Loading