diff options
Diffstat (limited to 'src/multipole.cc')
-rw-r--r-- | src/multipole.cc | 79 |
1 files changed, 50 insertions, 29 deletions
diff --git a/src/multipole.cc b/src/multipole.cc index b0bc015..c79653a 100644 --- a/src/multipole.cc +++ b/src/multipole.cc @@ -35,7 +35,6 @@ typedef struct } variables_desc; - static void fill_variable(int idx, const char *optstring, void *callback_arg) { assert(idx >= 0); @@ -187,10 +186,18 @@ void get_spin_weights(variable_desc vars[], int n_vars, int spin_weights[max_spi *n_weights = n_spin_weights; } +// For backward compatibility we allow the user to set l_mode instead +// of l_max, but if it is left at the default of -1, l_max is used. +static int get_l_max() +{ + DECLARE_CCTK_PARAMETERS; + return l_mode == -1 ? l_max : l_mode; +} static -void setup_harmonics(const int spin_weights[max_spin_weights], int n_spin_weights, int lmin, int lmax, - int m_mode, bool allmodes, CCTK_REAL th[], CCTK_REAL ph[], int array_size, +void setup_harmonics(const int spin_weights[max_spin_weights], + int n_spin_weights, int lmax, + CCTK_REAL th[], CCTK_REAL ph[], int array_size, CCTK_REAL *reY[max_spin_weights][max_l_modes][max_m_modes], CCTK_REAL *imY[max_spin_weights][max_l_modes][max_m_modes]) { @@ -209,22 +216,46 @@ void setup_harmonics(const int spin_weights[max_spin_weights], int n_spin_weight { int sw = spin_weights[si]; - for (int l=lmin; l <= lmax; l++) + for (int l=0; l <= lmax; l++) { - int mmin = (allmodes ? (m_mode > l ? -l : -m_mode) : m_mode); - int mmax = (allmodes ? (m_mode > l ? l : m_mode) : m_mode); - - for (int m=mmin; m <= mmax; m++) + for (int m=-l; m <= l; m++) { - reY[si][l-lmin][m-mmin] = new CCTK_REAL[array_size]; - imY[si][l-lmin][m-mmin] = new CCTK_REAL[array_size]; + reY[si][l][m+l] = new CCTK_REAL[array_size]; + imY[si][l][m+l] = new CCTK_REAL[array_size]; - Multipole_HarmonicSetup(sw, l, m, array_size, th, ph, reY[si][l-lmin][m-mmin], imY[si][l-lmin][m-mmin]); + Multipole_HarmonicSetup(sw, l, m, array_size, th, ph, + reY[si][l][m+l], imY[si][l][m+l]); } } } } +extern "C" void Multipole_ParamCheck(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_PARAMETERS; + DECLARE_CCTK_ARGUMENTS; + + if (l_mode != -1) + { + CCTK_WARN(CCTK_WARN_ALERT, "The parameter l_mode is deprecated. Use l_max instead. For compatibility, l_max = l_mode is being used."); + } + + if (!CCTK_Equals(mode_type, "deprecated")) + { + CCTK_WARN(CCTK_WARN_ALERT, "The parameter mode_type is deprecated and is no longer used. All modes will be computed."); + } + + if (l_min != -1) + { + CCTK_WARN(CCTK_WARN_ALERT, "The parameter l_min is deprecated and is no longer used. Modes from l = 0 will be computed."); + } + + if (m_mode != -100) + { + CCTK_WARN(CCTK_WARN_ALERT, "The parameter m_mode is deprecated. All m modes will be computed."); + } +} + extern "C" void Multipole_Calc(CCTK_ARGUMENTS) { DECLARE_CCTK_ARGUMENTS @@ -245,21 +276,11 @@ extern "C" void Multipole_Calc(CCTK_ARGUMENTS) int i, array_size=(ntheta+1)*(nphi+1); CCTK_REAL real_lm = 0.0, imag_lm = 0.0; - int lmin, lmax, mmin, mmax, allmodes=0; if (cctk_iteration % out_every != 0) return; - // Determine modes to compute - if (CCTK_EQUALS(mode_type, "all modes")) - { - allmodes=1; - } - //if mode_type is set to "all modes", all modes with l <= l_mode, - //abs(m) <= min{l_mode, m_mode} will be output. Otherwise, only - //the l_mode, m_mode mode will be output. - lmin = (allmodes ? l_min : l_mode); - lmax = l_mode; + int lmax = get_l_max(); assert(lmax + 1 <= max_l_modes); @@ -279,7 +300,8 @@ extern "C" void Multipole_Calc(CCTK_ARGUMENTS) parse_variables_string(variables, vars, &n_variables); get_spin_weights(vars, n_variables, spin_weights, &n_spin_weights); Multipole_CoordSetup(ntheta, nphi, xhat, yhat, zhat, th, ph); - setup_harmonics(spin_weights, n_spin_weights, lmin, lmax, m_mode, allmodes, th, ph, array_size, reY, imY); + setup_harmonics(spin_weights, n_spin_weights, lmax, th, ph, + array_size, reY, imY); initialized = true; } @@ -298,15 +320,14 @@ extern "C" void Multipole_Calc(CCTK_ARGUMENTS) // Interpolate Psi4r and Psi4i Multipole_Interp(CCTK_PASS_CTOC, xs, ys, zs, vars[v].index, vars[v].imag_index, real, imag); - for (int l=lmin; l <= lmax; l++) + for (int l=0; l <= lmax; l++) { - mmin = (allmodes ? (m_mode > l ? -l : -m_mode) : m_mode) ; - mmax = (allmodes ? (m_mode > l ? l : m_mode) : m_mode); - - for (int m=mmin; m <= mmax; m++) + for (int m=-l; m <= l; m++) { // Integrate sYlm (real + i imag) over the sphere at radius r - Multipole_Integrate(array_size, ntheta, reY[si][l-lmin][m-mmin], imY[si][l-lmin][m-mmin], real, imag, th, ph, + Multipole_Integrate(array_size, ntheta, + reY[si][l][m+l], imY[si][l][m+l], + real, imag, th, ph, &real_lm, &imag_lm); output_mode(CCTK_PASS_CTOC, &vars[v], radius[i], real_lm, imag_lm, l, m); |