Skip to content

Commit

Permalink
elm-pb example: Fix hypre input, save performance metrics
Browse files Browse the repository at this point in the history
Calling `phiSolver->savePerformance(...)` causes performance (e.g. iteration count)
diagnostics to be saved to the output file.

hypre input did have the wrong parallel transform, boundary conditions
that have not been implemented. Now uses hypre3d as the phiSolver.
  • Loading branch information
bendudson committed Jan 9, 2025
1 parent 90332a8 commit dc3b020
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 49 deletions.
59 changes: 15 additions & 44 deletions examples/elm-pb/data-hypre/BOUT.inp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@

nout = 40 # number of time-steps
timestep = 1 # time between outputs
wall_limit = 1.55 # wall time limit (in hours)

zperiod = 15 # Fraction of a torus to simulate
MZ = 16 # Number of points in Z

grid = "cbm18_dens8.grid_nx68ny64.nc" # Grid file

dump_format = "nc" # Dump file format. "nc" = NetCDF, "pdb" = PDB
restart_format = "nc" # Restart file format

[mesh]

staggergrids = false # Use staggered grids

[mesh:paralleltransform]

type = shifted # Use shifted metric method
type = shiftedinterp

##################################################
# derivative methods

[mesh:ddx]

first = C4 # order of first x derivatives
second = C4 # order of second x derivatives
upwind = W3 # order of upwinding method W3 = Weno3
Expand All @@ -44,20 +38,6 @@ first = C4 # Z derivatives can be done using FFT
second = C4
upwind = W3

[output]
shiftoutput = true # Put the output into field-aligned coordinates

##################################################
# Laplacian inversion routines

[laplace]
type=hypre3d

flags = 0 # Flags for Laplacian inversion

rtol = 1.e-9
atol = 1.e-14

##################################################
# FFTs

Expand All @@ -71,15 +51,12 @@ fft_measurement_flag = measure # If using FFTW, perform tests to determine fast
[solver]

# mudq, mldq, mukeep, mlkeep preconditioner options
atol = 1e-08 # absolute tolerance
rtol = 1e-05 # relative tolerance
atol = 1.0e-8 # absolute tolerance
rtol = 1.0e-5 # relative tolerance

use_precon = false # Use preconditioner: User-supplied or BBD
use_jacobian = false # Use user-supplied Jacobian

mxstep = 5000 # Number of internal steps between outputs
adams_moulton = false # Use Adams-Moulton method (default is BDF)
func_iter = false # Functional iteration (default is Newton)

##################################################
# settings for high-beta reduced MHD
Expand Down Expand Up @@ -116,7 +93,7 @@ diamag_phi0 = true # Balance ExB against Vd for stationary equilibrium
bm_exb_flag = 0
bm_mag_flag = 0
##################################################################
withflow = false # With flow or not
withflow = false # With flow or not
D_0 = 130000 # differential potential
D_s = 20 # shear parameter
K_H_term = false # Contain K-H term
Expand All @@ -125,8 +102,8 @@ x0 = 0.855 # peak location
D_min = 3000 # constant
##################################################################

eHall = false # Include electron pressue effects in Ohm's law?
AA = 2.0 # ion mass in units of proton mass
eHall = false # Include electron pressure effects in Ohm's law?
AA = 2.0 # ion mass in units of proton mass

noshear = false # zero all shear

Expand Down Expand Up @@ -174,14 +151,14 @@ damp_t_const = 1e-2 # Damping time constant

## Parallel pressure diffusion

diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
diffusion_p4 = -1e-05 # parallel hyper-viscous diffusion for pressure (< 0 = none)
diffusion_u4 = 1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
diffusion_u4 = -1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
diffusion_a4 = -1e-05 # parallel hyper-viscous diffusion for vector potential (< 0 = none)

## heat source in pressure in watts

heating_P = -1 # heat power in watts (< 0 = none)
heating_P = -1 # heat power in watts (< 0 = none)
hp_width = 0.1 # heat width, in percentage of nx (< 0 = none)
hp_length = 0.3 # heat length in percentage of nx (< 0 = none)

Expand All @@ -205,22 +182,19 @@ su_lengthr = 0.1 # right edge sink length in percentage of nx (< 0 = none)
## Viscosity and Hyper-viscosity

viscos_par = -0.1 # Parallel viscosity (< 0 = none)
viscos_perp = -1.0 # Perpendicular
viscos_perp = -1.0 # Perpendicular viscosity (< 0 = none)
hyperviscos = -1.0 # Radial hyper viscosity

## Compressional terms (only when compress = true)
phi_curv = true # Include curvature*Grad(phi) in P equation
# gamma = 1.6666

[phiSolver]
#inner_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
#outer_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
inner_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
outer_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
type = hypre3d
inner_boundary_flags = 0 # Dirichlet
outer_boundary_flags = 0 # Dirichlet

[aparSolver]
#inner_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
#outer_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
inner_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
outer_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP

Expand Down Expand Up @@ -271,12 +245,9 @@ bndry_ydown = free_o3
# Zero gradient in the core
bndry_core = neumann

[Vpar]

bndry_core = neumann

[phi]

bndry_xin = none
bndry_xout = none
bndry_target = neumann
#bndry_target = neumann

10 changes: 5 additions & 5 deletions examples/elm-pb/data/BOUT.inp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ diamag_phi0 = true # Balance ExB against Vd for stationary equilibrium
bm_exb_flag = 0
bm_mag_flag = 0
##################################################################
withflow = false # With flow or not
withflow = false # With flow or not
D_0 = 130000 # differential potential
D_s = 20 # shear parameter
K_H_term = false # Contain K-H term
Expand All @@ -104,7 +104,7 @@ D_min = 3000 # constant
##################################################################

eHall = false # Include electron pressure effects in Ohm's law?
AA = 2.0 # ion mass in units of proton mass
AA = 2.0 # ion mass in units of proton mass

noshear = false # zero all shear

Expand Down Expand Up @@ -152,14 +152,14 @@ damp_t_const = 1e-2 # Damping time constant

## Parallel pressure diffusion

diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
diffusion_p4 = -1e-05 # parallel hyper-viscous diffusion for pressure (< 0 = none)
diffusion_u4 = -1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
diffusion_u4 = -1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
diffusion_a4 = -1e-05 # parallel hyper-viscous diffusion for vector potential (< 0 = none)

## heat source in pressure in watts

heating_P = -1 # heat power in watts (< 0 = none)
heating_P = -1 # heat power in watts (< 0 = none)
hp_width = 0.1 # heat width, in percentage of nx (< 0 = none)
hp_length = 0.3 # heat length in percentage of nx (< 0 = none)

Expand Down
3 changes: 3 additions & 0 deletions examples/elm-pb/elm_pb.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,9 @@ class ELMpb : public PhysicsModel {

// Create a solver for the Laplacian
phiSolver = Laplacian::create(&globalOptions["phiSolver"]);
// Save performance metrics to output, using the
// given name as the prefix.
phiSolver->savePerformance(*solver, "phiSolver");

aparSolver = Laplacian::create(&globalOptions["aparSolver"], loc);

Expand Down

0 comments on commit dc3b020

Please sign in to comment.