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

Add more context to errors - mesh/ files #2450

Merged
merged 119 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
7601706
Adding context to errors when reading wrapper from xml
MelReyCG Mar 23, 2023
622f8d6
added XML hierarchy to the wrapper parsing error
MelReyCG Mar 24, 2023
a5fb1fe
Modified testXmlWrapper so it expect exceptions
MelReyCG Mar 27, 2023
4524704
Changed the regexs so the schema detects more errors
MelReyCG Mar 27, 2023
c36a052
updating LvArray submodule
MelReyCG Mar 27, 2023
081939c
Adding documentation
MelReyCG Mar 28, 2023
a123a15
added C++17 string_view comments
MelReyCG Apr 6, 2023
0b1cd21
- Added the ability to know the line of xml nodes & attributes
MelReyCG Apr 20, 2023
7a7331f
merge branch "feature/rey/error-xml-line-2" with PR branch "bugfix/re…
MelReyCG Apr 20, 2023
d56087e
Merge remote-tracking branch 'origin/bugfix/rey/2320-xml-errors-feedb…
MelReyCG Apr 20, 2023
fb418c8
Indentation, code style, naming
MelReyCG Apr 24, 2023
e995b0c
Renaming SourceContext to DataContext
MelReyCG Apr 24, 2023
7b793c9
comment update in Logger.hpp
jeannepellerin Apr 24, 2023
e1af0c6
- Added xml line to messages from PR 2341 & 2357
MelReyCG Apr 24, 2023
3e95803
Added getWrapperDataContext()
MelReyCG Apr 27, 2023
cbfa507
uncrustify + documentation corrections
MelReyCG Apr 27, 2023
c69a98d
added compatibility with GEOS_FMT
MelReyCG Apr 28, 2023
552ae0c
Added more context in various mesh/ error messages
MelReyCG Apr 28, 2023
703d88b
Adapted getGroupByPath test with new error message
MelReyCG May 10, 2023
7a7e053
error message improvements + bugfixes + removed unused header
MelReyCG May 10, 2023
9445618
Group::printDataHierarchy : wrapper type fix + layout
MelReyCG May 10, 2023
e289be9
Merge branch 'feature/rey/error-xml-line-2' into feature/rey/error-xm…
MelReyCG May 10, 2023
10fef50
perforation error message improvement
MelReyCG May 10, 2023
197ae38
made "cellBlocks" attribute a required one
MelReyCG May 10, 2023
e644d86
Error messages slight improvements + uncrustify
MelReyCG May 10, 2023
f25415e
Merge branch 'develop' into feature/rey/error-xml-line-2
MelReyCG May 11, 2023
8f26f6d
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 11, 2023
7d08ddc
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 16, 2023
0267860
uncrustify
MelReyCG May 16, 2023
40aae17
code style
MelReyCG May 16, 2023
f5f1276
update LvArray version
MelReyCG May 16, 2023
faa7358
update LvArray version
MelReyCG May 16, 2023
be91af3
improved messages with group/wrapper path
MelReyCG May 16, 2023
5fae7b6
rewrited WrapperContext message
MelReyCG May 16, 2023
e2a14be
Merge remote-tracking branch 'origin/feature/rey/error-xml-line-2' in…
MelReyCG May 16, 2023
585d59d
Documentation
MelReyCG May 17, 2023
3df8ced
Merge remote-tracking branch 'origin/feature/rey/error-xml-line-2' in…
MelReyCG May 17, 2023
e5e91b6
submodule develop sync
MelReyCG May 17, 2023
6c39256
face error message improvement
MelReyCG May 22, 2023
d79b0c9
code style / factorization + constness
MelReyCG May 23, 2023
7ab5641
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 23, 2023
226a5fa
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 23, 2023
a3639cd
Merge remote-tracking branch 'origin/feature/rey/error-xml-line-2' in…
MelReyCG May 23, 2023
f7217ee
docs fixes
MelReyCG May 24, 2023
df9a495
Merge remote-tracking branch 'origin/feature/rey/error-xml-line-2' in…
MelReyCG May 24, 2023
186d212
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 25, 2023
0df6f02
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG May 25, 2023
b3afd5c
error message fix
MelReyCG Jun 2, 2023
b8fb6bf
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jun 5, 2023
a6b495c
Merge remote-tracking branch 'origin/feature/rey/error-xml-line-2' in…
MelReyCG Jun 5, 2023
17759eb
code cleaning / refactoring, docs improvements
MelReyCG Jun 20, 2023
4045ce2
removing circular dependency:
MelReyCG Jun 20, 2023
b7b756e
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jun 20, 2023
041d4a7
Docs fixes & params names
MelReyCG Jun 26, 2023
d4851bd
Message review
MelReyCG Jun 27, 2023
1a5c02a
Refactorization: removing "isDataFileContext()"
MelReyCG Jun 29, 2023
1508b00
memleak fix
MelReyCG Jul 3, 2023
8db1cc3
Refactorization: removed getWrapperSeparator()
MelReyCG Jul 3, 2023
e416cdf
getTargetNameInPath() docs
MelReyCG Jul 3, 2023
5750d12
removed virtual destructors
MelReyCG Jul 3, 2023
8f35760
Refactorings
MelReyCG Jul 4, 2023
b96630b
Added a test for DataContext string formatting
MelReyCG Jul 4, 2023
f5e823f
improved getAttributeLine() robustness
MelReyCG Jul 5, 2023
729df9f
Refactoring: hide xml_document implementation
MelReyCG Jul 6, 2023
4864a30
xmlDocument refactorings
MelReyCG Jul 7, 2023
d5ab61a
WIP: more wrapping (xmlNode+xmlAttribute)
MelReyCG Jul 7, 2023
d463a93
Revert "WIP: more wrapping (xmlNode+xmlAttribute)"
MelReyCG Jul 7, 2023
c03e81f
Merge commit '08ba8f7e2c04af6ad07ff7d3ddc54f091b8e8564' into feature/…
MelReyCG Jul 10, 2023
dad53ce
wrong method name
MelReyCG Jul 10, 2023
39a0cdc
DataContext architecture refactorization
MelReyCG Jul 12, 2023
ee76f62
GroupContext / WrapperContext fixes
MelReyCG Jul 17, 2023
b627575
Extended test for WrapperContext::toString()
MelReyCG Jul 17, 2023
1a69a92
Merge branch 'develop' into feature/rey/error-xml-line-2
MelReyCG Jul 17, 2023
374223d
docs fixes
MelReyCG Jul 17, 2023
3b188ae
improving testGroupPath with more implicit groups & wrapper
MelReyCG Jul 18, 2023
e1ffd1d
GroupContext::toString() rewrite
MelReyCG Jul 18, 2023
630efc7
compilation bugfix
MelReyCG Jul 19, 2023
8cc3e8f
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jul 19, 2023
7bdf50f
compilation warning fix
MelReyCG Jul 20, 2023
a7fb525
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jul 21, 2023
fa4f7f2
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Jul 24, 2023
971ea0f
Merge branch 'develop' into feature/rey/error-xml-line-2
MelReyCG Jul 28, 2023
6eae848
Merge branch 'develop' into feature/rey/error-xml-line-2
TotoGaz Aug 8, 2023
9bcee6a
removed loadBuffer in favor of loadString
MelReyCG Aug 21, 2023
60599e5
missing a pugi::node_declaration wrapping
MelReyCG Aug 21, 2023
290285f
Merge branch 'feature/rey/error-xml-line-2' of https://github.com/GEO…
MelReyCG Aug 21, 2023
ebffe3f
changed to /** doxygen syntax
MelReyCG Aug 21, 2023
9795f54
Refactorings
MelReyCG Aug 22, 2023
5262422
Added a dedicated WrapperContext cpp & hpp file
MelReyCG Aug 22, 2023
83c5116
refactoring
MelReyCG Aug 22, 2023
9640797
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Aug 22, 2023
4501dc4
uncrustify
MelReyCG Aug 23, 2023
44f4fed
Docs fixes
MelReyCG Aug 23, 2023
40879dd
reverse iterator bugfix
MelReyCG Aug 23, 2023
b792974
DataContext format options fix
MelReyCG Aug 25, 2023
212e611
DataContext toString bugfix when no DataFileContext exist
MelReyCG Aug 25, 2023
42f53b5
Added docs for xmlWrapper attribute line search
MelReyCG Aug 25, 2023
0bc5032
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Aug 25, 2023
38d33d7
removed Group::forAllDataContext in profit of a private function in t…
MelReyCG Aug 25, 2023
1bcf5ba
refactoring DataContext::ToStringInfo
MelReyCG Aug 25, 2023
919830b
a few refactorings
MelReyCG Aug 30, 2023
e47099f
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Aug 31, 2023
071b10c
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Aug 31, 2023
474a8e3
Merge remote-tracking branch 'origin/feature/rey/error-xml-line-2' in…
MelReyCG Aug 31, 2023
bd78678
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Sep 13, 2023
1005dee
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Sep 14, 2023
b3ffe3a
merge mistake fix
MelReyCG Sep 15, 2023
c85cc91
GroupContext::toString(): showing file-name instead of file-path
MelReyCG Sep 15, 2023
fa57ee3
Show InternalWell name instead of region name
MelReyCG Sep 15, 2023
642d444
InternalWell error message refactoring
MelReyCG Sep 15, 2023
37103ea
error message factorization
MelReyCG Sep 18, 2023
5dc1dbf
compilation fixes
MelReyCG Sep 18, 2023
0620854
Merge remote-tracking branch 'origin/develop' into feature/rey/error-…
MelReyCG Sep 22, 2023
1ef175c
Merge branch 'develop' into feature/rey/error-xml-line-mesh
rrsettgast Oct 24, 2023
6652854
A few more message edits
MelReyCG Oct 25, 2023
b97246a
compil fix + doc
MelReyCG Oct 25, 2023
61949b6
Merge branch 'develop' into feature/rey/error-xml-line-mesh
rrsettgast Oct 25, 2023
80670af
Merge branch 'develop' into feature/rey/error-xml-line-mesh
rrsettgast Oct 26, 2023
6728e89
Merge branch 'develop' into feature/rey/error-xml-line-mesh
CusiniM Nov 1, 2023
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
26 changes: 17 additions & 9 deletions src/coreComponents/mainInterface/ProblemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,25 @@ void ProblemManager::parseXMLDocument( xmlWrapper::xmlDocument & xmlDocument )
for( xmlWrapper::xmlNode regionNode : elementRegionsNode.children() )
{
string const regionName = regionNode.attribute( "name" ).value();
string const
regionMeshBodyName = ElementRegionBase::verifyMeshBodyName( meshBodies,
regionNode.attribute( "meshBody" ).value() );
try
{
string const
regionMeshBodyName = ElementRegionBase::verifyMeshBodyName( meshBodies,
regionNode.attribute( "meshBody" ).value() );

MeshBody & meshBody = domain.getMeshBody( regionMeshBodyName );
meshBody.forMeshLevels( [&]( MeshLevel & meshLevel )
MeshBody & meshBody = domain.getMeshBody( regionMeshBodyName );
meshBody.forMeshLevels( [&]( MeshLevel & meshLevel )
{
ElementRegionManager & elementManager = meshLevel.getElemManager();
Group * newRegion = elementManager.createChild( regionNode.name(), regionName );
newRegion->processInputFileRecursive( xmlDocument, xmlDocument, regionNode );
MelReyCG marked this conversation as resolved.
Show resolved Hide resolved
} );
}
catch( InputError const & e )
{
ElementRegionManager & elementManager = meshLevel.getElemManager();
Group * newRegion = elementManager.createChild( regionNode.name(), regionName );
newRegion->processInputFileRecursive( xmlDocument, regionNode );
} );
string const nodePosString = xmlDocument.getNodePosition( regionNode ).toString();
throw InputError( e, "Error while parsing region " + regionName + " (" + nodePosString + "):\n" );
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/mesh/CellElementRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CellElementRegion::CellElementRegion( string const & name, Group * const parent
ElementRegionBase( name, parent )
{
registerWrapper( viewKeyStruct::sourceCellBlockNamesString(), &m_cellBlockNames ).
setInputFlag( InputFlags::OPTIONAL );
setInputFlag( InputFlags::REQUIRED );
Copy link
Contributor

Choose a reason for hiding this comment

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

This will change the rst file. And maybe will require a rebaseline.


registerWrapper( viewKeyStruct::coarseningRatioString(), &m_coarseningRatio ).
setInputFlag( InputFlags::OPTIONAL );
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/mesh/CellElementSubRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@ void CellElementSubRegion::
default:
{
GEOS_ERROR( GEOS_FMT( "Volume calculation not supported for element type {} in subregion {}",
m_elementType, getName() ) );
m_elementType, getDataContext() ) );
}
}

GEOS_ERROR_IF( m_elementVolume[k] <= 0.0,
GEOS_FMT( "Negative volume for element {} type {} in subregion {}",
k, m_elementType, getName() ) );
k, m_elementType, getDataContext() ) );
}

void CellElementSubRegion::calculateElementGeometricQuantities( NodeManager const & nodeManager,
Expand Down
21 changes: 16 additions & 5 deletions src/coreComponents/mesh/FaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "mesh/NodeManager.hpp"
#include "mesh/utilities/MeshMapUtilities.hpp"
#include "utilities/ComputationalGeometry.hpp"
#include "CellElementRegion.hpp"

namespace geos
{
Expand Down Expand Up @@ -196,12 +197,15 @@ void FaceManager::sortAllFaceNodes( NodeManager const & nodeManager,
ElementRegionManager::ElementViewAccessor< arrayView2d< real64 const > > elemCenter =
elemManager.constructArrayViewAccessor< real64, 2 >( ElementSubRegionBase::viewKeyStruct::elementCenterString() );

forAll< parallelHostPolicy >( size(), [=, elemCenter = elemCenter.toNestedViewConst()]( localIndex const faceIndex )
forAll< parallelHostPolicy >( size(), [=, elemCenter = elemCenter.toNestedViewConst(), &elemManager]( localIndex const faceIndex )
{
// The face should be connected to at least one element.
if( facesToElements( faceIndex, 0 ) < 0 && facesToElements( faceIndex, 1 ) < 0 )
{
GEOS_ERROR( "Face " << faceIndex << " is not connected to an element." );
GEOS_ERROR( getDataContext() << ": Face " << faceIndex << " is not connected to any cell." <<
"You might have forgotten one cell type in the " <<
elemManager.getWrapperDataContext( CellElementRegion::viewKeyStruct::sourceCellBlockNamesString() ) <<
", or your mesh might be invalid" );
}

// Take the first defined face-to-(elt/region/sub region) to sorting direction.
Expand All @@ -213,10 +217,17 @@ void FaceManager::sortAllFaceNodes( NodeManager const & nodeManager,

if( er < 0 || esr < 0 || ei < 0 )
{
GEOS_ERROR( GEOS_FMT( "Face {} is connected to an invalid element ({}/{}/{}).", faceIndex, er, esr, ei ) );
GEOS_ERROR( GEOS_FMT( "{0}: Face {1} is connected to an invalid element ({2}/{3}/{4}).",
getDataContext().toString(), faceIndex, er, esr, ei ) );
}

sortFaceNodes( X, elemCenter[er][esr][ei], facesToNodes[faceIndex] );
try
{
sortFaceNodes( X, elemCenter[er][esr][ei], facesToNodes[faceIndex] );
} catch( std::runtime_error const & e )
{
throw std::runtime_error( getDataContext().toString() + ": " + e.what() );
}
} );
}

Expand All @@ -225,7 +236,7 @@ void FaceManager::sortFaceNodes( arrayView2d< real64 const, nodes::REFERENCE_POS
Span< localIndex > const faceNodes )
{
localIndex const numFaceNodes = LvArray::integerConversion< localIndex >( faceNodes.size() );
GEOS_ERROR_IF_GT_MSG( numFaceNodes, MAX_FACE_NODES, "Node per face limit exceeded" );
GEOS_THROW_IF_GT_MSG( numFaceNodes, MAX_FACE_NODES, "The number of maximum nodes allocated per cell face has been reached.", std::runtime_error );

localIndex const firstNodeIndex = faceNodes[0];

Expand Down
3 changes: 2 additions & 1 deletion src/coreComponents/mesh/Perforation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Perforation::Perforation( string const & name, Group * const parent )
void Perforation::postProcessInput()
{
GEOS_ERROR_IF( m_distanceFromHead <= 0,
"Invalid distance well head to perforation " << getName() );
getWrapperDataContext( viewKeyStruct::distanceFromHeadString() ) <<
": distance from well head to perforation cannot be negative." );
}


Expand Down
12 changes: 8 additions & 4 deletions src/coreComponents/mesh/PerforationData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ void PerforationData::computeWellTransmissibility( MeshLevel const & mesh,
WellElementRegion const & wellRegion = dynamicCast< WellElementRegion const & >( wellElemSubRegion.getParent().getParent() );
GEOS_UNUSED_VAR( wellRegion ); // unused if geos_error_if is nulld
GEOS_LOG_RANK_IF( isZero( m_wellTransmissibility[iperf] ),
"\n \nWarning! A perforation is defined with a zero transmissibility in " << wellRegion.getWellGeneratorName() << "! \n" <<
"\n \nWarning! Perforation " << wellRegion.getWellGeneratorName() <<
" is defined with a zero transmissibility.\n" <<
"The simulation is going to proceed with this zero transmissibility,\n" <<
"but a better strategy to shut down a perforation is to remove the <Perforation> block from the XML\n \n" );
"but a better strategy to shut down a perforation is to remove the " <<
"<Perforation> block from the XML\n \n" );
MelReyCG marked this conversation as resolved.
Show resolved Hide resolved
continue;
}

Expand All @@ -150,7 +152,8 @@ void PerforationData::computeWellTransmissibility( MeshLevel const & mesh,
if( dx <= 0 || dy <= 0 || dz <= 0 )
{
WellElementRegion const & wellRegion = dynamicCast< WellElementRegion const & >( wellElemSubRegion.getParent().getParent() );
GEOS_THROW( "The reservoir element dimensions (dx, dy, and dz) should be positive in " << wellRegion.getWellGeneratorName(),
GEOS_THROW( "The reservoir element dimensions (dx, dy, and dz) should be positive in " <<
wellRegion.getWellGeneratorName(),
InputError );
}

Expand Down Expand Up @@ -212,7 +215,8 @@ void PerforationData::computeWellTransmissibility( MeshLevel const & mesh,
if( m_wellTransmissibility[iperf] <= 0 )
{
WellElementRegion const & wellRegion = dynamicCast< WellElementRegion const & >( wellElemSubRegion.getParent().getParent() );
GEOS_THROW( "The well index is negative or equal to zero in " << wellRegion.getWellGeneratorName(),
GEOS_THROW( "The well index is negative or equal to zero in " <<
wellRegion.getWellGeneratorName(),
InputError );
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/coreComponents/mesh/SurfaceElementRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ class SurfaceElementRegion : public ElementRegionBase
subRegionNames.push_back( sr.getName() );
} );
GEOS_ERROR_IF( subRegionNames.size() != 1,
"Surface region \"" << getName() << "\" should have one unique sub region. \"" << subRegionNames.size() << "\" found." );
"Surface region \"" << getDataContext() <<
"\" should have one unique sub region (" << subRegionNames.size() << " found)." );
return subRegionNames.front();
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/mesh/WellElementRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void WellElementRegion::generateWell( MeshLevel & mesh,

globalIndex const matchedPerforations = MpiWrapper::sum( perforationData->size() );
GEOS_THROW_IF( matchedPerforations != numPerforationsGlobal,
"Invalid mapping perforation-to-element in well " << lineBlock.getName() << "." <<
"Invalid mapping perforation-to-element in InternalWell " << lineBlock.getDataContext() << "." <<
MelReyCG marked this conversation as resolved.
Show resolved Hide resolved
" This happens when GEOSX cannot match a perforation with a reservoir element." <<
" There are two common reasons for this error:\n" <<
" 1- The most common reason for this error is that a perforation is on a section of " <<
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/mesh/WellElementSubRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void WellElementSubRegion::generate( MeshLevel & mesh,
// if they belong to the same well element. This is a temporary solution.
// TODO: split the well elements that contain multiple perforations, so that no element is shared
GEOS_THROW_IF( sharedElems.size() > 0,
"Well " << lineBlock.getName() << " contains shared well elements",
"Well " << lineBlock.getDataContext() << " contains shared well elements",
InputError );

// In Steps 1 and 2 we determine the local objects on this rank (elems and nodes)
Expand Down Expand Up @@ -519,7 +519,7 @@ void WellElementSubRegion::checkPartitioningValidity( LineBlockABC const & lineB
globalIndex const prevGlobal = prevElemIdsGlobal[iwelemGlobal][numBranches-1];

GEOS_THROW_IF( prevGlobal <= iwelemGlobal || prevGlobal < 0,
"The structure of well " << lineBlock.getName() << " is invalid. " <<
"The structure of well " << lineBlock.getDataContext() << " is invalid. " <<
" The main reason for this error is that there may be no perforation" <<
" in the bottom well element of the well, which is required to have" <<
" a well-posed problem.",
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/mesh/generators/CellBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void CellBlock::setElementType( ElementType elementType )
}
default:
{
GEOS_ERROR( "Invalid element type " << m_elementType << " for CellBlock " << getName() );
GEOS_ERROR( "Invalid element type " << m_elementType << " for CellBlock " << getDataContext() );
}
}

Expand Down
38 changes: 25 additions & 13 deletions src/coreComponents/mesh/generators/CellBlockUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ static localIndex getFaceNodesHex( localIndex const faceNum,
arraySlice1d< localIndex const, cells::NODE_MAP_USD-1 > const & elemNodes,
Span< localIndex > const faceNodes )
{
GEOS_ERROR_IF_LT( faceNodes.size(), 4 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 4,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
MelReyCG marked this conversation as resolved.
Show resolved Hide resolved
switch( faceNum )
{
case 0:
Expand Down Expand Up @@ -94,7 +95,8 @@ static localIndex getFaceNodesWedge( localIndex const faceNum,
{
case 0:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 4 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 4,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[0];
faceNodes[1] = elemNodes[1];
faceNodes[2] = elemNodes[5];
Expand All @@ -103,7 +105,8 @@ static localIndex getFaceNodesWedge( localIndex const faceNum,
}
case 1:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 4 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 4,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[0];
faceNodes[1] = elemNodes[2];
faceNodes[2] = elemNodes[3];
Expand All @@ -112,23 +115,26 @@ static localIndex getFaceNodesWedge( localIndex const faceNum,
}
case 2:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 3 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 3,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[0];
faceNodes[1] = elemNodes[4];
faceNodes[2] = elemNodes[2];
return 3;
}
case 3:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 3 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 3,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[1];
faceNodes[1] = elemNodes[3];
faceNodes[2] = elemNodes[5];
return 3;
}
case 4:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 4 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 4,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[2];
faceNodes[1] = elemNodes[4];
faceNodes[2] = elemNodes[5];
Expand All @@ -147,7 +153,8 @@ static localIndex getFaceNodesTet( localIndex const faceNum,
arraySlice1d< localIndex const, cells::NODE_MAP_USD-1 > const & elemNodes,
Span< localIndex > const faceNodes )
{
GEOS_ERROR_IF_LT( faceNodes.size(), 3 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 3,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
switch( faceNum )
{
case 0:
Expand Down Expand Up @@ -194,15 +201,17 @@ static localIndex getFaceNodesPyramid( localIndex const faceNum,
{
case 0:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 3 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 3,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[0];
faceNodes[1] = elemNodes[1];
faceNodes[2] = elemNodes[4];
return 3;
}
case 1:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 4 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 4,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[0];
faceNodes[1] = elemNodes[2];
faceNodes[2] = elemNodes[3];
Expand All @@ -211,23 +220,26 @@ static localIndex getFaceNodesPyramid( localIndex const faceNum,
}
case 2:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 3 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 3,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[0];
faceNodes[1] = elemNodes[4];
faceNodes[2] = elemNodes[2];
return 3;
}
case 3:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 3 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 3,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[1];
faceNodes[1] = elemNodes[3];
faceNodes[2] = elemNodes[4];
return 3;
}
case 4:
{
GEOS_ERROR_IF_LT( faceNodes.size(), 3 );
GEOS_ERROR_IF_LT_MSG( faceNodes.size(), 3,
"Invalid number of nodes for face (face index = " << faceNum << ")." );
faceNodes[0] = elemNodes[2];
faceNodes[1] = elemNodes[4];
faceNodes[2] = elemNodes[3];
Expand Down Expand Up @@ -295,7 +307,7 @@ localIndex getFaceNodes( ElementType const elementType,
}
default:
{
GEOS_ERROR( "Invalid element type: " << elementType );
GEOS_ERROR( "Invalid element type " << elementType << " at face index " << faceNumber );
}
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,30 @@ ExternalMeshGeneratorBase::ExternalMeshGeneratorBase( string const & name,

void ExternalMeshGeneratorBase::postProcessInput()
{
auto const checkSizes = [meshName = getName()]( arrayView1d< string const > from,
arrayView1d< string const > to,
string const & fromKey,
string const & toKey )
auto const checkSizes = [this]( arrayView1d< string const > from, arrayView1d< string const > to,
string const & fromKey, string const & toKey )
{
GEOS_THROW_IF_NE_MSG( from.size(), to.size(),
"Mesh '" << meshName << "': attributes '" << fromKey << "' and '" << toKey << "' must contain the same number of values.",
getWrapperDataContext( fromKey ) <<
" and " << getWrapperDataContext( toKey ) <<
" must contain the same number of values.",
InputError );
};
checkSizes( m_volumicFieldsToImport, m_volumicFieldsInGEOSX, viewKeyStruct::volumicFieldsToImportString(), viewKeyStruct::volumicFieldsInGEOSXString() );
checkSizes( m_surfacicFieldsToImport, m_surfacicFieldsInGEOSX, viewKeyStruct::surfacicFieldsToImportString(), viewKeyStruct::surfacicFieldsInGEOSXString() );

auto const checkDuplicates = [meshName = getName()]( arrayView1d< string const > v )
auto const checkDuplicates = [this]( arrayView1d< string const > v, string const & key )
{
std::set< string > const tmp{ v.begin(), v.end() };
bool const hasDuplicates = tmp.size() != LvArray::integerConversion< std::size_t >( v.size() );

GEOS_THROW_IF( hasDuplicates,
"Mesh '" << meshName << "': '" << stringutilities::join( v, ", " ) << "' already present in list of fields to import.",
getWrapperDataContext( key ) << ": '" << stringutilities::join( v, ", " ) <<
"' already present in list of fields to import.",
InputError );
};
checkDuplicates( m_volumicFieldsInGEOSX );
checkDuplicates( m_surfacicFieldsInGEOSX );
checkDuplicates( m_volumicFieldsInGEOSX, viewKeyStruct::volumicFieldsInGEOSXString() );
checkDuplicates( m_surfacicFieldsInGEOSX, viewKeyStruct::surfacicFieldsInGEOSXString() );

// Building the fields mapping from the two separated input/output vectors.
auto const buildMapping = [&]( arrayView1d< string const > from,
Expand Down
Loading