Class: Ignis::Solver::AMGXConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/nvruby/solver/amgx_config.rb

Overview

Configuration builder for AMGX solver Provides preset configurations and custom config strings

Constant Summary collapse

PRESETS =

Predefined solver configurations

{
  # Classical AMG with V-cycle, Jacobi smoother
  classical_v_cycle: <<~CONFIG,
    config_version=2,
    solver(main)=AMG,
    main:algorithm=CLASSICAL,
    main:selector=PMIS,
    main:interpolator=D2,
    main:presweeps=2,
    main:postsweeps=2,
    main:max_iters=100,
    main:convergence=RELATIVE_INI_CORE,
    main:tolerance=1e-8,
    main:norm=L2,
    main:cycle=V,
    main:smoother=BLOCK_JACOBI,
    main:coarse_solver=DENSE_LU_SOLVER,
    main:max_levels=20
  CONFIG

  # Aggregation AMG with V-cycle
  aggregation_v_cycle: <<~CONFIG,
    config_version=2,
    solver(main)=AMG,
    main:algorithm=AGGREGATION,
    main:selector=SIZE_2,
    main:presweeps=2,
    main:postsweeps=2,
    main:max_iters=100,
    main:convergence=RELATIVE_INI_CORE,
    main:tolerance=1e-8,
    main:norm=L2,
    main:cycle=V,
    main:smoother=MULTICOLOR_GS,
    main:coarse_solver=DENSE_LU_SOLVER
  CONFIG

  # PCG with AMG preconditioner
  pcg_amg: <<~CONFIG,
    config_version=2,
    solver(main)=PCG,
    main:preconditioner(amg)=AMG,
    main:max_iters=1000,
    main:convergence=RELATIVE_INI_CORE,
    main:tolerance=1e-10,
    main:norm=L2,
    amg:algorithm=CLASSICAL,
    amg:max_iters=1,
    amg:cycle=V,
    amg:smoother=BLOCK_JACOBI
  CONFIG

  # PBICGSTAB with AMG preconditioner
  pbicgstab_amg: <<~CONFIG,
    config_version=2,
    solver(main)=PBICGSTAB,
    main:preconditioner(amg)=AMG,
    main:max_iters=1000,
    main:convergence=RELATIVE_INI_CORE,
    main:tolerance=1e-10,
    main:norm=L2,
    amg:algorithm=AGGREGATION,
    amg:max_iters=1,
    amg:cycle=V
  CONFIG

  # Simple Jacobi iteration
  jacobi: <<~CONFIG,
    config_version=2,
    solver(main)=BLOCK_JACOBI,
    main:max_iters=1000,
    main:convergence=RELATIVE_INI_CORE,
    main:tolerance=1e-8
  CONFIG

  # Gauss-Seidel
  gauss_seidel: <<~CONFIG
    config_version=2,
    solver(main)=MULTICOLOR_GS,
    main:max_iters=1000,
    main:convergence=RELATIVE_INI_CORE,
    main:tolerance=1e-8
  CONFIG
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(preset: nil, custom: nil, **options) ⇒ AMGXConfig

Create configuration from preset or custom string

Parameters:

  • preset (Symbol, nil) (defaults to: nil)

    Preset name (:classical_v_cycle, :aggregation_v_cycle, etc.)

  • custom (String, nil) (defaults to: nil)

    Custom configuration string

  • options (Hash)

    Override options



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/nvruby/solver/amgx_config.rb', line 101

def initialize(preset: nil, custom: nil, **options)
  if custom
    @config_string = custom
  elsif preset
    raise ArgumentError, "Unknown preset: #{preset}" unless PRESETS.key?(preset)

    @config_string = PRESETS[preset].gsub(/\s+/, "")
  else
    @config_string = PRESETS[:classical_v_cycle].gsub(/\s+/, "")
  end

  apply_options!(options) unless options.empty?
end

Instance Attribute Details

#config_stringString (readonly)

Returns Configuration string.

Returns:

  • (String)

    Configuration string



95
96
97
# File 'lib/nvruby/solver/amgx_config.rb', line 95

def config_string
  @config_string
end

Class Method Details

.presetsArray<Symbol>

List available presets

Returns:

  • (Array<Symbol>)


122
123
124
# File 'lib/nvruby/solver/amgx_config.rb', line 122

def self.presets
  PRESETS.keys
end

Instance Method Details

#to_sString

Returns:

  • (String)


116
117
118
# File 'lib/nvruby/solver/amgx_config.rb', line 116

def to_s
  @config_string
end