User: hinder Date: 2010/06/13 06:13 PM
Modified: /trunk/ param.ccl, schedule.ccl /trunk/src/ multipole.cc
Log: Remove single mode extraction method
To simplfy the API, and because the common use case is to extract multiple modes, this commit removes support for extracting only a single mode. All modes up to l = l_max (a new parameter) are now computed always. The old parameter l_mode is now deprecated, but if it is used, it is a synonym for l_max. It will eventually be removed.
File Changes:
Directory: /trunk/src/ ======================
File [modified]: multipole.cc Delta lines: +50 -29 =================================================================== --- trunk/src/multipole.cc 2010-06-13 21:59:51 UTC (rev 56) +++ trunk/src/multipole.cc 2010-06-13 23:13:33 UTC (rev 57) @@ -35,7 +35,6 @@ } variables_desc;
- static void fill_variable(int idx, const char *optstring, void *callback_arg) { assert(idx >= 0); @@ -187,10 +186,18 @@ *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 @@ { 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 @@
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 @@ 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 @@ // 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);
Directory: /trunk/ ==================
File [modified]: param.ccl Delta lines: +28 -17 =================================================================== --- trunk/param.ccl 2010-06-13 21:59:51 UTC (rev 56) +++ trunk/param.ccl 2010-06-13 23:13:33 UTC (rev 57) @@ -70,27 +70,11 @@ { } "no"
-KEYWORD mode_type "Which type of mode extraction do we have" STEERABLE=always +CCTK_INT l_max "The maximum l mode to extract" STEERABLE=always { - "all modes" :: "Extract all modes up to (l_mode, m_mode)." - "specific mode" :: "Select one specific (l_mode, m_mode) mode" -} "all modes" - -CCTK_INT l_min "all modes: above which l mode to calculate/ specific mode: which l mode to extract" STEERABLE=always -{ 0:* :: "l >= 0" } 2
-CCTK_INT l_mode "all modes: Up to which l mode to calculate/ specific mode: which l mode to extract" STEERABLE=always -{ - 0:* :: "l >= 0" -} 2 - -CCTK_INT m_mode "all modes: Up to which m mode to calculate/ specific mode: which m mode to extract " STEERABLE=always -{ - 0:* :: "Positive Please" -} 2 - CCTK_BOOLEAN enable_test "whether to set a spherical harmonic in the 'harmonic' grid functions" { } "no" @@ -109,3 +93,30 @@ { * :: "Any integer" } -2 + +# This parameter is deprecated and is no longer used +KEYWORD mode_type "Which type of mode extraction do we have" STEERABLE=always +{ + "all modes" :: "Extract all modes up to (l_mode, m_mode)." + "specific mode" :: "Select one specific (l_mode, m_mode) mode" + "deprecated" :: "Deprecated" +} "deprecated" + +# This parameter is deprecated and is no longer used +CCTK_INT l_min "all modes: above which l mode to calculate/ specific mode: which l mode to extract" STEERABLE=always +{ + -1:* :: "Deprecated" +} -1 + +# This parameter is deprecated and is only used if set to a nondefault +# value, in which case it is a synonym for l_max. +CCTK_INT l_mode "The maximum l mode to extract" STEERABLE=always +{ + -1:* :: "Deprecated" +} -1 + +# This parameter is deprecated and is no longer used +CCTK_INT m_mode "all modes: Up to which m mode to calculate/ specific mode: which m mode to extract " STEERABLE=always +{ + -100:* :: "Deprecated" +} -100
File [modified]: schedule.ccl Delta lines: +6 -0 =================================================================== --- trunk/schedule.ccl 2010-06-13 21:59:51 UTC (rev 56) +++ trunk/schedule.ccl 2010-06-13 23:13:33 UTC (rev 57) @@ -18,3 +18,9 @@ LANG: C } "Populate grid functions with spherical harmonics" } + +schedule Multipole_ParamCheck at CCTK_PARAMCHECK +{ + LANG: C + OPTIONS: GLOBAL +} "Check Multipole parameters"
commits@lists.einsteintoolkit.org