<commit_before>/*
 * swe_sphere_rexi.cpp
 *
 *  Created on: 15 Aug 2016
 *      Author: <NAME> <<EMAIL>>
 */

#if SWEET_GUI
	#include <sweet/VisSweet.hpp>
	#include <sweet/plane/PlaneDataConfig.hpp>
	#include <sweet/plane/PlaneData.hpp>
	#include <sweet/Convert_SphereData_To_PlaneData.hpp>
#endif

#include <benchmarks_sphere/SphereBenchmarksCombined.hpp>

#include <sweet/sphere/SphereData.hpp>
#include <sweet/sphere/SphereDataPhysical.hpp>
#include <sweet/sphere/SphereDiagnostics.hpp>


#include <sweet/sphere/SphereOperators.hpp>
#include <sweet/sphere/SphereOperatorsComplex.hpp>
#include <sweet/sphere/SphereDataComplex.hpp>
#include <sweet/Stopwatch.hpp>
#include <sweet/FatalError.hpp>

#include "swe_sphere_rexi/SWE_Sphere_TimeSteppers.hpp"



SimulationVariables simVars;

// Plane data config
SphereDataConfig sphereDataConfigInstance;
SphereDataConfig *sphereDataConfig = &sphereDataConfigInstance;


#if SWEET_GUI
	PlaneDataConfig planeDataConfigInstance;
	PlaneDataConfig *planeDataConfig = &planeDataConfigInstance;
#endif



/*
 * This allows running REXI including Coriolis-related terms but just by setting f to 0
 */
bool param_compute_error = false;



class SimulationInstance
{
public:
	SphereOperators op;

	SWE_Sphere_TimeSteppers timeSteppers;


	// Diagnostics measures
	int last_timestep_nr_update_diagnostics = -1;

	SphereData prog_phi;
	SphereData prog_vort;
	SphereData prog_div;


	REXI_Terry<> rexi;

#if SWEET_GUI
	PlaneData viz_plane_data;
#endif

	int render_primitive_id = 1;

	SphereDiagnostics sphereDiagnostics;

#if SWEET_MPI
	int mpi_rank;
#endif


public:
	SimulationInstance()	:
		op(sphereDataConfig, simVars.sim.earth_radius),
		prog_phi(sphereDataConfig),
		prog_vort(sphereDataConfig),
		prog_div(sphereDataConfig),

#if SWEET_GUI
		viz_plane_data(planeDataConfig),
#endif
		sphereDiagnostics(sphereDataConfig, simVars)
	{
#if SWEET_MPI
		MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
#endif
		reset();
	}



	void update_diagnostics()
	{
		// assure, that the diagnostics are only updated for new time steps
		if (last_timestep_nr_update_diagnostics == simVars.timecontrol.current_timestep_nr)
			return;

		sphereDiagnostics.update_phi_vort_div_2_mass_energy_enstrophy(
				op,
				prog_phi,
				prog_vort,
				prog_div,
				simVars
		);
	}



