From 1855266790d87f6a7d0a27eb721b22d42cdea7cc Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Fri, 13 Dec 2024 16:43:05 -0800 Subject: [PATCH] feat: mgr strategy for lagrangeContactBubbleStabilization --- ...rangeContactBubbleStab_FixedSlip_smoke.xml | 5 +- .../linearAlgebra/CMakeLists.txt | 1 + .../interfaces/hypre/HypreMGR.cpp | 6 + .../interfaces/hypre/HypreMGR.hpp | 26 +++++ ...ianContactMechanicsBubbleStabilization.hpp | 106 ++++++++++++++++++ .../utilities/LinearSolverParameters.hpp | 2 + ...olidMechanicsLagrangeContactBubbleStab.cpp | 8 +- 7 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 src/coreComponents/linearAlgebra/interfaces/hypre/mgrStrategies/LagrangianContactMechanicsBubbleStabilization.hpp diff --git a/inputFiles/lagrangianContactMechanics/LagrangeContactBubbleStab_FixedSlip_smoke.xml b/inputFiles/lagrangianContactMechanics/LagrangeContactBubbleStab_FixedSlip_smoke.xml index 8258d2cc4a..02258b584d 100644 --- a/inputFiles/lagrangianContactMechanics/LagrangeContactBubbleStab_FixedSlip_smoke.xml +++ b/inputFiles/lagrangianContactMechanics/LagrangeContactBubbleStab_FixedSlip_smoke.xml @@ -22,9 +22,10 @@ lineSearchMaxCuts="2" maxTimeStepCuts="1"/> + logLevel="1"/> ( params.mgr, numComponentsPerField, precond, mgrData ); break; + } + case LinearSolverParameters::MGR::StrategyType::lagrangianContactMechanicsBubbleStab: + { + setStrategy< LagrangianContactMechanicsBubbleStabilization >( params.mgr, numComponentsPerField, precond, mgrData ); + break; } case LinearSolverParameters::MGR::StrategyType::multiphasePoromechanics: { diff --git a/src/coreComponents/linearAlgebra/interfaces/hypre/HypreMGR.hpp b/src/coreComponents/linearAlgebra/interfaces/hypre/HypreMGR.hpp index 8bacdf8b97..1585c4b1d4 100644 --- a/src/coreComponents/linearAlgebra/interfaces/hypre/HypreMGR.hpp +++ b/src/coreComponents/linearAlgebra/interfaces/hypre/HypreMGR.hpp @@ -269,6 +269,32 @@ class MGRStrategyBase setDisplacementAMG( mgrData.mechSolver, separateComponents ); HYPRE_MGRSetFSolver( precond.ptr, mgrData.mechSolver.solve, mgrData.mechSolver.setup, mgrData.mechSolver.ptr ); } + /** + * @brief + * + * @param solver + */ + void setILUCoarseSolver( HyprePrecWrapper & solver ) + { + /* (Required) Create ILU solver */ + HYPRE_ILUCreate(&solver.ptr); + + /* (Recommended) General solver options */ + int const ilu_type = 0; /* 0, 1, 10, 11, 20, 21, 30, 31, 40, 41, 50 */ + int const max_iter = 1; + double const tol = 0.0; + int const reordering = 0; /* 0: none, 1: RCM */ + int const print_level = 0; + HYPRE_ILUSetType(solver.ptr, ilu_type); + HYPRE_ILUSetMaxIter(solver.ptr, max_iter); + HYPRE_ILUSetTol(solver.ptr, tol); + HYPRE_ILUSetLocalReordering(solver.ptr, reordering); + HYPRE_ILUSetPrintLevel(solver.ptr, print_level); + + solver.setup = HYPRE_ILUSetup; + solver.solve = HYPRE_ILUSolve; + solver.destroy = HYPRE_ILUDestroy; + } }; diff --git a/src/coreComponents/linearAlgebra/interfaces/hypre/mgrStrategies/LagrangianContactMechanicsBubbleStabilization.hpp b/src/coreComponents/linearAlgebra/interfaces/hypre/mgrStrategies/LagrangianContactMechanicsBubbleStabilization.hpp new file mode 100644 index 0000000000..42ff8111bf --- /dev/null +++ b/src/coreComponents/linearAlgebra/interfaces/hypre/mgrStrategies/LagrangianContactMechanicsBubbleStabilization.hpp @@ -0,0 +1,106 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2024 TotalEnergies + * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2023-2024 Chevron + * Copyright (c) 2019- GEOS/GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file LagrangianContactMechanicsBubbleStabilization.hpp + */ + +#ifndef GEOS_LINEARALGEBRA_INTERFACES_HYPREMGRLAGRANGIACONTACTMECHANICSBUBBLESTAB_HPP_ +#define GEOS_LINEARALGEBRA_INTERFACES_HYPREMGRLAGRANGIACONTACTMECHANICSBUBBLESTAB_HPP_ + +#include "linearAlgebra/interfaces/hypre/HypreMGR.hpp" + +namespace geos +{ + +namespace hypre +{ + +namespace mgr +{ + +/** + * @brief LagrangianContactMechanicsBubbleStabilization strategy + * + * Contact mechanics with face-centered lagrangian multipliers + * + * dofLabel: 0 = displacement, x-component + * dofLabel: 1 = displacement, y-component + * dofLabel: 2 = displacement, z-component + * dofLabel: 3 = displacement bubble function, x-component + * dofLabel: 4 = displacement bubble function, y-component + * dofLabel: 5 = displacement bubble function, z-component + * dofLabel: 6 = face-centered lagrange multiplier (tn) + * dofLabel: 7 = face-centered lagrange multiplier (tt1) + * dofLabel: 8 = face-centered lagrange multiplier (tt2) + * + * Ingredients: + * 1. F-points displacement (0,1,2), C-points (3,4,5) + * 2. F-points smoother: AMG, single V-cycle, separate displacemente components + * 3. C-points coarse-grid/Schur complement solver: boomer AMG + * 4. Global smoother: none + * + */ +class LagrangianContactMechanicsBubbleStabilization : public MGRStrategyBase< 1 > +{ +public: + + /** + * @brief Constructor. + */ + explicit LagrangianContactMechanicsBubbleStabilization( arrayView1d< int const > const & ) + : MGRStrategyBase( 9 ) + { + // Level 0: we keep all three displacement + m_labels[0] = { 6, 7, 8 }; + + setupLabels(); + + // Level 0 + m_levelFRelaxType[0] = MGRFRelaxationType::amgVCycle; + m_levelFRelaxIters[0] = 1; + m_levelInterpType[0] = MGRInterpolationType::blockJacobi; + m_levelRestrictType[0] = MGRRestrictionType::injection; + m_levelCoarseGridMethod[0] = MGRCoarseGridMethod::galerkin; + m_levelGlobalSmootherType[0] = MGRGlobalSmootherType::none; + } + + /** + * @brief Setup the MGR strategy. + * @param mgrParams MGR configuration parameters + * @param precond preconditioner wrapper + * @param mgrData auxiliary MGR data + */ + void setup( LinearSolverParameters::MGR const & mgrParams, + HyprePrecWrapper & precond, + HypreMGRData & mgrData ) + { + setReduction( precond, mgrData ); + + // Configure the BoomerAMG solver used as F-relaxation for the first level + setMechanicsFSolver( precond, mgrData, mgrParams.separateComponents ); + + // Configure ILU) as a coarse solver + setILUCoarseSolver( mgrData.coarseSolver ); + } +}; + +} // namespace mgr + +} // namespace hypre + +} // namespace geos + +#endif /*GEOS_LINEARALGEBRA_INTERFACES_HYPREMGRLAGRANGIACONTACTMECHANICSBUBBLESTAB_HPP_*/ diff --git a/src/coreComponents/linearAlgebra/utilities/LinearSolverParameters.hpp b/src/coreComponents/linearAlgebra/utilities/LinearSolverParameters.hpp index 803946ac95..4d43955a0e 100644 --- a/src/coreComponents/linearAlgebra/utilities/LinearSolverParameters.hpp +++ b/src/coreComponents/linearAlgebra/utilities/LinearSolverParameters.hpp @@ -295,6 +295,7 @@ struct LinearSolverParameters thermalMultiphasePoromechanics, ///< thermal multiphase poromechanics with finite volume compositional multiphase flow hydrofracture, ///< hydrofracture lagrangianContactMechanics, ///< Lagrangian contact mechanics + lagrangianContactMechanicsBubbleStab, ///< Lagrangian contact mechanics with bubble stabilization solidMechanicsEmbeddedFractures ///< Embedded fractures mechanics }; @@ -387,6 +388,7 @@ ENUM_STRINGS( LinearSolverParameters::MGR::StrategyType, "thermalMultiphasePoromechanics", "hydrofracture", "lagrangianContactMechanics", + "lagrangianContactMechanicsBubbleStab", "solidMechanicsEmbeddedFractures" ); /// Declare strings associated with enumeration values. diff --git a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContactBubbleStab.cpp b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContactBubbleStab.cpp index 2d1f139362..da13cba917 100644 --- a/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContactBubbleStab.cpp +++ b/src/coreComponents/physicsSolvers/contact/SolidMechanicsLagrangeContactBubbleStab.cpp @@ -45,7 +45,11 @@ SolidMechanicsLagrangeContactBubbleStab::SolidMechanicsLagrangeContactBubbleStab { m_faceTypeToFiniteElements["Quadrilateral"] = std::make_unique< finiteElement::H1_QuadrilateralFace_Lagrange1_GaussLegendre2 >(); m_faceTypeToFiniteElements["Triangle"] = std::make_unique< finiteElement::H1_TriangleFace_Lagrange1_Gauss1 >(); - + + LinearSolverParameters & linSolParams = m_linearSolverParameters.get(); + linSolParams.mgr.strategy = LinearSolverParameters::MGR::StrategyType::lagrangianContactMechanicsBubbleStab; + linSolParams.mgr.separateComponents = true; + linSolParams.dofsPerNode = 3; } SolidMechanicsLagrangeContactBubbleStab::~SolidMechanicsLagrangeContactBubbleStab() @@ -249,6 +253,8 @@ void SolidMechanicsLagrangeContactBubbleStab::setupSystem( DomainPartition & dom solution.create( dofManager.numLocalDofs(), MPI_COMM_GEOS ); computeRotationMatrices( domain ); + + dofManager.printFieldInfo(); } void SolidMechanicsLagrangeContactBubbleStab::computeRotationMatrices( DomainPartition & domain ) const