camr.h 2.58 KB
Newer Older
jclamber's avatar
jclamber committed
1
// ============================================================================
2
// Copyright Jean-Charles LAMBERT - 2007-2016
jclamber's avatar
jclamber committed
3 4 5
//           Centre de donneeS Astrophysiques de Marseille (CeSAM)              
// e-mail:   Jean-Charles.Lambert@lam.fr                                      
// address:  Aix Marseille Universite, CNRS, LAM 
jclamber's avatar
jclamber committed
6 7 8 9 10 11 12 13
//           Laboratoire d'Astrophysique de Marseille                          
//           Pole de l'Etoile, site de Chateau-Gombert                         
//           38, rue Frederic Joliot-Curie                                     
//           13388 Marseille cedex 13 France                                   
//           CNRS U.M.R 7326                                                   
// ============================================================================

/* 
jclamber's avatar
jclamber committed
14
	@author Jean-Charles Lambert <Jean-Charles.Lambert@lam.fr>
jclamber's avatar
jclamber committed
15 16 17 18 19 20 21 22 23
 */
#ifndef CAMR_H
#define CAMR_H

#include <string>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <vector>
24
#include <cstdlib>
jclamber's avatar
jclamber committed
25 26 27 28
#include "cfortio.h"
#include "snapshotramses.h"

namespace uns {
29
template <class T> class CParticles;
jclamber's avatar
jclamber committed
30 31
}
namespace ramses {
32 33 34 35 36 37 38

typedef struct  {
  double time;
  double boxlen, omega_m, omega_l, omega_k, omega_b, h0, aexp_ini, boxlen_ini;
  double aexp,hexp,aexp_old,epot_tot_int,epot_tot_old;
} Header;

jclamber's avatar
jclamber committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
class CAmr  {
public:
    CAmr(const std::string,const bool _v=true);
    
    ~CAmr();
    void setBoundary(float x[8]) {
      xmin=x[0];
      xmax=x[1];
      ymin=x[2];
      ymax=x[3];
      zmin=x[4];
      zmax=x[5];
      
      if (x[7]==0.) {
        lmax= nlevelmax;
      } else {
        lmax = (int) x[7];
      } 
57

jclamber's avatar
jclamber committed
58
      lmin = std::min((int) x[6],lmax-1);                   
59 60
      std::cerr << "min = "<< (int) x[6] << " lmax="<<lmax<<" lmin="<<lmin<<"\n";
      //exit(1);
jclamber's avatar
jclamber committed
61 62
    }
    bool isValid();
63
    template <class T> int loadData(uns::CParticles<T> * particles,
jclamber's avatar
jclamber committed
64 65
                 const unsigned int req_bits);
    int getNbody()    { return nbody;}
66 67 68
    Header * getHeader() { return &header; }


jclamber's avatar
jclamber committed
69 70 71 72
private:
    // some variables
    
    bool verbose,valid;
73
    std::string infile,testhydrofile, indir;
jclamber's avatar
jclamber committed
74 75 76 77 78 79 80 81 82 83 84 85 86
    int select,nselect;
    int nbody;
    std::string s_run_index,ordering;
  
    float xmin,xmax,ymin,ymax,zmin,zmax;
    int lmin,lmax;
    CFortIO  amr, hydro;
    int readHeader();
    // amr header variables
    static const double XH, mH, kB;
    int ncpu, ndim, nx, ny ,nz, nlevelmax, ngridmax, nboundary, ngrid_current;
    int twotondim;
    double xbound[3];
87
    Header header;
jclamber's avatar
jclamber committed
88 89 90
    // hydro
    int nvarh;
    double scale_nH;
91

jclamber's avatar
jclamber committed
92 93 94
};
} // end of namespace
#endif // CAMR_H