#include #include #include #include "cctk.h" #include "cctk_parameters.h" #include "cctk_WarnLevel.h" #include "cctk_FortranString.h" #include "StoreNamedData.h" static pNamedData *LinConfMetricSolverDB; static pNamedData *LinMetricSolverDB; static pNamedData *LinFlatSolverDB; static pNamedData *BrBrConfMetricSolverDB; static pNamedData *PolyConfMetricSolverDB; #define ELLBASE_NOSOLVER 1 #define ELLBASE_OK 0 /*########## Elliptic Equation class: LinEllConfMetric */ /* Registers the Equation class wrapper (the function which is called for a specific class of problems by passing all the necessay arguments PLUS the name of the desired solver */ void Ell_LinConfMetricRegistry(void (*function), const char *sname) { StoreNamedData(&LinConfMetricSolverDB,sname,(void*)function); } /* The Equation class wrapper, for the ellitpic class LinConfMetric (linar elliptic problem that requires the metric plus a conformal factor). It derives the function to call from the passed registration name of the solver "sname". Specifically it takes: grid hierarchy, integer array of the metric+conf.factor indeces, field index, Mindex, Nindex, real array for absolute tolerances and relative tolerances, the registration name of the solver */ int Ell_LinConfMetricSolver(cGH *GH, int *MetricPsi, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, const char *sname) { /* prototype for the equation class wrapper */ void (*fn)(cGH *GH,int *MetricPsi, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol); /* derive the fucntion name from the requested name and hope it is there */ fn = (void(*))GetNamedData(LinConfMetricSolverDB,sname); if (!fn) { CCTK_WARN(2,"Cannot find solver! "); return(ELLBASE_NOSOLVER); } /* Call the solver and pass through all the necessary arguments */ fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol); return(ELLBASE_OK); } /* Fortran wrappr for the routine Ell_LinConfMetricSolver */ void FMODIFIER FORTRAN_NAME(Ell_LinConfMetricSolver) (int *ierr, cGH *GH, int *MetricPsi, int *FieldIndex, int *MIndex, int *NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(sname); *ierr = Ell_LinConfMetricSolver(GH, MetricPsi, *FieldIndex, *MIndex, *NIndex, AbsTol, RelTol, sname); free(sname); } /*########## Elliptic Equation class: LinEllMetric */ void Ell_LinMetricRegistry(void (*function), const char *sname) { StoreNamedData(&LinMetricSolverDB,sname,(void*)function); } int Ell_LinMetricSolver(cGH *GH, int *Metric, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, const char *sname) { void (*fn)(cGH *GH,int *Metric, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol); fn = (void(*))GetNamedData(LinMetricSolverDB,sname); if (!fn) { CCTK_WARN(2,"Cannot find solver! "); return(ELLBASE_NOSOLVER); } fn(GH, Metric, FieldIndex, MIndex, NIndex, AbsTol, RelTol); return(ELLBASE_OK); } void FMODIFIER FORTRAN_NAME(Ell_LinMetricSolver) (int *ierr, cGH *GH, int *Metric, int *FieldIndex, int *MIndex, int *NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(sname); *ierr = Ell_LinMetricSolver(GH, Metric, *FieldIndex, *MIndex, *NIndex, AbsTol, RelTol, sname); free(sname); } /*########## Elliptic Equation class: LinEllFlat */ void Ell_LinFlatRegistry(void (*function), const char *sname) { StoreNamedData(&LinFlatSolverDB,sname,(void*)function); } int Ell_LinFlatSolver(cGH *GH, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, const char *sname) { void (*fn)(cGH *GH, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol); fn = (void(*))GetNamedData(LinFlatSolverDB,sname); if (!fn) { CCTK_WARN(2,"Cannot find solver! "); return(ELLBASE_NOSOLVER); } fn(GH, FieldIndex, MIndex, NIndex, AbsTol, RelTol); return(ELLBASE_OK); } void FMODIFIER FORTRAN_NAME(Ell_LinFlatSolver) (int *ierr, cGH *GH, int *FieldIndex, int *MIndex, int *NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(sname); *ierr = Ell_LinFlatSolver(GH, *FieldIndex, *MIndex, *NIndex, AbsTol, RelTol, sname); free(sname); } /*########## Elliptic Equation class: BrBrConfMetric (Brandt-Bruemann Data with conformal metric) */ void Ell_BrBrConfMetricRegistry(void (*function), const char *sname) { StoreNamedData(&BrBrConfMetricSolverDB,sname, (void*)function); } int Ell_BrBrConfMetricSolver(cGH *GH, int *MetricPsi, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, const char *sname) { void (*fn)(cGH *GH,int *MetricPsi, int FieldIndex, int MIndex, int NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol); fn = (void(*))GetNamedData(BrBrConfMetricSolverDB,sname); if (!fn) { CCTK_WARN(2,"Cannot find solver! "); return(ELLBASE_NOSOLVER); } fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol); return(ELLBASE_OK); } void FMODIFIER FORTRAN_NAME(Ell_BrBrConfMetricSolver) (int *ierr, cGH *GH, int *MetricPsi, int *FieldIndex, int *MIndex, int *NIndex, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(sname); *ierr = Ell_BrBrConfMetricSolver(GH, MetricPsi, *FieldIndex, *MIndex, *NIndex, AbsTol, RelTol, sname); free(sname); } /*########## Elliptic Equation class: PolyConfMetric */ void Ell_PolyConfMetricRegistry(void (*function), const char *sname) { StoreNamedData(&PolyConfMetricSolverDB,sname, (void*)function); } int Ell_PolyConfMetricSolver(cGH *GH, int *MetricPsi, int FieldIndex, int *PIndex, int Pcount, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, const char *sname) { void (*fn)(cGH *GH,int *MetricPsi, int FieldIndex, int *PIndex, int Pcount, CCTK_REAL *AbsTol, CCTK_REAL *RelTol); fn = (void(*))GetNamedData(PolyConfMetricSolverDB,sname); if (!fn) { CCTK_WARN(2,"Cannot find solver! "); return(ELLBASE_NOSOLVER); } fn(GH, MetricPsi, FieldIndex, PIndex, Pcount, AbsTol, RelTol); return(ELLBASE_OK); } void FMODIFIER FORTRAN_NAME(Ell_PolyConfMetricSolver) (int *ierr, cGH *GH, int *MetricPsi, int *FieldIndex, int *PIndex, int *Pcount, CCTK_REAL *AbsTol, CCTK_REAL *RelTol, ONE_FORTSTRING_ARG) { ONE_FORTSTRING_CREATE(sname); *ierr = Ell_PolyConfMetricSolver(GH, MetricPsi, *FieldIndex, PIndex, *Pcount, AbsTol, RelTol, sname); free(sname); }