mirror of
https://github.com/cosmo-sims/MUSIC.git
synced 2024-09-19 17:03:46 +02:00
commit
eb86e9c56b
3 changed files with 106 additions and 40 deletions
3
mesh.hh
3
mesh.hh
|
@ -936,6 +936,9 @@ public:
|
|||
//! assign (element-wise) two grid hierarchies
|
||||
GridHierarchy<T>& operator=( const GridHierarchy<T>& gh )
|
||||
{
|
||||
bhave_refmask = gh.bhave_refmask;
|
||||
ref_mask = gh.ref_mask;
|
||||
|
||||
if( !is_consistent(gh) )
|
||||
{
|
||||
for( unsigned i=0; i<m_pgrids.size(); ++i )
|
||||
|
|
|
@ -33,7 +33,9 @@ protected:
|
|||
}header;
|
||||
|
||||
bool bhavehydro_;
|
||||
float metal_floor_;
|
||||
//float metal_floor_;
|
||||
int passive_variable_index_;
|
||||
float passive_variable_value_;
|
||||
|
||||
void write_file_header( std::ofstream& ofs, unsigned ilevel, const grid_hierarchy& gh )
|
||||
{
|
||||
|
@ -163,11 +165,11 @@ protected:
|
|||
|
||||
std::ofstream ofs_metals;
|
||||
|
||||
if( metal_floor_ > 0.0f )
|
||||
if( passive_variable_value_ > 0.0f )
|
||||
{
|
||||
sprintf(ff,"%s/level_%03d/ic_pvar_00001",fname_.c_str(), gh.levelmax() );
|
||||
ofs_metals.open(ff,std::ios::binary|std::ios::trunc);
|
||||
write_file_header( ofs_metals, gh.levelmax(), gh );
|
||||
sprintf(ff,"%s/level_%03d/ic_pvar_%05d",fname_.c_str(), gh.levelmax(), passive_variable_index_ );
|
||||
ofs_metals.open(ff,std::ios::binary|std::ios::trunc);
|
||||
write_file_header( ofs_metals, gh.levelmax(), gh );
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,11 +188,11 @@ protected:
|
|||
ofs.write( reinterpret_cast<char*> (&blksize), sizeof(unsigned) );
|
||||
|
||||
|
||||
if( metal_floor_ > 0.0f ){
|
||||
if( passive_variable_value_ > 0.0f ){
|
||||
|
||||
for( unsigned j=0; j<n2; ++j )
|
||||
for( unsigned i=0; i<n1; ++i )
|
||||
block[j*n1+i] = data[(i*n2+j)*n3+k] * metal_floor_;
|
||||
block[j*n1+i] = data[(i*n2+j)*n3+k] * passive_variable_value_;
|
||||
|
||||
unsigned blksize = n1*n2*sizeof(float);
|
||||
|
||||
|
@ -240,9 +242,9 @@ protected:
|
|||
write_file_header( ofs, ilevel, gh );
|
||||
|
||||
std::ofstream ofs_metals;
|
||||
if( metal_floor_ > 0.0f )
|
||||
if( passive_variable_value_ > 0.0f )
|
||||
{
|
||||
sprintf(ff,"%s/level_%03d/ic_pvar_00001",fname_.c_str(), ilevel );
|
||||
sprintf(ff,"%s/level_%03d/ic_pvar_%05d",fname_.c_str(), ilevel, passive_variable_index_ );
|
||||
ofs_metals.open(ff,std::ios::binary|std::ios::trunc);
|
||||
write_file_header( ofs_metals, ilevel, gh );
|
||||
}
|
||||
|
@ -261,11 +263,11 @@ protected:
|
|||
ofs.write( reinterpret_cast<char*> (&block[0]), blksize );
|
||||
ofs.write( reinterpret_cast<char*> (&blksize), sizeof(unsigned) );
|
||||
|
||||
if( metal_floor_ > 0.0f ){
|
||||
if( passive_variable_value_ > 0.0f ){
|
||||
|
||||
for( unsigned j=0; j<n2c; ++j )
|
||||
for( unsigned k=0; k<n1c; ++k )
|
||||
block[j*n1c+k] = data_coarse[(k*n2c+j)*n3c+i] * metal_floor_;
|
||||
block[j*n1c+k] = data_coarse[(k*n2c+j)*n3c+i] * passive_variable_value_;
|
||||
|
||||
unsigned blksize = n1c*n2c*sizeof(float);
|
||||
|
||||
|
@ -287,10 +289,36 @@ protected:
|
|||
sprintf(ff,"%s/ramses.nml",fname_.c_str() );
|
||||
|
||||
std::ofstream ofst(ff,std::ios::trunc);
|
||||
|
||||
// -- RUN_PARAMS -- //
|
||||
ofst
|
||||
<< "&RUN_PARAMS\n"
|
||||
<< "cosmo=.true.\n"
|
||||
<< "pic=.true.\n"
|
||||
<< "poisson=.true.\n";
|
||||
|
||||
if( bhavehydro_ )
|
||||
ofst << "hydro=.true.\n";
|
||||
else
|
||||
ofst << "hydro=.false.\n";
|
||||
|
||||
ofst
|
||||
<< "nrestart=0\n"
|
||||
<< "nremap=1\n"
|
||||
<< "nsubcycle=";
|
||||
|
||||
for( unsigned ilevel=gh.levelmin(); ilevel<=gh.levelmax(); ++ilevel )
|
||||
ofst << "1,";
|
||||
ofst << "1,2\n";
|
||||
|
||||
ofst
|
||||
<< "ncontrol=1\n"
|
||||
<< "verbose=.false.\n/\n\n";
|
||||
|
||||
ofst
|
||||
<< "&INIT_PARAMS\n"
|
||||
<< "filetype=\'grafic\'\n";
|
||||
// -- INIT_PARAMS -- //
|
||||
ofst
|
||||
<< "&INIT_PARAMS\n"
|
||||
<< "filetype=\'grafic\'\n";
|
||||
for( unsigned i=gh.levelmin();i<=gh.levelmax(); ++i)
|
||||
{
|
||||
sprintf(ff,"initfile(%d)=\'%s/level_%03d\'\n",i-gh.levelmin()+1,fname_.c_str(), i );
|
||||
|
@ -300,24 +328,42 @@ protected:
|
|||
|
||||
|
||||
unsigned naddref = 8; // initialize with settings for 10 additional levels of refinement
|
||||
unsigned nexp = cf_.getValue<unsigned>("setup","padding");
|
||||
unsigned nexpand = (cf_.getValue<unsigned>("setup","padding")-1)/2;
|
||||
|
||||
// -- AMR_PARAMS -- //
|
||||
ofst << "&AMR_PARAMS\n"
|
||||
<< "levelmin=" << gh.levelmin() << "\n"
|
||||
<< "levelmax=" << gh.levelmax()+naddref << "\n"
|
||||
<< "ngridtot=2000000\n"
|
||||
<< "nparttot=3000000\n"
|
||||
<< "nexpand="<< gh.levelmax()-gh.levelmin()+1+naddref << "*1,\n"
|
||||
<< "/\n\n";
|
||||
|
||||
<< "nexpand=";
|
||||
|
||||
if( gh.levelmax() == gh.levelmin() )
|
||||
ofst << "1";
|
||||
else
|
||||
{
|
||||
for( unsigned ilevel=gh.levelmin(); ilevel<gh.levelmax()-1; ++ilevel )
|
||||
ofst << nexpand << ",";
|
||||
ofst << "1,1";
|
||||
|
||||
}
|
||||
|
||||
ofst << "\n"
|
||||
<< "ngridtot=2000000\n"
|
||||
<< "nparttot=3000000\n"
|
||||
<< "/\n\n";
|
||||
|
||||
ofst << "&REFINE_PARAMS\n"
|
||||
<< "m_refine=" << gh.levelmax()-gh.levelmin()+1+naddref << "*8.,\n"
|
||||
<< "ivar_refine=6\n"
|
||||
<< "var_cut_refine=2e-6\n"
|
||||
//<< "mass_cut_refine=1e-9\n"
|
||||
<< "interpol_var=1\n"
|
||||
<< "interpol_type=0\n"
|
||||
<< "/\n\n";
|
||||
<< "m_refine=" << gh.levelmax()-gh.levelmin()+1+naddref << "*8.,\n";
|
||||
|
||||
if( bhavehydro_ )
|
||||
ofst << "ivar_refine=" << 5+passive_variable_index_ << "\n"
|
||||
<< "var_cut_refine=" << passive_variable_value_*0.01 << "\n";
|
||||
else
|
||||
ofst << "ivar_refine=0\n";
|
||||
|
||||
ofst << "mass_cut_refine=" << 2.0/pow(2,3*gh.levelmax()) << "\n"
|
||||
<< "interpol_var=1\n"
|
||||
<< "interpol_type=0\n"
|
||||
<< "/\n\n";
|
||||
|
||||
|
||||
LOGINFO("The grafic2 output plug-in wrote the grid data to a partial");
|
||||
|
@ -345,8 +391,6 @@ protected:
|
|||
|
||||
double xc,yc,zc,l;
|
||||
|
||||
|
||||
|
||||
ofst
|
||||
<< "&AMR_PARAMS\n"
|
||||
<< "levelmin=" << gh.levelmin() << "\n"
|
||||
|
@ -431,7 +475,9 @@ public:
|
|||
|
||||
|
||||
bhavehydro_ = cf.getValue<bool>("setup","baryons");
|
||||
metal_floor_ = cf.getValueSafe<float>("output","ramses_metal_floor",1e-5);
|
||||
//metal_floor_ = cf.getValueSafe<float>("output","ramses_metal_floor",1e-5);
|
||||
passive_variable_index_ = cf.getValueSafe<int>("output","ramses_pvar_idx",1);
|
||||
passive_variable_value_ = cf.getValueSafe<float>("output","ramses_pvar_val",1.0f);
|
||||
}
|
||||
|
||||
/*~grafic2_output_plugin()
|
||||
|
@ -518,9 +564,9 @@ public:
|
|||
write_ramses_namelist(gh);
|
||||
else if( cf_.getValueSafe<bool>("output","ramses_old_nml",false) )
|
||||
write_ramses_namelist_old(gh);
|
||||
|
||||
write_refinement_mask( gh );
|
||||
|
||||
|
||||
if( gh.levelmin() != gh.levelmax() )
|
||||
write_refinement_mask( gh );
|
||||
}
|
||||
|
||||
void write_dm_mass( const grid_hierarchy& gh )
|
||||
|
|
|
@ -63,14 +63,18 @@ private:
|
|||
size_t lnref_[3];
|
||||
bool bhave_nref_;
|
||||
unsigned levelmin_, levelmax_;
|
||||
|
||||
bool do_extra_padding_;
|
||||
int padding_;
|
||||
double padding_fine_;
|
||||
|
||||
public:
|
||||
region_box_plugin( config_file& cf )
|
||||
: region_generator_plugin( cf )
|
||||
{
|
||||
levelmin_ = pcf_->getValue<unsigned>("setup","levelmin");
|
||||
levelmax_ = pcf_->getValue<unsigned>("setup","levelmax");
|
||||
|
||||
padding_ = cf.getValue<int>("setup","padding");
|
||||
|
||||
std::string temp;
|
||||
|
||||
if( !pcf_->containsKey("setup","ref_offset") && !pcf_->containsKey("setup","ref_center") )
|
||||
|
@ -133,16 +137,29 @@ public:
|
|||
lxref_[2] = xr[2] - x0ref_[2];
|
||||
*/
|
||||
|
||||
// conditions should be added here
|
||||
{
|
||||
do_extra_padding_ = false;
|
||||
std::string output_plugin = cf.getValue<std::string>("output","format");
|
||||
if( output_plugin == std::string("grafic2") )
|
||||
do_extra_padding_ = true;
|
||||
padding_fine_ = 0.0;
|
||||
if( do_extra_padding_ )
|
||||
padding_fine_ = (double)(padding_+1) * 1.0/(1ul<<levelmax_);
|
||||
}
|
||||
}
|
||||
|
||||
void get_AABB( double *left, double *right, unsigned level )
|
||||
{
|
||||
|
||||
{
|
||||
double dx = 1.0/(1ul<<level);
|
||||
double pad = (double)(padding_+1) * dx;
|
||||
|
||||
if( ! do_extra_padding_ ) pad = 0.0;
|
||||
|
||||
for( int i=0; i<3; ++i )
|
||||
{
|
||||
left[i] = x0ref_[i];
|
||||
right[i] = x0ref_[i] + lxref_[i];
|
||||
left[i] = x0ref_[i] - pad;
|
||||
right[i] = x0ref_[i] + lxref_[i] + pad;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +186,7 @@ public:
|
|||
if( dx < -0.5 ) dx += 1.0;
|
||||
else if (dx > 0.5 ) dx -= 1.0;
|
||||
|
||||
check &= dx >= 0.0 & dx <= lxref_[i];
|
||||
check &= ((dx >= padding_fine_) & (dx <= lxref_[i]-padding_fine_));
|
||||
}
|
||||
return check;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue