diff --git a/fomo-c/docfiles/amrvac.dox b/fomo-c/docfiles/amrvac.dox index 03497bd..27c5c99 100644 --- a/fomo-c/docfiles/amrvac.dox +++ b/fomo-c/docfiles/amrvac.dox @@ -35,7 +35,7 @@ flexibility and removes the need for compilation after each change of option. For rendering the AMRVAC files with the AIA 193 filter and putting the results in a separate directory /path/to/datfiles/aia193, I would run the following command \code{.sh} - example/example_mpi_amrvac/render_all_datfiles -f /path/to/datfiles/file\*.dat -p /path/to/datfiles/amrvac.par -n 1e9 -T 1e6 -L 1e1 -o /path/to/datfiles/aia193 -c ../chiantitables/goft_tables_aia193_abco.dat -x 400 -y 400 -z 600 --lambda_pixel 1 -l 0.524 -b 1.047 + example/example_mpi_amrvac/render_all_datfiles -f /path/to/datfiles/file\*.dat -p /path/to/datfiles/amrvac.par -n 1e9 -T 1e6 -L 1e1 -o /path/to/datfiles/aia193 -c ../chiantitables/goft_table_aia193_abco.dat -x 400 -y 400 -z 600 --lambda_pixel 1 -l 0.524 -b 1.047 \endcode Let me explain these options separately. The first option \code{.sh} diff --git a/fomo-c/example/example_mpi_amrvac/read_amrvac_files.cpp b/fomo-c/example/example_mpi_amrvac/read_amrvac_files.cpp index 175b5c5..8d84e53 100644 --- a/fomo-c/example/example_mpi_amrvac/read_amrvac_files.cpp +++ b/fomo-c/example/example_mpi_amrvac/read_amrvac_files.cpp @@ -15,7 +15,9 @@ double kboltz = GSL_CONST_MKSA_BOLTZMANN; // # J/K = kg/K m_^2 double mhydro = GSL_CONST_MKSA_MASS_PROTON; // # kg (proton mass for the amrvac_nonAMR.par) double R_spec = kboltz/(0.5e0*mhydro); -std::vector compatible_versions={3}; +//Version 5 (AMRVAC 2.2) compatibility added by Krishna +//Version 4 may also be integrated here after testing +std::vector compatible_versions={3, 5}; // this recursive procedure loops through the forest and calculates the indices of each leaf block // the implementation is a carbon copy of the python code of Oliver Porth (included in AMRVAC) @@ -175,6 +177,16 @@ std::vector> read_blocks(istream & file, const int ndim, con } } /////////////////////////////////////////////////////////////// + // added by Krishna for compatibility with AMRVAC 2.2 (version 5) + /////////////////////////////////////////////////////////////// + if (version==5) + { + for (int j=0; j(&tempint), sizeof(int)); + file.read(reinterpret_cast(&tempint), sizeof(int)); + } + } /////////////////////////////////////////////////////////////// // then start reading the block // in principle, if the above number of ghost cells is non-zero, then we need to take a different block size, and select different numbers @@ -205,7 +217,11 @@ std::vector> build_block_info_morton(std::vector nblocks, // later on, we will prune simulation points from the mortoncurve // can this be optimized for 2D data? // If number of blocks is odd, make cube with +1 size - if (maxgridlength % 2 != 0) maxgridlength++; + //if (maxgridlength % 2 != 0) maxgridlength++; //removed by Krishna + //it seems mortonEncode_for will produce indices of the same size as the number of grid cells only + //when the dimensions of the grid is in powers of 2. So added the below line to accommodate this. + //perhaps not an efficient approach when maxgridlength is large. Should be optimized in the future. + maxgridlength = pow(2, ceil(log(maxgridlength)/log(2))); //added by Krishna mortoncurve.resize(pow(maxgridlength,3)); for (int k=0; k(&nx.at(i)), sizeof(int)); nglev1*=nx.at(i); std::cout << "block_nx(" << i << "):" << nx.at(i) << std::endl; + } + /////////////////////////////////////////////////////////////// + // added by Krishna for compatibility with AMRVAC 2.2 (version 5) + /////////////////////////////////////////////////////////////// + if (version == 5) + { + std::vector periodic(ndim); + for (int i=0; i(&periodic.at(i)), sizeof(int)); + std::cout << "Boundary Periodicity ["<< i <<"]:" << periodic.at(i) << std::endl; + } + char geom[16]; + file.read(geom,16); + std::cout << "Geometry:" << geom <(&stag),sizeof(int)); + std::cout << "Staggered:" << stag < varnames(nw); for (int i=0; i eqpar(neqpar); std::vector eqparnames(neqpar); - std::string gammaname="gamma "; + std::string gammaname="gamma"; //removed spaces by Krishna for compatibility with versions 3 & 5 for (int i=0; i(&tmpeqpar), sizeof(double)); @@ -522,7 +556,8 @@ FoMo::FoMoObject read_amrvac_new_dat_file(const char* datfile, int version_numbe eqparnames.at(i)=temp; // if the variable name matches gammaname, then take that value for gamma // this has as consequence that the last of such values will eventually be used - if (eqparnames.at(i).compare(gammaname)==0) gamma=eqpar.at(i); + if (eqparnames.at(i).substr(0,5).compare(gammaname)==0) gamma=eqpar.at(i); //added substr by Krishna + std::cout << "Gamma:" << gamma << std::endl; //added by Krishna } if (gamma==0.) { @@ -544,6 +579,7 @@ FoMo::FoMoObject read_amrvac_new_dat_file(const char* datfile, int version_numbe //compute the dx in each direction std::vector cellsize(ndim); blocksandsize(nxlone,nx,xprobmin,xprobmax,nblocks,cellsize); + for (int i=0; i