	void reset()
	{
		simVars.reset();

		if (simVars.misc.sphere_use_robert_functions != 1)
			FatalError("Only Robert formulation allowed");

		// one month runtime
		if (simVars.timecontrol.max_simulation_time == -1)
		{
			if (simVars.setup.benchmark_scenario_id == 10)
			{
				simVars.timecontrol.max_simulation_time = 31*60*60*24;

				// 200 h
				simVars.timecontrol.max_simulation_time = 200*60*60;
			}
		}

		// Diagnostics measures
		last_timestep_nr_update_diagnostics = -1;

		simVars.misc.output_next_sim_seconds = 0;


		if (simVars.sim.CFL < 0)
			simVars.timecontrol.current_timestep_size = -simVars.sim.CFL;

		std::cout << simVars.timecontrol.current_timestep_size << std::endl;

		if (simVars.timecontrol.current_timestep_size <= 0)
		{
			// TRY to guess optimal time step size

			// time step size
			if (sphereDataConfig->physical_num_lat < 256)
				simVars.timecontrol.current_timestep_size = 0.002*simVars.sim.earth_radius/(double)sphereDataConfig->physical_num_lat;
			else
				simVars.timecontrol.current_timestep_size = 0.001*simVars.sim.earth_radius/(double)sphereDataConfig->physical_num_lat;
		}

		if (simVars.timecontrol.current_timestep_size <= 0)
			FatalError("Only fixed time step size supported");



		SphereData prog_h(sphereDataConfig);
		SphereData prog_u(sphereDataConfig);
		SphereData prog_v(sphereDataConfig);

		SphereBenchmarksCombined::setupInitialConditions(prog_h, prog_u, prog_v, simVars, op);

		prog_phi = prog_h*simVars.sim.gravitation;
		op.robert_uv_to_vortdiv(prog_u.getSphereDataPhysical(), prog_v.getSphereDataPhysical(), prog_vort, prog_div);

		simVars.outputConfig();

		std::cout << std::endl;
		std::cout << "LOCAL PARAMETERS:" << std::endl;
		std::cout << " + param_compute_error: " << param_compute_error << std::endl;
		std::cout << std::endl;
<commit_msg>Removed too much output with MPI<commit_after>/*
 * swe_sphere_rexi.cpp
 *
 *  Created on: 15 Aug 2016
 *      Author: <NAME> <<EMAIL>>
 */

#if SWEET_GUI
	#include <sweet/VisSweet.hpp>
	#include <sweet/plane/PlaneDataConfig.hpp>
	#include <sweet/plane/PlaneData.hpp>
	#include <sweet/Convert_SphereData_To_PlaneData.hpp>
#endif

#include <benchmarks_sphere/SphereBenchmarksCombined.hpp>

#include <sweet/sphere/SphereData.hpp>
#include <sweet/sphere/SphereDataPhysical.hpp>
#include <sweet/sphere/SphereDiagnostics.hpp>


#include <sweet/sphere/SphereOperators.hpp>
#include <sweet/sphere/SphereOperatorsComplex.hpp>
#include <sweet/sphere/SphereDataComplex.hpp>
#include <sweet/Stopwatch.hpp>
#include <sweet/FatalError.hpp>

#include "swe_sphere_rexi/SWE_Sphere_TimeSteppers.hpp"



SimulationVariables simVars;

// Plane data config
SphereDataConfig sphereDataConfigInstance;
SphereDataConfig *sphereDataConfig = &sphereDataConfigInstance;


#if SWEET_GUI
	PlaneDataConfig planeDataConfigInstance;
	PlaneDataConfig *planeDataConfig = &planeDataConfigInstance;
#endif



/*
 * This allows running REXI including Coriolis-related terms but just by setting f to 0
 */
bool param_compute_error = false;



class SimulationInstance
{
public:
	SphereOperators op;

	SWE_Sphere_TimeSteppers timeSteppers;


	// Diagnostics measures
	int last_timestep_nr_update_diagnostics = -1;

	SphereData prog_phi;
	SphereData prog_vort;
	SphereData prog_div;


	REXI_Terry<> rexi;

#if SWEET_GUI
	PlaneData viz_plane_data;
#endif

	int render_primitive_id = 1;

	SphereDiagnostics sphereDiagnostics;

#if SWEET_MPI
	int mpi_rank;
#endif


public:
	SimulationInstance()	:
		op(sphereDataConfig, simVars.sim.earth_radius),
		prog_phi(sphereDataConfig),
		prog_vort(sphereDataConfig),
		prog_div(sphereDataConfig),

#if SWEET_GUI
		viz_plane_data(planeDataConfig),
#endif
		sphereDiagnostics(sphereDataConfig, simVars)
	{
#if SWEET_MPI
		MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
#endif
		reset();
	}



	void update_diagnostics()
	{
		// assure, that the diagnostics are only updated for new time steps
		if (last_timestep_nr_update_diagnostics == simVars.timecontrol.current_timestep_nr)
			return;

		sphereDiagnostics.update_phi_vort_div_2_mass_energy_enstrophy(
				op,
				prog_phi,
				prog_vort,
				prog_div,
				simVars
		);
	}



	void reset()
	{
		simVars.reset();

		if (simVars.misc.sphere_use_robert_functions != 1)
			FatalError("Only Robert formulation allowed");

		// one month runtime
		if (simVars.timecontrol.max_simulation_time == -1)
		{
			if (simVars.setup.benchmark_scenario_id == 10)
			{
				simVars.timecontrol.max_simulation_time = 31*60*60*24;

				// 200 h
				simVars.timecontrol.max_simulation_time = 200*60*60;
			}
		}

		// Diagnostics measures
		last_timestep_nr_update_diagnostics = -1;

		simVars.misc.output_next_sim_seconds = 0;


		if (simVars.sim.CFL < 0)
			simVars.timecontrol.current_timestep_size = -simVars.sim.CFL;

		std::cout << simVars.timecontrol.current_timestep_size << std::endl;

		if (simVars.timecontrol.current_timestep_size <= 0)
		{
			// TRY to guess optimal time step size

			// time step size
			if (sphereDataConfig->physical_num_lat < 256)
				simVars.timecontrol.current_timestep_size = 0.002*simVars.sim.earth_radius/(double)sphereDataConfig->physical_num_lat;
			else
				simVars.timecontrol.current_timestep_size = 0.001*simVars.sim.earth_radius/(double)sphereDataConfig->physical_num_lat;
		}

		if (simVars.timecontrol.current_timestep_size <= 0)
			FatalError("Only fixed time step size supported");



		SphereData prog_h(sphereDataConfig);
		SphereData prog_u(sphereDataConfig);
		SphereData prog_v(sphereDataConfig);

		SphereBenchmarksCombined::setupInitialConditions(prog_h, prog_u, prog_v, simVars, op);

		prog_phi = prog_h*simVars.sim.gravitation;
		op.robert_uv_to_vortdiv(prog_u.getSphereDataPhysical(), prog_v.getSphereDataPhysical(), prog_vort, prog_div);

		if (mpi_ranks == 0)
		{
			simVars.outputConfig();

			std::cout << std::endl;
			std::cout << "LOCAL PARAMETERS:" << std::endl;
			std::cout << " + param_compute_error: " << param_compute_error << std::endl;
			std::cout << std::endl;
		}

{'fraction_non_alphanumeric': 0.1037895244991552, 'fraction_numerical': 0.011706492879555877, 'mean_word_length': 5.062179956108266, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4206656', 'n_tokens_mistral': 3447, 'n_tokens_neox': 2993, 'n_words': 512}