From 67bdd7289f8d34c210939ca00ed84652dbcd029f Mon Sep 17 00:00:00 2001 From: goodale Date: Mon, 17 May 2004 12:28:57 +0000 Subject: Untabified. Please try to adhere to the Cactus coding guidelines when modifying or adding files. git-svn-id: http://svn.cactuscode.org/arrangements/CactusElliptic/EllSOR/trunk@91 fa3da13c-9f13-4301-a575-cf5b8c5e1907 --- src/ConfMetric.c | 58 +++++++++++++++++----------------- src/Flat.c | 94 +++++++++++++++++++++++++++----------------------------- src/Startup.c | 46 +++++++++++++-------------- src/Wrapper.c | 71 +++++++++++++++++++++--------------------- 4 files changed, 133 insertions(+), 136 deletions(-) diff --git a/src/ConfMetric.c b/src/ConfMetric.c index e4accc5..db9fb98 100644 --- a/src/ConfMetric.c +++ b/src/ConfMetric.c @@ -36,8 +36,8 @@ CCTK_FILEVERSION(CactusElliptic_EllSOR_ConfMetric_c) ********************************************************************/ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, - int FieldIndex, int MIndex, int NIndex, - CCTK_REAL *AbsTol, CCTK_REAL *RelTol); + int FieldIndex, int MIndex, int NIndex, + CCTK_REAL *AbsTol, CCTK_REAL *RelTol); /******************************************************************** ***************** Scheduled Routine Prototypes ********************* @@ -75,8 +75,8 @@ static int firstcall = 1; @@*/ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, - int FieldIndex, int MIndex, int NIndex, - CCTK_REAL *AbsTol, CCTK_REAL *RelTol) + int FieldIndex, int MIndex, int NIndex, + CCTK_REAL *AbsTol, CCTK_REAL *RelTol) { DECLARE_CCTK_PARAMETERS @@ -145,7 +145,7 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, if (sum_handle<0) { CCTK_WARN(1,"SORConfMetric3D: " - "Cannot get handle for sum reduction"); + "Cannot get handle for sum reduction"); retval = ELL_FAILURE; } @@ -178,12 +178,12 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, ierr = Ell_GetRealKey(&finf, "EllLinConfMetric::Bnd::Robin::inf"); if (ierr < 0) { - CCTK_WARN(1,"EllLinConfMetric::Bnd::Robin::inf is not set"); + CCTK_WARN(1,"EllLinConfMetric::Bnd::Robin::inf is not set"); } ierr = Ell_GetIntKey (&npow, "EllLinConfMetric::Bnd::Robin::falloff"); if (ierr < 0) { - CCTK_WARN(1,"EllLinConfMetric::Bnd::Robin::falloff is not set"); + CCTK_WARN(1,"EllLinConfMetric::Bnd::Robin::falloff is not set"); } } else @@ -191,12 +191,12 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, ierr = Ell_GetRealKey(&finf, "EllLinMetric::Bnd::Robin::inf"); if (ierr < 0) { - CCTK_WARN(1,"EllLinMetric::Bnd::Robin::inf is not set"); + CCTK_WARN(1,"EllLinMetric::Bnd::Robin::inf is not set"); } ierr = Ell_GetIntKey (&npow, "EllLinMetric::Bnd::Robin::falloff"); if (ierr < 0) { - CCTK_WARN(1,"EllLinMetric::Bnd::Robin::falloff is not set"); + CCTK_WARN(1,"EllLinMetric::Bnd::Robin::falloff is not set"); } } } @@ -205,7 +205,7 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, if (Ell_GetIntKey(&maxit, "Ell::SORmaxit") == ELLGET_NOTSET) { CCTK_WARN(1,"SORConfMetric3D: Ell::SORmaxit not set. " - "Maximum allowed iterations being set to 100."); + "Maximum allowed iterations being set to 100."); maxit = 100; } @@ -217,7 +217,7 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, { const char tmpstr[6] = "const"; CCTK_WARN(3,"SORConfMetric3D: Ell::SORaccel not set. " - "Omega being set to a constant value of 1.8."); + "Omega being set to a constant value of 1.8."); sor_accel = strdup(tmpstr); } @@ -384,7 +384,7 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, uyy[ijk]=(-SQR(gxz[ijk]) + gxx[ijk]*gzz[ijk])*detrec_pm4; uyz[ijk]=( gxy[ijk]*gxz[ijk] - gxx[ijk]*gyz[ijk])*detrec_pm4; uzz[ijk]=(-SQR(gxy[ijk]) + gxx[ijk]*gyy[ijk])*detrec_pm4; - + det = det*p12; sqrtdet= sqrt(det); @@ -405,7 +405,7 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, uxz[ijk]=uxz[ijk]*dxdz*sqrtdet; uyz[ijk]=uyz[ijk]*dydz*sqrtdet; - } + } /* Initialize omega. */ /* TODO: Make it so that the value of the constant omega can be set. */ @@ -435,9 +435,9 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, { for (j=1; jcctk_lsh[1]-1; j++) { - for (i=1; icctk_lsh[0]-1; i++) + for (i=1; icctk_lsh[0]-1; i++) { - if ((origin_sign+i+j+k)%2 == sorit%2) + if ((origin_sign+i+j+k)%2 == sorit%2) { ijk = CCTK_GFINDEX3D(GH,i ,j ,k ); @@ -452,12 +452,12 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, ipjmk = CCTK_GFINDEX3D(GH,i+1,j-1,k ); imjpk = CCTK_GFINDEX3D(GH,i-1,j+1,k ); imjmk = CCTK_GFINDEX3D(GH,i-1,j-1,k ); - + ijpkp = CCTK_GFINDEX3D(GH,i ,j+1,k+1); ijpkm = CCTK_GFINDEX3D(GH,i ,j+1,k-1); ijmkp = CCTK_GFINDEX3D(GH,i ,j-1,k+1); ijmkm = CCTK_GFINDEX3D(GH,i ,j-1,k-1); - + ipjkp = CCTK_GFINDEX3D(GH,i+1,j ,k+1); ipjkm = CCTK_GFINDEX3D(GH,i+1,j ,k-1); imjkp = CCTK_GFINDEX3D(GH,i-1,j ,k+1); @@ -466,7 +466,7 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, ac = -1.0*uxx[ipjk] - 2.0*uxx[ijk] - 1.0*uxx[imjk] -1.0*uyy[ijpk] - 2.0*uyy[ijk] - 1.0*uyy[ijmk] -1.0*uzz[ijkp] - 2.0*uzz[ijk] - 1.0*uzz[ijkm]; - + if (Mstorage) { ac += Mlin[ijk]; @@ -478,30 +478,30 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, as = uyy[ijmk]+uyy[ijk]; at = uzz[ijkp]+uzz[ijk]; ab = uzz[ijkm]+uzz[ijk]; - + ane = uxy[ijpk]+uxy[ipjk]; anw =-uxy[imjk]-uxy[ijpk]; ase =-uxy[ipjk]-uxy[ijmk]; asw = uxy[imjk]+uxy[ijmk]; - + ate = uxz[ijkp]+uxz[ipjk]; atw =-uxz[imjk]-uxz[ijkp]; abe =-uxz[ipjk]-uxz[ijkm]; abw = uxz[imjk]+uxz[ijkm]; - + atn = uyz[ijpk]+uyz[ijkp]; ats =-uyz[ijkp]-uyz[ijmk]; abn =-uyz[ijkm]-uyz[ijpk]; absol = uyz[ijkm]+uyz[ijmk]; - + residual = ac * var[ijk] + ae *var[ipjk] + aw*var[imjk] + an *var[ijpk] + as*var[ijmk] + at *var[ijkp] + ab*var[ijkm]; - + residual = residual + ane*var[ipjpk] + anw*var[imjpk]; - + residual = residual + ase*var[ipjmk] + asw*var[imjmk]; @@ -521,13 +521,13 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, var[ijk] = var[ijk] - omega*residual/ac; } - } + } } } /* reduction operation on processor-local residual values */ if (CCTK_ReduceLocScalar(GH, -1, sum_handle, - &resnorm, &glob_residual, CCTK_VARIABLE_REAL)<0) + &resnorm, &glob_residual, CCTK_VARIABLE_REAL)<0) { CCTK_WARN(1,"SORConfMetric3D: Reduction of residual failed"); } @@ -556,8 +556,8 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, if (ierr < 0) { CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, - "ConfMetric3D: Synchronization of %s failed (Error: %d)", - CCTK_VarName(FieldIndex),ierr); + "ConfMetric3D: Synchronization of %s failed (Error: %d)", + CCTK_VarName(FieldIndex),ierr); } /* Leave iteration loop if tolerance criterium is met */ @@ -593,7 +593,7 @@ int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, if (glob_residual>tol) { CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, - "SOR Solver did not converge (reached tol:%f at %d iterations, requested tol:%f",glob_residual,sorit,tol); + "SOR Solver did not converge (reached tol:%f at %d iterations, requested tol:%f",glob_residual,sorit,tol); retval = ELL_NOCONVERGENCE; } diff --git a/src/Flat.c b/src/Flat.c index bfc5df5..f83d5a1 100644 --- a/src/Flat.c +++ b/src/Flat.c @@ -27,10 +27,10 @@ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusElliptic_EllSOR_Flat_c) int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, - CCTK_REAL *AbsTol, CCTK_REAL *RelTol); + CCTK_REAL *AbsTol, CCTK_REAL *RelTol); int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, - CCTK_REAL *AbsTol, CCTK_REAL *RelTol) + CCTK_REAL *AbsTol, CCTK_REAL *RelTol) { DECLARE_CCTK_PARAMETERS @@ -104,18 +104,18 @@ int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, sw[2]=1; if (Ell_GetRealKey(&finf, "EllLinFlat::Bnd::Robin::inf") == - ELLGET_NOTSET) + ELLGET_NOTSET) { - CCTK_WARN(1,"SORFlat3D: EllLinFlat::Bnd::Robin::inf not set, " - "setting to 1"); - finf = 1; + CCTK_WARN(1,"SORFlat3D: EllLinFlat::Bnd::Robin::inf not set, " + "setting to 1"); + finf = 1; } if (Ell_GetIntKey(&npow, "EllLinFlat::Bnd::Robin::falloff") - == ELLGET_NOTSET) + == ELLGET_NOTSET) { - CCTK_WARN(1,"SORFlat3D: EllLinFlat::Bnd::Robin::falloff not set, " - "setting to 1"); - npow = 1; + CCTK_WARN(1,"SORFlat3D: EllLinFlat::Bnd::Robin::falloff not set, " + "setting to 1"); + npow = 1; } } } @@ -124,7 +124,7 @@ int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, if (Ell_GetIntKey(&maxit, "Ell::SORmaxit") == ELLGET_NOTSET) { CCTK_WARN(1,"SORFlat3D: Ell::SORmaxit not set. " - "Maximum allowed iterations being set to 100."); + "Maximum allowed iterations being set to 100."); maxit = 100; } @@ -136,7 +136,7 @@ int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, { const char tmpstr[6] = "const"; CCTK_WARN(3, "SORFlat3D: Ell::SORaccel not set. " - "Omega being set to a constant value of 1.8."); + "Omega being set to a constant value of 1.8."); sor_accel = strdup(tmpstr); } @@ -149,15 +149,15 @@ int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, { if (CCTK_Equals(sor_accel, "cheb")) { - CCTK_INFO("SOR with Chebyshev acceleration"); + CCTK_INFO("SOR with Chebyshev acceleration"); } else if (CCTK_Equals(sor_accel, "const")) { - CCTK_INFO("SOR with hardcoded omega = 1.8"); + CCTK_INFO("SOR with hardcoded omega = 1.8"); } else if (CCTK_Equals(sor_accel, "none")) { - CCTK_INFO("SOR with unaccelerated relaxation (omega = 1)"); + CCTK_INFO("SOR with unaccelerated relaxation (omega = 1)"); } else { @@ -249,47 +249,47 @@ int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, { for (j=1; jcctk_lsh[1]-1; j++) { - for (i=1; icctk_lsh[0]-1; i++) + for (i=1; icctk_lsh[0]-1; i++) { if ((origin_sign + i + j + k)%2 == sorit%2) { - ac = ac_orig; - - ijk = CCTK_GFINDEX3D(GH,i ,j ,k ); - ipjk = CCTK_GFINDEX3D(GH,i+1,j ,k ); - imjk = CCTK_GFINDEX3D(GH,i-1,j ,k ); - ijpk = CCTK_GFINDEX3D(GH,i ,j+1,k ); - ijmk = CCTK_GFINDEX3D(GH,i ,j-1,k ); - ijkp = CCTK_GFINDEX3D(GH,i ,j ,k+1); - ijkm = CCTK_GFINDEX3D(GH,i ,j ,k-1); - - if (Mstorage) - { - ac += Mlin[ijk]; - } - - residual = ac * var[ijk] - + ae*var[ipjk] + aw*var[imjk] - + an*var[ijpk] + as*var[ijmk] - + at*var[ijkp] + ab*var[ijkm]; - - if (Nstorage) - { - residual += Nlin[ijk]; - } - - resnorm += fabs(residual); - - var[ijk] -= omega*residual/ac; + ac = ac_orig; + + ijk = CCTK_GFINDEX3D(GH,i ,j ,k ); + ipjk = CCTK_GFINDEX3D(GH,i+1,j ,k ); + imjk = CCTK_GFINDEX3D(GH,i-1,j ,k ); + ijpk = CCTK_GFINDEX3D(GH,i ,j+1,k ); + ijmk = CCTK_GFINDEX3D(GH,i ,j-1,k ); + ijkp = CCTK_GFINDEX3D(GH,i ,j ,k+1); + ijkm = CCTK_GFINDEX3D(GH,i ,j ,k-1); + + if (Mstorage) + { + ac += Mlin[ijk]; + } + + residual = ac * var[ijk] + + ae*var[ipjk] + aw*var[imjk] + + an*var[ijpk] + as*var[ijmk] + + at*var[ijkp] + ab*var[ijkm]; + + if (Nstorage) + { + residual += Nlin[ijk]; + } + + resnorm += fabs(residual); + + var[ijk] -= omega*residual/ac; } - } + } } } /* reduction operation on processor-local residual values */ if (CCTK_ReduceLocScalar(GH, -1, sum_handle, - &resnorm, &glob_residual, CCTK_VARIABLE_REAL)<0) + &resnorm, &glob_residual, CCTK_VARIABLE_REAL)<0) { CCTK_WARN(1,"SORFlat3D: Reduction of Norm failed"); } @@ -370,5 +370,3 @@ int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, return retval; } - - diff --git a/src/Startup.c b/src/Startup.c index 7f4249d..2cf60ea 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -34,25 +34,25 @@ CCTK_FILEVERSION(CactusElliptic_EllSOR_Startup_c) void EllSOR_Register(CCTK_ARGUMENTS); void SORConfMetric(cGH *GH, - int *MetricPsiI, - int FieldI, - int MI, - int NI, - CCTK_REAL *AbsTol, - CCTK_REAL *RelTol); + int *MetricPsiI, + int FieldI, + int MI, + int NI, + CCTK_REAL *AbsTol, + CCTK_REAL *RelTol); void SORMetric(cGH *GH, - int *MetricI, - int FieldI, - int MI, - int NI, - CCTK_REAL *AbsTol, - CCTK_REAL *RelTol); + int *MetricI, + int FieldI, + int MI, + int NI, + CCTK_REAL *AbsTol, + CCTK_REAL *RelTol); void SORFlat(cGH *GH, - int FieldI, - int MI, - int NI, - CCTK_REAL *AbsTol, - CCTK_REAL *RelTol); + int FieldI, + int MI, + int NI, + CCTK_REAL *AbsTol, + CCTK_REAL *RelTol); /******************************************************************** @@ -98,17 +98,17 @@ void EllSOR_Register(CCTK_ARGUMENTS) int err; if (Ell_RegisterSolver(SORConfMetric,"sor","Ell_LinConfMetric") - != ELL_SUCCESS) + != ELL_SUCCESS) { CCTK_WARN(0, - "EllSOR_Register: Failed to register sor for Ell_LinConfMetric"); + "EllSOR_Register: Failed to register sor for Ell_LinConfMetric"); } if (Ell_RegisterSolver(SORMetric,"sor","Ell_LinMetric") - != ELL_SUCCESS) + != ELL_SUCCESS) { CCTK_WARN(0, - "EllSOR_Register: Failed to register sor for Ell_LinMetric"); + "EllSOR_Register: Failed to register sor for Ell_LinMetric"); } if (Ell_RegisterSolver(SORFlat,"sor","Ell_LinFlat") != ELL_SUCCESS) @@ -124,13 +124,13 @@ void EllSOR_Register(CCTK_ARGUMENTS) if (err == ELLCREATE_FAILED) { CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, - "EllSOR_Register: Failed to create key EllLinFlat::Bnd::Robin (Error %d)",err); + "EllSOR_Register: Failed to create key EllLinFlat::Bnd::Robin (Error %d)",err); } err = Ell_CreateKey(CCTK_VARIABLE_STRING,"EllLinFlat::Bnd::Const"); if (err == ELLCREATE_FAILED) { CCTK_WARN(1, - "EllSOR_Register: Failed to create key EllLinFlat::Bnd::Const"); + "EllSOR_Register: Failed to create key EllLinFlat::Bnd::Const"); } /* Create a key for the maximum number of iterations allowed. */ diff --git a/src/Wrapper.c b/src/Wrapper.c index cbbca49..251b21e 100644 --- a/src/Wrapper.c +++ b/src/Wrapper.c @@ -29,23 +29,23 @@ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusElliptic_EllSOR_Wrapper_c) int SORFlat3D(cGH *GH, int FieldIndex, int MIndex, int NIndex, - CCTK_REAL *AbsTol, CCTK_REAL *RelTol); + CCTK_REAL *AbsTol, CCTK_REAL *RelTol); int SORConfMetric3D(cGH *GH, int *MetricPsiI, int conformal, - int FieldIndex, int MIndex, int NIndex, - CCTK_REAL *AbsTol, CCTK_REAL *RelTol); + int FieldIndex, int MIndex, int NIndex, + CCTK_REAL *AbsTol, CCTK_REAL *RelTol); int SORConfMetric(cGH *GH, - int *MetricPsiI, - int FieldIndex, - int MIndex, - int NIndex, - CCTK_REAL *AbsTol, - CCTK_REAL *RelTol); + int *MetricPsiI, + int FieldIndex, + int MIndex, + int NIndex, + CCTK_REAL *AbsTol, + CCTK_REAL *RelTol); int SORFlat(cGH *GH, - int FieldIndex, - int MIndex, - int NIndex, - CCTK_REAL *AbsTol, - CCTK_REAL *RelTol); + int FieldIndex, + int MIndex, + int NIndex, + CCTK_REAL *AbsTol, + CCTK_REAL *RelTol); /*@@ @routine SORConfMetric @@ -72,12 +72,12 @@ int SORFlat(cGH *GH, @@*/ int SORConfMetric(cGH *GH, - int *MetricPsiI, - int FieldIndex, - int MIndex, - int NIndex, - CCTK_REAL *AbsTol, - CCTK_REAL *RelTol) + int *MetricPsiI, + int FieldIndex, + int MIndex, + int NIndex, + CCTK_REAL *AbsTol, + CCTK_REAL *RelTol) { int retval = ELL_NOSOLVER; @@ -91,8 +91,8 @@ int SORConfMetric(cGH *GH, break; case 3: retval = SORConfMetric3D(GH, MetricPsiI, 1, - FieldIndex, MIndex, NIndex, - AbsTol, RelTol); + FieldIndex, MIndex, NIndex, + AbsTol, RelTol); break; default: CCTK_WARN(1,"SORConfMetric: Solver only implemented for 3D"); @@ -103,12 +103,12 @@ int SORConfMetric(cGH *GH, } int SORMetric(cGH *GH, - int *MetricI, - int FieldIndex, - int MIndex, - int NIndex, - CCTK_REAL *AbsTol, - CCTK_REAL *RelTol) + int *MetricI, + int FieldIndex, + int MIndex, + int NIndex, + CCTK_REAL *AbsTol, + CCTK_REAL *RelTol) { int retval = ELL_NOSOLVER; @@ -122,8 +122,8 @@ int SORMetric(cGH *GH, break; case 3: retval = SORConfMetric3D(GH, MetricI, 0, - FieldIndex, MIndex, NIndex, - AbsTol, RelTol); + FieldIndex, MIndex, NIndex, + AbsTol, RelTol); break; default: CCTK_WARN(1,"SORMetric: Solver only implemented for 3D"); @@ -158,11 +158,11 @@ int SORMetric(cGH *GH, @@*/ int SORFlat(cGH *GH, - int FieldIndex, - int MIndex, - int NIndex, - CCTK_REAL *AbsTol, - CCTK_REAL *RelTol) + int FieldIndex, + int MIndex, + int NIndex, + CCTK_REAL *AbsTol, + CCTK_REAL *RelTol) { int retval; @@ -187,4 +187,3 @@ int SORFlat(cGH *GH, return retval; } - -- cgit v1.2.3