From fe9a8983f7bb56187b6fa914c851b37e759553ca Mon Sep 17 00:00:00 2001 From: Pavel Tomin Date: Tue, 10 Dec 2024 10:44:19 -0600 Subject: [PATCH] refactor: remove assemblyLaunch duplicates in poromechanics solvers --- .../multiphysics/MultiphasePoromechanics.cpp | 6 +- .../multiphysics/MultiphasePoromechanics.hpp | 58 ------------------- .../multiphysics/PoromechanicsSolver.hpp | 39 +++++++++++++ .../multiphysics/SinglePhasePoromechanics.cpp | 6 +- .../multiphysics/SinglePhasePoromechanics.hpp | 55 ------------------ 5 files changed, 45 insertions(+), 119 deletions(-) diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp index c477f2b83d..81032cd766 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.cpp @@ -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, @@ -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, @@ -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(), diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.hpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.hpp index 9251d86dac..b9241d3479 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanics.hpp @@ -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_ */ diff --git a/src/coreComponents/physicsSolvers/multiphysics/PoromechanicsSolver.hpp b/src/coreComponents/physicsSolvers/multiphysics/PoromechanicsSolver.hpp index 7053aec0d0..58e9822387 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/PoromechanicsSolver.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/PoromechanicsSolver.hpp @@ -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, diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp index 8026c45a80..891aea467c 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.cpp @@ -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, @@ -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, @@ -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(), diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.hpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.hpp index f311b786c3..c1abd96dab 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanics.hpp @@ -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 @@ -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_ */