-
Notifications
You must be signed in to change notification settings - Fork 97
fix: error in MappedVector::insert #3610
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
base: develop
Are you sure you want to change the base?
Conversation
|
@wrtobin I made the redundant registration attempts an error if the registration doesn't have the same exact pointer address as the existing entry. This is the only case that is OK imo. There are a lot of errors. Things seem to be registered in the mesh generation/ mesh level creation in a quite inconsistent way. No big surprise. Can you have a go at resolving some the errors? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Files not reviewed (2)
- src/coreComponents/schema/schema.xsd: Language not supported
- src/coreComponents/schema/schema.xsd.other: Language not supported
Comments suppressed due to low confidence (1)
src/coreComponents/dataRepository/MappedVector.hpp:510
- If 'takeOwnership' is true but the source pointer differs from the existing value, the code only updates the ownership flag without replacing the pointer. Verify that this logic aligns with the intended behavior to correctly handle duplicate entries.
else if( m_values[index].second != source ) // this insertion is OK if the source pointer is the same address as the existing value
| arrayView1d< bool const > const nodeInCurSet = nodeInSet[setName]; | ||
|
|
||
| SortedArray< localIndex > & targetSet = elementSets.registerWrapper< SortedArray< localIndex > >( setName ).reference(); | ||
| // SortedArray< localIndex > & targetSet = elementSets.registerWrapper< SortedArray< localIndex > >( setName ).reference(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // SortedArray< localIndex > & targetSet = elementSets.registerWrapper< SortedArray< localIndex > >( setName ).reference(); |
| MeshBody & meshBody = domain.getMeshBodies().registerGroup< MeshBody >( meshGen.getName() ); | ||
| meshBody.createMeshLevel( 0 ); | ||
| MeshBody & meshBody = domain.getMeshBodies().getGroup< MeshBody >( meshGen.getName() ); | ||
| // meshBody.createMeshLevel( 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
| setPlotLevel( PlotLevel::NOPLOT ); | ||
|
|
||
| m_sets.registerWrapper< SortedArray< localIndex > >( this->m_ObjectManagerBaseViewKeys.externalSet ); | ||
| // m_sets.registerWrapper< SortedArray< localIndex > >( this->m_ObjectManagerBaseViewKeys.externalSet ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // m_sets.registerWrapper< SortedArray< localIndex > >( this->m_ObjectManagerBaseViewKeys.externalSet ); |
| } | ||
|
|
||
| // if value is empty, then move source into value slot | ||
| if( m_values[index].second==nullptr ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, when do we use this functionality of inserting a nullptr? It seems like the kind of thing that could reasonably be disallowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
....err....good point.
|
@rrsettgast is this still active PR? |
|
@wrtobin you were supposed to pick this up a while back. |
|
I'm gonna try and get this working this week. |
574b80c to
617534e
Compare
652a70d to
653ee13
Compare
| <!-- SPHINX_SOLVER_END --> | ||
| </Solvers> | ||
|
|
||
| <NumericalMethods> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already present in the included base file.
| xMax="{ 101.01, 101.01, 101.01 }"/> | ||
| </Geometry> | ||
|
|
||
| <!-- The free surface condition the domain --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already present in the included base file.
| { | ||
| string const wrapperName = makeFieldName( this->getName(), wrapper.first ); | ||
| parent.registerWrapper( wrapper.second->clone( wrapperName, parent ) ). | ||
| parent.registerWrapper( wrapper.second->clone( wrapperName, parent ), true ). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These sorts of changes registerWrapper(..., true) and registerGroup(..., true) permit an object with the given name to already exist, and return the existing object.
| Group * ConstitutiveManager::createChild( string const & childKey, | ||
| string const & childName, | ||
| bool const allowExistence ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were some places where createChild needed to change, since this is a virtual function in Group, changing the signature there required changes everywhere.
| std::unique_ptr< ConstitutiveBase > material = | ||
| ConstitutiveBase::CatalogInterface::factory( childKey, getDataContext(), childName, this ); | ||
| return ®isterGroup< ConstitutiveBase >( childName, std::move( material ) ); | ||
| return ®isterGroup< ConstitutiveBase >( std::move( material ), allowExistence ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also made it so that methods such as these, which register an existing Group or Wrapper no longer require an additional name (childName in this example). In every instance in the code the provided name is the same as the name of the Group (or Wrapper itself, and it seems this is something we should enforce.
| auto & set = m_sets.registerWrapper< SortedArray< localIndex > >( newSetName, true ).reference(); | ||
| set.clear(); | ||
| return set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this set.clear() behavior is new.
| m_registeredField.insert( FIELD_TRAIT::key()); | ||
|
|
||
| return this->registerWrapper< typename FIELD_TRAIT::type >( FIELD_TRAIT::key() ). | ||
| return this->registerWrapper< typename FIELD_TRAIT::type >( FIELD_TRAIT::key(), nullptr, true ). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nullptr here is to satisfy the following signature without having to introduce a similar function without rkey
template< typename T, typename TBASE=T >
Wrapper< TBASE > & registerWrapper( string const & name,
wrapperMap::KeyIndex::index_type * const rkey = nullptr,
bool const allowExistence=false );| parent ) | ||
| { | ||
| registerWrapper( viewKeyStruct::sourceConstantsString(), &m_sourceConstantsx ). | ||
| registerWrapper( viewKeyStruct::sourceConstantsXString(), &m_sourceConstantsx ). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the true mistakes I found. The few failing integrated tests are due to this and will require a rebaseline.
| subRegion.registerWrapper< string >( viewKeyStruct::porousMaterialNamesString() ). | ||
| setPlotLevel( dataRepository::PlotLevel::NOPLOT ). | ||
| setRestartFlags( dataRepository::RestartFlags::NO_WRITE ). | ||
| setSizedFromParent( 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These must have been registered elsewhere, but I couldn't find where.
| SortedArrayView< localIndex const > const & faceSet = faceManager->sets().getReference< SortedArray< localIndex > >( setIter.first ); | ||
| SortedArray< localIndex > & faceElementSet = subRegion.sets().registerWrapper< SortedArray< localIndex > >( setIter.first ).reference(); | ||
| SortedArray< localIndex > & faceElementSet = subRegion.sets().getReference< SortedArray< localIndex > >( setIter.first ); | ||
| // faceElementSet.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rrsettgast For all the set building I initially cleared the set because I mistakenly assumed the old behavior of registerWrapper would replace the previously held data (effectively calling clear). This worked fine everywhere else, in fact I still kept that behavior. But here this presented a problem with some integrated tests having diffs in the the size of FractureElementSubregion/sets/externalSet, but only in parallel.
My question is: do we actually want to clear the sets every time?
|
I updated the error messages and conditions as requested. Here are two examples |
MappedVector::insert incorrectly delete object if it is a duplicate entry and the overwrite flag isn't true. This means that the insert is a no-op, and the object that was supposed to be inserted was deleted. Bad news bears.
nameparameter from certainregisterGroupandregisterWrappermethods.Related to: GEOS-DEV/LvArray#350