From fc8dc00bf59a006df78044daef3811abdae874b3 Mon Sep 17 00:00:00 2001 From: goodale Date: Tue, 30 Apr 2002 07:54:15 +0000 Subject: Added StaticConformal_PhysToConfInPlace and StaticConformal_ConfToPhysInPlace. I was going to add them as aliased functions, but don't think the alias stuff can cope with ints as opposed to CCTK_INTs at the moment, but cctk_lsh is an array of ints. Tom git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinBase/StaticConformal/trunk@8 0cbbb82d-14ec-4423-a1fb-2ab18257ecaa --- interface.ccl | 12 +++ src/ConfPhys.c | 277 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/make.code.defn | 2 +- 3 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 src/ConfPhys.c diff --git a/interface.ccl b/interface.ccl index 7454ed4..d9ccc56 100644 --- a/interface.ccl +++ b/interface.ccl @@ -33,3 +33,15 @@ REAL confac_2derivs TYPE = GF #{ # psi_11, psi_12, psi_13, psi_22, psi_23, psi_33 #} "Second spatial derivatives of conformal factor divided by psi" + +#void FUNCTION StaticConformal_ConfToPhysInPlace CCTK_INT nx, CCTK_INT ny, CCTK_INT nz, \ +# CCTK_REAL:ARRAY gxx, CCTK_REAL:ARRAY gxy, CCTK_REAL:ARRAY gxz, \ +# CCTK_REAL:ARRAY gyy, CCTK_REAL:ARRAY gyz, CCTK_REAL:ARRAY gzz, + +#PROVIDES FUNCTION StaticConformal_ConfToPhysInPlace WITH StaticConformali_ConfToPhysInPlace + +#void FUNCTION StaticConformal_PhysToConfInPlace CCTK_INT nx, CCTK_INT ny, CCTK_INT nz, \ +# CCTK_REAL:ARRAY gxx, CCTK_REAL:ARRAY gxy, CCTK_REAL:ARRAY gxz, \ +# CCTK_REAL:ARRAY gyy, CCTK_REAL:ARRAY gyz, CCTK_REAL:ARRAY gzz, + +#PROVIDES FUNCTION StaticConformal_PhysToConfInPlace WITH StaticConformali_PhysToConfInPlace diff --git a/src/ConfPhys.c b/src/ConfPhys.c new file mode 100644 index 0000000..65e7f3b --- /dev/null +++ b/src/ConfPhys.c @@ -0,0 +1,277 @@ +/*@@ + @file ConfPhys.c + @date September 3rd 1999 + @author Gabrielle Allen + @desc + Conversions between physical and conformal metrics. + Be very careful using these functions, note that + conformal_state is not changed, this is up to the + calling routine + @enddesc + @version $Header$ + @@*/ + + +#include "cctk.h" + +static const char *rcsid = "$Header$"; + +CCTK_FILEVERSION(CactusEinstein_StaticConformal_ConfPhys_c) + +/******************************************************************** + ********************* Local Data Types *********************** + ********************************************************************/ + +/******************************************************************** + ********************* Local Routine Prototypes ********************* + ********************************************************************/ + +/******************************************************************** + ***************** Scheduled Routine Prototypes ********************* + ********************************************************************/ + +/******************************************************************** + ********************* Other Routine Prototypes ********************* + ********************************************************************/ + +void CCTK_FCALL CCTK_FNAME (StaticConformal_PhysToConfInPlace) (int *nx, + int *ny, + int *nz, + CCTK_REAL *psi, + CCTK_REAL *gxx, + CCTK_REAL *gxy, + CCTK_REAL *gxz, + CCTK_REAL *gyy, + CCTK_REAL *gyz, + CCTK_REAL *gzz); +void CCTK_FCALL CCTK_FNAME (StaticConformal_ConfToPhysInPlace) (int *nx, + int *ny, + int *nz, + CCTK_REAL *psi, + CCTK_REAL *gxx, + CCTK_REAL *gxy, + CCTK_REAL *gxz, + CCTK_REAL *gyy, + CCTK_REAL *gyz, + CCTK_REAL *gzz); + +/******************************************************************** + ********************* Local Data ***************************** + ********************************************************************/ + +/******************************************************************** + ********************* External Routines ********************** + ********************************************************************/ + + + /*@@ + @routine StaticConformal_ConfToPhysInPlace + @date September 3rd 1999 + @author Gabrielle Allen + @desc + Convert the conformal metric to the physical in place. + @enddesc + @calls + @calledby + @history + + @endhistory + @var nx + @vdesc number of points in the x direction + @vtype int + @vio in + @var ny + @vdesc number of points in the y direction + @vtype int + @vio in + @var nz + @vdesc number of points in the z direction + @vtype int + @vio in + @var psi + @vdesc conformal factor + @vtype const CCTK_REAL * + @vio in + @var gxx + @vdesc xx componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gxy + @vdesc xy componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gxz + @vdesc xz componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gyy + @vdesc yy componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gyz + @vdesc yz componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gzz + @vdesc zz componenent of metric + @vtype CCTK_REAL * + @vio inout + + @@*/ +void StaticConformal_ConfToPhysInPlace (int nx, + int ny, + int nz, + const CCTK_REAL *psi, + CCTK_REAL *gxx, + CCTK_REAL *gxy, + CCTK_REAL *gxz, + CCTK_REAL *gyy, + CCTK_REAL *gyz, + CCTK_REAL *gzz) +{ + CCTK_REAL psi4; + int index; + + + CCTK_WARN (4, "Converting metric: conformal -> physical"); + + index = nx * ny * nz; + while (--index >= 0) + { + /* this should be faster than psi4 = pow (psi[index], 4) */ + psi4 = psi[index] * psi[index]; + psi4 = psi4 * psi4; + + gxx[index] *= psi4; + gxy[index] *= psi4; + gxz[index] *= psi4; + gyy[index] *= psi4; + gyz[index] *= psi4; + gzz[index] *= psi4; + } +} + + +void CCTK_FCALL CCTK_FNAME (StaticConformal_ConfToPhysInPlace) (int *nx, + int *ny, + int *nz, + CCTK_REAL *psi, + CCTK_REAL *gxx, + CCTK_REAL *gxy, + CCTK_REAL *gxz, + CCTK_REAL *gyy, + CCTK_REAL *gyz, + CCTK_REAL *gzz) +{ + StaticConformal_ConfToPhysInPlace (*nx, *ny, *nz, psi, gxx, gxy, gxz, gyy, gyz, gzz); +} + + + /*@@ + @routine StaticConformal_PhysToConfInPlace + @date September 3rd 1999 + @author Gabrielle Allen + @desc + Convert the physical metric to the conformal in place. + @enddesc + @calls + @calledby + @history + + @endhistory + @var nx + @vdesc number of points in the x direction + @vtype int + @vio in + @var ny + @vdesc number of points in the y direction + @vtype int + @vio in + @var nz + @vdesc number of points in the z direction + @vtype int + @vio in + @var psi + @vdesc conformal factor + @vtype const CCTK_REAL * + @vio in + @var gxx + @vdesc xx componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gxy + @vdesc xy componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gxz + @vdesc xz componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gyy + @vdesc yy componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gyz + @vdesc yz componenent of metric + @vtype CCTK_REAL * + @vio inout + @var gzz + @vdesc zz componenent of metric + @vtype CCTK_REAL * + @vio inout + + @@*/ +void StaticConformal_PhysToConfInPlace (int nx, + int ny, + int nz, + const CCTK_REAL *psi, + CCTK_REAL *gxx, + CCTK_REAL *gxy, + CCTK_REAL *gxz, + CCTK_REAL *gyy, + CCTK_REAL *gyz, + CCTK_REAL *gzz) +{ + int index; + CCTK_REAL psi4; + + + CCTK_WARN (4, "Converting metric: physical -> conformal"); + + index = nx * ny * nz; + while (--index >= 0) + { + /* this should be faster than psi4 = pow (psi[index], 4) */ + psi4 = psi[index] * psi[index]; + psi4 = psi4 * psi4; + + /* get the reciprocal for turning divisions into multiplications */ + psi4 = 1.0 / psi4; + + gxx[index] *= psi4; + gxy[index] *= psi4; + gxz[index] *= psi4; + gyy[index] *= psi4; + gyz[index] *= psi4; + gzz[index] *= psi4; + } +} + + +void CCTK_FCALL CCTK_FNAME (StaticConformal_PhysToConfInPlace) (int *nx, + int *ny, + int *nz, + CCTK_REAL *psi, + CCTK_REAL *gxx, + CCTK_REAL *gxy, + CCTK_REAL *gxz, + CCTK_REAL *gyy, + CCTK_REAL *gyz, + CCTK_REAL *gzz) +{ + StaticConformal_PhysToConfInPlace (*nx, *ny, *nz, psi, gxx, gxy, gxz, gyy, gyz, gzz); +} + +/******************************************************************** + ********************* Local Routines ************************* + ********************************************************************/ diff --git a/src/make.code.defn b/src/make.code.defn index 176a3a0..db87b26 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -2,7 +2,7 @@ # $Header$ # Source files in this directory -SRCS = Initialise.c +SRCS = Initialise.c ConfPhys.c # Subdirectories containing source files SUBDIRS = -- cgit v1.2.3