-
Notifications
You must be signed in to change notification settings - Fork 104
Polynomial reconstruction in SharpClaw #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
1d44160
62ecd18
f9edcb1
ffe513f
9a648ee
1dbfabe
5a53304
943c2f2
f7f409f
e51b1d5
385bc83
e5ac2fe
4de6e91
0f939e8
d572d19
8b7ad7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
module poly | ||
contains | ||
|
||
! =================================================================== | ||
subroutine poly4(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
! =================================================================== | ||
|
||
implicit none | ||
|
||
integer, intent(in) :: num_eqn, maxnx, num_ghost | ||
double precision, intent(in) :: q(num_eqn,maxnx+2*num_ghost) | ||
double precision, intent(out) :: ql(num_eqn,maxnx+2*num_ghost),qr(num_eqn,maxnx+2*num_ghost) | ||
|
||
integer :: i,n | ||
|
||
do n = 1,num_eqn | ||
do i = num_ghost-1,maxnx+num_ghost+1 | ||
ql(n,i) = (-5.d0*q(n,-2+i)+60.d0*q(n,-1+i)+90.d0*q(n,i)-20.d0*q(n,1+i)+3.d0*q(n,2+i))/128.d0 | ||
qr(n,i) = (3.d0*q(n,-2+i)-20.d0*q(n,-1+i)+90.d0*q(n,i)+60.d0*q(n,1+i)-5.d0*q(n,2+i))/128.d0 | ||
end do | ||
end do | ||
|
||
end subroutine poly4 | ||
|
||
! =================================================================== | ||
subroutine poly6(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
! =================================================================== | ||
|
||
implicit none | ||
|
||
integer, intent(in) :: num_eqn, maxnx, num_ghost | ||
double precision, intent(in) :: q(num_eqn,maxnx+2*num_ghost) | ||
double precision, intent(out) :: ql(num_eqn,maxnx+2*num_ghost),qr(num_eqn,maxnx+2*num_ghost) | ||
|
||
integer :: i,n | ||
|
||
do n = 1,num_eqn | ||
do i = num_ghost-1,maxnx+num_ghost+1 | ||
ql(n,i) = (7.d0*q(n,-3+i) - 70.d0*q(n,-2+i) + 525.d0*q(n,-1+i) + 700.d0*q(n,i) & | ||
- 175.d0*q(n,1+i) + 42.d0*q(n,2+i) - 5.d0*q(n,3+i))/1024.d0 | ||
qr(n,i) = (42.d0*q(n,-2+i) - 175.d0*q(n,-1+i) + 700.d0*q(n,i) & | ||
+ 525.d0*q(n,1+i) - 70.d0*q(n,2+i) + 7.d0*q(n,3+i) - 5.d0*q(n,-3+i))/1024.d0 | ||
end do | ||
end do | ||
|
||
end subroutine poly6 | ||
|
||
! =================================================================== | ||
subroutine poly8(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
! =================================================================== | ||
|
||
implicit none | ||
|
||
integer, intent(in) :: num_eqn, maxnx, num_ghost | ||
double precision, intent(in) :: q(num_eqn,maxnx+2*num_ghost) | ||
double precision, intent(out) :: ql(num_eqn,maxnx+2*num_ghost),qr(num_eqn,maxnx+2*num_ghost) | ||
|
||
integer :: i,n | ||
|
||
do n = 1,num_eqn | ||
do i = num_ghost-1,maxnx+num_ghost+1 | ||
ql(n,i) = (-45.d0*q(n,-4+i) + 504.d0*q(n,-3+i) - 2940.d0*q(n,-2+i) + 17640.d0*q(n,-1+i) & | ||
+ 22050.d0*q(n,i) - 5880.d0*q(n,1+i) + 1764.d0*q(n,2+i) - 360.d0*q(n,3+i) + 35.d0*q(n,4+i))/32768.d0 | ||
qr(n,i) = (35.d0*q(n,-4+i) - 360.d0*q(n,-3+i) + 1764.d0*q(n,-2+i) - 5880.d0*q(n,-1+i) + 22050.d0*q(n,i) & | ||
+ 17640.d0*q(n,1+i) - 2940.d0*q(n,2+i) + 504.d0*q(n,3+i) - 45.d0*q(n,4+i))/32768.d0 | ||
end do | ||
end do | ||
|
||
end subroutine poly8 | ||
|
||
! =================================================================== | ||
subroutine poly10(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
! =================================================================== | ||
|
||
implicit none | ||
|
||
integer, intent(in) :: num_eqn, maxnx, num_ghost | ||
double precision, intent(in) :: q(num_eqn,maxnx+2*num_ghost) | ||
double precision, intent(out) :: ql(num_eqn,maxnx+2*num_ghost),qr(num_eqn,maxnx+2*num_ghost) | ||
|
||
integer :: i,n | ||
|
||
do n = 1,num_eqn | ||
do i = num_ghost-1,maxnx+num_ghost+1 | ||
ql(n,i) = (77.d0*q(n,-5+i) - 990.d0*q(n,-4+i) + 6237.d0*q(n,-3+i) - 27720.d0*q(n,-2+i) & | ||
+ 145530.d0*q(n,-1+i) + 174636.d0*q(n,i) - 48510.d0*q(n,1+i) + 16632.d0*q(n,2+i) - 4455.d0*q(n,3+i) & | ||
+ 770.d0*q(n,4+i) - 63.d0*q(n,5+i))/262144.d0 | ||
qr(n,i) = (-63.d0*q(n,-5+i) + 770.d0*q(n,-4+i) - 4455.d0*q(n,-3+i) + 16632.d0*q(n,-2+i) & | ||
- 48510.d0*q(n,-1+i) + 174636.d0*q(n,i) + 145530.d0*q(n,1+i) - 27720.d0*q(n,2+i) + 6237.d0*q(n,3+i) & | ||
- 990.d0*q(n,4+i) + 77.d0*q(n,5+i))/262144.d0 | ||
end do | ||
end do | ||
end subroutine poly10 | ||
|
||
end module poly |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,8 +83,12 @@ subroutine dealloc_recon_workspace(lim_type,char_decomp) | |
deallocate(hh) | ||
deallocate(uh) | ||
end select | ||
recon_alloc = .False. | ||
case(3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, @sanromd! |
||
deallocate(uu) | ||
deallocate(dq1m) | ||
end select | ||
recon_alloc = .False. | ||
|
||
end subroutine dealloc_recon_workspace | ||
|
||
! =================================================================== | ||
|
@@ -97,14 +101,14 @@ subroutine weno_comp(q,ql,qr,num_eqn,maxnx,num_ghost) | |
! It does no characteristic decomposition | ||
|
||
use weno | ||
use clawparams, only: weno_order | ||
use clawparams, only: reconstruction_order | ||
implicit none | ||
|
||
integer, intent(in) :: num_eqn, maxnx, num_ghost | ||
double precision, intent(in) :: q(num_eqn,maxnx+2*num_ghost) | ||
double precision, intent(out) :: ql(num_eqn,maxnx+2*num_ghost),qr(num_eqn,maxnx+2*num_ghost) | ||
|
||
select case(weno_order) | ||
select case(reconstruction_order) | ||
case (5) | ||
call weno5(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
case (7) | ||
|
@@ -120,7 +124,7 @@ subroutine weno_comp(q,ql,qr,num_eqn,maxnx,num_ghost) | |
case (17) | ||
call weno17(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
case default | ||
print *, 'ERROR: weno_order must be an odd number between 5 and 17 (inclusive).' | ||
print *, 'ERROR: reconstruction_order in WENO must be an odd number between 5 and 17 (inclusive).' | ||
stop | ||
end select | ||
|
||
|
@@ -821,4 +825,35 @@ subroutine tvd2_wave(q,ql,qr,wave,s,mthlim,num_eqn,num_ghost) | |
return | ||
end subroutine tvd2_wave | ||
|
||
! =================================================================== | ||
subroutine poly_comp(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
! =================================================================== | ||
|
||
use poly | ||
use clawparams, only: reconstruction_order | ||
implicit none | ||
|
||
integer, intent(in) :: num_eqn, maxnx, num_ghost | ||
double precision, intent(in) :: q(num_eqn,maxnx+2*num_ghost) | ||
double precision, intent(out) :: ql(num_eqn,maxnx+2*num_ghost),qr(num_eqn,maxnx+2*num_ghost) | ||
|
||
select case(reconstruction_order) | ||
case (4) | ||
call poly4(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
case (6) | ||
call poly6(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
case (8) | ||
print *, 'Warning: 8th reconstruction order is not fully tested' | ||
call poly8(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
case(10) | ||
print *, 'Warning: 10th reconstruction order is not fully tested' | ||
call poly10(q,ql,qr,num_eqn,maxnx,num_ghost) | ||
case default | ||
print *, 'ERROR: reconstruction_order for polynomial must be an odd number between 4 and 10 (inclusive)' | ||
stop | ||
end select | ||
|
||
return | ||
end subroutine poly_comp | ||
|
||
end module reconstruct |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,13 +42,14 @@ class SharpClawSolver(Solver): | |
- 0: No limiting. | ||
- 1: TVD reconstruction. | ||
- 2: WENO reconstruction. | ||
- 3: Polynomial reconstruction. | ||
|
||
``Default = 2`` | ||
|
||
.. attribute:: weno_order | ||
|
||
Order of the WENO reconstruction. From 1st to 17th order (PyWENO) | ||
.. attribute:: reconstruction_order | ||
|
||
Order of the reconstruction. From 1st to 17th order (PyWENO), and from | ||
4 to 10 (even) in Poly | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should say
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I just noticed that it's wrong in master... |
||
``Default = 5`` | ||
|
||
.. attribute:: time_integrator | ||
|
@@ -161,7 +162,7 @@ def __init__(self,riemann_solver=None,claw_package=None): | |
""" | ||
self.limiters = [1] | ||
self.lim_type = 2 | ||
self.weno_order = 5 | ||
self.reconstruction_order = 5 | ||
self.time_integrator = 'SSP104' | ||
self.char_decomp = 0 | ||
self.tfluct_solver = False | ||
|
@@ -206,9 +207,12 @@ def setup(self,solution): | |
Allocate RK stage arrays or previous step solutions and fortran routine work arrays. | ||
""" | ||
if self.lim_type == 2: | ||
self.num_ghost = (self.weno_order+1)//2 | ||
self.num_ghost = int((self.reconstruction_order+1)/2) | ||
|
||
if self.lim_type == 3: | ||
self.num_ghost = int(1 + self.reconstruction_order/2) | ||
|
||
if self.lim_type == 2 and self.weno_order != 5 and self.kernel_language == 'Python': | ||
if self.lim_type == 2 and self.reconstruction_order != 5 and self.kernel_language == 'Python': | ||
raise Exception('Only 5th-order WENO reconstruction is implemented in Python kernels. \ | ||
Use Fortran for higher-order WENO.') | ||
# This is a hack to deal with the fact that petsc4py | ||
|
@@ -565,7 +569,7 @@ def _set_fortran_parameters(self,state,clawparams,workspace,reconstruct): | |
grid = state.grid | ||
clawparams.num_dim = grid.num_dim | ||
clawparams.lim_type = self.lim_type | ||
clawparams.weno_order = self.weno_order | ||
clawparams.reconstruction_order = self.reconstruction_order | ||
clawparams.char_decomp = self.char_decomp | ||
clawparams.tfluct_solver = self.tfluct_solver | ||
clawparams.fwave = self.fwave | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: renaming
weno_order
toreconstruction_order
is backward-incompatible, but it is a small enough change that I think it's okay for this to go into 5.3.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ketch, if needed for 5.4 I can add backward-compatibility...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that's a good idea; we can just emit a warning saying that the old attribute will be deprecated in future versions.