From cbdaa223fa30c1ea1b9f10d3472eb58b8fbd644b Mon Sep 17 00:00:00 2001 From: lanfer Date: Tue, 26 Sep 2000 10:57:16 +0000 Subject: adapting wrapper to C version git-svn-id: http://svn.cactuscode.org/arrangements/CactusElliptic/EllSOR/trunk@60 fa3da13c-9f13-4301-a575-cf5b8c5e1907 --- src/sor_wrapper.c | 204 +++++++++++++++++++++--------------------------------- 1 file changed, 78 insertions(+), 126 deletions(-) diff --git a/src/sor_wrapper.c b/src/sor_wrapper.c index d05e646..0bd976c 100644 --- a/src/sor_wrapper.c +++ b/src/sor_wrapper.c @@ -22,39 +22,34 @@ #include "cctk_Parameters.h" #include "cctk_FortranString.h" -void CCTK_FNAME(sor_confmetric_core3d) - (_CCTK_C2F_PROTO(GH), - int *, - CCTK_REAL *, - int *, - CCTK_REAL *, - CCTK_REAL *, - CCTK_REAL *, - CCTK_REAL *, - CCTK_REAL *, - CCTK_REAL *, - CCTK_REAL *, - CCTK_REAL *, - CCTK_REAL *, - int *, - CCTK_REAL *, - CCTK_REAL *); +void sor_confmetric_3d(cGH *GH, int *MetricPsiI, int conformal, + int FieldIndex, int MIndex, int NIndex, + CCTK_REAL *AbsTol, CCTK_REAL *RelTol); + +/*@@ + @routine sor_confmetric + @date Tue Sep 26 11:31:42 2000 + @author Gerd Lanfermann + @desc + elliptic solver wrapper which provides a interface to the + different n-dimensional SOR solvers for the conformal metric, + of which only 3D is coded currently. + + This wrapper is registered and if it is being called with + a n-dim. grid function, it goes of and picks the correct solver. + + We pass in the arguments that are neccessary for this class of elliptic eq. + this solver is intended to solve. See ./CactusElliptic/EllBase/src/ for the + classes of elliptic eq. + @enddesc + @calls + @calledby + @history + + @endhistory -void CCTK_FNAME(sor_flat_core3d) - (int *ierr, - _CCTK_C2F_PROTO(GH), - int *, - CCTK_REAL *, - int *, - CCTK_REAL *, - CCTK_REAL *, - int *, - CCTK_REAL *, - CCTK_REAL *); +@@*/ -/* We pass in the arguments that are neccessary for this class of elliptic eq. - this solver is intended to solve. See ./CactusElliptic/EllBase/src/ for the - classes of elliptic eq. */ void sor_confmetric(cGH *GH, int *MetricPsiI, int FieldIndex, @@ -63,117 +58,74 @@ void sor_confmetric(cGH *GH, CCTK_REAL *AbsTol, CCTK_REAL *RelTol) { - - CCTK_REAL *gxx=NULL, *gxy=NULL, *gxz=NULL; - CCTK_REAL *gyy=NULL, *gyz=NULL, *gzz=NULL; - CCTK_REAL *psi=NULL; - CCTK_REAL *Mlinear=NULL, *Nsources=NULL; - CCTK_REAL *Field =NULL; - int i; - - int Mlinear_lsh[3], Nsource_lsh[3]; - - /* derive the metric data pointer from the index array. Note the ordering. - Also get datapointers to the field to solve for. - All of these are mandatory */ - - gxx = (CCTK_REAL*) CCTK_VarDataPtrI(GH, 0, MetricPsiI[0]); - gxy = (CCTK_REAL*) CCTK_VarDataPtrI(GH, 0, MetricPsiI[1]); - gxz = (CCTK_REAL*) CCTK_VarDataPtrI(GH, 0, MetricPsiI[2]); - gyy = (CCTK_REAL*) CCTK_VarDataPtrI(GH, 0, MetricPsiI[3]); - gyz = (CCTK_REAL*) CCTK_VarDataPtrI(GH, 0, MetricPsiI[4]); - gzz = (CCTK_REAL*) CCTK_VarDataPtrI(GH, 0, MetricPsiI[5]); - psi = (CCTK_REAL*) CCTK_VarDataPtrI(GH, 0, MetricPsiI[6]); - - Field = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,FieldIndex); - - if ((!gxx)||(!gxy)||(!gxz)||(!gyy)||(!gyz)||(!gzz)||(!psi)||(!Field)) + switch (CCTK_GroupDimFromVarI(FieldIndex)) { - CCTK_WARN(0,"SOR_WRAPPER: One of the metric data fields, or the GF to solve could not be found!"); - } - - /* derive the data pointer for the fields. the M/N fields are not - allocated (better: are of size 1), if the passed index is negative, - or we get back an empty GF of size 1 */ - if (MIndex>=0) Mlinear = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,MIndex); - if (NIndex>=0) Nsources = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,NIndex); - - - /* we pass the size of M/N through to fortran, so F can - tell the difference between an allocated GF (Mlinear_lsh.eq.cctk_lsh) or - unallocated GF (Mlinear_lsh=1). maximal dimension is three. */ - - if (GH->cctk_dim>3) - CCTK_WARN(0,"This elliptic solver implementation does not do dimension>3!"); - - for (i=0;icctk_dim;i++) - { - if((MIndex<0)) Mlinear_lsh[i]=1; - else Mlinear_lsh[i]=GH->cctk_lsh[i]; - if((NIndex<0)) Nsource_lsh[i]=1; - else Nsource_lsh[i]=GH->cctk_lsh[i]; + case 1: + CCTK_WARN(0,"No 1D SOR solver implemented"); + break; + case 2: + CCTK_WARN(0,"No 2D SOR solver implemented"); + break; + case 3: + sor_confmetric_3d(GH, MetricPsiI, 1, FieldIndex, MIndex, NIndex, + AbsTol, RelTol); + break; + default: + CCTK_WARN(1,"Requested SOR solver for dimension equal " + "zero or gt. three not implemented!"); + break; } +} +/*@@ + @routine sor_flat + @date Tue Sep 26 11:31:42 2000 + @author Gerd Lanfermann + @desc + elliptic solver wrapper which provides a interface to the + different n-dimensional SOR solvers (flat case), + of which only 3D is coded currently. - /* call the fortran routine */ - CCTK_FNAME(sor_confmetric_core3d)(_PASS_CCTK_C2F(GH), - Mlinear_lsh, Mlinear, - Nsource_lsh, Nsources, - gxx,gxy,gxz,gyy,gyz,gzz,psi, - Field, &FieldIndex, AbsTol, RelTol); + This wrapper is registered and if it is being called with + a n-dim. grid function, it goes of and picks the correct solver. -} + We pass in the arguments that are neccessary for this class of elliptic eq. + this solver is intended to solve. See ./CactusElliptic/EllBase/src/ for the + classes of elliptic eq. + @enddesc + @calls + @calledby + @history + @endhistory -int sor_flat(cGH *GH, +@@*/ + +void sor_flat(cGH *GH, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol) { - int ierr; - CCTK_REAL *Mlinear=NULL, *Nsources=NULL; - CCTK_REAL *Field=NULL; - int i; - int Mlinear_lsh[3], Nsource_lsh[3]; - - Field = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,FieldIndex); - - if (MIndex>0) Mlinear = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,MIndex); - if (NIndex>0) Nsources = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,NIndex); - - if (GH->cctk_dim>3) + switch (CCTK_GroupDimFromVarI(FieldIndex)) { - CCTK_WARN(0,"This elliptic solver implementation does not do dimension>3!"); + case 1: + CCTK_WARN(1,"No 1D SOR solver implemented"); + break; + case 2: + CCTK_WARN(1,"No 2D SOR solver implemented"); + break; + case 3: + printf(" wrapper: %d %d %d \n",FieldIndex, MIndex, NIndex); + sor_flat_3d(GH, FieldIndex, MIndex, NIndex, AbsTol, RelTol); + break; + default: + CCTK_WARN(1,"Requested SOR solver for dimension equal" + "zero or gt. three not implemented!"); + break; } - for (i=0;icctk_dim;i++) - { - if((MIndex<0)) Mlinear_lsh[i]=1; - else Mlinear_lsh[i]=GH->cctk_lsh[i]; - if((NIndex<0)) Nsource_lsh[i]=1; - else - { - Nsource_lsh[i]=GH->cctk_lsh[i]; - } - } - - /* call the fortran routine */ - CCTK_FNAME(sor_flat_core3d) - (&ierr, - _PASS_CCTK_C2F(GH), - Mlinear_lsh, - Mlinear, - Nsource_lsh, - Nsources, - Field, - &FieldIndex, - AbsTol, - RelTol); - - return ierr; - } -- cgit v1.2.3