diff options
Diffstat (limited to 'src/ConfPhys.c')
-rw-r--r-- | src/ConfPhys.c | 277 |
1 files changed, 277 insertions, 0 deletions
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 ************************* + ********************************************************************/ |