1
0
Fork 0
mirror of https://github.com/cosmo-sims/MUSIC.git synced 2024-09-19 17:03:46 +02:00

cleaned up some screen and log outputs

This commit is contained in:
Oliver Hahn 2023-02-14 19:43:18 -08:00
parent 16bdb25e21
commit 1d4d4787c1
9 changed files with 112 additions and 120 deletions

View file

@ -196,5 +196,6 @@ if(ENABLE_PANPHASIA)
target_compile_options(${PRGNAME} PRIVATE "-DHAVE_PANPHASIA") target_compile_options(${PRGNAME} PRIVATE "-DHAVE_PANPHASIA")
endif(ENABLE_PANPHASIA) endif(ENABLE_PANPHASIA)
target_include_directories(${PRGNAME} PRIVATE ${GSL_INCLUDE_DIR})
target_link_libraries(${PRGNAME} PRIVATE GSL::gsl) target_link_libraries(${PRGNAME} PRIVATE GSL::gsl)

View file

@ -37,11 +37,8 @@ void perform(kernel *pk, void *pd, bool shift, bool fix, bool flip)
cdata = reinterpret_cast<complex_t *>(data); cdata = reinterpret_cast<complex_t *>(data);
ckernel = reinterpret_cast<complex_t *>(pk->get_ptr()); ckernel = reinterpret_cast<complex_t *>(pk->get_ptr());
std::cout << " - Performing density convolution... (" music::ilog.Print("- Performing kernel convolution on (%5d,%5d,%5d) grid", cparam_.nx, cparam_.ny, cparam_.nz);
<< cparam_.nx << ", " << cparam_.ny << ", " << cparam_.nz << ")\n"; music::ilog.Print("- Performing forward FFT...");
music::ulog.Print("Performing kernel convolution on (%5d,%5d,%5d) grid", cparam_.nx, cparam_.ny, cparam_.nz);
music::ulog.Print("Performing forward FFT...");
fftw_plan_t plan, iplan; fftw_plan_t plan, iplan;
plan = FFTW_API(plan_dft_r2c_3d)(cparam_.nx, cparam_.ny, cparam_.nz, data, cdata, FFTW_ESTIMATE); plan = FFTW_API(plan_dft_r2c_3d)(cparam_.nx, cparam_.ny, cparam_.nz, data, cdata, FFTW_ESTIMATE);

View file

