Skip to content

Commit

Permalink
refactor: remove assemblyLaunch duplicates in poromechanics solvers
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Tomin authored and Pavel Tomin committed Dec 10, 2024
1 parent 7e2c33b commit fe9a898
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementBa
if( this->m_isThermal )
{
poromechanicsMaxForce =
assemblyLaunch< constitutive::PorousSolidBase,
this->template assemblyLaunch< constitutive::PorousSolidBase,
thermalPoromechanicsKernels::ThermalMultiphasePoromechanicsKernelFactory >( mesh,
dofManager,
regionNames,
Expand All @@ -159,7 +159,7 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementBa
else
{
poromechanicsMaxForce =
assemblyLaunch< constitutive::PorousSolidBase,
this->template assemblyLaunch< constitutive::PorousSolidBase,
poromechanicsKernels::MultiphasePoromechanicsKernelFactory >( mesh,
dofManager,
regionNames,
Expand Down Expand Up @@ -203,7 +203,7 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementBa
}

mechanicsMaxForce =
assemblyLaunch< constitutive::SolidBase,
this->template assemblyLaunch< constitutive::SolidBase,
solidMechanicsLagrangianFEMKernels::QuasiStaticFactory >( mesh,
dofManager,
filteredRegionNames.toViewConst(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,72 +107,14 @@ class MultiphasePoromechanics : public PoromechanicsSolver< FLOW_SOLVER, MECHANI

virtual void initializePostInitialConditionsPreSubGroups() override;



private:

/**
* @brief Helper function to recompute the bulk density
* @param[in] subRegion the element subRegion
*/
virtual void updateBulkDensity( ElementSubRegionBase & subRegion ) override;

template< typename CONSTITUTIVE_BASE,
typename KERNEL_WRAPPER,
typename ... PARAMS >
real64 assemblyLaunch( MeshLevel & mesh,
DofManager const & dofManager,
arrayView1d< string const > const & regionNames,
string const & materialNamesString,
CRSMatrixView< real64, globalIndex const > const & localMatrix,
arrayView1d< real64 > const & localRhs,
real64 const dt,
PARAMS && ... params );


};

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
template< typename CONSTITUTIVE_BASE,
typename KERNEL_WRAPPER,
typename ... PARAMS >
real64 MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assemblyLaunch( MeshLevel & mesh,
DofManager const & dofManager,
arrayView1d< string const > const & regionNames,
string const & materialNamesString,
CRSMatrixView< real64, globalIndex const > const & localMatrix,
arrayView1d< real64 > const & localRhs,
real64 const dt,
PARAMS && ... params )
{
GEOS_MARK_FUNCTION;

NodeManager const & nodeManager = mesh.getNodeManager();

string const dofKey = dofManager.getKey( fields::solidMechanics::totalDisplacement::key() );
arrayView1d< globalIndex const > const & dofNumber = nodeManager.getReference< globalIndex_array >( dofKey );

real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( PhysicsSolverBase::gravityVector() );

KERNEL_WRAPPER kernelWrapper( dofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
gravityVectorData,
std::forward< PARAMS >( params )... );

return finiteElement::
regionBasedKernelApplication< parallelDevicePolicy< >,
CONSTITUTIVE_BASE,
CellElementSubRegion >( mesh,
regionNames,
this->solidMechanicsSolver()->getDiscretizationName(),
materialNamesString,
kernelWrapper );
}


} /* namespace geos */

#endif /* GEOS_PHYSICSSOLVERS_MULTIPHYSICS_MULTIPHASEPOROMECHANICS_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,45 @@ class PoromechanicsSolver : public CoupledSolver< FLOW_SOLVER, MECHANICS_SOLVER

protected:

template< typename CONSTITUTIVE_BASE,
typename KERNEL_WRAPPER,
typename ... PARAMS >
real64 assemblyLaunch( MeshLevel & mesh,
DofManager const & dofManager,
arrayView1d< string const > const & regionNames,
string const & materialNamesString,
CRSMatrixView< real64, globalIndex const > const & localMatrix,
arrayView1d< real64 > const & localRhs,
real64 const dt,
PARAMS && ... params )
{
GEOS_MARK_FUNCTION;

NodeManager const & nodeManager = mesh.getNodeManager();

string const dofKey = dofManager.getKey( fields::solidMechanics::totalDisplacement::key() );
arrayView1d< globalIndex const > const & dofNumber = nodeManager.getReference< globalIndex_array >( dofKey );

real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( PhysicsSolverBase::gravityVector() );

KERNEL_WRAPPER kernelWrapper( dofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
gravityVectorData,
std::forward< PARAMS >( params )... );

return finiteElement::
regionBasedKernelApplication< parallelDevicePolicy< >,
CONSTITUTIVE_BASE,
CellElementSubRegion >( mesh,
regionNames,
this->solidMechanicsSolver()->getDiscretizationName(),
materialNamesString,
kernelWrapper );
}

/* Implementation of Nonlinear Acceleration (Aitken) of averageMeanTotalStressIncrement */

void recordAverageMeanTotalStressIncrement( DomainPartition & domain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementB
if( this->m_isThermal )
{
poromechanicsMaxForce =
assemblyLaunch< constitutive::PorousSolidBase,
this->template assemblyLaunch< constitutive::PorousSolidBase,
thermalPoromechanicsKernels::ThermalSinglePhasePoromechanicsKernelFactory >( mesh,
dofManager,
regionNames,
Expand All @@ -209,7 +209,7 @@ void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementB
else
{
poromechanicsMaxForce =
assemblyLaunch< constitutive::PorousSolidBase,
this->template assemblyLaunch< constitutive::PorousSolidBase,
poromechanicsKernels::SinglePhasePoromechanicsKernelFactory >( mesh,
dofManager,
regionNames,
Expand Down Expand Up @@ -248,7 +248,7 @@ void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementB
}

mechanicsMaxForce =
assemblyLaunch< constitutive::SolidBase,
this->template assemblyLaunch< constitutive::SolidBase,
solidMechanicsLagrangianFEMKernels::QuasiStaticFactory >( mesh,
dofManager,
filteredRegionNames.toViewConst(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,6 @@ class SinglePhasePoromechanics : public PoromechanicsSolver< FLOW_SOLVER, MECHAN

virtual void initializePostInitialConditionsPreSubGroups() override;

template< typename CONSTITUTIVE_BASE,
typename KERNEL_WRAPPER,
typename ... PARAMS >
real64 assemblyLaunch( MeshLevel & mesh,
DofManager const & dofManager,
arrayView1d< string const > const & regionNames,
string const & materialNamesString,
CRSMatrixView< real64, globalIndex const > const & localMatrix,
arrayView1d< real64 > const & localRhs,
real64 const dt,
PARAMS && ... params );

private:

/**
* @brief Helper function to recompute the bulk density
* @param[in] subRegion the element subRegion
Expand All @@ -142,47 +128,6 @@ class SinglePhasePoromechanics : public PoromechanicsSolver< FLOW_SOLVER, MECHAN

};

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
template< typename CONSTITUTIVE_BASE,
typename KERNEL_WRAPPER,
typename ... PARAMS >
real64 SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assemblyLaunch( MeshLevel & mesh,
DofManager const & dofManager,
arrayView1d< string const > const & regionNames,
string const & materialNamesString,
CRSMatrixView< real64, globalIndex const > const & localMatrix,
arrayView1d< real64 > const & localRhs,
real64 const dt,
PARAMS && ... params )
{
GEOS_MARK_FUNCTION;

NodeManager const & nodeManager = mesh.getNodeManager();

string const dofKey = dofManager.getKey( fields::solidMechanics::totalDisplacement::key() );
arrayView1d< globalIndex const > const & dofNumber = nodeManager.getReference< globalIndex_array >( dofKey );

real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( PhysicsSolverBase::gravityVector() );

KERNEL_WRAPPER kernelWrapper( dofNumber,
dofManager.rankOffset(),
localMatrix,
localRhs,
dt,
gravityVectorData,
std::forward< PARAMS >( params )... );

return finiteElement::
regionBasedKernelApplication< parallelDevicePolicy< >,
CONSTITUTIVE_BASE,
CellElementSubRegion >( mesh,
regionNames,
this->solidMechanicsSolver()->getDiscretizationName(),
materialNamesString,
kernelWrapper );
}


} /* namespace geos */

#endif /* GEOS_PHYSICSSOLVERS_MULTIPHYSICS_SINGLEPHASEPOROMECHANICS_HPP_ */

0 comments on commit fe9a898

Please sign in to comment.