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
paveltomin authored Dec 11, 2024
1 parent 6cc493e commit ec52431
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,39 +141,39 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementBa
if( this->m_isThermal )
{
poromechanicsMaxForce =
assemblyLaunch< constitutive::PorousSolidBase,
thermalPoromechanicsKernels::ThermalMultiphasePoromechanicsKernelFactory >( mesh,
dofManager,
regionNames,
Base::viewKeyStruct::porousMaterialNamesString(),
localMatrix,
localRhs,
dt,
flowDofKey,
this->flowSolver()->numFluidComponents(),
this->flowSolver()->numFluidPhases(),
this->flowSolver()->useTotalMassEquation(),
this->m_performStressInitialization,
FlowSolverBase::viewKeyStruct::fluidNamesString() );
this->template assemblyLaunch< constitutive::PorousSolidBase,
thermalPoromechanicsKernels::ThermalMultiphasePoromechanicsKernelFactory >( mesh,
dofManager,
regionNames,
Base::viewKeyStruct::porousMaterialNamesString(),
localMatrix,
localRhs,
dt,
flowDofKey,
this->flowSolver()->numFluidComponents(),
this->flowSolver()->numFluidPhases(),
this->flowSolver()->useTotalMassEquation(),
this->m_performStressInitialization,
FlowSolverBase::viewKeyStruct::fluidNamesString() );
}
else
{
poromechanicsMaxForce =
assemblyLaunch< constitutive::PorousSolidBase,
poromechanicsKernels::MultiphasePoromechanicsKernelFactory >( mesh,
dofManager,
regionNames,
Base::viewKeyStruct::porousMaterialNamesString(),
localMatrix,
localRhs,
dt,
flowDofKey,
this->flowSolver()->numFluidComponents(),
this->flowSolver()->numFluidPhases(),
this->flowSolver()->useSimpleAccumulation(),
this->flowSolver()->useTotalMassEquation(),
this->m_performStressInitialization,
FlowSolverBase::viewKeyStruct::fluidNamesString() );
this->template assemblyLaunch< constitutive::PorousSolidBase,
poromechanicsKernels::MultiphasePoromechanicsKernelFactory >( mesh,
dofManager,
regionNames,
Base::viewKeyStruct::porousMaterialNamesString(),
localMatrix,
localRhs,
dt,
flowDofKey,
this->flowSolver()->numFluidComponents(),
this->flowSolver()->numFluidPhases(),
this->flowSolver()->useSimpleAccumulation(),
this->flowSolver()->useTotalMassEquation(),
this->m_performStressInitialization,
FlowSolverBase::viewKeyStruct::fluidNamesString() );
}
} );

Expand Down Expand Up @@ -203,14 +203,14 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::assembleElementBa
}

mechanicsMaxForce =
assemblyLaunch< constitutive::SolidBase,
solidMechanicsLagrangianFEMKernels::QuasiStaticFactory >( mesh,
dofManager,
filteredRegionNames.toViewConst(),
SolidMechanicsLagrangianFEM::viewKeyStruct::solidMaterialNamesString(),
localMatrix,
localRhs,
dt );
this->template assemblyLaunch< constitutive::SolidBase,
solidMechanicsLagrangianFEMKernels::QuasiStaticFactory >( mesh,
dofManager,
filteredRegionNames.toViewConst(),
SolidMechanicsLagrangianFEM::viewKeyStruct::solidMaterialNamesString(),
localMatrix,
localRhs,
dt );

} );

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
Loading

0 comments on commit ec52431

Please sign in to comment.