@ -267,21 +267,17 @@ void GenerateDensityUnigrid(config_file &cf, transfer_function *ptf, tf_type typ
unsigned nbase = 1 << levelmin; unsigned nbase = 1 << levelmin;
std::cerr << " - Running unigrid version\n"; music::ilog.Print("- Running unigrid density convolution...");
music::ulog.Print("Running unigrid density convolution...");
//... select the transfer function to be used //... select the transfer function to be used
convolution::kernel_creator *the_kernel_creator = convolution::get_kernel_map()["tf_kernel_k"]; convolution::kernel_creator *the_kernel_creator = convolution::get_kernel_map()["tf_kernel_k"];
std::cout << " - Using k-space transfer function kernel.\n";
music::ulog.Print("Using k-space transfer function kernel.");
//... initialize convolution kernel //... initialize convolution kernel
convolution::kernel *the_tf_kernel = the_kernel_creator->create(cf, ptf, refh, type); convolution::kernel *the_tf_kernel = the_kernel_creator->create(cf, ptf, refh, type);
//... //...
std::cout << " - Performing noise convolution on level " << std::setw(2) << levelmax << " ..." << std::endl; music::ulog.Print("- Performing noise convolution on level %3d", levelmax);
music::ulog.Print("Performing noise convolution on level %3d", levelmax);
//... create convolution mesh //... create convolution mesh
DensityGrid<real_t> *top = new DensityGrid<real_t>(nbase, nbase, nbase); DensityGrid<real_t> *top = new DensityGrid<real_t>(nbase, nbase, nbase);
@ -322,7 +318,7 @@ void GenerateDensityHierarchy(config_file &cf, transfer_function *ptf, tf_type t
double tstart, tend; double tstart, tend;
#ifndef SINGLETHREAD_FFTW #if defined(_OPENMP)
tstart = omp_get_wtime(); tstart = omp_get_wtime();
#else #else
tstart = (double)clock() / CLOCKS_PER_SEC; tstart = (double)clock() / CLOCKS_PER_SEC;
@ -343,10 +339,6 @@ void GenerateDensityHierarchy(config_file &cf, transfer_function *ptf, tf_type t
unsigned nbase = 1 << levelmin; unsigned nbase = 1 << levelmin;
convolution::kernel_creator *the_kernel_creator = convolution::get_kernel_map()["tf_kernel_k"]; convolution::kernel_creator *the_kernel_creator = convolution::get_kernel_map()["tf_kernel_k"];
std::cout << " - Using k-space transfer function kernel.\n";
music::ulog.Print("Using k-space transfer function kernel.");
convolution::kernel *the_tf_kernel = the_kernel_creator->create(cf, ptf, refh, type); convolution::kernel *the_tf_kernel = the_kernel_creator->create(cf, ptf, refh, type);
/***** PERFORM CONVOLUTIONS *****/ /***** PERFORM CONVOLUTIONS *****/
@ -423,14 +415,14 @@ void GenerateDensityHierarchy(config_file &cf, transfer_function *ptf, tf_type t
delete the_tf_kernel; delete the_tf_kernel;
#ifndef SINGLETHREAD_FFTW #if defined(_OPENMP)
tend = omp_get_wtime(); tend = omp_get_wtime();
if (true) //verbosity > 1 ) if (true) //verbosity > 1 )
std::cout << " - Density calculation took " << tend - tstart << "s with " << omp_get_max_threads() << " threads." << std::endl; music::ulog << " - Density calculation took " << tend - tstart << "s with " << omp_get_max_threads() << " threads." << std::endl;
#else #else
tend = (double)clock() / CLOCKS_PER_SEC; tend = (double)clock() / CLOCKS_PER_SEC;
if (true) //verbosity > 1 ) if (true) //verbosity > 1 )
std::cout << " - Density calculation took " << tend - tstart << "s." << std::endl; music::ulog << " - Density calculation took " << tend - tstart << "s." << std::endl;
#endif #endif
if( !fourier_splicing ){ if( !fourier_splicing ){
@ -467,8 +459,7 @@ void normalize_density(grid_hierarchy &delta)
sum /= (double)(nx * ny * nz); sum /= (double)(nx * ny * nz);
} }
std::cout << " - Top grid mean density is off by " << sum << ", correcting..." << std::endl; music::ilog << "- Top grid mean density is off by " << sum << ", correcting..." << std::endl;
music::ulog.Print("Grid mean density is %g. Correcting...", sum);
for (unsigned i = levelmin; i <= levelmax; ++i) for (unsigned i = levelmin; i <= levelmax; ++i)
{ {

View file

@ -94,18 +94,18 @@ double compute_finest_sigma(grid_hierarchy &u);
void splash(void) void splash(void)
{ {
std::cout music::ilog << std::endl
<< "\n __ __ __ __ ______ __ ______ \n" << " __ __ __ __ ______ __ ______ " << std::endl
<< " /\\ \"-./ \\ /\\ \\/\\ \\ /\\ ___\\ /\\ \\ /\\ ___\\ \n" << " /\\ \"-./ \\ /\\ \\/\\ \\ /\\ ___\\ /\\ \\ /\\ ___\\ " << std::endl
<< " \\ \\ \\-./\\ \\ \\ \\ \\_\\ \\ \\ \\___ \\ \\ \\ \\ \\ \\ \\____ \n" << " \\ \\ \\-./\\ \\ \\ \\ \\_\\ \\ \\ \\___ \\ \\ \\ \\ \\ \\ \\____ " << std::endl
<< " \\ \\_\\ \\ \\_\\ \\ \\_____\\ \\/\\_____\\ \\ \\_\\ \\ \\_____\\ \n" << " \\ \\_\\ \\ \\_\\ \\ \\_____\\ \\/\\_____\\ \\ \\_\\ \\ \\_____\\ " << std::endl
<< " \\/_/ \\/_/ \\/_____/ \\/_____/ \\/_/ \\/_____/ \n\n" << " \\/_/ \\/_/ \\/_____/ \\/_____/ \\/_/ \\/_____/ " << std::endl << std::endl
<< " this is " << THE_CODE_NAME << " version " << THE_CODE_VERSION << "\n\n"; << " this is " << THE_CODE_NAME << " version " << THE_CODE_VERSION << std::endl << std::endl;
#if defined(CMAKE_BUILD) #if defined(CMAKE_BUILD)
music::ilog.Print("Version built from git rev.: %s, tag: %s, branch: %s", GIT_REV, GIT_TAG, GIT_BRANCH); music::ilog.Print("Version built from git rev.: %s, tag: %s, branch: %s", GIT_REV, GIT_TAG, GIT_BRANCH);
#endif #endif
std::cout << "\n\n"; music::ilog << std::endl << std::endl;
} }
void modify_grid_for_TF(const refinement_hierarchy &rh_full, refinement_hierarchy &rh_TF, config_file &cf) void modify_grid_for_TF(const refinement_hierarchy &rh_full, refinement_hierarchy &rh_TF, config_file &cf)
@ -151,7 +151,7 @@ void modify_grid_for_TF(const refinement_hierarchy &rh_full, refinement_hierarch
if (lbaseTF > lbase) if (lbaseTF > lbase)
{ {
std::cout << " - Will use levelmin = " << lbaseTF << " to compute density field...\n"; music::ilog << "- Will use levelmin = " << lbaseTF << " to compute density field...\n";
for (unsigned i = lbase; i <= lbaseTF; ++i) for (unsigned i = lbase; i <= lbaseTF; ++i)
{ {
@ -180,48 +180,48 @@ void print_hierarchy_stats(config_file &cf, const refinement_hierarchy &rh)
else else
cmass = omegam * rhom * dx3; cmass = omegam * rhom * dx3;
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
if (rh.get_shift(0) != 0 || rh.get_shift(1) != 0 || rh.get_shift(2) != 0) if (rh.get_shift(0) != 0 || rh.get_shift(1) != 0 || rh.get_shift(2) != 0)
std::cout << " - Domain will be shifted by (" << rh.get_shift(0) << ", " << rh.get_shift(1) << ", " << rh.get_shift(2) << ")\n" music::ilog << "- Domain will be shifted by (" << rh.get_shift(0) << ", " << rh.get_shift(1) << ", " << rh.get_shift(2) << ")\n"
<< std::endl; << std::endl;
std::cout << " - Grid structure:\n"; music::ilog << "- Grid structure:\n";
for (unsigned ilevel = rh.levelmin(); ilevel <= rh.levelmax(); ++ilevel) for (unsigned ilevel = rh.levelmin(); ilevel <= rh.levelmax(); ++ilevel)
{ {
double rfac = 1.0 / (1 << (ilevel - rh.levelmin())), rfac3 = rfac * rfac * rfac; double rfac = 1.0 / (1 << (ilevel - rh.levelmin())), rfac3 = rfac * rfac * rfac;
mtotgrid = omegam * rhom * dx3 * rfac3 * rh.size(ilevel, 0) * rh.size(ilevel, 1) * rh.size(ilevel, 2); mtotgrid = omegam * rhom * dx3 * rfac3 * rh.size(ilevel, 0) * rh.size(ilevel, 1) * rh.size(ilevel, 2);
std::cout music::ilog
<< " Level " << std::setw(3) << ilevel << " : offset = (" << std::setw(5) << rh.offset(ilevel, 0) << ", " << std::setw(5) << rh.offset(ilevel, 1) << ", " << std::setw(5) << rh.offset(ilevel, 2) << ")\n" << " Level " << std::setw(3) << ilevel << " : offset = (" << std::setw(5) << rh.offset(ilevel, 0) << ", " << std::setw(5) << rh.offset(ilevel, 1) << ", " << std::setw(5) << rh.offset(ilevel, 2) << ")\n"
<< " size = (" << std::setw(5) << rh.size(ilevel, 0) << ", " << std::setw(5) << rh.size(ilevel, 1) << ", " << std::setw(5) << rh.size(ilevel, 2) << ")\n"; << " size = (" << std::setw(5) << rh.size(ilevel, 0) << ", " << std::setw(5) << rh.size(ilevel, 1) << ", " << std::setw(5) << rh.size(ilevel, 2) << ")\n";
if (ilevel == rh.levelmax()) if (ilevel == rh.levelmax())
{ {
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
std::cout << " - Finest level :\n"; music::ilog << "- Finest level :\n";
if (dx * rfac > 0.1) if (dx * rfac > 0.1)
std::cout << " extent = " << dx * rfac * rh.size(ilevel, 0) << " x " << dx * rfac * rh.size(ilevel, 1) << " x " << dx * rfac * rh.size(ilevel, 2) << " h-3 Mpc**3\n"; music::ilog << " extent = " << dx * rfac * rh.size(ilevel, 0) << " x " << dx * rfac * rh.size(ilevel, 1) << " x " << dx * rfac * rh.size(ilevel, 2) << " h-3 Mpc**3\n";
else if (dx * rfac > 1e-4) else if (dx * rfac > 1e-4)
std::cout << " extent = " << dx * rfac * 1000.0 * rh.size(ilevel, 0) << " x " << dx * rfac * 1000.0 * rh.size(ilevel, 1) << " x " << dx * rfac * 1000.0 * rh.size(ilevel, 2) << " h-3 kpc**3\n"; music::ilog << " extent = " << dx * rfac * 1000.0 * rh.size(ilevel, 0) << " x " << dx * rfac * 1000.0 * rh.size(ilevel, 1) << " x " << dx * rfac * 1000.0 * rh.size(ilevel, 2) << " h-3 kpc**3\n";
else else
std::cout << " extent = " << dx * rfac * 1.e6 * rh.size(ilevel, 0) << " x " << dx * rfac * 1.e6 * rh.size(ilevel, 1) << " x " << dx * rfac * 1.e6 * rh.size(ilevel, 2) << " h-3 pc**3\n"; music::ilog << " extent = " << dx * rfac * 1.e6 * rh.size(ilevel, 0) << " x " << dx * rfac * 1.e6 * rh.size(ilevel, 1) << " x " << dx * rfac * 1.e6 * rh.size(ilevel, 2) << " h-3 pc**3\n";
std::cout << " mtotgrid = " << mtotgrid << " h-1 M_o\n"; music::ilog << " mtotgrid = " << mtotgrid << " h-1 M_o\n";
std::cout << " particle mass = " << cmass * rfac3 << " h-1 M_o\n"; music::ilog << " particle mass = " << cmass * rfac3 << " h-1 M_o\n";
if (bbaryons) if (bbaryons)
std::cout << " baryon mass/cell = " << bmass * rfac3 << " h-1 M_o\n"; music::ilog << " baryon mass/cell = " << bmass * rfac3 << " h-1 M_o\n";
if (dx * rfac > 0.1) if (dx * rfac > 0.1)
std::cout << " dx = " << dx * rfac << " h-1 Mpc\n"; music::ilog << " dx = " << dx * rfac << " h-1 Mpc\n";
else if (dx * rfac > 1e-4) else if (dx * rfac > 1e-4)
std::cout << " dx = " << dx * rfac * 1000.0 << " h-1 kpc\n"; music::ilog << " dx = " << dx * rfac * 1000.0 << " h-1 kpc\n";
else else
std::cout << " dx = " << dx * rfac * 1.e6 << " h-1 pc\n"; music::ilog << " dx = " << dx * rfac * 1.e6 << " h-1 pc\n";
} }
} }
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
} }
void store_grid_structure(config_file &cf, const refinement_hierarchy &rh) void store_grid_structure(config_file &cf, const refinement_hierarchy &rh)
@ -372,9 +372,10 @@ int main(int argc, const char *argv[])
//... parse command line options //... parse command line options
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
splash();
if (argc != 2) if (argc != 2)
{ {
splash();
std::cout << " This version is compiled with the following plug-ins:\n"; std::cout << " This version is compiled with the following plug-ins:\n";
print_region_generator_plugins(); print_region_generator_plugins();
@ -394,6 +395,8 @@ int main(int argc, const char *argv[])
snprintf(logfname, 128, "%s_log.txt", argv[1]); snprintf(logfname, 128, "%s_log.txt", argv[1]);
music::logger::set_output(logfname); music::logger::set_output(logfname);
time_t ltime = time(NULL); time_t ltime = time(NULL);
splash();
music::ilog.Print("Opening log file \'%s\'.", logfname); music::ilog.Print("Opening log file \'%s\'.", logfname);
music::ulog.Print("Running %s, version %s", THE_CODE_NAME, THE_CODE_VERSION); music::ulog.Print("Running %s, version %s", THE_CODE_NAME, THE_CODE_VERSION);
music::ulog.Print("Log is for run started %s", asctime(localtime(&ltime))); music::ulog.Print("Log is for run started %s", asctime(localtime(&ltime)));
@ -413,6 +416,10 @@ int main(int argc, const char *argv[])
CONFIG::FFTW_threads_ok = FFTW_API(init_threads)(); CONFIG::FFTW_threads_ok = FFTW_API(init_threads)();
CONFIG::num_threads = cf.get_value_safe<unsigned>("execution", "NumThreads",std::thread::hardware_concurrency()); CONFIG::num_threads = cf.get_value_safe<unsigned>("execution", "NumThreads",std::thread::hardware_concurrency());
music::ilog << "-------------------------------------------------------------------------------" << std::endl;
output_system_info();
music::ilog << "-------------------------------------------------------------------------------" << std::endl;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//... initialize some parameters about grid set-up //... initialize some parameters about grid set-up
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -427,8 +434,8 @@ int main(int argc, const char *argv[])
if (lbaseTF < lbase) if (lbaseTF < lbase)
{ {
std::cout << " - WARNING: levelminTF < levelmin. This is not good!\n" music::ilog << " - WARNING: levelminTF < levelmin. This is not good!" << std::endl
<< " I will set levelminTF = levelmin.\n"; << " I will set levelminTF = levelmin." << std::endl;
music::ulog.Print("levelminTF < levelmin. set levelminTF = levelmin."); music::ulog.Print("levelminTF < levelmin. set levelminTF = levelmin.");
@ -460,7 +467,7 @@ int main(int argc, const char *argv[])
cosmology cosmo(cf); cosmology cosmo(cf);
std::cout << " - starting at a=" << cosmo.astart << std::endl; music::ilog << "- starting at a=" << cosmo.astart << std::endl;
CosmoCalc ccalc(cosmo, the_transfer_function_plugin); CosmoCalc ccalc(cosmo, the_transfer_function_plugin);
cosmo.pnorm = ccalc.ComputePNorm(2.0 * M_PI / boxlength); cosmo.pnorm = ccalc.ComputePNorm(2.0 * M_PI / boxlength);
@ -499,8 +506,8 @@ int main(int argc, const char *argv[])
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
if (!the_transfer_function_plugin->tf_is_distinct() && do_baryons) if (!the_transfer_function_plugin->tf_is_distinct() && do_baryons)
std::cout << " - WARNING: The selected transfer function does not support\n" music::wlog << " - WARNING: The selected transfer function does not support" << std::endl
<< " distinct amplitudes for baryon and DM fields!\n" << " distinct amplitudes for baryon and DM fields!" << std::endl
<< " Perturbation amplitudes will be identical!" << std::endl; << " Perturbation amplitudes will be identical!" << std::endl;
@ -538,10 +545,10 @@ int main(int argc, const char *argv[])
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//... initialize the random numbers //... initialize the random numbers
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " GENERATING WHITE NOISE\n"; music::ilog << " GENERATING WHITE NOISE\n";
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing white noise..."); music::ilog << "Computing white noise..." << std::endl;
// rand_gen rand(cf, rh_TF, the_transfer_function_plugin); // rand_gen rand(cf, rh_TF, the_transfer_function_plugin);
rand.initialize_for_grid_structure( rh_TF ); rand.initialize_for_grid_structure( rh_TF );
@ -597,9 +604,9 @@ int main(int argc, const char *argv[])
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//... cdm density and displacements //... cdm density and displacements
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING DARK MATTER DISPLACEMENTS\n"; music::ilog << " COMPUTING DARK MATTER DISPLACEMENTS\n";
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing dark matter displacements..."); music::ulog.Print("Computing dark matter displacements...");
grid_hierarchy f(nbnd); //, u(nbnd); grid_hierarchy f(nbnd); //, u(nbnd);
@ -667,9 +674,9 @@ int main(int argc, const char *argv[])
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
if (do_baryons) if (do_baryons)
{ {
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING BARYON DENSITY\n"; music::ilog << " COMPUTING BARYON DENSITY\n";
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing baryon density..."); music::ulog.Print("Computing baryon density...");
GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, false, bbshift); GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, false, bbshift);
coarsen_density(rh_Poisson, f, bspectral_sampling); coarsen_density(rh_Poisson, f, bspectral_sampling);
@ -736,9 +743,9 @@ int main(int argc, const char *argv[])
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
if ((!the_transfer_function_plugin->tf_has_velocities() || !do_baryons) && !bsph) if ((!the_transfer_function_plugin->tf_has_velocities() || !do_baryons) && !bsph)
{ {
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING VELOCITIES\n"; music::ilog << " COMPUTING VELOCITIES\n";
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing velocitites..."); music::ulog.Print("Computing velocitites...");
if (do_baryons || the_transfer_function_plugin->tf_has_velocities()) if (do_baryons || the_transfer_function_plugin->tf_has_velocities())
@ -807,9 +814,9 @@ int main(int argc, const char *argv[])
else else
{ {
music::ilog.Print("Computing separate velocities for CDM and baryons:"); music::ilog.Print("Computing separate velocities for CDM and baryons:");
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING DARK MATTER VELOCITIES\n"; music::ilog << " COMPUTING DARK MATTER VELOCITIES" << std::endl;
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing dark matter velocitites..."); music::ulog.Print("Computing dark matter velocitites...");
//... we do baryons and have velocity transfer functions, or we do SPH and not to shift //... we do baryons and have velocity transfer functions, or we do SPH and not to shift
@ -868,9 +875,9 @@ int main(int argc, const char *argv[])
data_forIO.deallocate(); data_forIO.deallocate();
f.deallocate(); f.deallocate();
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING BARYON VELOCITIES\n"; music::ilog << " COMPUTING BARYON VELOCITIES" << std::endl;
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing baryon velocitites..."); music::ulog.Print("Computing baryon velocitites...");
//... do baryons //... do baryons
GenerateDensityHierarchy(cf, the_transfer_function_plugin, vbaryon, rh_TF, rand, f, false, bbshift); GenerateDensityHierarchy(cf, the_transfer_function_plugin, vbaryon, rh_TF, rand, f, false, bbshift);
@ -944,18 +951,16 @@ int main(int argc, const char *argv[])
if (!do_baryons || !the_transfer_function_plugin->tf_has_velocities()) if (!do_baryons || !the_transfer_function_plugin->tf_has_velocities())
my_tf_type = total; my_tf_type = total;
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
if (my_tf_type == total) if (my_tf_type == total)
{ {
std::cout << " COMPUTING VELOCITIES\n"; music::ilog << " COMPUTING VELOCITIES" << std::endl;
music::ulog.Print("Computing velocities...");
} }
else else
{ {
std::cout << " COMPUTING DARK MATTER VELOCITIES\n"; music::ilog << " COMPUTING DARK MATTER VELOCITIES" << std::endl;
music::ulog.Print("Computing dark matter velocities...");
} }
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
GenerateDensityHierarchy(cf, the_transfer_function_plugin, my_tf_type, rh_TF, rand, f, false, false); GenerateDensityHierarchy(cf, the_transfer_function_plugin, my_tf_type, rh_TF, rand, f, false, false);
coarsen_density(rh_Poisson, f, bspectral_sampling); coarsen_density(rh_Poisson, f, bspectral_sampling);
@ -980,16 +985,16 @@ int main(int argc, const char *argv[])
else else
f.deallocate(); f.deallocate();
music::ilog.Print("Computing 2LPT term...."); music::ilog.Print("- Computing 2LPT term....");
if (!kspace2LPT) if (!kspace2LPT)
compute_2LPT_source(u1, f2LPT, grad_order); compute_2LPT_source(u1, f2LPT, grad_order);
else else
{ {
music::ulog.Print("computing term using FFT"); music::ulog.Print(" computing term using FFT");
compute_2LPT_source_FFT(cf, u1, f2LPT); compute_2LPT_source_FFT(cf, u1, f2LPT);
} }
music::ilog.Print("Solving 2LPT Poisson equation"); music::ilog.Print("- Solving 2LPT Poisson equation");
u2LPT = u1; u2LPT = u1;
u2LPT.zero(); u2LPT.zero();
the_poisson_solver->solve(f2LPT, u2LPT); the_poisson_solver->solve(f2LPT, u2LPT);
@ -1034,8 +1039,8 @@ int main(int argc, const char *argv[])
double maxv = compute_finest_absmax(data_forIO); double maxv = compute_finest_absmax(data_forIO);
music::ilog.Print("max of abs of %c-velocity of high-res particles is %f", 'x' + icoord, maxv); music::ilog.Print("max of abs of %c-velocity of high-res particles is %f", 'x' + icoord, maxv);
std::cerr << " - velocity component " << icoord << " : sigma = " << sigv << std::endl; music::ilog << " - velocity component " << icoord << " : sigma = " << sigv << std::endl;
std::cerr << " - velocity component " << icoord << " : mean = " << meanv << std::endl; music::ilog << " - velocity component " << icoord << " : mean = " << meanv << std::endl;
coarsen_density(rh_Poisson, data_forIO, false); coarsen_density(rh_Poisson, data_forIO, false);
@ -1058,9 +1063,9 @@ int main(int argc, const char *argv[])
if (do_baryons && (the_transfer_function_plugin->tf_has_velocities() || bsph)) if (do_baryons && (the_transfer_function_plugin->tf_has_velocities() || bsph))
{ {
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING BARYON VELOCITIES\n"; music::ilog << " COMPUTING BARYON VELOCITIES" << std::endl;
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing baryon displacements..."); music::ulog.Print("Computing baryon displacements...");
GenerateDensityHierarchy(cf, the_transfer_function_plugin, vbaryon, rh_TF, rand, f, false, bbshift); GenerateDensityHierarchy(cf, the_transfer_function_plugin, vbaryon, rh_TF, rand, f, false, bbshift);
@ -1132,8 +1137,8 @@ int main(int argc, const char *argv[])
double maxv = compute_finest_absmax(data_forIO); double maxv = compute_finest_absmax(data_forIO);
music::ilog.Print("max of abs of %c-velocity of high-res baryons is %f", 'x' + icoord, maxv); music::ilog.Print("max of abs of %c-velocity of high-res baryons is %f", 'x' + icoord, maxv);
std::cerr << " - velocity component " << icoord << " : sigma = " << sigv << std::endl; music::ilog << " - velocity component " << icoord << " : sigma = " << sigv << std::endl;
std::cerr << " - velocity component " << icoord << " : mean = " << meanv << std::endl; music::ilog << " - velocity component " << icoord << " : mean = " << meanv << std::endl;
coarsen_density(rh_Poisson, data_forIO, false); coarsen_density(rh_Poisson, data_forIO, false);
@ -1147,9 +1152,9 @@ int main(int argc, const char *argv[])
u1.deallocate(); u1.deallocate();
} }
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING DARK MATTER DISPLACEMENTS\n"; music::ilog << " COMPUTING DARK MATTER DISPLACEMENTS" << std::endl;
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing dark matter displacements..."); music::ulog.Print("Computing dark matter displacements...");
//... if baryons are enabled, the displacements have to be recomputed //... if baryons are enabled, the displacements have to be recomputed
@ -1254,9 +1259,9 @@ int main(int argc, const char *argv[])
if (do_baryons && !bsph) if (do_baryons && !bsph)
{ {
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING BARYON DENSITY\n"; music::ilog << " COMPUTING BARYON DENSITY" << std::endl;
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing baryon density..."); music::ulog.Print("Computing baryon density...");
GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, true, false); GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, true, false);
@ -1297,9 +1302,9 @@ int main(int argc, const char *argv[])
} }
else if (do_baryons && bsph) else if (do_baryons && bsph)
{ {
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
std::cout << " COMPUTING BARYON DISPLACEMENTS\n"; music::ilog << " COMPUTING BARYON DISPLACEMENTS" << std::endl;
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ulog.Print("Computing baryon displacements..."); music::ulog.Print("Computing baryon displacements...");
GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, false, bbshift); GenerateDensityHierarchy(cf, the_transfer_function_plugin, baryon, rh_TF, rand, f, false, bbshift);
@ -1385,11 +1390,10 @@ int main(int argc, const char *argv[])
bfatal = true; bfatal = true;
} }
std::cout << "=============================================================\n"; music::ilog << "===============================================================================" << std::endl;
if (!bfatal) if (!bfatal)
{ {
std::cout << " - Wrote output file \'" << outfname << "\'\n using plugin \'" << outformat << "\'...\n"; music::ilog << " - Wrote output file \'" << outfname << "\'\n using plugin \'" << outformat << "\'...\n";
music::ulog.Print("Wrote output file \'%s\'.", outfname.c_str()); music::ulog.Print("Wrote output file \'%s\'.", outfname.c_str());
} }
@ -1405,8 +1409,7 @@ int main(int argc, const char *argv[])
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//... we are done ! //... we are done !
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::cout << " - Done!" << std::endl music::ilog << " - Done!" << std::endl << std::endl;
<< std::endl;
ltime = time(NULL); ltime = time(NULL);

View file

@ -1811,22 +1811,22 @@ public:
//! write refinement hierarchy to stdout //! write refinement hierarchy to stdout
void output(void) const void output(void) const
{ {
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
if (xshift_[0] != 0 || xshift_[1] != 0 || xshift_[2] != 0) if (xshift_[0] != 0 || xshift_[1] != 0 || xshift_[2] != 0)
std::cout << " - Domain will be shifted by (" << xshift_[0] << ", " << xshift_[1] << ", " << xshift_[2] << ")\n" music::ilog << " - Domain will be shifted by (" << xshift_[0] << ", " << xshift_[1] << ", " << xshift_[2] << ")\n"
<< std::endl; << std::endl;
std::cout << " - Grid structure:\n"; music::ilog << " - Grid structure:\n";
for (unsigned ilevel = levelmin_; ilevel <= levelmax_; ++ilevel) for (unsigned ilevel = levelmin_; ilevel <= levelmax_; ++ilevel)
{ {
std::cout music::ilog
<< " Level " << std::setw(3) << ilevel << " : offset = (" << std::setw(5) << offsets_[ilevel][0] << ", " << std::setw(5) << offsets_[ilevel][1] << ", " << std::setw(5) << offsets_[ilevel][2] << ")\n" << " Level " << std::setw(3) << ilevel << " : offset = (" << std::setw(5) << offsets_[ilevel][0] << ", " << std::setw(5) << offsets_[ilevel][1] << ", " << std::setw(5) << offsets_[ilevel][2] << ")\n"
<< " offset_abs = (" << std::setw(5) << absoffsets_[ilevel][0] << ", " << std::setw(5) << absoffsets_[ilevel][1] << ", " << std::setw(5) << absoffsets_[ilevel][2] << ")\n" << " offset_abs = (" << std::setw(5) << absoffsets_[ilevel][0] << ", " << std::setw(5) << absoffsets_[ilevel][1] << ", " << std::setw(5) << absoffsets_[ilevel][2] << ")\n"
<< " size = (" << std::setw(5) << len_[ilevel][0] << ", " << std::setw(5) << len_[ilevel][1] << ", " << std::setw(5) << len_[ilevel][2] << ")\n"; << " size = (" << std::setw(5) << len_[ilevel][0] << ", " << std::setw(5) << len_[ilevel][1] << ", " << std::setw(5) << len_[ilevel][2] << ")\n";
} }
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
} }
void output_log(void) const void output_log(void) const

View file

@ -864,7 +864,7 @@ public:
double rhom = 2.77519737e11; // h-1 M_o / (h-1 Mpc)**3 double rhom = 2.77519737e11; // h-1 M_o / (h-1 Mpc)**3
double cmass, bmass(0.0); double cmass, bmass(0.0);
std::cout << "-------------------------------------------------------------" << std::endl; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
music::ilog.Print("TIPSY: particle resampling is enabled"); music::ilog.Print("TIPSY: particle resampling is enabled");
music::ilog.Print("TIPSY: new high-res particles have the masses:"); music::ilog.Print("TIPSY: new high-res particles have the masses:");
if( with_baryons_ ) if( with_baryons_ )

View file

@ -601,7 +601,7 @@ void RNG_music::fill_grid(int ilevel, DensityGrid<real_t> &A)
delete mem_cache_[ilevel - levelmin_]; delete mem_cache_[ilevel - levelmin_];
mem_cache_[ilevel - levelmin_] = NULL; mem_cache_[ilevel - levelmin_] = NULL;
} }
}; }
namespace namespace
{ {

View file

@ -59,8 +59,8 @@ real_t multigrid_poisson_plugin::solve(grid_hierarchy &f, grid_hierarchy &u)
if (verbosity > 0) if (verbosity > 0)
{ {
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
std::cout << " - Invoking multi-grid Poisson solver..." << std::endl; music::ilog << "- Invoking multi-grid Poisson solver..." << std::endl;
} }
real_t acc = 1e-5, err; real_t acc = 1e-5, err;
@ -99,7 +99,7 @@ real_t multigrid_poisson_plugin::solve(grid_hierarchy &f, grid_hierarchy &u)
real_t tstart, tend; real_t tstart, tend;
#ifndef SINGLETHREAD_FFTW #if defined(_OPENMP)
tstart = omp_get_wtime(); tstart = omp_get_wtime();
#else #else
tstart = (real_t)clock() / CLOCKS_PER_SEC; tstart = (real_t)clock() / CLOCKS_PER_SEC;
@ -132,7 +132,7 @@ real_t multigrid_poisson_plugin::solve(grid_hierarchy &f, grid_hierarchy &u)
//------------------------------// //------------------------------//
#ifndef SINGLETHREAD_FFTW #if defined(_OPENMP)
tend = omp_get_wtime(); tend = omp_get_wtime();
if (verbosity > 1) if (verbosity > 1)
std::cout << " - Poisson solver took " << tend - tstart << "s with " << omp_get_max_threads() << " threads." << std::endl; std::cout << " - Poisson solver took " << tend - tstart << "s with " << omp_get_max_threads() << " threads." << std::endl;
@ -430,8 +430,8 @@ real_t fft_poisson_plugin::solve(grid_hierarchy &f, grid_hierarchy &u)
if (verbosity > 0) if (verbosity > 0)
{ {
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
std::cout << " - Invoking unigrid FFT Poisson solver..." << std::endl; music::ilog << " - Invoking unigrid FFT Poisson solver..." << std::endl;
} }
int nx, ny, nz, nzp; int nx, ny, nz, nzp;
@ -882,7 +882,7 @@ void poisson_hybrid(T &f, int idir, int order, bool periodic, bool deconvolve_ci
data = new real_t[(size_t)nxp * (size_t)nyp * (size_t)(nzp + 2)]; data = new real_t[(size_t)nxp * (size_t)nyp * (size_t)(nzp + 2)];
if (idir == 0) if (idir == 0)
std::cout << " - Performing hybrid Poisson step... (" << nxp << ", " << nyp << ", " << nzp << ")\n"; music::ilog << " - Performing hybrid Poisson step... (" << nxp << ", " << nyp << ", " << nzp << ")" << std::endl;
#pragma omp parallel for #pragma omp parallel for
for (int i = 0; i < nxp; ++i) for (int i = 0; i < nxp; ++i)

View file

@ -417,8 +417,8 @@ double solver<S, O>::solve(GridHierarchy<real_t> &uh, double acc, double h, bool
if (verbose) if (verbose)
{ {
std::cout << "--> Step No. " << std::setw(3) << niter << ", Max Err = " << err << std::endl; music::ilog << "--> Step No. " << std::setw(3) << niter << ", Max Err = " << err << std::endl;
std::cout << "-------------------------------------------------------------\n"; music::ilog << "-------------------------------------------------------------------------------" << std::endl;
} }
if ((niter > 1) && ((err < acc) || (niter > 20))) if ((niter > 1) && ((err < acc) || (niter > 20)))
@ -429,9 +429,9 @@ double solver<S, O>::solve(GridHierarchy<real_t> &uh, double acc, double h, bool
} }
if (err > acc) if (err > acc)
std::cout << "Error : no convergence in Poisson solver" << std::endl; music::elog << "Error : no convergence in Poisson solver" << std::endl;
else if (verbose) else if (verbose)
std::cout << " - Converged in " << niter << " steps to req. acc. of " << acc << std::endl; music::ulog << " - Converged in " << niter << " steps to req. acc. of " << acc << std::endl;
// uh = uhnew; // uh = uhnew;
//*m_pf = fsave; //*m_pf = fsave;