20 #ifndef GEOS_LINEARALGEBRA_INTERFACES_HYPREMGRSTRATEGIES_HPP_
21 #define GEOS_LINEARALGEBRA_INTERFACES_HYPREMGRSTRATEGIES_HPP_
29 #include <_hypre_utilities.h>
62 HYPRE_Real tolerance{ 0.0 };
63 HYPRE_Int maxIterations{ 1 };
64 HYPRE_Int printLevel{ 0 };
65 HYPRE_Int cycleType{ 1 };
66 HYPRE_Int fRelaxCycle{ 1 };
67 HYPRE_Int globalSmoothCycle{ 1 };
68 HYPRE_Int nonCpointsToFpoints{ 1 };
69 HYPRE_Int nonGalerkinMaxElmts{ 1 };
70 HYPRE_Int pMaxElmts{ 0 };
78 HYPRE_Int constexpr hydrofractureMinCoarseSize = 1000;
80 inline void setMGRCycleSettings( HYPRE_Solver
const solver,
81 MGRParameters
const & params = defaultMGRParameters() )
99 HYPRE_Real tolerance{ 0.0 };
100 HYPRE_Int maxIterations{ 1 };
101 HYPRE_Int printLevel{ 0 };
102 HYPRE_Int minCoarseSize{ -1 };
103 HYPRE_Int maxCoarseSize{ 9 };
104 HYPRE_Int smoothType{ 6 };
105 HYPRE_Int smoothNumLevels{ 0 };
106 HYPRE_Int smoothNumSweeps{ 1 };
107 HYPRE_Int smoothMaxRowNnz{ 20 };
108 HYPRE_Int iluLocalReordering{ 0 };
110 HYPRE_Real maxRowSum{ -1.0 };
111 HYPRE_Real strongThreshold{ -1.0 };
112 HYPRE_Int numFunctions{ -1 };
113 HYPRE_Int filterFunctions{ -1 };
114 HYPRE_Int pMaxElmts{ -1 };
116 HYPRE_Int aggressiveNumLevels{ -1 };
117 HYPRE_Int aggressiveInterpType{ -1 };
118 HYPRE_Int aggressivePMaxElmts{ -1 };
119 HYPRE_Int coarseningType{ -1 };
121 HYPRE_Int relaxType{ -1 };
122 HYPRE_Int downRelaxType{ -1 };
123 HYPRE_Int upRelaxType{ -1 };
124 HYPRE_Int coarseRelaxType{ -1 };
125 HYPRE_Int numSweeps{ -1 };
126 HYPRE_Int relaxOrder{ -1 };
130 bool const filterFunctions,
131 bool const useALMSmoother =
false )
134 result.maxRowSum = 1.0;
135 result.strongThreshold = useALMSmoother ? 0.8 : 0.6;
136 result.numFunctions = 3;
137 result.filterFunctions = filterFunctions ? separateComponents : 0;
141 result.pMaxElmts = 20;
142 result.aggressiveNumLevels = 1;
143 #if GEOS_USE_HYPRE_DEVICE != GEOS_USE_HYPRE_CUDA && GEOS_USE_HYPRE_DEVICE != GEOS_USE_HYPRE_HIP
148 #if GEOS_USE_HYPRE_DEVICE == GEOS_USE_HYPRE_CUDA || GEOS_USE_HYPRE_DEVICE == GEOS_USE_HYPRE_HIP
151 result.numSweeps = useALMSmoother ? 2 : 1;
155 result.downRelaxType = 89;
156 result.upRelaxType = 89;
157 result.coarseRelaxType = 9;
158 result.numSweeps = 2;
159 result.relaxOrder = 0;
163 result.relaxOrder = 1;
170 inline BoomerAMGParameters almBubbleAMGParameters()
172 BoomerAMGParameters result = displacementAMGParameters( 0,
false,
true );
173 result.strongThreshold = 0.75;
174 result.filterFunctions = 0;
175 result.pMaxElmts = 10;
176 result.aggressiveNumLevels = -1;
177 #if GEOS_USE_HYPRE_DEVICE == GEOS_USE_HYPRE_CUDA || GEOS_USE_HYPRE_DEVICE == GEOS_USE_HYPRE_HIP
180 result.coarseningType = -1;
182 result.numSweeps = 1;
186 inline BoomerAMGParameters almReservoirDisplacementAMGParameters(
integer const separateComponents )
188 BoomerAMGParameters result = displacementAMGParameters( separateComponents,
true );
189 #if GEOS_USE_HYPRE_DEVICE != GEOS_USE_HYPRE_CUDA && GEOS_USE_HYPRE_DEVICE != GEOS_USE_HYPRE_HIP
190 result.downRelaxType = 89;
191 result.upRelaxType = 89;
192 result.coarseRelaxType = 9;
193 result.numSweeps = 1;
194 result.relaxOrder = 0;
199 inline BoomerAMGParameters pressureAMGParameters( HYPRE_Int
const minCoarseSize = -1 )
201 BoomerAMGParameters result;
202 result.minCoarseSize = minCoarseSize;
203 result.aggressiveNumLevels = 1;
204 result.aggressivePMaxElmts = 20;
207 #if GEOS_USE_HYPRE_DEVICE == GEOS_USE_HYPRE_CUDA || GEOS_USE_HYPRE_DEVICE == GEOS_USE_HYPRE_HIP
210 result.maxRowSum = 1.0;
212 result.numSweeps = 2;
214 result.relaxOrder = 1;
220 inline BoomerAMGParameters pressureTemperatureAMGParameters()
222 BoomerAMGParameters result;
223 result.aggressiveNumLevels = 1;
224 result.aggressivePMaxElmts = 16;
225 result.numFunctions = 2;
227 #if GEOS_USE_HYPRE_DEVICE == GEOS_USE_HYPRE_CUDA || GEOS_USE_HYPRE_DEVICE == GEOS_USE_HYPRE_HIP
228 result.aggressiveNumLevels = 0;
230 result.maxRowSum = 1.0;
232 result.numSweeps = 2;
234 result.relaxOrder = 1;
240 inline void configureBoomerAMG( HyprePrecWrapper & solver,
241 BoomerAMGParameters
const & params )
244 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetILULocalReordering( solver.ptr, params.iluLocalReordering ) );
249 if( params.minCoarseSize >= 0 )
255 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetSmoothNumLevels( solver.ptr, params.smoothNumLevels ) );
256 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetSmoothNumSweeps( solver.ptr, params.smoothNumSweeps ) );
258 if( params.maxRowSum >= 0.0 )
262 if( params.strongThreshold >= 0.0 )
264 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetStrongThreshold( solver.ptr, params.strongThreshold ) );
266 if( params.numFunctions >= 0 )
270 if( params.filterFunctions >= 0 )
272 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetFilterFunctions( solver.ptr, params.filterFunctions ) );
274 if( params.pMaxElmts >= 0 )
278 if( params.aggressiveNumLevels >= 0 )
280 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetAggNumLevels( solver.ptr, params.aggressiveNumLevels ) );
282 if( params.aggressiveInterpType >= 0 )
284 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetAggInterpType( solver.ptr, params.aggressiveInterpType ) );
286 if( params.aggressivePMaxElmts >= 0 )
288 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetAggPMaxElmts( solver.ptr, params.aggressivePMaxElmts ) );
290 if( params.coarseningType >= 0 )
294 if( params.relaxType >= 0 )
298 if( params.numSweeps >= 0 )
302 if( params.relaxOrder >= 0 )
306 if( params.downRelaxType >= 0 )
308 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetCycleRelaxType( solver.ptr, params.downRelaxType, 1 ) );
310 if( params.upRelaxType >= 0 )
314 if( params.coarseRelaxType >= 0 )
316 GEOS_LAI_CHECK_ERROR( HYPRE_BoomerAMGSetCycleRelaxType( solver.ptr, params.coarseRelaxType, 3 ) );
328 template<
typename STRATEGY >
334 STRATEGY strategy( numComponentsPerField );
335 strategy.setup( params, precond, mgrData );
342 template<
int NLEVEL >
378 HYPRE_Int result = 0;
379 for(
localIndex i = 0; i < numComponentsPerField.size(); ++i )
381 result += LvArray::integerConversion< HYPRE_Int >( numComponentsPerField[i] );
393 for( HYPRE_Int i = 0; i <
numLevels; ++i )
408 for( HYPRE_Int i = 0; i <
numLevels; ++i )
462 for( HYPRE_Int i = 0; i <
numLevels; ++i )
483 integer const & separateComponents )
485 configureBoomerAMG( solver, displacementAMGParameters( separateComponents,
true ) );
487 solver.
setup = HYPRE_BoomerAMGSetup;
488 solver.
solve = HYPRE_BoomerAMGSolve;
489 solver.
destroy = HYPRE_BoomerAMGDestroy;
503 integer const separateComponents,
504 bool const bubbleCoarse )
506 configureBoomerAMG( solver, bubbleCoarse
507 ? almBubbleAMGParameters()
508 : displacementAMGParameters( separateComponents,
true,
true ) );
510 solver.
setup = HYPRE_BoomerAMGSetup;
511 solver.
solve = HYPRE_BoomerAMGSolve;
512 solver.
destroy = HYPRE_BoomerAMGDestroy;
521 integer const separateComponents )
523 configureBoomerAMG( solver, almReservoirDisplacementAMGParameters( separateComponents ) );
525 solver.
setup = HYPRE_BoomerAMGSetup;
526 solver.
solve = HYPRE_BoomerAMGSolve;
527 solver.
destroy = HYPRE_BoomerAMGDestroy;
535 HYPRE_Int
const minCoarseSize = -1 )
537 configureBoomerAMG( solver, pressureAMGParameters( minCoarseSize ) );
539 solver.
setup = HYPRE_BoomerAMGSetup;
540 solver.
solve = HYPRE_BoomerAMGSolve;
541 solver.
destroy = HYPRE_BoomerAMGDestroy;
550 configureBoomerAMG( solver, pressureTemperatureAMGParameters() );
552 solver.
setup = HYPRE_BoomerAMGSetup;
553 solver.
solve = HYPRE_BoomerAMGSolve;
554 solver.
destroy = HYPRE_BoomerAMGDestroy;
568 integer const & separateComponents )
579 integer const & separateComponents,
580 HYPRE_Int
const level )
623 HYPRE_ILUCreate( &solver.
ptr );
626 int const ilu_type = 0;
627 int const max_iter = 1;
628 double const tol = 0.0;
629 int const reordering = 0;
630 int const print_level = 0;
631 HYPRE_ILUSetType( solver.
ptr, ilu_type );
632 HYPRE_ILUSetMaxIter( solver.
ptr, max_iter );
633 HYPRE_ILUSetTol( solver.
ptr, tol );
634 HYPRE_ILUSetLocalReordering( solver.
ptr, reordering );
635 HYPRE_ILUSetPrintLevel( solver.
ptr, print_level );
637 solver.
setup = HYPRE_ILUSetup;
638 solver.
solve = HYPRE_ILUSolve;
639 solver.
destroy = HYPRE_ILUDestroy;
void createMGR(LinearSolverParameters const ¶ms, DofManager const *const dofManager, HyprePrecWrapper &precond, HypreMGRData &mgrData)
Create the MGR preconditioner object.
void setStrategy(LinearSolverParameters::MGR const ¶ms, arrayView1d< int const > const &numComponentsPerField, HyprePrecWrapper &precond, HypreMGRData &mgrData)
Helper to simplify MGR setup.
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Helper struct for strategies that provides some basic parameter arrays needed by MGR.
MGRCoarseGridMethod m_levelCoarseGridMethod[numLevels]
Coarse grid method for each level.
HYPRE_Int m_numBlocks
Number of different matrix blocks treated separately.
void setALMDisplacementAMG(HyprePrecWrapper &solver, integer const separateComponents, bool const bubbleCoarse)
Set up one of the two BoomerAMG instances used by the fully coupled single-phase ALM hierarchy.
void setDisplacementAMG(HyprePrecWrapper &solver, integer const &separateComponents)
Set up BoomerAMG to perform the solve for the displacement system.
MGRInterpolationType m_levelInterpType[numLevels]
Interpolation type for each level.
static HYPRE_Int totalNumBlocks(arrayView1d< int const > const &numComponentsPerField)
Total number of dof labels, i.e. the sum of all fields' components.
void setILUCoarseSolver(HyprePrecWrapper &solver)
MGRStrategyBase(HYPRE_Int const numBlocks)
Constructor.
void setPressureTemperatureAMG(HyprePrecWrapper &solver)
Set up BoomerAMG to perform the solve for the pressure/temperature system.
static constexpr HYPRE_Int numLevels
Number of levels.
void setMechanicsFSolverAtLevel(HyprePrecWrapper &precond, HypreMGRData &mgrData, integer const &separateComponents, HYPRE_Int const level)
Configure the displacement F-solver attached to a specific MGR level.
stdVector< HYPRE_Int > m_labels[numLevels]
Dof labels kept at each level.
void setMechanicsFSolver(HyprePrecWrapper &precond, HypreMGRData &mgrData, integer const &separateComponents)
Set up BoomerAMG to perform the mechanics F-solve for the first F-relaxation.
void normalizeReductionParameters()
Normalize MGR iteration counts without touching a HYPRE handle.
void configure(LinearSolverParameters::MGR const &)
Apply parameter-dependent changes to the reduction hierarchy.
void setupLabels()
Call this after populating lv_cindexes.
void setALMReservoirDisplacementAMG(HyprePrecWrapper &solver, integer const separateComponents)
Set up the displacement F-solver used by the reservoir ALM strategy.
void setPressureAMG(HyprePrecWrapper &solver, HYPRE_Int const minCoarseSize=-1)
Set up BoomerAMG to perform the solve for the pressure system.
HYPRE_Int m_levelFRelaxIters[numLevels]
Number of F-relaxation iterations for each level.
void setReduction(HyprePrecWrapper &precond, HypreMGRData &mgrData)
Helper function that sets the reduction features common to all mgr strategies.
MGRFRelaxationType m_levelFRelaxType[numLevels]
F-relaxation type for each level.
HYPRE_Int * m_ptrLabels[numLevels]
Pointers to each level's labels, as consumed by MGR.
HYPRE_Int m_levelGlobalSmootherIters[numLevels]
Number of global smoother iterations for each level.
HYPRE_Real m_coarseGridThreshold
Coarse grid truncation threshold.
MGRGlobalSmootherType m_levelGlobalSmootherType[numLevels]
Global smoother type for each level.
HYPRE_Int m_numLabels[numLevels]
Number of dof labels kept.
void setILUFSolverAtLevel(HYPRE_Int const level, HyprePrecWrapper &precond, HypreMGRData &mgrData)
Set up an explicitly configured ILU(0) F-solver for a given MGR level.
MGRRestrictionType m_levelRestrictType[numLevels]
Restriction type for each level.
#define GEOS_LAI_CHECK_ERROR(call)
MGRCoarseGridMethod
This enum class specifies the strategy for level coarse grid computation in MGR.
@ galerkin
Galerkin coarse grid computation using RAP.
MGRRestrictionType
This enum class specifies the strategy for computing the level restriction operator in MGR.
HYPRE_Int getAMGAggressiveInterpolationType(LinearSolverParameters::AMG::AggInterpType const &type)
Returns hypre's identifier of the AMG aggressive interpolation type.
MGRFRelaxationType
This enum class specifies the F-relaxation type.
@ none
no F-relaxation if performed
HYPRE_Int getAMGRelaxationType(LinearSolverParameters::AMG::SmootherType const &type)
Returns hypre's identifier of the AMG smoother type.
HYPRE_Int getAMGCoarseningType(LinearSolverParameters::AMG::CoarseningType const &type)
Returns hypre's identifier of the AMG coarsening type.
MGRInterpolationType
This enum class specifies the strategy for computing the level intepolation operator in MGR.
@ jacobi
Diagonal scaling.
MGRGlobalSmootherType
This enum class specifies the global smoother type.
@ none
no global smoothing is performed (default)
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
int integer
Signed integer type.
Array< T, 1 > array1d
Alias for 1D array.
internal::StdVectorWrapper< T, Allocator, USE_STD_CONTAINER_BOUNDS_CHECKING > stdVector
Container for hypre preconditioner auxiliary data for MGR.
HyprePrecWrapper mechSolver
MGR mechanics fine solver pointer and functions.
HyprePrecWrapper nestedSolver
Optional nested MGR F-relaxation wrapper.
HyprePrecWrapper coarseSolver
MGR coarse solver pointer and functions.
HyprePrecWrapper iluSolver
MGR ILU fine solver pointer and functions.
array1d< HYPRE_Int > pointMarkers
array1d of unique tags for local degrees of freedom
Container for hypre preconditioner function pointers.
HYPRE_Solver ptr
pointer to preconditioner
SetupFunc setup
pointer to setup function
DestroyFunc destroy
pointer to destroy function
SolveFunc solve
pointer to apply function
@ chebyshev
Chebyshev polynomial smoothing.
@ l1jacobi
l1-Jacobi smoothing
@ Falgout
Ruge-Stueben followed by CLJP.
@ PMIS
Parallel coarsening as CLJP but with lower complexities (GPU support)
@ multipass
Multipass (GPU support)
@ modifiedExtendedE
Modularized Extended+e (GPU support)
Multigrid reduction parameters.
Set of parameters for a linear solver or preconditioner.
The BoomerAMG options used by the MGR strategies.
MGR settings shared by the legacy HYPRE setup and generated YAML.