diff options
author | Anton Khirnov <anton@khirnov.net> | 2018-10-03 15:24:53 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2018-10-03 15:24:53 +0200 |
commit | 73768fe52c75899fe20c831c4f489194e7b9ae27 (patch) | |
tree | 00187a96d6eda920fbf9b15260d53365752fea85 | |
parent | df370e24e912011721ed16099d9caab199dec15c (diff) |
-rw-r--r-- | src/ms_solve.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ms_solve.c b/src/ms_solve.c index 1bf87a2..ceb6802 100644 --- a/src/ms_solve.c +++ b/src/ms_solve.c @@ -234,12 +234,33 @@ static const CCTK_INT interp_operation_codes[] = { [I_BETAZ] = 0, }; + +static int ctz(int a) +{ + int ret = 0; + + if (!a) + return INT_MAX; + + while (!(a & 1)) { + a >>= 1; + ret++; + } + + return ret; +} + /* interpolate the cactus gridfunctions onto the pseudospectral grid */ static int interp_geometry(MSSolver *ctx) { MSSolverPriv *s = ctx->priv; + int level = ctz(s->gh->cctk_levfac[0]); int ret; + ret = Util_TableSetInt(s->interp_params, level + 1, "max_reflevel"); + if (ret < 0) + CCTK_WARN(0, "Error setting max reflevel"); + ret = CCTK_InterpGridArrays(s->gh, 3, s->interp_operator, s->interp_params, s->coord_system, NB_COLLOC_POINTS(ctx), CCTK_VARIABLE_REAL, (const void * const *)s->interp_coords, ARRAY_ELEMS(s->interp_vars_indices), s->interp_vars_indices, |