aboutsummaryrefslogtreecommitdiff
path: root/src/sor_wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sor_wrapper.c')
-rw-r--r--src/sor_wrapper.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/sor_wrapper.c b/src/sor_wrapper.c
new file mode 100644
index 0000000..989229a
--- /dev/null
+++ b/src/sor_wrapper.c
@@ -0,0 +1,88 @@
+ /*@@
+ @file jacobi_wrapper.c
+ @date Tue Aug 24 12:50:07 1999
+ @author Gerd Lanfermann
+ @desc
+ Provides the C wrapper to the different elliptic FORTRAN routines in this thorn
+ * These C routines are registered in the Startup routine.
+ * The LINELL_*_ARGS macro used here is provided by LinearElliptic.h
+ This cannot be modified, since this argument structure is the same
+ across all solves which will be registered as *_hhgr3d. See LinearElliptic.c
+ @enddesc
+ @@*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "cctk.h"
+#include "cctk_parameters.h"
+#include "cctk_FortranString.h"
+
+#include "CactusElliptic/LinearElliptic/src/LinearElliptic.h"
+
+
+void sor_confmetric(cGH *GH, int *MetricPsiI, int *FieldIndex,
+ int *MIndex, int *NIndex, int *AbsTol,int *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 *var=NULL;
+
+ CCTK_REAL tolerance;
+ int i;
+ int toltype;
+
+ int Mlinear_lsh[3], Nsource_lsh[3];
+
+ int retcode;
+
+ /* derive the metric data pointer from the index array. Note the ordering. */
+ 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]);
+ var = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,*FieldIndex);
+
+ if ((!gxx)||(!gxy)||(!gxz)||(!gyy)||(!gyz)||(!gzz)||(!psi)||(!var))
+ 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 frotran, so F can tell the difference
+ between an allocated GF (Mlinear_lsh=cctk_lsh) or unallocated GF (Mlinear_lsh=1)
+ maximal dimension is three. */
+ /*$FIXME: We need to get the group index first!
+ printf("XXXX %d \n",CCTK_QueryGroupStorage(GH,*MIndex,NULL));$*/
+ if (GH->cctk_dim>3)
+ CCTK_WARN(0,"This elliptic solver implementation does not do dimension>3!");
+ for (i=0;i<GH->cctk_dim;i++) {
+ if((*MIndex<0)) /*$|| (CCTK_QueryGroupStorage(GH,*MIndex,NULL)==0))$*/
+ Mlinear_lsh[i]=1;
+ else Mlinear_lsh[i]=GH->cctk_lsh[i];
+ if((*NIndex<0)) /*$|| (CCTK_QueryGroupStorage(GH,*NIndex,NULL)==0))$*/
+ Nsource_lsh[i]=1;
+ else Nsource_lsh[i]=GH->cctk_lsh[i];
+ printf("%d %d \n",Nsource_lsh[i],Mlinear_lsh[i]);
+ }
+
+
+ /* call the fortran routine */
+ FORTRAN_NAME(sor_confmetric_core3d)(_PASS_CCTK_C2F(GH),
+ Mlinear_lsh, Mlinear,
+ Nsource_lsh, Nsources,
+ gxx,gxy,gxz,gyy,gyz,gzz,psi,
+ var, AbsTol, RelTol);
+
+}
+