Quickstart#

Running the flow past a cylinder example#

In its most straightforward workflow, using NekROM requires running a full-order model simulation to generate solution snapshots and then executing NekROM targeting these snapshots to generate POD bases and run the reduced-order simulation. Here we illustrate the process with the 2D flow past a cylinder example.

  1. Clone NekROM and Nek5000

git clone https://github.com/Nek5000/NekROM.git
git clone https://github.com/Nek5000/Nek5000.git
  1. Set environment variables

export PATH=$PATH:$(pwd)/NekROM/bin:$(pwd)/Nek5000/bin
export MOR_DIR=$(pwd)/NekROM/bin
  1. Build Nek5000 tools

cd Nek5000/tools
./maketools
cd ../../
  1. Change to cylinder example directory

cd NekROM/examples/cyl
  1. Generate the FOM snapshots

./run_fom

This run script executes the Nek5000 cylinder case and extracts drag and lift data. See below for more details.

  1. Run the ROM using the FOM snapshots

./run_rom

This run script creates the POD bases and uses them to run the reduced-order simulation. See below for more details.

  1. Visualize the ROM

visnek romcyl

Open the resulting romcyl.nek5000 file with Visit or Paraview to visualize the ROM output

Understanding the run scripts#

The run_fom and run_rom scripts automate several tasks in the NekROM workflow. NekROM users are encouraged to write similar run scripts for their own cases.

The run_fom script, shown below, builds the Nek5000 case for the FOM, gnerates the mesh, and runs the Nek5000 simulation. After the simulation completes, the script copies the output snapshots to the snaps directory and creates file.list to tell NekROM which snapshots to use. Finally, the script extracts some drag and lift data from the log file. The details of the computation of the drag in the ROM can be found in [Kan22].

#!/bin/bash

np=$1 # number of processors to use for FOM calculation
makerom cyl_fom # Could also use makenek, but makerom needs to be executed for the MOR include statement

# generate mesh connectivity information
genmap << EOF
cyl
0.1
EOF

echo 'running Nek5000 FOM calculation...'
neklmpi cyl $np
logfile=cyl.log.$np
mkdir snaps
mv *cyl0.f* cyl0.f* $logfile snaps 
ls -r snaps/cyl0.f* > file.list

# For the current case, we have Re=100. The drag and lift coefficients are also computed by calls in userchk. The following lines extract the data to .dat files
grep dragx snaps/$logfile | sed 's/1dragx//g' > fom.dragx.dat
grep dragy snaps/$logfile | sed 's/1dragy//g' > fom.dragy.dat

echo 'done with FOM, exiting...'

The run_rom script builds the cyl_rom case, executes the ROM with Nek5000, and extracts the data lift and drag data from the log file of the ROM simulation.

#!/bin/bash

casename="cyl"
makerom ${casename}_rom
neklmpi ${casename} 1

logfile=${casename}_rom.log.1

snaps_dir="snaps"
mv *${casename}0.f* $snaps_dir

# The detail computation of drag in the ROM is in Kento Kaneko An Augmented Basis Method for Reduced Order Models of Turbulent Flow. Ph.D. thesis (2022).
grep dragx $logfile | sed 's/dragx//' > rom.dragx.dat
grep dragy $logfile | sed 's/dragy//' > rom.dragy.dat

NekROM output files for the cylinder case#

Executing NekROM generates several different kinds of files.

romcyl0.*: Snapshots of the ROM solution over time, similar to the snapshots of the FOM.

bascyl0.*: Snapshots of the POD modes. The mode number is indicated in the file extension.

avgcyl0.f00001: The average of the snapshots

avgcyl0.f00002: The reconstructed average with mb modes

uiccyl0.*: Initial conditions

tkecyl0.*: Turbulent kinetic energy

lapcyl0.*: Laplace operator operating on a field (specific to the cylinder case)

tmncyl0.*: \(<u'T'>\) RMS field where \(u'\) and \(T'\) are the fluctuated velocity and temperature. The first tmn is calculated from the snaphots. The second is reconstructed from the reduced basis functions.

rom.dragx.dat: Data file containing the drag in the \(x\) direction at output time steps

rom.dragy.dat: Data file containing the drag in the \(y\) direction at output time steps

NekROM input files#

LMOR: Compile-time parameters for NekROM. This is generated when makerom is executed.

! MOR Compile-Time Allocation Parameters

parameter (lmu=1)   ! 0 -> disable velocity allocation
parameter (lmp=1)   ! 0 -> disable pressure allocation
parameter (lmt=1)   ! 0 -> disable temperature allocation

parameter (ls=500)  ! max number of snapshots
parameter (lcs=ls)  ! max number of coefficient set

parameter (lei=0)   ! 0 -> one residual, 1 -> affine decomp
parameter (lb=20)       ! max number of basis
parameter (lelm=lelt)   ! number of local elements
parameter (ltr=1+0*399) ! max number of tensor rank
parameter (ledvis=0)   ! 0 -> disable eddy viscosity allocation

parameter (lk=1)   ! largest wave number for pdrag calculation
parameter (lmsk=1) ! number of partitions

parameter (lintp=1) ! max number of interpolation points
parameter (lbat=1024) ! max size of batch vector (inner-product iter.)

parameter (lbavg=1+0*(lb-1)) ! size of average field allocation

! Auxiliary

parameter (lsu=(lcs-1)*lmu+1) ! size of velocity snapshots allocation
parameter (lsp=(lcs-1)*lmp+1) ! size of pressure snapshots allocation
parameter (lst=(lcs-1)*lmt+1) ! size of temperature snapshots allocation

parameter (lub=(lb-1)*lmu+1) ! size of velocity basis allocation
parameter (lpb=(lb-1)*lmp+1) ! size of pressure basis allocation
parameter (ltb=(lb-1)*lmt+1) ! size of temperature basis allocation

parameter (lres=1) ! size of residual storage
parameter (lres_u=((3*lb+lb**2)-1)*lei+1) ! size of residual storage for vel
parameter (lres_t=((2*lb+lb**2)-1)*lei+1) ! size of residual storage for temp

cyl.mor: Run-time parameters for NekROM

[GENERAL]
mode    = all # (off=offline,on=online,all=both,onb=online with bases,cp)
field   = v  # fields to perform the pod-rom (v=vel.,t=temp.,vt=both)
nb      = 20  # number of modes for the pod-rom

[POD]
type     = h10 # pod-inner product (l2,h10,hlm)
mode0    = avg # 0th mode of the POD basis (avg=mean(snaps),state=vx,vy,vz,t)

[QOI]
freq = 10 # frequency of qoi dump (<1 -> iostep)
tke  = no # turbulence kinetic energy
drag = yes # drag based on OBJ data
nu   = 0  # nusselt number based on problem type (1-3)

[DEIM]
nbnl = 0 # number of nonlinear (convection) POD-bases
dumpnls = no # whether or not to dump the non-linear snapshots

cyl_rom.usr: User specified functions for NekROM case. This is similar to the Nek5000 cyl_fom.usr file, but also has several NekROM specific functions. Additionally, param(170) = -1 is added to userchk in this file to tell NekROM to read from cyl.mor rather than the FOM cyl.rea file. NekROM specific functions include the following: rom_userchk, rom_userbases, rom_userfop, and rom_userrhs.

Running parametrically#

TODO