aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallen <allen@57bc7290-fb3d-4efd-a9b1-28e84cce6043>2000-01-05 14:06:31 +0000
committerallen <allen@57bc7290-fb3d-4efd-a9b1-28e84cce6043>2000-01-05 14:06:31 +0000
commitb13b17b9a1fb3868dff62e4784da205b90e08623 (patch)
tree9875e3150183bad19fb4129c4b2c9983a61b8dc4
parentbc8c42986f183032e9cc2592eec10082bf6150a4 (diff)
Tidying and adding error codes.
Also made each of the registered solvers return an integer rather than a void so that the error codes can be passed back Standard elliptic error codes are now in CactusElliptic/EllBase/src/EllBase.h and so far are ELL_SUCCESS ELL_NOCONVERGENCE ELL_NOSOLVER git-svn-id: http://svn.cactuscode.org/arrangements/CactusElliptic/EllBase/trunk@29 57bc7290-fb3d-4efd-a9b1-28e84cce6043
-rw-r--r--src/EllBase.h8
-rw-r--r--src/Ell_Interface.c392
2 files changed, 294 insertions, 106 deletions
diff --git a/src/EllBase.h b/src/EllBase.h
index 985b7ee..59f40bc 100644
--- a/src/EllBase.h
+++ b/src/EllBase.h
@@ -7,9 +7,14 @@
@enddesc
@version $Header$
@@*/
+
#ifndef _ELLBASE_H_
#define _ELLBASE_H_
+#define ELL_SUCCESS 0
+#define ELL_NOSOLVER -1
+#define ELL_NOCONVERGENCE -2
+
#ifdef CCODE
@@ -18,7 +23,8 @@
are arrays holding the grid function indices of the metric, metric+psi or
the 27 stencil grid functions, respectively */
-#define LINELL_FLAT3D_ARGS cGH *GH, \
+#define LINELL_FLAT3D_ARGS \
+ cGH *GH, \
CCTK_REAL tolerance, \
int FieldIndex, \
int MIndex, \
diff --git a/src/Ell_Interface.c b/src/Ell_Interface.c
index e235b9e..c94f4fe 100644
--- a/src/Ell_Interface.c
+++ b/src/Ell_Interface.c
@@ -9,14 +9,14 @@
#include "cctk_FortranString.h"
#include "StoreNamedData.h"
+#include "EllBase.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 */
@@ -24,11 +24,12 @@ static pNamedData *PolyConfMetricSolverDB;
/* 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);
+
+void Ell_LinConfMetricRegistry(int (*function), const char *sname) {
+ StoreNamedData(&LinConfMetricSolverDB,sname,(int*)function);
}
-/* The Equation class wrapper, for the ellitpic class LinConfMetric
+/* The Equation class wrapper, for the elliptic 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".
@@ -37,174 +38,355 @@ void Ell_LinConfMetricRegistry(void (*function), const char *sname) {
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);
+int Ell_LinConfMetricSolver(cGH *GH,
+ int *MetricPsi,
+ int FieldIndex,
+ int MIndex,
+ int NIndex,
+ CCTK_REAL *AbsTol,
+ CCTK_REAL *RelTol,
+ const char *sname)
+{
+
+ int retval=0;
+ int (*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);
+ fn = (int(*)(cGH*,int*,int,int,int,CCTK_REAL*,CCTK_REAL*))
+ (GetNamedData(LinConfMetricSolverDB,sname));
+
+ if (fn)
+ {
+ retval = fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol);
+ }
+ else
+ {
+ CCTK_WARN(2,"Cannot find solver for LinEllConfMetric");
+ retval = ELL_NOSOLVER;
}
-
- /* Call the solver and pass through all the necessary arguments */
- fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol);
- return(ELLBASE_OK);
-}
+ return retval;
+
+}
-/* 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) {
+ (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);
+
+ *ierr = Ell_LinConfMetricSolver(GH,
+ MetricPsi,
+ *FieldIndex,
+ *MIndex,
+ *NIndex,
+ AbsTol,
+ RelTol,
+ sname);
free(sname);
+
}
-/*########## Elliptic Equation class: LinEllMetric */
+/*
+##################################################
+###### Elliptic Equation class: LinEllMetric #####
+##################################################
+*/
-void Ell_LinMetricRegistry(void (*function), const char *sname) {
+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);
+int Ell_LinMetricSolver(cGH *GH,
+ int *Metric,
+ int FieldIndex,
+ int MIndex,
+ int NIndex,
+ CCTK_REAL *AbsTol,
+ CCTK_REAL *RelTol,
+ const char *sname)
+{
+
+ int retval=0;
+ int (*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 = (int(*)(cGH*,int*,int,int,int,CCTK_REAL*,CCTK_REAL*))
+ (GetNamedData(LinMetricSolverDB,sname));
+
+ if (fn)
+ {
+ retval = fn(GH, Metric, FieldIndex, MIndex, NIndex, AbsTol, RelTol);
+ }
+ else
+ {
+ CCTK_WARN(2,"Cannot find solver for LinEllMetric");
+ retval = ELL_NOSOLVER;
}
-
- fn(GH, Metric, FieldIndex, MIndex, NIndex, AbsTol, RelTol);
- return(ELLBASE_OK);
+
+ return(ELL_SUCCESS);
}
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) {
+ (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);
+
+ *ierr = Ell_LinMetricSolver(GH,
+ Metric,
+ *FieldIndex,
+ *MIndex,
+ *NIndex,
+ AbsTol,
+ RelTol,
+ sname);
free(sname);
}
+/*
+################################################
+###### Elliptic Equation class: LinEllFlat #####
+################################################
+*/
-/*########## Elliptic Equation class: LinEllFlat */
-
-void Ell_LinFlatRegistry(void (*function), const char *sname) {
+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);
+int Ell_LinFlatSolver(cGH *GH,
+ int FieldIndex,
+ int MIndex,
+ int NIndex,
+ CCTK_REAL *AbsTol,
+ CCTK_REAL *RelTol,
+ const char *sname)
+{
+
+ int retval=0;
+ int (*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 = (int (*)(cGH *,int,int,int,CCTK_REAL *,CCTK_REAL *))
+ (GetNamedData(LinFlatSolverDB,sname));
+
+ if (fn)
+ {
+ retval = fn(GH, FieldIndex, MIndex, NIndex, AbsTol, RelTol);
+ }
+ else
+ {
+ CCTK_WARN(2,"Cannot find solver for LinEllFlat");
+ retval = ELL_NOSOLVER;
}
- fn(GH, FieldIndex, MIndex, NIndex, AbsTol, RelTol);
- return(ELLBASE_OK);
+ return retval;
}
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) {
+ (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);
+ *ierr = Ell_LinFlatSolver(GH,
+ *FieldIndex,
+ *MIndex,
+ *NIndex,
+ AbsTol,
+ RelTol,
+ sname);
free(sname);
-}
+}
-/*########## Elliptic Equation class: BrBrConfMetric
- (Brandt-Bruemann Data with conformal metric) */
+/*
+####################################################
+###### Elliptic Equation class: BrBrConfMetric #####
+####################################################
+(Brandt-Bruemann Data with conformal metric)
+*/
-void Ell_BrBrConfMetricRegistry(void (*function), const char *sname) {
+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);
+int Ell_BrBrConfMetricSolver(cGH *GH,
+ int *MetricPsi,
+ int FieldIndex,
+ int MIndex,
+ int NIndex,
+ CCTK_REAL *AbsTol,
+ CCTK_REAL *RelTol,
+ const char *sname)
+{
+
+ int retval=0;
+ int (*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 = (int(*)(cGH*,int*,int,int,int,CCTK_REAL*,CCTK_REAL*))
+ (GetNamedData(BrBrConfMetricSolverDB,sname));
+
+ if (fn)
+ {
+ retval = fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol);
+ }
+ else
+ {
+ CCTK_WARN(2,"Cannot find solver for BrBrConfMetric");
+ retval = ELL_NOSOLVER;
}
-
- fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol);
- return(ELLBASE_OK);
+
+ return retval;
+
}
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) {
+ (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);
+
+ *ierr = Ell_BrBrConfMetricSolver(GH,
+ MetricPsi,
+ *FieldIndex,
+ *MIndex,
+ *NIndex,
+ AbsTol,
+ RelTol,
+ sname);
+
free(sname);
+
}
-/*########## Elliptic Equation class: PolyConfMetric */
+/*
+####################################################
+###### Elliptic Equation class: PolyConfMetric #####
+####################################################
+*/
-void Ell_PolyConfMetricRegistry(void (*function), const char *sname) {
+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);
+int Ell_PolyConfMetricSolver(cGH *GH,
+ int *MetricPsi,
+ int FieldIndex,
+ int *PIndex,
+ int Pcount,
+ CCTK_REAL *AbsTol,
+ CCTK_REAL *RelTol,
+ const char *sname)
+{
+
+ int retval=0;
+ int (*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 = (int(*)(cGH*,int*,int,int*,int,CCTK_REAL*,CCTK_REAL*))
+ (GetNamedData(PolyConfMetricSolverDB,sname));
+
+ if (fn)
+ {
+ retval = fn(GH, MetricPsi, FieldIndex, PIndex, Pcount, AbsTol, RelTol);
+ }
+ else
+ {
+ CCTK_WARN(2,"Cannot find solver for PolyConfMetric");
+ retval = ELL_NOSOLVER;
}
- fn(GH, MetricPsi, FieldIndex, PIndex, Pcount, AbsTol, RelTol);
- return(ELLBASE_OK);
+ return retval;
+
}
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) {
+ (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);
+ *ierr = Ell_PolyConfMetricSolver(GH,
+ MetricPsi,
+ *FieldIndex,
+ PIndex,
+ *Pcount,
+ AbsTol,
+ RelTol,
+ sname);
free(sname);
+
}