aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgoodale <goodale@7256fff6-a868-4c47-a7f4-99a4b5411c7d>1999-12-16 13:28:36 +0000
committergoodale <goodale@7256fff6-a868-4c47-a7f4-99a4b5411c7d>1999-12-16 13:28:36 +0000
commitab7fca677615176f4d16ec6f3d09b5ceb6fb7be7 (patch)
treed8b3982bef4295298cb95d434a4295a16d01860e
parentf56ce72d078eea52215a31fd38b676f5e18e1abc (diff)
This commit was generated by cvs2svn to compensate for changes in r2, which
included commits to RCS files with non-trunk default branches. git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinBase/EOS_Base/trunk@3 7256fff6-a868-4c47-a7f4-99a4b5411c7d
-rw-r--r--README7
-rw-r--r--interface.ccl7
-rw-r--r--param.ccl2
-rw-r--r--schedule.ccl2
-rw-r--r--src/EOS_Base.h42
-rw-r--r--src/EOS_Base.inc20
-rw-r--r--src/Register.c247
-rw-r--r--src/make.code.defn9
8 files changed, 336 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..c54f8d5
--- /dev/null
+++ b/README
@@ -0,0 +1,7 @@
+Cactus Code Thorn EOS_Base
+Authors : ...
+CVS info : $Header$
+--------------------------------------------------------------------------
+
+Purpose of the thorn:
+
diff --git a/interface.ccl b/interface.ccl
new file mode 100644
index 0000000..c6fa47a
--- /dev/null
+++ b/interface.ccl
@@ -0,0 +1,7 @@
+# Interface definition for thorn EOS_Base
+# $Header$
+
+implements: EOS_Base
+
+INCLUDES: EOS_Base.h in EOS_Base.h
+INCLUDES: EOS_Base.inc in EOS_Base.inc
diff --git a/param.ccl b/param.ccl
new file mode 100644
index 0000000..4b86e8b
--- /dev/null
+++ b/param.ccl
@@ -0,0 +1,2 @@
+# Parameter definitions for thorn EOS_Base
+# $Header$
diff --git a/schedule.ccl b/schedule.ccl
new file mode 100644
index 0000000..079caae
--- /dev/null
+++ b/schedule.ccl
@@ -0,0 +1,2 @@
+# Schedule definitions for thorn EOS_Base
+# $Header$
diff --git a/src/EOS_Base.h b/src/EOS_Base.h
new file mode 100644
index 0000000..ce4a982
--- /dev/null
+++ b/src/EOS_Base.h
@@ -0,0 +1,42 @@
+ /*@@
+ @file EOS_Base.h
+ @date Tue Dec 14 22:18:46 1999
+ @author Tom Goodale
+ @desc
+ Header file for EOS basic functions
+ @enddesc
+ @versions $Header$
+ @@*/
+
+#ifndef _EOS_BASE_H_
+#define _EOS_BASE_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+int EOS_RegisterMethod(const char *name);
+int EOS_Handle(const char *name);
+
+
+#define EOS_REGISTER_FUNCTION(x) int EOS_Register ## x (int , CCTK_REAL (*func)(CCTK_REAL, CCTK_REAL))
+#define EOS_CALL_FUNCTION(x) CCTK_REAL EOS_ ## x (int , CCTK_REAL, CCTK_REAL)
+
+EOS_REGISTER_FUNCTION(Pressure);
+EOS_REGISTER_FUNCTION(SpecificIntEnergy);
+EOS_REGISTER_FUNCTION(RestMassDens);
+EOS_REGISTER_FUNCTION(DPressByDRho);
+EOS_REGISTER_FUNCTION(DPressByDEps);
+
+EOS_CALL_FUNCTION(Pressure);
+EOS_CALL_FUNCTION(SpecificIntEnergy);
+EOS_CALL_FUNCTION(RestMassDens);
+EOS_CALL_FUNCTION(DPressByDRho);
+EOS_CALL_FUNCTION(DPressByDEps);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* EOS_Base.h */
diff --git a/src/EOS_Base.inc b/src/EOS_Base.inc
new file mode 100644
index 0000000..70d9a8d
--- /dev/null
+++ b/src/EOS_Base.inc
@@ -0,0 +1,20 @@
+c /*@@
+c @header EOS_Base.inc
+c @date Thu Dec 16 14:16:25 1999
+c @author Tom Goodale
+c @desc
+c
+c @enddesc
+c @version $Header$
+c @@*/
+
+#ifndef _EOS_BASE_INC_
+#define _EOS_BASE_INC_
+
+ CCTK_REAL EOS_Pressure
+ CCTK_REAL EOS_SpecificIntEnergy
+ CCTK_REAL EOS_RestMassDens
+ CCTK_REAL EOS_DPressByDRho
+ CCTK_REAL EOS_DPressByDEps
+
+#endif /* _EOS_BASE_INC_ */
diff --git a/src/Register.c b/src/Register.c
new file mode 100644
index 0000000..7134e91
--- /dev/null
+++ b/src/Register.c
@@ -0,0 +1,247 @@
+ /*@@
+ @file Register.c
+ @date Tue Dec 14 20:55:06 1999
+ @author Tom Goodale
+ @desc
+ Functions for registering and calling EOS routines
+ @enddesc
+ @@*/
+
+static char *rcsid = "$Header$";
+
+#include <stdlib.h>
+
+#include "cctk.h"
+#include "cctk_FortranString.h"
+
+#include "StoreHandledData.h"
+
+#include "EOS_Base.h"
+
+static cHandledData *methods = NULL;
+
+enum call_methods {none, c, f} ;
+
+typedef struct
+{
+ enum call_methods lang;
+
+ CCTK_REAL (*f)(CCTK_REAL *, CCTK_REAL *);
+ CCTK_REAL (*c)(CCTK_REAL, CCTK_REAL);
+} func_t;
+
+typedef struct
+{
+ func_t Pressure;
+ func_t SpecificIntEnergy;
+ func_t RestMassDens;
+ func_t DPressByDRho;
+ func_t DPressByDEps;
+} method_t;
+
+ /*@@
+ @routine EOS_RegisterMethod
+ @date Tue Dec 14 22:04:23 1999
+ @author Tom Goodale
+ @desc
+ Registers an EOS method
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int EOS_RegisterMethod(const char *name)
+{
+ int handle;
+
+ method_t *method;
+
+ method = (method_t *)malloc(sizeof(method_t));
+
+ if(method)
+ {
+ method->Pressure.lang = none;
+ method->SpecificIntEnergy.lang = none;
+ method->RestMassDens.lang = none;
+ method->DPressByDRho.lang = none;
+ method->DPressByDEps.lang = none;
+
+ handle = Util_NewHandle(&methods, name, (void *)method);
+ }
+ else
+ {
+ handle = -1;
+ }
+
+ return handle;
+}
+
+void FORTRAN_NAME(EOS_RegisterMethod)(int *handle, ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE(name)
+
+ *handle = EOS_RegisterMethod(name);
+
+ free(name);
+}
+
+
+ /*@@
+ @routine EOS_Handle
+ @date Tue Dec 14 22:04:47 1999
+ @author Tom Goodale
+ @desc
+ Gets the handle associated with an EOS method
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int EOS_Handle(const char *name)
+{
+ int handle;
+ method_t method;
+
+ handle = Util_GetHandle(methods, name, (void *)&method);
+
+ return handle;
+}
+
+void FORTRAN_NAME(EOS_Handle)(int *handle, ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE(name)
+
+ *handle = EOS_Handle(name);
+
+ free(name);
+}
+
+#define REGISTER_FUNCTION(x) \
+int EOS_Register ## x (int handle, CCTK_REAL (*func)(CCTK_REAL, CCTK_REAL)) \
+{ \
+ int retval; \
+ method_t *method; \
+ \
+ method = (method_t *)Util_GetHandledData(methods, handle); \
+ \
+ if(method) \
+ { \
+ method->x.lang = c; \
+ method->x.c = func; \
+ retval = 0; \
+ } \
+ else \
+ { \
+ retval = 1; \
+ } \
+ \
+ return retval; \
+}
+
+/* Functions to register C EOS functions */
+REGISTER_FUNCTION(Pressure)
+REGISTER_FUNCTION(SpecificIntEnergy)
+REGISTER_FUNCTION(RestMassDens)
+REGISTER_FUNCTION(DPressByDRho)
+REGISTER_FUNCTION(DPressByDEps)
+
+
+#define REGISTER_FORTRAN_FUNCTION(x)\
+(int *retval, int *handle, CCTK_REAL (*func)(CCTK_REAL *, CCTK_REAL *)) \
+{ \
+ method_t *method; \
+ \
+ method = (method_t *)Util_GetHandledData(methods, *handle); \
+ \
+ if(method) \
+ { \
+ method->x.lang = f; \
+ method->x.f = func; \
+ *retval = 0; \
+ } \
+ else \
+ { \
+ *retval = 1; \
+ } \
+ \
+}
+
+/* Functions to register Fortran EOS functions */
+void FORTRAN_NAME(EOS_RegisterPressure) REGISTER_FORTRAN_FUNCTION(Pressure)
+void FORTRAN_NAME(EOS_RegisterSpecificIntEnergy) REGISTER_FORTRAN_FUNCTION(SpecificIntEnergy)
+void FORTRAN_NAME(EOS_RegisterRestMassDens) REGISTER_FORTRAN_FUNCTION(RestMassDens)
+void FORTRAN_NAME(EOS_RegisterDPressByDRho) REGISTER_FORTRAN_FUNCTION(DPressByDRho)
+void FORTRAN_NAME(EOS_RegisterDPressByDEps) REGISTER_FORTRAN_FUNCTION(DPressByDEps)
+
+#define CALL_FUNC(x) \
+CCTK_REAL EOS_ ## x (int handle, CCTK_REAL a, CCTK_REAL b) \
+{ \
+ CCTK_REAL retval; \
+ method_t *method; \
+ \
+ method = (method_t *)Util_GetHandledData(methods, handle); \
+ \
+ if(method && method->x.lang != none) \
+ { \
+ if(method->x.lang == c) \
+ { \
+ retval = method->x.c(a,b); \
+ } \
+ else \
+ { \
+ retval = method->x.f(&a, &b); \
+ } \
+ } \
+ else \
+ { \
+ retval = -1; \
+ } \
+ return retval; \
+}
+
+/* Functions to call EOS functions from C */
+CALL_FUNC(Pressure)
+CALL_FUNC(SpecificIntEnergy)
+CALL_FUNC(RestMassDens)
+CALL_FUNC(DPressByDRho)
+CALL_FUNC(DPressByDEps)
+
+#define CALL_FORTRAN_FUNC(x) \
+(int *handle, CCTK_REAL *a, CCTK_REAL *b) \
+{ \
+ CCTK_REAL retval; \
+ method_t *method; \
+ \
+ method = (method_t *)Util_GetHandledData(methods, *handle); \
+ \
+ if(method && method->x.lang != none) \
+ { \
+ if(method->x.lang == c) \
+ { \
+ retval = method->x.c(*a,*b); \
+ } \
+ else \
+ { \
+ retval = method->x.f(a, b); \
+ } \
+ } \
+ else \
+ { \
+ retval = -1; \
+ } \
+ return retval; \
+}
+
+/* Functions to call EOS functions from Fortran*/
+CCTK_REAL FORTRAN_NAME(EOS_Pressure) CALL_FORTRAN_FUNC(Pressure)
+CCTK_REAL FORTRAN_NAME(EOS_SpecificIntEnergy) CALL_FORTRAN_FUNC(SpecificIntEnergy)
+CCTK_REAL FORTRAN_NAME(EOS_RestMassDens) CALL_FORTRAN_FUNC(RestMassDens)
+CCTK_REAL FORTRAN_NAME(EOS_DPressByDRho) CALL_FORTRAN_FUNC(DPressByDRho)
+CCTK_REAL FORTRAN_NAME(EOS_DPressByDEps) CALL_FORTRAN_FUNC(DPressByDEps)
+
diff --git a/src/make.code.defn b/src/make.code.defn
new file mode 100644
index 0000000..b22025f
--- /dev/null
+++ b/src/make.code.defn
@@ -0,0 +1,9 @@
+# Main make.code.defn file for thorn EOS_Base
+# $Header$
+
+# Source files in this directory
+SRCS = Register.c
+
+# Subdirectories containing source files
+SUBDIRS =
+