Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 0 additions & 8 deletions inputFiles/lagrangianContactMechanics/TFrac_smoke.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
<!-- SPHINX_SOLVER_END -->
</Solvers>

<NumericalMethods>
Copy link
Contributor

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.

<FiniteElements>
<FiniteElementSpace
name="FE1"
order="1"/>
</FiniteElements>
</NumericalMethods>

<!-- SPHINX_MESH -->
<Mesh>
<InternalMesh
Expand Down
9 changes: 0 additions & 9 deletions inputFiles/wavePropagation/acous3D_Q3_abc_fs_smoke.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,4 @@
xMin="{ -0.01, -0.01, 100.99 }"
xMax="{ 101.01, 101.01, 101.01 }"/>
</Geometry>

<!-- The free surface condition the domain -->
Copy link
Contributor

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.

<FieldSpecifications>
<FieldSpecification
name="zposFreeSurface"
objectPath="mesh/FE2/faceManager"
fieldName="FreeSurface"
setNames="{ zpos }"/>
</FieldSpecifications>
</Problem>
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,4 @@
xMin="{ -0.01, -0.01, 100.99 }"
xMax="{ 101.01, 101.01, 101.01 }"/>
</Geometry>

<!-- The free surface condition the domain -->
<FieldSpecifications>
<FieldSpecification
name="zposFreeSurface"
objectPath="mesh/FE1/faceManager"
fieldName="FreeSurface"
setNames="{ zpos }"/>
</FieldSpecifications>
</Problem>
9 changes: 0 additions & 9 deletions inputFiles/wavePropagation/acous3D_abc_fs_smoke.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,4 @@
xMin="{ -0.01, -0.01, 100.99 }"
xMax="{ 101.01, 101.01, 101.01 }"/>
</Geometry>

<!-- The free surface condition the domain -->
<FieldSpecifications>
<FieldSpecification
name="zposFreeSurface"
objectPath="faceManager"
fieldName="FreeSurface"
setNames="{ zpos }"/>
</FieldSpecifications>
</Problem>
9 changes: 0 additions & 9 deletions inputFiles/wavePropagation/acous3D_firstOrder_fs_smoke.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,4 @@
xMin="{ -0.01, -0.01, 100.99 }"
xMax="{ 101.01, 101.01, 101.01 }"/>
</Geometry>

<!-- The free surface condition the domain -->
<FieldSpecifications>
<FieldSpecification
name="zposFreeSurface"
objectPath="faceManager"
fieldName="FreeSurface"
setNames="{ zpos }"/>
</FieldSpecifications>
</Problem>
8 changes: 0 additions & 8 deletions inputFiles/wavePropagation/acous3D_vti_smoke.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,6 @@
fieldName="acousticVelocity"
scale="1500"
setNames="{ all }"/>

<!-- 3) The free surface condition the domain -->
<FieldSpecification
name="zposFreeSurface"
objectPath="faceManager"
fieldName="FreeSurface"
scale="0.0"
setNames="{ zpos }"/>
</FieldSpecifications>

<Events
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/LvArray
4 changes: 2 additions & 2 deletions src/coreComponents/constitutive/ConstitutiveBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ).
Copy link
Contributor

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.

setRestartFlags( RestartFlags::NO_WRITE );
}
}
Expand All @@ -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 );
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/coreComponents/constitutive/ConstitutiveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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.

{
GEOS_LOG_RANK_0( GEOS_FMT( "{}: adding {} {}", getName(), childKey, childName ) );
std::unique_ptr< ConstitutiveBase > material =
ConstitutiveBase::CatalogInterface::factory( childKey, getDataContext(), childName, this );
return &registerGroup< ConstitutiveBase >( childName, std::move( material ) );
return &registerGroup< ConstitutiveBase >( std::move( material ), allowExistence );
Copy link
Contributor

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.

}


Expand Down Expand Up @@ -92,7 +94,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() );

Expand Down
4 changes: 3 additions & 1 deletion src/coreComponents/constitutive/ConstitutiveManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class ConstitutiveManager : public dataRepository::Group
ConstitutiveManager( string const & name,
Group * const parent );

virtual Group * createChild( string const & childKey, string const & childName ) override final;
virtual Group * createChild( string const & childKey,
string const & childName,
bool const allowExistence=false ) override final;

/// This function is used to expand any catalogs in the data structure
virtual void expandObjectCatalogs() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ MultiFluidBase::MultiFluidBase( string const & name, Group * const parent )

registerWrapper( viewKeyStruct::componentNamesString(), &m_componentNames ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "List of component names" );
setDescription( "List of fluid components (e.g. CH4, H2O, C5H12)" );

registerWrapper( viewKeyStruct::componentMolarWeightString(), &m_componentMolarWeight ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "Component molar weights" );
setDescription( "Molar weights of components" );

registerWrapper( viewKeyStruct::phaseNamesString(), &m_phaseNames ).
setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "List of fluid phases" );
setDescription( "List of fluid phases (e.g. gas, water, oil)" );
Comment on lines -40 to +49
Copy link
Contributor

Choose a reason for hiding this comment

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

These obviously weren't required, but I copied the slightly more detailed description from the duplicate registration in InvariantImmiscibleFluid.


registerWrapper( viewKeyStruct::useMassString(), &m_useMass ).
setRestartFlags( RestartFlags::NO_WRITE ).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ InvariantImmiscibleFluid::InvariantImmiscibleFluid( string const & name, Group *
: MultiFluidBase( name, parent )
{
// Override input flags for mandatory options
getWrapperBase( viewKeyStruct::componentNamesString() )
.setInputFlag( dataRepository::InputFlags::REQUIRED );

registerWrapper( viewKeyStruct::componentNamesString(), &m_componentNames )
.setInputFlag( dataRepository::InputFlags::REQUIRED )
.setDescription( "List of fluid components (e.g. CH4, H2O, C5H12)" );

registerWrapper( viewKeyStruct::phaseNamesString(), &m_phaseNames )
.setInputFlag( dataRepository::InputFlags::REQUIRED )
.setDescription( "List of fluid phases (e.g. gas, water, oil)" );
getWrapperBase( viewKeyStruct::componentMolarWeightString() )
.setInputFlag( dataRepository::InputFlags::REQUIRED );

registerWrapper( viewKeyStruct::componentMolarWeightString(), &m_componentMolarWeight )
.setInputFlag( dataRepository::InputFlags::REQUIRED )
.setDescription( "Molar weights of components" );
getWrapperBase( viewKeyStruct::phaseNamesString() )
.setInputFlag( dataRepository::InputFlags::REQUIRED );

// Densities: constant phase densities
registerWrapper( "densities", &m_densities )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void FluidModelTest< FLUID_TYPE, NUM_COMP, NUM_PHASE >::createFunctionManager()
// TODO: FunctionManager is a singleton
string const name = FunctionManager::catalogName();
auto functionManager = std::make_unique< FunctionManager >( name, &m_parent );
m_parent.registerGroup( name, std::move( functionManager ) );
m_parent.registerGroup( std::move( functionManager ) );
}

} // namespace testing
Expand Down
75 changes: 64 additions & 11 deletions src/coreComponents/dataRepository/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand Down Expand Up @@ -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 &registerGroup( childName,
CatalogInterface::factory( childKey, getDataContext(),
childName, this ) );
return &registerGroup( CatalogInterface::factory( childKey, getDataContext(), childName, this ), allowExistence );
}

void Group::printDataHierarchy( integer const indent ) const
Expand Down Expand Up @@ -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 )
{
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 */
Loading
Loading