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 compiler warnings appearing with newer versions of gcc (tested with gcc 4.8)

This commit is contained in:
Oliver Hahn 2013-11-05 15:34:00 +01:00
parent 86b85edadd
commit 458607f2f6
9 changed files with 123 additions and 108 deletions

View file

@ -4,7 +4,7 @@
a code to generate multi-scale initial conditions
for cosmological simulations
Copyright (C) 2010-13 Oliver Hahn
Copyright (C) 2010 Oliver Hahn
*/
@ -27,9 +27,9 @@ void fft_interpolate( m1& V, m2& v, bool from_basegrid=false )
if( !from_basegrid )
{
oxf += nxF/4;
oyf += nyF/4;
ozf += nzF/4;
oxf += nxF/4;
oyf += nyF/4;
ozf += nzF/4;
}
LOGUSER("FFT interpolate: offset=%d,%d,%d size=%d,%d,%d",oxf,oyf,ozf,nxf,nyf,nzf);
@ -58,16 +58,15 @@ void fft_interpolate( m1& V, m2& v, bool from_basegrid=false )
size_t q = ((size_t)ii*nyc+(size_t)jj)*nzcp+(size_t)kk;
rcoarse[q] = V( oxf+i, oyf+j, ozf+k );
}
#pragma omp parallel for
for( int i=0; i<(int)nxf; ++i )
for( int j=0; j<(int)nyf; ++j )
for( int k=0; k<(int)nzf; ++k )
{
size_t q = ((size_t)i*nyf+(size_t)j)*nzfp+(size_t)k;
rfine[q] = v(i,j,k);
rfine[q] = v(i,j,k);
}
#ifdef FFTW3
#ifdef SINGLE_PRECISION
@ -244,7 +243,6 @@ void fft_interpolate( m1& V, m2& v, bool from_basegrid=false )
}
delete[] rfine;
}
@ -274,7 +272,7 @@ void GenerateDensityUnigrid( config_file& cf, transfer_function *ptf, tf_type ty
if( kspace )
{
std::cout << " - Using new k-space transfer function kernel.\n";
std::cout << " - Using k-space transfer function kernel.\n";
LOGUSER("Using k-space transfer function kernel.");
#ifdef SINGLE_PRECISION
@ -334,84 +332,63 @@ void GenerateDensityUnigrid( config_file& cf, transfer_function *ptf, tf_type ty
/*******************************************************************************************/
void GenerateDensityHierarchy( config_file& cf, transfer_function *ptf, tf_type type,
refinement_hierarchy& refh, rand_gen& rand, grid_hierarchy& delta, bool smooth, bool shift )
refinement_hierarchy& refh, rand_gen& rand,
grid_hierarchy& delta, bool smooth, bool shift )
{
unsigned levelmin,levelmax,levelminPoisson;
std::vector<long> rngseeds;
std::vector<std::string> rngfnames;
bool kspaceTF;
double tstart, tend;
unsigned levelmin, levelmax, levelminPoisson;
std::vector<long> rngseeds;
std::vector<std::string> rngfnames;
bool kspaceTF;
double tstart, tend;
#ifndef SINGLETHREAD_FFTW
tstart = omp_get_wtime();
tstart = omp_get_wtime();
#else
tstart = (double)clock() / CLOCKS_PER_SEC;
tstart = (double)clock() / CLOCKS_PER_SEC;
#endif
levelminPoisson = cf.getValue<unsigned>("setup","levelmin");
levelmin = cf.getValueSafe<unsigned>("setup","levelmin_TF",levelminPoisson);
levelmax = cf.getValue<unsigned>("setup","levelmax");
kspaceTF = cf.getValueSafe<bool>("setup", "kspace_TF", false);
unsigned nbase = 1<<levelmin;
levelminPoisson = cf.getValue<unsigned>("setup","levelmin");
levelmin = cf.getValueSafe<unsigned>("setup","levelmin_TF",levelminPoisson);
levelmax = cf.getValue<unsigned>("setup","levelmax");
kspaceTF = cf.getValueSafe<bool>("setup", "kspace_TF", false);
convolution::kernel_creator *the_kernel_creator;
unsigned nbase = 1<<levelmin;
convolution::kernel_creator *the_kernel_creator;
if( kspaceTF )
{
if( levelmin!=levelmax )
{
//LOGERR("K-space transfer function can only be used in unigrid density mode!");
// throw std::runtime_error("k-space transfer function can only be used in unigrid density mode");
std::cout << " - Using new k-space transfer function kernel.\n";
LOGUSER("Using new k-space transfer function kernel.");
if( kspaceTF )
{
std::cout << " - Using k-space transfer function kernel.\n";
LOGUSER("Using k-space transfer function kernel.");
#ifdef SINGLE_PRECISION
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_k_new_float" ];
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_k_new_float" ];
#else
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_k_new_double" ];
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_k_new_double" ];
#endif
}else{
std::cout << " - Using new k-space transfer function kernel.\n";
LOGUSER("Using new k-space transfer function kernel.");
}
else
{
std::cout << " - Using real-space transfer function kernel.\n";
LOGUSER("Using real-space transfer function kernel.");
#ifdef SINGLE_PRECISION
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_k_new_float" ];
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_real_float" ];
#else
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_k_new_double" ];
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_real_double" ];
#endif
}
}
else
{
std::cout << " - Using real-space transfer function kernel.\n";
LOGUSER("Using real-space transfer function kernel.");
#ifdef SINGLE_PRECISION
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_real_float" ];
#else
the_kernel_creator = convolution::get_kernel_map()[ "tf_kernel_real_double" ];
#endif
}
}
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 *****/
if( kspaceTF ){
//... create and initialize density grids with white noise
DensityGrid<real_t> *top(NULL);
PaddedDensitySubGrid<real_t> *coarse(NULL), *fine(NULL);
int nlevels = (int)levelmax-(int)levelmin+1;
// do coarse level
top = new DensityGrid<real_t>( nbase, nbase, nbase );
LOGINFO("Performing noise convolution on level %3d",levelmin);
@ -424,34 +401,44 @@ void GenerateDensityHierarchy( config_file& cf, transfer_function *ptf, tf_type
for( int i=1; i<nlevels; ++i )
{
LOGINFO("Performing noise convolution on level %3d...",levelmin+i);
/////////////////////////////////////////////////////////////////////////
//... add new refinement patch
LOGUSER("Allocating refinement patch");
LOGUSER(" offset=(%5d,%5d,%5d)",refh.offset(levelmin+i,0), refh.offset(levelmin+i,1), refh.offset(levelmin+i,2));
LOGUSER(" size =(%5d,%5d,%5d)",refh.size(levelmin+i,0), refh.size(levelmin+i,1), refh.size(levelmin+i,2));
fine = new PaddedDensitySubGrid<real_t>(refh.offset(levelmin+i,0), refh.offset(levelmin+i,1), refh.offset(levelmin+i,2),
refh.size(levelmin+i,0), refh.size(levelmin+i,1), refh.size(levelmin+i,2) );
LOGUSER(" offset=(%5d,%5d,%5d)",refh.offset(levelmin+i,0),
refh.offset(levelmin+i,1), refh.offset(levelmin+i,2));
LOGUSER(" size =(%5d,%5d,%5d)",refh.size(levelmin+i,0),
refh.size(levelmin+i,1), refh.size(levelmin+i,2));
fine = new PaddedDensitySubGrid<real_t>(refh.offset(levelmin+i,0),
refh.offset(levelmin+i,1),
refh.offset(levelmin+i,2),
refh.size(levelmin+i,0),
refh.size(levelmin+i,1),
refh.size(levelmin+i,2) );
/////////////////////////////////////////////////////////////////////////
// load white noise for patch
rand.load(*fine,levelmin+i);
convolution::perform<real_t>( the_tf_kernel->fetch_kernel( levelmin+i, true ), reinterpret_cast<void*>( fine->get_data_ptr() ), shift );
convolution::perform<real_t>( the_tf_kernel->fetch_kernel( levelmin+i, true ),
reinterpret_cast<void*>( fine->get_data_ptr() ), shift );
if( i==1 )
fft_interpolate( *top, *fine, true );
else
fft_interpolate( *coarse, *fine, false );
delta.add_patch( refh.offset(levelmin+i,0), refh.offset(levelmin+i,1), refh.offset(levelmin+i,2),
refh.size(levelmin+i,0), refh.size(levelmin+i,1), refh.size(levelmin+i,2) );
delta.add_patch( refh.offset(levelmin+i,0),
refh.offset(levelmin+i,1),
refh.offset(levelmin+i,2),
refh.size(levelmin+i,0),
refh.size(levelmin+i,1),
refh.size(levelmin+i,2) );
fine->copy_unpad( *delta.get_grid(levelmin+i) );
if( i==1 )
delete top;
else
delete coarse;
if( i==1 ) delete top;
else delete coarse;
coarse = fine;
}
@ -466,7 +453,8 @@ void GenerateDensityHierarchy( config_file& cf, transfer_function *ptf, tf_type
if( levelmax == levelmin )
{
std::cout << " - Performing noise convolution on level " << std::setw(2) << levelmax << " ..." << std::endl;
std::cout << " - Performing noise convolution on level "
<< std::setw(2) << levelmax << " ..." << std::endl;
LOGUSER("Performing noise convolution on level %3d...",levelmax);
top = new DensityGrid<real_t>( nbase, nbase, nbase );
@ -474,7 +462,9 @@ void GenerateDensityHierarchy( config_file& cf, transfer_function *ptf, tf_type
rand.load( *top, levelmin );
convolution::perform<real_t>( the_tf_kernel->fetch_kernel( levelmax ), reinterpret_cast<void*>( top->get_data_ptr() ), shift );
convolution::perform<real_t>( the_tf_kernel->fetch_kernel( levelmax ),
reinterpret_cast<void*>( top->get_data_ptr() ),
shift );
the_tf_kernel->deallocate();
delta.create_base_hierarchy(levelmin);
@ -496,8 +486,12 @@ void GenerateDensityHierarchy( config_file& cf, transfer_function *ptf, tf_type
rand.load(*top,levelmin);
}
fine = new PaddedDensitySubGrid<real_t>( refh.offset(levelmin+i+1,0), refh.offset(levelmin+i+1,1), refh.offset(levelmin+i+1,2),
refh.size(levelmin+i+1,0), refh.size(levelmin+i+1,1), refh.size(levelmin+i+1,2) );
fine = new PaddedDensitySubGrid<real_t>( refh.offset(levelmin+i+1,0),
refh.offset(levelmin+i+1,1),
refh.offset(levelmin+i+1,2),
refh.size(levelmin+i+1,0),
refh.size(levelmin+i+1,1),
refh.size(levelmin+i+1,2) );
rand.load(*fine,levelmin+i+1);
@ -509,7 +503,8 @@ void GenerateDensityHierarchy( config_file& cf, transfer_function *ptf, tf_type
/**********************************************************************************************************\
* multi-grid: top-level grid grids .....
\**********************************************************************************************************/
std::cout << " - Performing noise convolution on level " << std::setw(2) << levelmin+i << " ..." << std::endl;
std::cout << " - Performing noise convolution on level "
<< std::setw(2) << levelmin+i << " ..." << std::endl;
LOGUSER("Performing noise convolution on level %3d",levelmin+i);
LOGUSER("Creating base hierarchy...");
@ -756,8 +751,8 @@ void coarsen_density( const refinement_hierarchy& rh, GridHierarchy<real_t>& u )
}
}
for( int i=rh.levelmax(); i>0; --i )
mg_straight().restrict( *(u.get_grid(i)), *(u.get_grid(i-1)) );
for( int i=rh.levelmax(); i>0; --i )
mg_straight().restrict( *(u.get_grid(i)), *(u.get_grid(i-1)) );
}

View file

@ -286,7 +286,7 @@ struct convex_hull{
for( j=i, l=0; l<npoints_; ++l )
if( i!=l && turn(&points[3*i],&points[3*j],&points[3*l]) >= 0 ) j=l;
int nt = omp_get_num_threads();
int nt = omp_get_max_threads();
omp_set_num_threads( std::min(2,omp_get_max_threads()) );
#pragma omp parallel for

View file

@ -205,7 +205,7 @@ inline real_t get_cic( const grid_hierarchy & gh, int ilevel, real_t u, real_t v
}
MyIDType compute_midpoint( const size_t *connect )
MyIDType compute_midpoint( const MyIDType *connect )
{
MyIDType lid1, lid2, newlid, lcoord1[3], lcoord2[3];
@ -282,7 +282,7 @@ void split_lagrange_cube( size_t ip )
// insert mass carying "true" particles
for( k=0; k<nmassc; ++k )
{
size_t edge_ids[2] = { P[ip].get_vertex( massc_edge[k][0] ), P[ip].get_vertex( massc_edge[k][1] ) };
MyIDType edge_ids[2] = { P[ip].get_vertex( massc_edge[k][0] ), P[ip].get_vertex( massc_edge[k][1] ) };
P[newi+count].Lagrange_ID = compute_midpoint( edge_ids );
@ -300,7 +300,7 @@ void split_lagrange_cube( size_t ip )
// insert massless helper particles
for( k=0; k<nmassl; ++k )
{
size_t edge_ids[2] = { P[ip].get_vertex( massl_edge[k][0] ), P[ip].get_vertex( massl_edge[k][1] ) };
MyIDType edge_ids[2] = { P[ip].get_vertex( massl_edge[k][0] ), P[ip].get_vertex( massl_edge[k][1] ) };
//P[newi+count].ID = new_tracer_id+count;
P[newi+count].Lagrange_ID = compute_midpoint( edge_ids );

View file

@ -4,7 +4,7 @@
a code to generate multi-scale initial conditions
for cosmological simulations
Copyright (C) 2010 Oliver Hahn
Copyright (C) 2010-13 Oliver Hahn
*/
@ -32,7 +32,7 @@ protected:
for(int k=-nb; k<n2+nb; ++k )
vdata.push_back( data(i,j,k) );
unsigned nd[3] = { n0+2*nb,n1+2*nb,n2+2*nb };
unsigned nd[3] = { (unsigned)(n0+2*nb),(unsigned)(n1+2*nb),(unsigned)(n2+2*nb) };
HDFWriteDataset3D( fname, dname, nd, vdata);
}

View file

@ -12,6 +12,7 @@
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <fstream>
#include <unistd.h>
#include "output.hh"

View file

@ -5,10 +5,11 @@ public:
explicit RNG_music( config_file& cf )
: RNG_plugin( cf )
{ }
~RNG_music() { }
bool is_multiscale() const
{
}
{ return true; }
};

View file

@ -1,3 +1,13 @@
/*
region_convex_hull.cc - This file is part of MUSIC -
a code to generate multi-scale initial conditions
for cosmological simulations
Copyright (C) 2010-13 Oliver Hahn
*/
#include <vector>
#include <iostream>
#include <cmath>
@ -68,7 +78,7 @@ public:
phull_->expand( sqrt(3.)*dx );
// output the center
float c[3] = { phull_->centroid_[0], phull_->centroid_[1], phull_->centroid_[2] };
double c[3] = { phull_->centroid_[0], phull_->centroid_[1], phull_->centroid_[2] };
LOGINFO("Region center from convex hull centroid determined at\n\t (%f,%f,%f)",c[0],c[1],c[2]);
//-----------------------------------------------------------------
@ -140,7 +150,7 @@ public:
void get_center_unshifted( double *xc )
{
double dx = 1.0/(1<<shift_level);
float c[3] = { phull_->centroid_[0], phull_->centroid_[1], phull_->centroid_[2] };
double c[3] = { phull_->centroid_[0], phull_->centroid_[1], phull_->centroid_[2] };
xc[0] = c[0]+shift[0]*dx;
xc[1] = c[1]+shift[1]*dx;
xc[2] = c[2]+shift[2]*dx;

View file

@ -1,4 +1,14 @@
#include <vector>
/*
region_ellipsoid.cc - This file is part of MUSIC -
a code to generate multi-scale initial conditions
for cosmological simulations
Copyright (C) 2010-13 Oliver Hahn
*/
#include <iostream>
#include <cmath>
#include <cassert>
@ -53,7 +63,7 @@ void Inverse_4x4( float *mat )
double det; /* determinant */
double dst[16];
/* transpose matrix */
/* transpose matrix */
for (int i = 0; i < 4; i++)
{
src[i] = mat[i*4];
@ -397,9 +407,9 @@ public:
{
dist = (dist + 1.0) * detA13;
float q[3] = {x[0]-c[0],x[1]-c[1],x[2]-c[2]};
T q[3] = {x[0]-c[0],x[1]-c[1],x[2]-c[2]};
double r = 0.0;
T r = 0.0;
for( int i=0; i<3; ++i )
for( int j=0; j<3; ++j )
r += q[i]*A[3*j+i]*q[j];
@ -517,7 +527,7 @@ public:
{
std::vector<double> pp;
for( int i=0; i<=levelmax_; ++i )
for( unsigned i=0; i<=levelmax_; ++i )
pellip_.push_back( NULL );
@ -537,12 +547,10 @@ public:
padding_ = cf.getValue<int>("setup","padding");
std::string point_file;
bool bfrom_file = true;
if( cf.containsKey("setup", "region_point_file") )
{
point_file = cf.getValue<std::string>("setup","region_point_file");
bfrom_file = true;
point_reader pfr;
pfr.read_points_from_file( point_file, vfac_, pp );
@ -668,14 +676,14 @@ public:
~region_ellipsoid_plugin()
{
for( int i=0; i<=levelmax_; ++i )
for( unsigned i=0; i<=levelmax_; ++i )
if( pellip_[i] != NULL )
delete pellip_[i];
}
void get_AABB( double *left, double *right, unsigned level )
{
if( level <= levelmin_ )
if( level <= levelmin_ )
{
left[0] = left[1] = left[2] = 0.0;
right[0] = right[1] = right[2] = 1.0;

View file

@ -12,7 +12,7 @@
class region_generator_plugin{
public:
config_file *pcf_;
int levelmin_, levelmax_;
unsigned levelmin_, levelmax_;
public:
region_generator_plugin( config_file& cf )