-
Notifications
You must be signed in to change notification settings - Fork 100
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?
Changes from all commits
23b6510
4511ce5
59fc3d3
728060c
3da4a6e
6f5eadf
4356899
23fa30a
95fe965
8133922
6a1804f
653ee13
12db88d
fd8f913
a22944d
f2e3f87
c2b55b9
6525094
98e3a89
85a4ce0
1c6a2f7
390fa6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,7 @@ void ConstitutiveBase::allocateConstitutiveData( Group & parent, localIndex cons | |
| if( wrapper.second->sizedFromParent() ) | ||
| { | ||
| string const wrapperName = makeFieldName( this->getName(), wrapper.first ); | ||
| parent.registerWrapper( wrapper.second->clone( wrapperName, parent ) ). | ||
| parent.registerWrapper( wrapper.second->clone( wrapperName, parent ), true ). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These sorts of changes |
||
| setRestartFlags( RestartFlags::NO_WRITE ); | ||
| } | ||
| } | ||
|
|
@@ -64,7 +64,7 @@ void ConstitutiveBase::allocateConstitutiveData( Group & parent, localIndex cons | |
| if( wrapper.second->sizedFromParent() ) | ||
| { | ||
| string const wrapperName = makeFieldName( this->getName(), wrapper.first ); | ||
| parent.registerWrapper( wrapper.second->clone( wrapperName, parent ) ). | ||
| parent.registerWrapper( wrapper.second->clone( wrapperName, parent ), true ). | ||
| setRestartFlags( RestartFlags::NO_WRITE ); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,12 +41,14 @@ ConstitutiveManager::~ConstitutiveManager() | |
| {} | ||
|
|
||
|
|
||
| Group * ConstitutiveManager::createChild( string const & childKey, string const & childName ) | ||
| Group * ConstitutiveManager::createChild( string const & childKey, | ||
| string const & childName, | ||
| bool const allowExistence ) | ||
|
Comment on lines
+44
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There were some places where |
||
| { | ||
| GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) ); | ||
| 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 ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
|
|
||
|
|
||
|
|
@@ -93,7 +95,7 @@ ConstitutiveManager::hangConstitutiveRelation( string const & constitutiveRelati | |
| numConstitutivePointsPerParentIndex ) ); | ||
|
|
||
| ConstitutiveBase & | ||
| materialGroup = constitutiveGroup->registerGroup< ConstitutiveBase >( constitutiveRelationInstanceName, std::move( material ) ); | ||
| materialGroup = constitutiveGroup->registerGroup< ConstitutiveBase >( std::move( material ) ); | ||
| materialGroup.setSizedFromParent( 1 ); | ||
| materialGroup.resize( constitutiveGroup->size() ); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,13 +67,6 @@ Group::CatalogInterface::CatalogType & Group::getCatalog() | |
| return catalog; | ||
| } | ||
|
|
||
| WrapperBase & Group::registerWrapper( std::unique_ptr< WrapperBase > wrapper ) | ||
| { | ||
| // Extract `wrapperName` first to prevent from UB call order in the `insert` call. | ||
| string const wrapperName = wrapper->getName(); | ||
| return *m_wrappers.insert( wrapperName, wrapper.release(), true ); | ||
| } | ||
|
|
||
| void Group::deregisterWrapper( string const & name ) | ||
| { | ||
| GEOS_ERROR_IF( !hasWrapper( name ), | ||
|
|
@@ -275,12 +268,10 @@ void Group::registerDataOnMeshRecursive( Group & meshBodies ) | |
| } | ||
| } | ||
|
|
||
| Group * Group::createChild( string const & childKey, string const & childName ) | ||
| Group * Group::createChild( string const & childKey, string const & childName, bool const allowExistence ) | ||
| { | ||
| GEOS_LOG_RANK_0( "Adding Object " << childKey<<" named "<< childName<<" from Group::Catalog." ); | ||
| return ®isterGroup( childName, | ||
| CatalogInterface::factory( childKey, getDataContext(), | ||
| childName, this ) ); | ||
| return ®isterGroup( CatalogInterface::factory( childKey, getDataContext(), childName, this ), allowExistence ); | ||
| } | ||
|
|
||
| void Group::printDataHierarchy( integer const indent ) const | ||
|
|
@@ -749,5 +740,67 @@ stdVector< string > Group::getWrappersNames() const | |
| return wrappersNames; | ||
| } | ||
|
|
||
| void Group::insertWrapper( std::unique_ptr< WrapperBase > wrapper, bool const allowExistence ) | ||
| { | ||
| GEOS_ERROR_IF( !wrapper, "Trying to register a nullptr WrapperBase with " << getPath() ); | ||
|
|
||
| // Extract data from wrapper in case it's free'd in insert. | ||
| string const name = wrapper->getName(); | ||
| std::type_info const & typeId = wrapper->getTypeId(); | ||
| string const typeName = wrapper->getRTTypeName(); | ||
|
|
||
| WrapperBase * const ret = m_wrappers.insert( name, wrapper.release(), true ); | ||
|
|
||
| if( ret == nullptr ) | ||
| { | ||
| WrapperBase const & existingWrapper = getWrapperBase( name ); | ||
| bool const typesMatch = existingWrapper.getTypeId() == typeId; | ||
|
|
||
| if( !allowExistence || !typesMatch ) | ||
| { | ||
| string registrationString = ""; | ||
| if( !existingWrapper.getRegisteringObjects().empty() ) | ||
| { | ||
| std::ostringstream oss; | ||
| oss << ". The existing wrapper was registered by the following:"; | ||
| for( string const & object : existingWrapper.getRegisteringObjects() ) | ||
| { | ||
| oss << "\n\t" << object; | ||
| } | ||
|
|
||
| registrationString = oss.str(); | ||
| } | ||
|
|
||
| GEOS_ERROR( "Tried registering a wrapper \"" << name << "\" of type " << typeName << | ||
| " with \"" << getPath() << "\"\n" << | ||
| "A wrapper of this name already exists with type " << existingWrapper.getRTTypeName() << registrationString ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void Group::insertGroup( Group * const newObject, bool const takeOwnership, bool const allowExistence ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same remark |
||
| { | ||
| GEOS_ERROR_IF( !newObject, "Attempting to register a nullptr as a subgroup of " << getPath() ); | ||
|
|
||
| newObject->m_parent = this; | ||
|
|
||
| // Extract data from newObject in case it's free'd in insert. | ||
| string const name = newObject->getName(); | ||
| std::type_info const & typeId = typeid( *newObject ); | ||
|
|
||
| Group * const ret = m_subGroups.insert( name, newObject, takeOwnership ); | ||
|
|
||
| if( ret == nullptr ) | ||
| { | ||
| Group const & existingGroup = getGroup( name ); | ||
| std::type_info const & existingTypeId = typeid( existingGroup ); | ||
|
|
||
| GEOS_ERROR_IF( !allowExistence || (existingTypeId != typeId), | ||
| "Tried registering a Group \"" << name << "\" of type " << rtTypes::getTypeName( typeId ) << | ||
| " with \"" << getPath() << "\"\n" << | ||
| "A Group of this name already exists with type " << rtTypes::getTypeName( existingTypeId ) ); | ||
| } | ||
| } | ||
|
|
||
| } /* end namespace dataRepository */ | ||
| } /* end namespace geos */ | ||
Uh oh!
There was an error while loading. Please reload this page.