Skip to content

Commit

Permalink
add specific fieldName when enter wrong name
Browse files Browse the repository at this point in the history
  • Loading branch information
arng40 committed Dec 27, 2024
1 parent 563d0ac commit 75ebbff
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,40 +193,41 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c

if( isFieldNameFound == 0 )
{
std::ostringstream listFieldsName;
fs.apply< dataRepository::Group >( mesh,
[&]( FieldSpecificationBase const &,
string const &,
SortedArrayView< localIndex const > const &,
Group & targetGroup,
string const fieldName )
{

if( !targetGroup.hasWrapper( fieldName ) )
{
for( auto const & wrapperIter : targetGroup.wrappers() )
{
auto const & wrapper = wrapperIter.second;
listFieldsName<< wrapper->getName() << " ";
}
}
} );

char const fieldNameNotFoundMessage[] =
"\n{}: there is no {} named `{}` under the {} `{}`.\n The fields ame available are :\n{}";
string const errorMsg =
GEOS_FMT( fieldNameNotFoundMessage,
fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ),
FieldSpecificationBase::viewKeyStruct::fieldNameString(),
fs.getFieldName(), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath(),
listFieldsName.str() );
"\n{}: there is no {} named `{}` under the {} `{}`.\n";
string errorMsg = GEOS_FMT( fieldNameNotFoundMessage,
fs.getWrapperDataContext( FieldSpecificationBase::viewKeyStruct::fieldNameString() ),
FieldSpecificationBase::viewKeyStruct::fieldNameString(),
fs.getFieldName(), FieldSpecificationBase::viewKeyStruct::objectPathString(), fs.getObjectPath());

if( areAllSetsEmpty )
{
GEOS_LOG_RANK_0( errorMsg );
}
else
{
std::ostringstream listFieldsName;
bool stopIteration = false;

ElementRegionManager const & elemRegionGroup = mesh.getElemManager();
elemRegionGroup.forElementRegions( [&]( ElementRegionBase const & elemRegion )
{
if( stopIteration )
return;
auto const & subCellRegion = elemRegion.getSubRegion< CellElementSubRegion >( 0 );
if( !subCellRegion.hasWrapper( fs.getFieldName() ) )
{
stopIteration = true;
for( auto const & wrapperIter : subCellRegion.wrappers() )
{
auto const & wrapper = wrapperIter.second;
listFieldsName<< wrapper->getName() << " ";
}
}
} );

string fieldAvailable = GEOS_FMT( "The fields ame available are :\n{}", listFieldsName.str());
errorMsg.append( listFieldsName.str());
GEOS_THROW( errorMsg, InputError );
}
}
Expand Down

0 comments on commit 75ebbff

Please sign in to comment.