From 6fdbf297784da5711d8801877103cd7b4f43f383 Mon Sep 17 00:00:00 2001 From: diener Date: Fri, 18 Apr 2008 21:40:46 +0000 Subject: Add stencils for non-SBP operators. git-svn-id: https://svn.cct.lsu.edu/repos/numrel/LSUThorns/SummationByParts/trunk@104 f69c4107-0314-4c4f-9ad4-17e986b73f4a --- param.ccl | 8 ++++ src/All_Coeffs_mod.F90 | 106 ++++++++++++++++++++++++++++++++++++++++++++++++ src/Coefficients2_2.F90 | 55 +++++++++++++++++++++++++ src/Coefficients2_4.F90 | 62 ++++++++++++++++++++++++++++ src/Coefficients2_6.F90 | 68 +++++++++++++++++++++++++++++++ src/Coefficients2_8.F90 | 74 +++++++++++++++++++++++++++++++++ src/get_coeffs2.c | 103 ++++++++++++++++++++++++++++++++++------------ src/make.code.defn | 4 ++ 8 files changed, 454 insertions(+), 26 deletions(-) create mode 100644 src/Coefficients2_2.F90 create mode 100644 src/Coefficients2_4.F90 create mode 100644 src/Coefficients2_6.F90 create mode 100644 src/Coefficients2_8.F90 diff --git a/param.ccl b/param.ccl index 0430e02..7d69ca3 100644 --- a/param.ccl +++ b/param.ccl @@ -13,6 +13,10 @@ KEYWORD operator_type "Type of operator" STEERABLE=always "Optimized" :: "Optimized for performance" } "Optimized" +BOOLEAN sbp_2nd_deriv "Should the 2nd derivative operator be SBP" STEERABLE=always +{ +} "yes" + INT order "Order of accuracy" STEERABLE=always { 2:8:2 :: "" @@ -30,6 +34,10 @@ BOOLEAN use_dissipation "Should we add dissipation" { } "no" +BOOLEAN use_shiftout "Should we use the boundary_shift_out parameters from CoordBase to shift the dissipation stencils" +{ +} "no" + # Note: scaling the dissipation operators with h reduces the order by one. BOOLEAN scale_with_h "Should we scale the dissipation with the grid spacing h" { diff --git a/src/All_Coeffs_mod.F90 b/src/All_Coeffs_mod.F90 index 1b773ad..539e46e 100644 --- a/src/All_Coeffs_mod.F90 +++ b/src/All_Coeffs_mod.F90 @@ -76,6 +76,18 @@ module All_Coeffs_mod end subroutine coeffs_2_2_1 + subroutine coeffs_2_2 ( a, q ) + + CCTK_REAL, dimension(2), intent(OUT) :: a + CCTK_REAL, dimension(1,1), intent(OUT) :: q + + a(1) = -2.0_wp + a(2) = 1.0_wp + + q(1,1) = 0.0_wp + + end subroutine coeffs_2_2 + subroutine coeffs_1_4_2 ( a, q ) CCTK_REAL, dimension(2), intent(OUT) :: a @@ -267,6 +279,25 @@ module All_Coeffs_mod end subroutine coeffs_2_4_2_opt + subroutine coeffs_2_4 ( a, q ) + + CCTK_REAL, dimension(3), intent(OUT) :: a + CCTK_REAL, dimension(3,2), intent(OUT) :: q + + a(1) = -2.5_wp + a(2) = 1.333333333333333333333333333333333333333_wp + a(3) = -0.08333333333333333333333333333333333333333_wp + + q(1,1) = zero + q(2,1) = zero + q(3,1) = zero + + q(1,2) = 1.0_wp + q(2,2) = -2.0_wp + q(3,2) = 1.0_wp + + end subroutine coeffs_2_4 + subroutine coeffs_1_6_3 ( a, q ) CCTK_REAL, dimension(3), intent(OUT) :: a @@ -622,6 +653,36 @@ module All_Coeffs_mod end subroutine coeffs_2_6_3 + subroutine coeffs_2_6 ( a, q ) + + CCTK_REAL, dimension(4), intent(OUT) :: a + CCTK_REAL, dimension(5,3), intent(OUT) :: q + + a(1) = -2.722222222222222222222222222222222222222_wp + a(2) = 1.500000000000000000000000000000000000000_wp + a(3) = -0.1500000000000000000000000000000000000000_wp + a(4) = 0.01111111111111111111111111111111111111111_wp + + q(1,1) = zero + q(2,1) = zero + q(3,1) = zero + q(4,1) = zero + q(5,1) = zero + + q(1,2) = 1.0_wp + q(2,2) = -2.0_wp + q(3,2) = 1.0_wp + q(4,2) = zero + q(5,2) = zero + + q(1,3) = -0.08333333333333333333333333333333333333333_wp + q(2,3) = 1.333333333333333333333333333333333333333_wp + q(3,3) = -2.5_wp + q(4,3) = 1.333333333333333333333333333333333333333_wp + q(5,3) = -0.08333333333333333333333333333333333333333_wp + + end subroutine coeffs_2_6 + subroutine coeffs_1_8_4 ( a, q ) CCTK_REAL, dimension(4), intent(OUT) :: a @@ -1250,6 +1311,51 @@ module All_Coeffs_mod end subroutine coeffs_2_8_4 + subroutine coeffs_2_8 ( a, q ) + + CCTK_REAL, dimension(5), intent(OUT) :: a + CCTK_REAL, dimension(7,4), intent(OUT) :: q + + a(1) = -2.847222222222222222222222222222222222222_wp + a(2) = 1.600000000000000000000000000000000000000_wp + a(3) = -0.2000000000000000000000000000000000000000_wp + a(4) = 0.02539682539682539682539682539682539682540_wp + a(5) = -0.001785714285714285714285714285714285714286_wp + + q(1,1) = zero + q(2,1) = zero + q(3,1) = zero + q(4,1) = zero + q(5,1) = zero + q(6,1) = zero + q(7,1) = zero + + q(1,2) = 1.0_wp + q(2,2) = -2.0_wp + q(3,2) = 1.0_wp + q(4,2) = zero + q(5,2) = zero + q(6,2) = zero + q(7,2) = zero + + q(1,3) = -0.08333333333333333333333333333333333333333_wp + q(2,3) = 1.333333333333333333333333333333333333333_wp + q(3,3) = -2.5_wp + q(4,3) = 1.333333333333333333333333333333333333333_wp + q(5,3) = -0.08333333333333333333333333333333333333333_wp + q(6,3) = zero + q(7,3) = zero + + q(1,4) = 0.01111111111111111111111111111111111111111_wp + q(2,4) = -0.15_wp + q(3,4) = 1.5_wp + q(4,4) = -2.722222222222222222222222222222222222222_wp + q(5,4) = 1.5_wp + q(6,4) = -0.15_wp + q(7,4) = 0.01111111111111111111111111111111111111111_wp + + end subroutine coeffs_2_8 + subroutine coeffs_1_4_3 ( a, q ) CCTK_REAL, dimension(2), intent(OUT) :: a diff --git a/src/Coefficients2_2.F90 b/src/Coefficients2_2.F90 new file mode 100644 index 0000000..ab3f8e1 --- /dev/null +++ b/src/Coefficients2_2.F90 @@ -0,0 +1,55 @@ +#include "cctk.h" +#include "cctk_Functions.h" +#include "cctk_Parameters.h" + +subroutine set_coeff2_2 ( nsize, loc_order, bb, gsize, imin, imax, dd ) + + use All_Coeffs_mod + + implicit none + + DECLARE_CCTK_FUNCTIONS + DECLARE_CCTK_PARAMETERS + + CCTK_INT, intent(IN) :: nsize, loc_order + CCTK_INT, dimension(2), intent(IN) :: bb + CCTK_INT, intent(IN) :: gsize + CCTK_INT, dimension(nsize), intent(OUT) :: imin, imax + CCTK_REAL, dimension(nsize,nsize), intent(OUT) :: dd + + CCTK_REAL, dimension(2), save :: a + CCTK_REAL, dimension(1,1), save :: q + + CCTK_INT :: i, il, ir + + logical, save :: first = .true. + + if ( first ) then + call coeffs_2_2 ( a, q ) + first = .false. + end if + + dd = zero + imin = 0 + imax = -1 + + if ( bb(1) == 0 ) then + il = 1 + gsize + else + dd(1,1) = q(1,1); + imin(1) = 1; imax(1) = 1 + il = 2 + end if + if ( bb(2) == 0 ) then + ir = nsize - gsize + else + dd(nsize,nsize) = q(1,1) + imin(nsize) = nsize; imax(nsize) = nsize + ir = nsize - 1 + end if + do i = il, ir + dd(i-1,i) = a(2); dd(i:i+1,i) = a(1:2) + imin(i) = i-1; imax(i) = i+1 + end do + +end subroutine set_coeff2_2 diff --git a/src/Coefficients2_4.F90 b/src/Coefficients2_4.F90 new file mode 100644 index 0000000..465a2a7 --- /dev/null +++ b/src/Coefficients2_4.F90 @@ -0,0 +1,62 @@ +#include "cctk.h" +#include "cctk_Functions.h" +#include "cctk_Parameters.h" + +subroutine set_coeff2_4 ( nsize, loc_order, bb, gsize, imin, imax, dd ) + + use All_Coeffs_mod + + implicit none + + DECLARE_CCTK_FUNCTIONS + DECLARE_CCTK_PARAMETERS + + CCTK_INT, intent(IN) :: nsize, loc_order + CCTK_INT, dimension(2), intent(IN) :: bb + CCTK_INT, intent(IN) :: gsize + CCTK_INT, dimension(nsize), intent(OUT) :: imin, imax + CCTK_REAL, dimension(nsize,nsize), intent(OUT) :: dd + + CCTK_REAL, dimension(3), save :: a + CCTK_REAL, dimension(3,2), save :: q + + CCTK_INT :: i, il, ir + + logical, save :: first = .true. + + if ( first ) then + call coeffs_2_4 ( a, q ) + first = .false. + end if + + dd = zero + imin = 0 + imax = -1 + + if ( bb(1) == 0 ) then + il = 1 + gsize + else + dd(1:3,1) = q(1:3,1) + imin(1) = 1; imax(1) = 1 + + dd(1:3,2) = q(1:3,2) + imin(2) = 1; imax(2) = 3 + + il = 3 + end if + if ( bb(2) == 0 ) then + ir = nsize - gsize + else + dd(nsize-2:nsize,nsize-1) = q(3:1:-1,2) + imin(nsize-1) = nsize-2; imax(nsize-1) = nsize + + dd(nsize-2:nsize,nsize) = q(3:1:-1,1) + imin(nsize) = nsize; imax(nsize) = nsize + + ir = nsize - 2 + end if + do i = il, ir + dd(i-2:i-1,i) = a(3:2:-1); dd(i:i+2,i) = a(1:3) + imin(i) = i-2; imax(i) = i+2 + end do +end subroutine set_coeff2_4 diff --git a/src/Coefficients2_6.F90 b/src/Coefficients2_6.F90 new file mode 100644 index 0000000..e45985f --- /dev/null +++ b/src/Coefficients2_6.F90 @@ -0,0 +1,68 @@ +#include "cctk.h" +#include "cctk_Functions.h" +#include "cctk_Parameters.h" + +subroutine set_coeff2_6 ( nsize, loc_order, bb, gsize, imin, imax, dd ) + + use All_Coeffs_mod + + implicit none + + DECLARE_CCTK_FUNCTIONS + DECLARE_CCTK_PARAMETERS + + CCTK_INT, intent(IN) :: nsize, loc_order + CCTK_INT, dimension(2), intent(IN) :: bb + CCTK_INT, intent(IN) :: gsize + CCTK_INT, dimension(nsize), intent(OUT) :: imin, imax + CCTK_REAL, dimension(nsize,nsize), intent(OUT) :: dd + + CCTK_REAL, dimension(4), save :: a + CCTK_REAL, dimension(5,3), save :: q + + CCTK_INT :: i, il, ir + + logical, save :: first = .true. + + if ( first ) then + call coeffs_2_6 ( a, q ) + first = .false. + end if + + dd = zero + imin = 0 + imax = -1 + + if ( bb(1) == 0 ) then + il = 1 + gsize + else + dd(1:5,1) = q(1:5,1) + imin(1) = 1; imax(1) = 1 + + dd(1:5,2) = q(1:5,2) + imin(2) = 1; imax(2) = 3 + + dd(1:5,3) = q(1:5,3) + imin(3) = 1; imax(3) = 5 + + il = 4 + end if + if ( bb(2) == 0 ) then + ir = nsize - gsize + else + dd(nsize-4:nsize,nsize-2) = q(5:1:-1,3) + imin(nsize-2) = nsize-4; imax(nsize-2) = nsize + + dd(nsize-4:nsize,nsize-1) = q(5:1:-1,2) + imin(nsize-1) = nsize-2; imax(nsize-1) = nsize + + dd(nsize-4:nsize,nsize) = q(5:1:-1,1) + imin(nsize) = nsize; imax(nsize) = nsize + + ir = nsize - 3 + end if + do i = il, ir + dd(i-3:i-1,i) = a(4:2:-1); dd(i:i+3,i) = a(1:4) + imin(i) = i-3; imax(i) = i+3 + end do +end subroutine set_coeff2_6 diff --git a/src/Coefficients2_8.F90 b/src/Coefficients2_8.F90 new file mode 100644 index 0000000..9fbae7a --- /dev/null +++ b/src/Coefficients2_8.F90 @@ -0,0 +1,74 @@ +#include "cctk.h" +#include "cctk_Functions.h" +#include "cctk_Parameters.h" + +subroutine set_coeff2_8 ( nsize, loc_order, bb, gsize, imin, imax, dd ) + + use All_Coeffs_mod + + implicit none + + DECLARE_CCTK_FUNCTIONS + DECLARE_CCTK_PARAMETERS + + CCTK_INT, intent(IN) :: nsize, loc_order + CCTK_INT, dimension(2), intent(IN) :: bb + CCTK_INT, intent(IN) :: gsize + CCTK_INT, dimension(nsize), intent(OUT) :: imin, imax + CCTK_REAL, dimension(nsize,nsize), intent(OUT) :: dd + + CCTK_REAL, dimension(5), save :: a + CCTK_REAL, dimension(7,4), save :: q + + CCTK_INT :: i, il, ir + + logical, save :: first = .true. + + if ( first ) then + call coeffs_2_8 ( a, q ) + first = .false. + end if + + dd = zero + imin = 0 + imax = -1 + + if ( bb(1) == 0 ) then + il = 1 + gsize + else + dd(1:7,1) = q(1:7,1) + imin(1) = 1; imax(1) = 1 + + dd(1:7,2) = q(1:7,2) + imin(2) = 1; imax(2) = 3 + + dd(1:7,3) = q(1:7,3) + imin(3) = 1; imax(3) = 5 + + dd(1:7,4) = q(1:7,4) + imin(4) = 1; imax(4) = 7 + + il = 5 + end if + if ( bb(2) == 0 ) then + ir = nsize - gsize + else + dd(nsize-6:nsize,nsize-3) = q(7:1:-1,4) + imin(nsize-3) = nsize-6; imax(nsize-3) = nsize + + dd(nsize-6:nsize,nsize-2) = q(7:1:-1,3) + imin(nsize-2) = nsize-4; imax(nsize-2) = nsize + + dd(nsize-6:nsize,nsize-1) = q(7:1:-1,2) + imin(nsize-1) = nsize-2; imax(nsize-1) = nsize + + dd(nsize-6:nsize,nsize) = q(7:1:-1,1) + imin(nsize) = nsize; imax(nsize) = nsize + + ir = nsize - 4 + end if + do i = il, ir + dd(i-4:i-1,i) = a(5:2:-1); dd(i:i+4,i) = a(1:5) + imin(i) = i-4; imax(i) = i+4 + end do +end subroutine set_coeff2_8 diff --git a/src/get_coeffs2.c b/src/get_coeffs2.c index fff110d..6779ecf 100644 --- a/src/get_coeffs2.c +++ b/src/get_coeffs2.c @@ -32,6 +32,13 @@ void DiffCoeff2 ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir, CCTK_INT *imin, CCTK_INT *imax, CCTK_REAL *q); + void CCTK_FCALL CCTK_FNAME(set_coeff2_2)(const CCTK_INT *nsize, + const CCTK_INT *loc_order, + const CCTK_INT *bb, + const CCTK_INT *gsize, + CCTK_INT *imin, + CCTK_INT *imax, + CCTK_REAL *q); void CCTK_FCALL CCTK_FNAME(set_coeff2_4_2)(const CCTK_INT *nsize, const CCTK_INT *loc_order, const CCTK_INT *bb, @@ -46,6 +53,13 @@ void DiffCoeff2 ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir, CCTK_INT *imin, CCTK_INT *imax, CCTK_REAL *q); + void CCTK_FCALL CCTK_FNAME(set_coeff2_4)(const CCTK_INT *nsize, + const CCTK_INT *loc_order, + const CCTK_INT *bb, + const CCTK_INT *gsize, + CCTK_INT *imin, + CCTK_INT *imax, + CCTK_REAL *q); void CCTK_FCALL CCTK_FNAME(set_coeff2_6_3)(const CCTK_INT *nsize, const CCTK_INT *loc_order, const CCTK_INT *bb, @@ -53,6 +67,13 @@ void DiffCoeff2 ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir, CCTK_INT *imin, CCTK_INT *imax, CCTK_REAL *q); + void CCTK_FCALL CCTK_FNAME(set_coeff2_6)(const CCTK_INT *nsize, + const CCTK_INT *loc_order, + const CCTK_INT *bb, + const CCTK_INT *gsize, + CCTK_INT *imin, + CCTK_INT *imax, + CCTK_REAL *q); void CCTK_FCALL CCTK_FNAME(set_coeff2_8_4)(const CCTK_INT *nsize, const CCTK_INT *loc_order, const CCTK_INT *bb, @@ -60,6 +81,13 @@ void DiffCoeff2 ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir, CCTK_INT *imin, CCTK_INT *imax, CCTK_REAL *q); + void CCTK_FCALL CCTK_FNAME(set_coeff2_8)(const CCTK_INT *nsize, + const CCTK_INT *loc_order, + const CCTK_INT *bb, + const CCTK_INT *gsize, + CCTK_INT *imin, + CCTK_INT *imax, + CCTK_REAL *q); ni = cctk_lsh[0]; nj = cctk_lsh[1]; nk = cctk_lsh[2]; @@ -100,50 +128,73 @@ void DiffCoeff2 ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir, } if ( CCTK_Equals(norm_type,"Diagonal") ) { - if ( CCTK_Equals(operator_type,"Minimal Bandwidth") ) { - switch(loc_order) { - case 2: { - CCTK_FNAME(set_coeff2_2_1)(&nsize,&loc_order,bb,&gsize,imin,imax,q); - break; - } - case 4: { - CCTK_FNAME(set_coeff2_4_2)(&nsize,&loc_order,bb,&gsize,imin,imax,q); - break; - } - case 6: { - CCTK_FNAME(set_coeff2_6_3)(&nsize,&loc_order,bb,&gsize,imin,imax,q); - break; - } - case 8: { - CCTK_FNAME(set_coeff2_8_4)(&nsize,&loc_order,bb,&gsize,imin,imax,q); - break; - } - default: - CCTK_WARN (0, "Unknown stencil specified"); + if ( sbp_2nd_deriv ) { + if ( CCTK_Equals(operator_type,"Minimal Bandwidth") ) { + switch(loc_order) { + case 2: { + CCTK_FNAME(set_coeff2_2_1)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + break; + } + case 4: { + CCTK_FNAME(set_coeff2_4_2)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + break; + } + case 6: { + CCTK_FNAME(set_coeff2_6_3)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + break; + } + case 8: { + CCTK_FNAME(set_coeff2_8_4)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + break; + } + default: + CCTK_WARN (0, "Unknown stencil specified"); + } + } else { + switch(loc_order) { + case 2: { + CCTK_FNAME(set_coeff2_2_1)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + break; + } + case 4: { + CCTK_FNAME(set_coeff2_4_2_opt)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + break; + } + case 6: { + CCTK_FNAME(set_coeff2_6_3)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + break; + } + case 8: { + CCTK_FNAME(set_coeff2_8_4)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + break; + } + default: + CCTK_WARN (0, "Unknown stencil specified"); + } } } else { switch(loc_order) { case 2: { - CCTK_FNAME(set_coeff2_2_1)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + CCTK_FNAME(set_coeff2_2)(&nsize,&loc_order,bb,&gsize,imin,imax,q); break; } case 4: { - CCTK_FNAME(set_coeff2_4_2_opt)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + CCTK_FNAME(set_coeff2_4)(&nsize,&loc_order,bb,&gsize,imin,imax,q); break; } case 6: { - CCTK_FNAME(set_coeff2_6_3)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + CCTK_FNAME(set_coeff2_6)(&nsize,&loc_order,bb,&gsize,imin,imax,q); break; } case 8: { - CCTK_FNAME(set_coeff2_8_4)(&nsize,&loc_order,bb,&gsize,imin,imax,q); + CCTK_FNAME(set_coeff2_8)(&nsize,&loc_order,bb,&gsize,imin,imax,q); break; } default: - CCTK_WARN (0, "Unknown stencil specified"); + CCTK_WARN (0, "Unknown 2nd derivative stencil specified"); } } } else { CCTK_WARN (0, "Second derivatives not implemented for restricted full norm"); } -} +} diff --git a/src/make.code.defn b/src/make.code.defn index e2a0294..1a7867e 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -46,15 +46,19 @@ SRCS = call_derivs.c \ get_coeffs2.c \ Coefficients_2_1.F90 \ Coefficients2_2_1.F90 \ + Coefficients2_2.F90 \ Coefficients_4_2.F90 \ Coefficients2_4_2.F90 \ Coefficients2_4_2_min_err_coeff.F90 \ + Coefficients2_4.F90 \ Coefficients_6_3.F90 \ Coefficients2_6_3.F90 \ Coefficients_6_3_min_err_coeff.F90 \ + Coefficients2_6.F90 \ Coefficients_8_4.F90 \ Coefficients2_8_4.F90 \ Coefficients_8_4_min_err_coeff.F90 \ + Coefficients2_8.F90 \ Coefficients_4_3.F90 \ Coefficients_4_3_min_err_coeff.F90 \ Coefficients_6_5.F90 \ -- cgit v1.2.3