From 93d997291d78ca3cebf36f33673b75ffcd8a4ba6 Mon Sep 17 00:00:00 2001 From: diener Date: Thu, 18 Oct 2007 13:35:10 +0000 Subject: Make 2nd derivative interface consistent with FiniteDifferencing and FourierDifferencing, providing a routine to return mixed derivatives obtained by applying two succesive 1st derivatives in different directions. Not tested yet, but compiles. git-svn-id: https://svn.cct.lsu.edu/repos/numrel/LSUThorns/SummationByParts/trunk@87 f69c4107-0314-4c4f-9ad4-17e986b73f4a --- interface.ccl | 3 ++- src/Derivatives2_mixed.F90 | 29 +++++++++++++++++++++++++++++ src/call_derivs2.c | 22 +++++++++++++++++++--- src/make.code.defn | 1 + 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/Derivatives2_mixed.F90 diff --git a/interface.ccl b/interface.ccl index a9f203d..02614a6 100644 --- a/interface.ccl +++ b/interface.ccl @@ -26,7 +26,8 @@ SUBROUTINE Diff_up_gv ( CCTK_POINTER_TO_CONST IN cctkGH, \ PROVIDES FUNCTION Diff_up_gv WITH DiffUpGv LANGUAGE C SUBROUTINE Diff2_gv ( CCTK_POINTER_TO_CONST IN cctkGH, \ - CCTK_INT IN dir, \ + CCTK_INT IN dir1, \ + CCTK_INT IN dir2, \ CCTK_REAL IN ARRAY var, \ CCTK_REAL OUT ARRAY dvar, \ CCTK_INT IN table_handle ) diff --git a/src/Derivatives2_mixed.F90 b/src/Derivatives2_mixed.F90 new file mode 100644 index 0000000..7c9e644 --- /dev/null +++ b/src/Derivatives2_mixed.F90 @@ -0,0 +1,29 @@ +#include "cctk.h" +#include "cctk_Functions.h" +#include "cctk_Parameters.h" + + +subroutine deriv2_mixed ( cctkGH, dir1, dir2, var, ni, nj, nk, & + dvar2, table_handle ) + + implicit none + + DECLARE_CCTK_FUNCTIONS + DECLARE_CCTK_PARAMETERS + + CCTK_POINTER, intent(IN) :: cctkGH + CCTK_INT, intent(IN) :: dir1, dir2 + CCTK_REAL, dimension(ni,nj,nk), intent(IN) :: var + CCTK_INT, intent(IN) :: ni, nj, nk + CCTK_REAL, dimension(ni,nj,nk), intent(OUT) :: dvar2 + CCTK_INT, intent(IN) :: table_handle + CCTK_REAL, dimension(:,:,:), allocatable :: tmp + + allocate ( tmp(ni,nj,nk) ) + + call Diff_gv ( cctkGH, dir1, var, tmp, table_handle) + call Diff_gv ( cctkGH, dir2, tmp, dvar2, table_handle ) + + deallocate ( tmp ) + +end subroutine deriv2_mixed diff --git a/src/call_derivs2.c b/src/call_derivs2.c index cf193c6..5ec2100 100644 --- a/src/call_derivs2.c +++ b/src/call_derivs2.c @@ -9,15 +9,15 @@ -void DiffGv2 ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir, - const CCTK_REAL *var, CCTK_REAL *dvar2, +void DiffGv2 ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir1, + const CCTK_INT dir2, const CCTK_REAL *var, CCTK_REAL *dvar2, const CCTK_INT table_handle ) { cGH const * restrict const cctkGH = cctkGH_; DECLARE_CCTK_PARAMETERS DECLARE_CCTK_ARGUMENTS - CCTK_INT ni, nj, nk, gsize, loc_order; + CCTK_INT ni, nj, nk, gsize, loc_order, dir; CCTK_REAL delta; CCTK_INT bb[2]; int onesided[6]; @@ -50,10 +50,26 @@ void DiffGv2 ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir, const CCTK_INT *gsize, const CCTK_REAL *delta, CCTK_REAL *dvar2); + void CCTK_FCALL CCTK_FNAME(deriv2_mixed)(const CCTK_POINTER_TO_CONST *cctkGH, + const CCTK_INT *dir1, + const CCTK_INT *dir2, + const CCTK_REAL *var, + const CCTK_INT *ni, + const CCTK_INT *nj, + const CCTK_INT *nk, + CCTK_REAL *dvar2, + const CCTK_INT *table_handle); ni = cctk_lsh[0]; nj = cctk_lsh[1]; nk = cctk_lsh[2]; + if ( dir1 != dir2 ) { + CCTK_FNAME(deriv2_mixed)(&cctkGH_,&dir1,&dir2,var,&ni,&nk,&nk,dvar2,&table_handle); + return; + } else { + dir = dir1; + } + if ( table_handle >=0 ) { nelements = Util_TableGetInt ( table_handle, &loc_order, "order" ); if ( nelements == UTIL_ERROR_TABLE_NO_SUCH_KEY ) { diff --git a/src/make.code.defn b/src/make.code.defn index 4357264..7c20a83 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -20,6 +20,7 @@ SRCS = call_derivs.c \ Derivatives_4_3_min_err_coeff.F90 \ Derivatives_6_5.F90 \ Derivatives_6_5_min_err_coeff.F90 \ + Derivatives2_mixed.F90 \ Get_Coeff.F90 \ set_norm_mask.F90 \ GetScalProdDiag.F90 \ -- cgit v1.2.3