diff --git a/examples/cyl/README.md b/examples/cyl/README.md index eaedd5be..5a5b1b3d 100644 --- a/examples/cyl/README.md +++ b/examples/cyl/README.md @@ -4,13 +4,23 @@ A unit-diameter cylinder is centered at (0,0) in a box on [-2.5,17] x [-5,5]. With unit inflow velocity at x=-2.5, the Reynolds number is given by Re = 1/viscosity -For the current case, we have Re=100. The drag and lift coefficients are also -computed by calls in userchk. To see the drag vs. time: - -grep drag logfile +Run (with NekROM/bin and Nek5000/bin in $PATH and $MOR_DIR set to NekROM) `./run_fom` to generate the FOM fields and drag/lift data. ## ROM: Flow past a cylinder in 2D +To obtain the ROM solution, run + +``` +mkdir snaps && cp cyl0.f* snaps && ls snaps/*0.f* > file.list +makerom cyl_rom +nekbmpi cyl 1 +``` + +``` +grep dragx logfile | sed 's/dragx//g' > rom.dragx.dat +grep dragy logfile | sed 's/dragy//g' > rom.dragy.dat +``` + The usr file for the ROM, cyl_rom.usr, mimics the FOM user file. In particular the rom_userchk subroutine is only a slight modification of the FOM userchk subroutine to accomodate variable name conflicts. To see the drag vs. time: diff --git a/examples/cyl/cyl.usr b/examples/cyl/cyl_fom.usr similarity index 100% rename from examples/cyl/cyl.usr rename to examples/cyl/cyl_fom.usr diff --git a/examples/cyl/cyl_rom.usr b/examples/cyl/cyl_rom.usr index e53fb2d5..f9f01ec4 100644 --- a/examples/cyl/cyl_rom.usr +++ b/examples/cyl/cyl_rom.usr @@ -52,6 +52,9 @@ c----------------------------------------------------------------------- include 'TOTAL' include 'MOR' + param(170) = -1 + nsteps = 25 * 1e3 ! reduce to 100 CTUs + call rom_update call exitt0 @@ -198,6 +201,11 @@ c----------------------------------------------------------------------- include 'TOTAL' include 'MOR' + if (ad_step.eq.0) then + isnap = 100 ! restart from 401 CTU snapshot + call copy(u,uk(1+(isnap-1)*(nb+1)),nb+1) + endif + return end c----------------------------------------------------------------------- diff --git a/examples/cyl/post.m b/examples/cyl/post.m new file mode 100644 index 00000000..a14de17e --- /dev/null +++ b/examples/cyl/post.m @@ -0,0 +1,28 @@ +% read fom and rom data +fx=dlmread('fom.dragx.dat'); +fy=dlmread('fom.dragy.dat'); +rx=dlmread('rom.dragx.dat'); +ry=dlmread('rom.dragy.dat'); + +% plot fom result: + +tstart=401; +tend=500; + +figure; +plot(fx(:,2),fx(:,3)); xlim([tstart tend]); +title('Drag result'); +xlabel('Time'); +ylabel('Drag'); + +% plot rom result: +%figure; +hold on +rx(:,1)=rx(:,1)+tstart; % restart from t=400 +%plot(rx(:,1),rx(:,4)); xlim([400 500]); +plot(rx(:,1),rx(:,4),'--'); +legend('FOM','ROM'); +%title('ROM drag result'); +xlabel('Time'); +ylabel('Drag'); + diff --git a/examples/cyl/run_fom b/examples/cyl/run_fom new file mode 100755 index 00000000..fb3044ef --- /dev/null +++ b/examples/cyl/run_fom @@ -0,0 +1,21 @@ +#!/bin/bash + +np=8 # number of processors to use for FOM calculation +makerom cyl_fom # `makerom` can be replaced with `makenek` + +# 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* $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...' diff --git a/examples/cyl/run_rom b/examples/cyl/run_rom new file mode 100755 index 00000000..3ee5fcd9 --- /dev/null +++ b/examples/cyl/run_rom @@ -0,0 +1,11 @@ +#!/bin/bash + +makerom cyl_rom +neklmpi cyl 1 + +logfile=cyl.log.1 + +# 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 +