From 1579ffc95acf1a5e91780d7f2c463faa8330ab0e Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Fri, 3 May 2013 16:23:52 +0200 Subject: [PATCH] some convenience adjustments to output better ramses namelist files --- plugins/output_grafic2.cc | 112 +++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 33 deletions(-) diff --git a/plugins/output_grafic2.cc b/plugins/output_grafic2.cc index eecfee2..ac24b66 100644 --- a/plugins/output_grafic2.cc +++ b/plugins/output_grafic2.cc @@ -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 (&blksize), sizeof(unsigned) ); - if( metal_floor_ > 0.0f ){ + if( passive_variable_value_ > 0.0f ){ for( unsigned j=0; j 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 (&block[0]), blksize ); ofs.write( reinterpret_cast (&blksize), sizeof(unsigned) ); - if( metal_floor_ > 0.0f ){ + if( passive_variable_value_ > 0.0f ){ for( unsigned j=0; j("setup","padding"); + unsigned nexpand = (cf_.getValue("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("setup","baryons"); - metal_floor_ = cf.getValueSafe("output","ramses_metal_floor",1e-5); + //metal_floor_ = cf.getValueSafe("output","ramses_metal_floor",1e-5); + passive_variable_index_ = cf.getValueSafe("output","ramses_pvar_idx",1); + passive_variable_value_ = cf.getValueSafe("output","ramses_pvar_val",1.0f); } /*~grafic2_output_plugin() @@ -518,9 +564,9 @@ public: write_ramses_namelist(gh); else if( cf_.getValueSafe("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 )