Skip to content

Commit

Permalink
Multipole: beautify func outputModes
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Jun 26, 2024
1 parent a82ee43 commit 68555af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 48 deletions.
27 changes: 0 additions & 27 deletions Multipole/param.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,6 @@ CCTK_INT l_max "The maximum l mode to extract" STEERABLE=always
0:9 :: "l >= 0"
} 2

CCTK_BOOLEAN enable_test "whether to set a spherical harmonic in the 'harmonic' grid functions"
{
} "no"

CCTK_BOOLEAN enable_test_Weyl "whether to set a spherical harmonic in the 'Weyl::Psi4r and i' grid functions"
{
} "no"

CCTK_INT test_l "which mode to put into the test variables"
{
* :: "Any integer"
} 2

CCTK_INT test_m "which mode to put into the test variables"
{
* :: "Any integer"
} 2

CCTK_INT test_sw "which spin weight to put into the test variables"
{
* :: "Any integer"
} -2

CCTK_BOOLEAN test_mode_proportional_to_r "whether the test spherical harmonic coefficient is proportional to the radial coordinate"
{
} "no"

CCTK_BOOLEAN output_tsv "Output a simple ASCII file for each mode at each radius"
{
} "yes"
Expand Down
39 changes: 18 additions & 21 deletions Multipole/src/multipole.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,31 @@ static Sphere *g_sphere = nullptr;
static vector<VariableParse> g_vars;
static vector<int> g_spin_weights;

static void output_modes(CCTK_ARGUMENTS, const VariableParse vars[],
const CCTK_REAL radii[], const ModeArray &modes) {
// Function to output modes
static void outputModes(CCTK_ARGUMENTS, const VariableParse vars[],
const CCTK_REAL radii[], const ModeArray &modes) {
DECLARE_CCTK_ARGUMENTS;
DECLARE_CCTK_PARAMETERS;

if (output_tsv) {
if (CCTK_MyProc(cctkGH) == 0) {
for (int v = 0; v < modes.getNumVars(); v++) {
for (int i = 0; i < modes.getNumRadii(); i++) {
const CCTK_REAL rad = radii[i];
for (int l = 0; l <= modes.getMaxL(); l++) {
for (int m = -l; m <= l; m++) {
ostringstream name;
name << "mp_" << vars[v].name << "_l" << l << "_m" << m << "_r"
<< setiosflags(ios::fixed) << setprecision(2) << rad
<< ".tsv";
OutputComplexToFile(CCTK_PASS_CTOC, name.str(),
modes(v, i, l, m, 0), modes(v, i, l, m, 1));
}
if (output_tsv && CCTK_MyProc(cctkGH) == 0) {
for (int v = 0; v < modes.getNumVars(); ++v) {
for (int i = 0; i < modes.getNumRadii(); ++i) {
const CCTK_REAL rad = radii[i];
for (int l = 0; l <= modes.getMaxL(); ++l) {
for (int m = -l; m <= l; ++m) {
std::ostringstream filename;
filename << "mp_" << vars[v].name << "_l" << l << "_m" << m << "_r"
<< std::fixed << std::setprecision(2) << rad << ".tsv";

OutputComplexToFile(CCTK_PASS_CTOC, filename.str(),
modes(v, i, l, m, 0), modes(v, i, l, m, 1));
}
}
}
}
}
if (output_hdf5) {
if (CCTK_MyProc(cctkGH) == 0) {
OutputComplexToH5File(CCTK_PASS_CTOC, vars, radii, modes);
}
if (output_hdf5 && CCTK_MyProc(cctkGH) == 0) {
OutputComplexToH5File(CCTK_PASS_CTOC, vars, radii, modes);
}
}

Expand Down Expand Up @@ -203,7 +200,7 @@ extern "C" void Multipole_Calc(CCTK_ARGUMENTS) {
} // loop over radii
} // loop over variables

output_modes(CCTK_PASS_CTOC, g_vars.data(), radius, modes);
outputModes(CCTK_PASS_CTOC, g_vars.data(), radius, modes);
}

} // namespace Multipole

0 comments on commit 68555af

Please sign in to comment.