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

refactor: trying to improve the constitutive allocation message #3511

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
24 changes: 5 additions & 19 deletions src/coreComponents/constitutive/ConstitutiveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ ConstitutiveManager::hangConstitutiveRelation( string const & constitutiveRelati

material->allocateConstitutiveData( *parent,
numConstitutivePointsPerParentIndex );
GEOS_LOG_RANK_0( GEOS_FMT( " {}/{} allocated",
dkachuma marked this conversation as resolved.
Show resolved Hide resolved
constitutiveGroup->getName(),
constitutiveRelation.getName(),
numConstitutivePointsPerParentIndex ) );

ConstitutiveBase &
materialGroup = constitutiveGroup->registerGroup< ConstitutiveBase >( constitutiveRelationInstanceName, std::move( material ) );
Expand All @@ -95,25 +99,7 @@ ConstitutiveManager::hangConstitutiveRelation( string const & constitutiveRelati
std::vector< string > const subRelationNames = constitutiveRelation.getSubRelationNames();
for( string const & subRelationName : subRelationNames )
{
// we only want to register the subRelation if it has not been registered yet.
GEOS_ERROR_IF( constitutiveGroup->hasGroup( subRelationName ),
GEOS_FMT( "Error! The constitutive relation {} has already been registered on the subRegion {}. "
"Make sure that the same constitutive model is not listed as a material on a"
" region both as a stand-alone one and as part of a compound constitutive model.",
subRelationName, parent->getDataContext().toString() ) );

ConstitutiveBase const & subRelation = getConstitutiveRelation( subRelationName );

std::unique_ptr< ConstitutiveBase > constitutiveModel = subRelation.deliverClone( subRelationName, parent );

constitutiveModel->allocateConstitutiveData( *parent,
numConstitutivePointsPerParentIndex );


ConstitutiveBase &
group = constitutiveGroup->registerGroup< ConstitutiveBase >( subRelationName, std::move( constitutiveModel ) );
group.setSizedFromParent( 1 );
group.resize( constitutiveGroup->size() );
hangConstitutiveRelation( subRelationName, parent, numConstitutivePointsPerParentIndex );
Copy link
Contributor

Choose a reason for hiding this comment

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

This recursive call potentially goes deeper than the original code. Are we sure it will terminate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, i am sure it will terminate but not sure what way is correct
@rrsettgast @CusiniM could you please confirm?

}
}

Expand Down
15 changes: 0 additions & 15 deletions src/coreComponents/constitutive/ConstitutiveManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,11 @@ class ConstitutiveManager : public dataRepository::Group
return this->getGroup< T >( key );
}

// template< typename T >
// ViewAccessor< T >
// GetConstitutiveData( string const & name,
// dataRepository::Group * const relationGroup );

template< typename T >
ViewAccessor< T >
getConstitutiveData( string const & name,
dataRepository::Group const * const relationGroup ) const;


struct groupKeyStruct
{
static constexpr auto constitutiveModelsString() { return "ConstitutiveModels"; }
Expand Down Expand Up @@ -110,15 +104,6 @@ ConstitutiveManager::getConstitutiveData( string const & name,
return rval;
}

// template< typename T >
// ViewAccessor< T >
// ConstitutiveManager::GetConstitutiveData( string const & name,
// dataRepository::Group * const relationGroup )
// {
// return const_cast< ViewAccessor<T> >(const_cast<ConstitutiveManager const *>(this->
// GetConstitutiveData<T>( name, relationGroup ) );
// }

}
} /* namespace geos */

Expand Down
21 changes: 3 additions & 18 deletions src/coreComponents/mainInterface/ProblemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,9 @@ void ProblemManager::setRegionQuadrature( Group & meshBodies,
string const regionName = std::get< 2 >( key );
string const subRegionName = std::get< 3 >( key );

GEOS_LOG_RANK_0( "regionQuadrature: meshBodyName, meshLevelName, regionName, subRegionName = "<<
meshBodyName<<", "<<meshLevelName<<", "<<regionName<<", "<<subRegionName );


GEOS_LOG_RANK_0( GEOS_FMT( "meshBodyName/meshLevelName/regionName/subRegionName = {}/{}/{}/{}, {} quadrature {}",
meshBodyName, meshLevelName, regionName, subRegionName, numQuadraturePoints,
numQuadraturePoints == 1 ? "point" : "points" ) );

MeshBody & meshBody = meshBodies.getGroup< MeshBody >( meshBodyName );
MeshLevel & meshLevel = meshBody.getMeshLevel( meshLevelName );
Expand All @@ -1063,13 +1062,6 @@ void ProblemManager::setRegionQuadrature( Group & meshBodies,
for( auto & materialName : materialList )
{
constitutiveManager.hangConstitutiveRelation( materialName, &particleSubRegion, numQuadraturePoints );
GEOS_LOG_RANK_0( GEOS_FMT( "{}/{}/{}/{}/{} allocated {} quadrature points",
meshBodyName,
meshLevelName,
regionName,
subRegionName,
materialName,
numQuadraturePoints ) );
}
}
// if( meshLevel.isShallowCopy() )
Expand All @@ -1083,13 +1075,6 @@ void ProblemManager::setRegionQuadrature( Group & meshBodies,
for( auto & materialName : materialList )
{
constitutiveManager.hangConstitutiveRelation( materialName, &elemSubRegion, numQuadraturePoints );
GEOS_LOG_RANK_0( GEOS_FMT( "{}/{}/{}/{}/{} allocated {} quadrature points",
meshBodyName,
meshLevelName,
regionName,
subRegionName,
materialName,
numQuadraturePoints ) );
}
}
}
Expand Down
Loading