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

code now explicitly fails if zoom region is more than half box size instead of having undefined behaviour.

fixed a missing default option for levelmin_TF in constraints.cc.
This commit is contained in:
Oliver Hahn 2013-07-29 17:56:15 +02:00
parent 8657bdee4d
commit 6df708ce8d
2 changed files with 14 additions and 1 deletions

View file

@ -170,7 +170,8 @@ constraint_set::constraint_set( config_file& cf, transfer_function *ptf )
unsigned i=0;
unsigned levelmin_TF = pcf_->getValue<unsigned>("setup","levelmin_TF");
unsigned levelmin = pcf_->getValue<unsigned>("setup","levelmin");
unsigned levelmin_TF = pcf_->getValueSafe<unsigned>("setup","levelmin_TF",levelmin);
constr_level_ = pcf_->getValueSafe<unsigned>("constraints","level",levelmin_TF);
constr_level_ = std::max(constr_level_,levelmin_TF);

12
mesh.hh
View file

@ -1474,6 +1474,18 @@ public:
xl_[ilevel] = yl_[ilevel] = zl_[ilevel] = 1.0;
nx_[ilevel] = ny_[ilevel] = nz_[ilevel] = n;
}
// do a consistency check that largest subgrid in zoom is not larger than half the box size
for( unsigned ilevel=levelmin_+1; ilevel<=levelmax_; ++ilevel )
{
if( nx_[ilevel] > (1ul<<(ilevel-1)) ||
ny_[ilevel] > (1ul<<(ilevel-1)) ||
nz_[ilevel] > (1ul<<(ilevel-1)) )
{
LOGERR("On level %d, subgrid is larger than half the box. This is not allowed!",ilevel);
throw std::runtime_error("Fatal: Subgrid larger than half boxin zoom.");
}
}
// update the region generator with what has been actually created
double left[3] = { x0_[levelmax_]+rshift_[0], y0_[levelmax_]+rshift_[1], z0_[levelmax_]+rshift_[2] };