aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallen <allen@57bc7290-fb3d-4efd-a9b1-28e84cce6043>2000-01-07 14:04:57 +0000
committerallen <allen@57bc7290-fb3d-4efd-a9b1-28e84cce6043>2000-01-07 14:04:57 +0000
commitb582839906c815007a292251953fe2d4ed0e1c14 (patch)
tree47c2f56ee7fb9f9a012776e6c4fc570a490ccc56
parente38733892767ea31fdb110738cf6fca40dedfb93 (diff)
More error checking and tidying
git-svn-id: http://svn.cactuscode.org/arrangements/CactusElliptic/EllBase/trunk@32 57bc7290-fb3d-4efd-a9b1-28e84cce6043
-rw-r--r--schedule.ccl2
-rw-r--r--src/EllBase.h9
-rw-r--r--src/Ell_Interface.c119
-rw-r--r--src/Ell_Register.c57
-rw-r--r--src/Startup.c12
5 files changed, 151 insertions, 48 deletions
diff --git a/schedule.ccl b/schedule.ccl
index eb27b40..8406abc 100644
--- a/schedule.ccl
+++ b/schedule.ccl
@@ -4,4 +4,4 @@
schedule Ell_RegisterBaseEqTypes at STARTUP
{
LANG:C
-} "Register the SOR solvers"
+} "Register the standard elliptic classes"
diff --git a/src/EllBase.h b/src/EllBase.h
index fa4c518..536eadf 100644
--- a/src/EllBase.h
+++ b/src/EllBase.h
@@ -15,13 +15,16 @@
#define ELL_NOSOLVER -1
#define ELL_NOCONVERGENCE -2
#define ELL_NOCLASS -3
+#define ELL_SOLVEREXISTS -4
+#define ELL_CLASSEXISTS -5
+#define ELL_FAILURE -6
#ifdef CCODE
/* Argumennt structure for the four different types of elliptic solvers
- provided at this point. Difference is MetricI, MetricPsiI and StencilGFI, which
- are arrays holding the grid function indices of the metric, metric+psi or
- the 27 stencil grid functions, respectively */
+ provided at this point. Difference is MetricI, MetricPsiI and StencilGFI,
+ which 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, \
diff --git a/src/Ell_Interface.c b/src/Ell_Interface.c
index 259f40b..838e3e6 100644
--- a/src/Ell_Interface.c
+++ b/src/Ell_Interface.c
@@ -1,3 +1,21 @@
+ /*@@
+ @header Ell_Interface.h
+ @date
+ @author Gerd Lanferman
+ @desc
+ Elliptic class routines for:
+
+ * Registering 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
+
+ * Equation class wrapper, for each elliptic class
+ Derives the function to call from the passed registration name of the
+ solver "sname".
+
+ @enddesc
+ @version $Header$
+ @@*/
#include <stdio.h>
#include <stdlib.h>
@@ -18,26 +36,29 @@ static pNamedData *BrBrConfMetricSolverDB;
static pNamedData *PolyConfMetricSolverDB;
-/*########## Elliptic Equation class: LinEllConfMetric */
-
+/*
+######################################################
+###### 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 */
+int Ell_LinConfMetricRegistry(int (*function), const char *sname)
+{
+ int retval;
-void Ell_LinConfMetricRegistry(int (*function), const char *sname) {
- StoreNamedData(&LinConfMetricSolverDB,sname,(int*)function);
+ if(!GetNamedData(LinConfMetricSolverDB,sname))
+ {
+ StoreNamedData(&LinConfMetricSolverDB,sname,(int*)function);
+ retval = ELL_SUCCESS;
+ }
+ else
+ {
+ retval = ELL_SOLVEREXISTS;
+ }
+
+ return retval;
}
-/* 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".
- 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,
@@ -108,9 +129,21 @@ void FMODIFIER FORTRAN_NAME(Ell_LinConfMetricSolver)
##################################################
*/
-void Ell_LinMetricRegistry(void (*function), const char *sname)
+int Ell_LinMetricRegistry(void (*function), const char *sname)
{
- StoreNamedData(&LinMetricSolverDB,sname,(void*)function);
+ int retval;
+
+ if(!GetNamedData(LinMetricSolverDB,sname))
+ {
+ StoreNamedData(&LinMetricSolverDB,sname,(void*)function);
+ retval = ELL_SUCCESS;
+ }
+ else
+ {
+ retval = ELL_SOLVEREXISTS;
+ }
+
+ return retval;
}
int Ell_LinMetricSolver(cGH *GH,
@@ -181,9 +214,22 @@ void FMODIFIER FORTRAN_NAME(Ell_LinMetricSolver)
################################################
*/
-void Ell_LinFlatRegistry(void (*function), const char *sname)
+int Ell_LinFlatRegistry(void (*function), const char *sname)
{
- StoreNamedData(&LinFlatSolverDB,sname,(void*)function);
+ int retval;
+
+ if(!GetNamedData(LinFlatSolverDB,sname))
+ {
+ StoreNamedData(&LinFlatSolverDB,sname,(void*)function);
+ retval = ELL_SUCCESS;
+ }
+ else
+ {
+ retval = ELL_SOLVEREXISTS;
+ }
+
+ return retval;
+
}
int Ell_LinFlatSolver(cGH *GH,
@@ -250,9 +296,22 @@ void FMODIFIER FORTRAN_NAME(Ell_LinFlatSolver)
(Brandt-Bruemann Data with conformal metric)
*/
-void Ell_BrBrConfMetricRegistry(void (*function), const char *sname)
+int Ell_BrBrConfMetricRegistry(void (*function), const char *sname)
{
- StoreNamedData(&BrBrConfMetricSolverDB,sname, (void*)function);
+ int retval;
+
+ if(!GetNamedData(BrBrConfMetricSolverDB,sname))
+ {
+ StoreNamedData(&BrBrConfMetricSolverDB,sname, (void*)function);
+ retval = ELL_SUCCESS;
+ }
+ else
+ {
+ retval = ELL_SOLVEREXISTS;
+ }
+
+ return retval;
+
}
int Ell_BrBrConfMetricSolver(cGH *GH,
@@ -325,9 +384,21 @@ void FMODIFIER FORTRAN_NAME(Ell_BrBrConfMetricSolver)
####################################################
*/
-void Ell_PolyConfMetricRegistry(void (*function), const char *sname)
+int Ell_PolyConfMetricRegistry(void (*function), const char *sname)
{
- StoreNamedData(&PolyConfMetricSolverDB,sname, (void*)function);
+ int retval;
+
+ if(!GetNamedData(PolyConfMetricSolverDB,sname))
+ {
+ StoreNamedData(&PolyConfMetricSolverDB,sname, (void*)function);
+ retval = ELL_SUCCESS;
+ }
+ else
+ {
+ retval = ELL_SOLVEREXISTS;
+ }
+
+ return retval;
}
int Ell_PolyConfMetricSolver(cGH *GH,
diff --git a/src/Ell_Register.c b/src/Ell_Register.c
index ee233b7..d296c6d 100644
--- a/src/Ell_Register.c
+++ b/src/Ell_Register.c
@@ -32,6 +32,7 @@ int Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname)
DECLARE_CCTK_PARAMETERS
+ int retval = ELL_FAILURE;
/* Register if function not already there with this name */
if (!GetNamedData(EqNameDB, eqname))
@@ -47,6 +48,7 @@ int Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname)
CCTK_INFO(msg);
free(msg);
}
+ retval = ELL_SUCCESS;
}
else
{
@@ -62,10 +64,13 @@ int Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname)
char *msg;
msg = (char *)malloc( (200+strlen(eqname))*sizeof(char) );
sprintf(msg,"Elliptic class %s already registered",eqname);
- CCTK_INFO(msg);
+ CCTK_WARN(0,msg);
free(msg);
+ retval = ELL_CLASSEXISTS;
}
+ return retval;
+
}
/* Ell_RegisterSolver takes a routine ("function") and registers that
@@ -86,34 +91,58 @@ int Ell_RegisterSolver(void (*function),
DECLARE_CCTK_PARAMETERS
- int retval;
- void (*fn)(void *, const char *);
+ int retval=ELL_FAILURE;
+ int ierr;
+ int (*fn)(void *, const char *);
- fn = (void(*)(void (*function), const char *sname))
+ fn = (int(*)(void (*function), const char *sname))
GetNamedData(EqNameDB, eqname);
if (fn)
{
- fn(function,sname);
+ ierr = fn(function,sname);
- if CCTK_EQUALS(elliptic_verbose,"yes")
+ if (ierr==ELL_SUCCESS)
+ {
+
+ if CCTK_EQUALS(elliptic_verbose,"yes")
+ {
+ char *msg;
+ msg = (char *)malloc((200+strlen(eqname)+strlen(sname))*sizeof(char));
+ sprintf(msg,"Registered elliptic solver %s for %s",sname,eqname);
+ CCTK_INFO(msg);
+ free(msg);
+ }
+
+ retval = ELL_SUCCESS;
+ }
+ else if (ierr==ELL_SOLVEREXISTS)
{
char *msg;
- msg = (char *)malloc( (200+strlen(eqname)+strlen(sname))*sizeof(char) );
- sprintf(msg,"Registered elliptic solver %s for %s",sname,eqname);
- CCTK_INFO(msg);
+ msg = (char *)malloc((200+strlen(eqname)+strlen(sname))*sizeof(char));
+ sprintf(msg,"Registered second solver %s for %s",sname,eqname);
+ CCTK_WARN(0,msg);
+ free(msg);
+
+ retval = ELL_SOLVEREXISTS;
+ }
+ else
+ {
+ char *msg;
+ msg = (char *)malloc((200+strlen(eqname)+strlen(sname))*sizeof(char));
+ sprintf(msg,"Failed to register solver %s for %s",sname,eqname);
+ CCTK_WARN(1,msg);
free(msg);
}
- retval = ELL_SUCCESS;
}
else
{
- CCTK_WARN(0,"Cannot get function in EqName");
- retval = ELL_NOCLASS;
+ CCTK_WARN(0,"Cannot get function in EqName");
+ retval = ELL_NOCLASS;
}
-
- return retval;
+
+ return retval;
}
diff --git a/src/Startup.c b/src/Startup.c
index c11ce66..a008e8e 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -15,7 +15,7 @@ void Ell_RegisterBaseEqTypes(cGH *GH)
{
DECLARE_CCTK_PARAMETERS
- void Ell_RegisterEq(void (*function),const char *);
+ int Ell_RegisterEq(void (*function),const char *);
void Ell_LinConfMetricRegistry(void (*function),const char *);
void Ell_LinMetricRegistry(void (*function),const char *);
void Ell_LinFlatRegistry(void (*function),const char *);
@@ -24,11 +24,11 @@ void Ell_RegisterBaseEqTypes(cGH *GH)
int err;
- Ell_RegisterEq(Ell_LinConfMetricRegistry, "Ell_LinConfMetric");
- Ell_RegisterEq(Ell_BrBrConfMetricRegistry,"Ell_BrBrConfMetric");
- Ell_RegisterEq(Ell_PolyConfMetricRegistry,"Ell_PolyConfMetric");
- Ell_RegisterEq(Ell_LinMetricRegistry, "Ell_LinMetric");
- Ell_RegisterEq(Ell_LinFlatRegistry, "Ell_LinFlat");
+ err = Ell_RegisterEq(Ell_LinConfMetricRegistry, "Ell_LinConfMetric");
+ err = Ell_RegisterEq(Ell_BrBrConfMetricRegistry,"Ell_BrBrConfMetric");
+ err = Ell_RegisterEq(Ell_PolyConfMetricRegistry,"Ell_PolyConfMetric");
+ err = Ell_RegisterEq(Ell_LinMetricRegistry, "Ell_LinMetric");
+ err = Ell_RegisterEq(Ell_LinFlatRegistry, "Ell_LinFlat");
err = Ell_CreateKey(CCTK_VARIABLE_STRING,
"EllLinFlat::Bnd");