From 95b5e0d75452a02fa92be6e9b16cb53941a43b5f Mon Sep 17 00:00:00 2001
From: Josh Borrow <joshua.borrow@durham.ac.uk>
Date: Fri, 29 May 2020 17:11:02 +0100
Subject: [PATCH] Fixed testSelectOutput to work with new scheme
---
tests/selectOutput.yml | 13 +++-------
tests/selectOutputParameters.yml | 8 ++++++
tests/testSelectOutput.c | 13 +++++++---
tests/testSelectOutput.py | 42 ++++++++++++++++----------------
4 files changed, 42 insertions(+), 34 deletions(-)
create mode 100644 tests/selectOutputParameters.yml
diff --git a/tests/selectOutput.yml b/tests/selectOutput.yml
index 1778935146..bbcbadff8f 100644
--- a/tests/selectOutput.yml
+++ b/tests/selectOutput.yml
@@ -1,12 +1,7 @@
-SelectOutput:
+Default:
# Particle Type 0
- Coordinates_Gas: 1 # check if written when specified
- Velocities_Gas: 0 # check if not written when specified
- Masses_Gas: -5 # check warning if not 0 or 1 and if written
- Pot_Gas: 1 # check warning if wrong name
+ Coordinates_Gas: on # check if written when specified
+ Velocities_Gas: off # check if not written when specified
+ Pot_Gas: on # check warning if wrong name
# Density_Gas: 1 # check if written when not specified
-# Parameters for the hydrodynamics scheme
-SPH:
- resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
- CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
diff --git a/tests/selectOutputParameters.yml b/tests/selectOutputParameters.yml
new file mode 100644
index 0000000000..984b105b02
--- /dev/null
+++ b/tests/selectOutputParameters.yml
@@ -0,0 +1,8 @@
+# Parameters for the hydrodynamics scheme
+SPH:
+ resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
+ CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
+
+Snapshots:
+ select_output_on: 1
+ select_output: selectOutput.yml
diff --git a/tests/testSelectOutput.c b/tests/testSelectOutput.c
index 872609dd79..6ff3f59e18 100644
--- a/tests/testSelectOutput.c
+++ b/tests/testSelectOutput.c
@@ -26,12 +26,14 @@
void select_output_engine_init(struct engine *e, struct space *s,
struct cosmology *cosmo,
struct swift_params *params,
+ struct output_options *output,
struct cooling_function_data *cooling,
struct hydro_props *hydro_properties) {
/* set structures */
e->s = s;
e->cooling_func = cooling;
e->parameter_file = params;
+ e->output_options = output;
e->cosmology = cosmo;
e->policy = engine_policy_hydro;
e->hydro_properties = hydro_properties;
@@ -96,9 +98,12 @@ int main(int argc, char *argv[]) {
/* parse parameters */
message("Reading parameters.");
struct swift_params param_file;
- const char *input_file = "selectOutput.yml";
+ const char *input_file = "selectOutputParameters.yml";
parser_read_file(input_file, ¶m_file);
+ struct output_options output_options;
+ output_options_init(¶m_file, 0, &output_options);
+
/* Default unit system */
message("Initialization of the unit system.");
struct unit_system us;
@@ -149,14 +154,14 @@ int main(int argc, char *argv[]) {
e.physical_constants = &prog_const;
sprintf(e.snapshot_base_name, "testSelectOutput");
sprintf(e.run_name, "Select Output Test");
- select_output_engine_init(&e, &s, &cosmo, ¶m_file, &cooling,
- &hydro_properties);
+ select_output_engine_init(&e, &s, &cosmo, ¶m_file, &output_options,
+ &cooling, &hydro_properties);
/* check output selection */
message("Checking output parameters.");
long long N_total[swift_type_count] = {
(long long)Ngas, (long long)Ngpart, 0, 0, (long long)Nspart, 0};
- io_check_output_fields(¶m_file, N_total, /*with_cosmology=*/1);
+ io_check_output_fields(¶m_file, N_total, /*with_cosmology=*/0);
/* write output file */
message("Writing output.");
diff --git a/tests/testSelectOutput.py b/tests/testSelectOutput.py
index 97e1c865d1..79316d867a 100644
--- a/tests/testSelectOutput.py
+++ b/tests/testSelectOutput.py
@@ -1,22 +1,22 @@
###############################################################################
- # This file is part of SWIFT.
- # Copyright (c) 2015 Bert Vandenbroucke (bert.vandenbroucke@ugent.be)
- # Matthieu Schaller (matthieu.schaller@durham.ac.uk)
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Lesser General Public License as published
- # by the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU Lesser General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- ##############################################################################
+# This file is part of SWIFT.
+# Copyright (c) 2015 Bert Vandenbroucke (bert.vandenbroucke@ugent.be)
+# Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
# Check the output done with swift
@@ -47,8 +47,8 @@ if "Densities" not in part0:
with open(log_filename, "r") as f:
data = f.read()
-if "SelectOutput:Masses_Gas" not in data:
- raise Exception("Input error in `SelectOuput:Masses_Gas` not detected")
+if "Default:Masses_Gas" not in data:
+ raise Exception("Input error in `Default:Masses_Gas` not detected")
-if "SelectOutput:Pot_Gas" not in data:
+if "Default:Pot_Gas" not in data:
raise Exception("Parameter name error not detected for `SelectOutput:Pot_Gas`")
--
GitLab