From 8fe30673017e2b23c630c2f6e0575c6df98f3773 Mon Sep 17 00:00:00 2001 From: Ping-Hsuan Date: Mon, 21 Oct 2024 16:18:55 -0500 Subject: [PATCH] support EFR-ROM in NekROM --- code/MOR | 1 + code/MORDICT | 31 ++++++++++++++++--------------- code/filter.f | 22 ++++++++++++++++++++++ code/mpar.f | 4 ++++ code/time.f | 21 ++++++++++++++------- 5 files changed, 57 insertions(+), 22 deletions(-) diff --git a/code/MOR b/code/MOR index 5362560c..c7a9cbac 100644 --- a/code/MOR +++ b/code/MOR @@ -219,6 +219,7 @@ c parameters and common blocks for MOR integer rbf common /morfilter/ rdft,dfops(lub*lub) common /morifilt/ rbf + common /morrelax/ relax ! Tensor Decomposition diff --git a/code/MORDICT b/code/MORDICT index 342b1967..81e66da6 100644 --- a/code/MORDICT +++ b/code/MORDICT @@ -4,7 +4,7 @@ c Note: Keys have to be in capital letters c integer MORDICT_NKEYS - parameter (MORDICT_NKEYS = 61) + parameter (MORDICT_NKEYS = 62) character*132 mordictkey(MORDICT_NKEYS) data @@ -55,17 +55,18 @@ c & mordictkey(45) / 'FILTER:TYPE' / & mordictkey(46) / 'FILTER:MODES' / & mordictkey(47) / 'FILTER:RADIUS' / - & mordictkey(48) / 'BUOYANCY' / - & mordictkey(49) / 'BUOYANCY:MAGNITUDE' / - & mordictkey(50) / 'BUOYANCY:ANGLE' / - & mordictkey(51) / 'BUOYANCY:GX' / - & mordictkey(52) / 'BUOYANCY:GY' / - & mordictkey(53) / 'BUOYANCY:GZ' / - & mordictkey(54) / 'EI' / - & mordictkey(55) / 'EI:MODE' / - & mordictkey(56) / 'EI:EQN' / - & mordictkey(57) / 'TENDEC' / - & mordictkey(58) / 'TENDEC:MODE' / - & mordictkey(59) / 'TENDEC:RANK' / - & mordictkey(60) / 'TENDEC:CORE' / - & mordictkey(61) / 'TENDEC:SKEW' / + & mordictkey(48) / 'FILTER:RELAXATION' / + & mordictkey(49) / 'BUOYANCY' / + & mordictkey(50) / 'BUOYANCY:MAGNITUDE' / + & mordictkey(51) / 'BUOYANCY:ANGLE' / + & mordictkey(52) / 'BUOYANCY:GX' / + & mordictkey(53) / 'BUOYANCY:GY' / + & mordictkey(54) / 'BUOYANCY:GZ' / + & mordictkey(55) / 'EI' / + & mordictkey(56) / 'EI:MODE' / + & mordictkey(57) / 'EI:EQN' / + & mordictkey(58) / 'TENDEC' / + & mordictkey(59) / 'TENDEC:MODE' / + & mordictkey(60) / 'TENDEC:RANK' / + & mordictkey(61) / 'TENDEC:CORE' / + & mordictkey(62) / 'TENDEC:SKEW' / diff --git a/code/filter.f b/code/filter.f index 49a9728c..9bbe8d76 100644 --- a/code/filter.f +++ b/code/filter.f @@ -245,3 +245,25 @@ subroutine evalnut(nut,u1,u2,u3) return end c----------------------------------------------------------------------- + subroutine efr_relaxation(filtered_coef,coef,relax,nb) + + ! perform the relaxation step in the evolve-filter-relaxation method + + ! INPUT: + ! filtered_coef := filtered ROM coefficient + ! coef := ROM coefficient + ! relax := relaxation parameter ([0, 1]) + ! nb := size of filtered_coef and coef arrays + + ! OUTPUT: + ! filtered_coef := (1-relax)*coef + relax*filtered_coef + + real filtered_coef(1:nb), coef(1:nb) + real relax + integer nb + + call cmult(filtered_coef,relax,nb) + call add2s2(filtered_coef,coef,(1.-relax),nb) + + return + end diff --git a/code/mpar.f b/code/mpar.f index 38c4a394..3c173fdf 100644 --- a/code/mpar.f +++ b/code/mpar.f @@ -411,6 +411,9 @@ subroutine mpar_read(ierr) endif endif + call finiparser_getdbl(d_out,'filter:relaxation',ifnd) + if (ifnd.eq.1) relax=d_out + ! EI call finiparser_getbool(i_out,'ei:mode',ifnd) @@ -547,6 +550,7 @@ subroutine bcastmpar call bcast(tbarr0,wdsize) call bcast(rbf,wdsize) call bcast(rdft,wdsize) + call bcast(relax,wdsize) call bcast(gx,wdsize) call bcast(gy,wdsize) call bcast(gz,wdsize) diff --git a/code/time.f b/code/time.f index 265402c3..7cebe5c7 100644 --- a/code/time.f +++ b/code/time.f @@ -198,11 +198,13 @@ subroutine bdfext_step endif if (cfloc.eq.'POST') then - if (cftype.eq.'TFUN') then - call pod_proj(rhs(1,1),rbf,nb,'step ') - else if (cftype.eq.'DIFF') then - call pod_df(rhs(1,1)) - endif + ! copy unfiltered coefficients + call copy(utmp1(1),rhs(1,1),nb) + if (cftype.eq.'TFUN') then + call pod_proj(rhs(1,1),rbf,nb,'step ') + else if (cftype.eq.'DIFF') then + call pod_df(rhs(1,1)) + endif endif solve_time=solve_time+dnekclock()-ttime @@ -238,8 +240,13 @@ subroutine bdfext_step call copy(rhs(1,2),rhs(1,1),nb) endif - if (cfloc.eq.'POST'.and.cftype.eq.'POLY') - $ call apply_les_imp(rhs(0,1),rhs(0,2),rdft,fles1,fles2,rtmp1) + if (cfloc.eq.'POST') then + if (cftype.eq.'POLY') then + call apply_les_imp(rhs(0,1),rhs(0,2),rdft,fles1,fles2,rtmp1) + elseif ((cftype.eq.'TFUN').or.(cftype.eq.'DIFF')) then + call efr_relaxation(rhs(1,1),utmp1(1),relax,nb) + endif + endif if (ifrom(2)) call shift(ut,rhs(0,2),nb+1,5) if (ifrom(1)) call shift(u,rhs,nb+1,5)