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:
parent
8657bdee4d
commit
6df708ce8d
2 changed files with 14 additions and 1 deletions
|
@ -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
12
mesh.hh
|
@ -1475,6 +1475,18 @@ public:
|
|||
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] };
|
||||
double right[3] = { left[0]+xl_[levelmax_], left[1]+yl_[levelmax_], left[2]+zl_[levelmax_] };
|
||||
|
|
Loading…
Reference in a new issue