Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

tree3_evolve.C

Go to the documentation of this file.
00001 
00012 
00013 //   Note: low_n3_evolve() uses flat trees
00014 
00015 // Starlab library function.
00016 
00017 #include "scatter3.h"
00018 
00019 #ifndef TOOLBOX
00020 
00021 // Integration parameters:
00022 
00023 #define SOFTENING            0
00024 #define X_FLAG               1
00025 #define TIMESTEP_CRITERION  "dynamic_timestep"
00026 #define S_FLAG               1
00027 #define N_ITER               1
00028 #define N_MAX               -1
00029 
00030 void tree3_evolve(sdyn3 * b,          // sdyn3 array
00031                  real delta_t,        // time span of the integration
00032                  real dt_out,         // output time interval
00033                  real dt_snap,        // snapshot output interval
00034                  real snap_cube_size, // limit output to particles within cube
00035                  real eta,            // time step parameter
00036                  real cpu_time_check,
00037                  real dt_print,       // external print interval
00038                  sdyn3_print_fp p)    // pointer to external print function
00039 {
00040     // Use offset times within the integrator to avoid roundoff.
00041     // Reset before returning.
00042 
00043     real t_offset = b->get_time();
00044 
00045     b->begin_offset_time(t_offset);
00046     for_all_daughters(sdyn3, b, bb)
00047         bb->begin_offset_time(t_offset);
00048 
00049     low_n3_evolve(b, delta_t, dt_out, dt_snap, snap_cube_size,
00050                   SOFTENING, eta, X_FLAG, TIMESTEP_CRITERION,
00051                   S_FLAG, N_ITER, N_MAX,
00052                   cpu_time_check, dt_print, p);
00053 
00054     b->end_offset_time();
00055     for_all_daughters(sdyn3, b, bbb)
00056         bbb->end_offset_time();
00057 
00058 }
00059 
00060 #else
00061 
00062 main(int argc, char **argv)
00063 {
00064     sdyn3* b;            // pointer to the nbody system
00065     
00066     real  delta_t = 10;  // time span of the integration
00067     real  eta = 0.02;    // time step parameter (for fixed time step,
00068                          //   equal to the time step size; for variable
00069                          //   time step, a multiplication factor)
00070     real  dt_out = VERY_LARGE_NUMBER;
00071                          // output time interval
00072     real  dt_snap = VERY_LARGE_NUMBER;
00073                          // snap output interval
00074     real  snap_cube_size = 10;
00075 
00076     real cpu_time_check = 3600;
00077 
00078     check_help();
00079 
00080     extern char *poptarg;
00081     int c;
00082     char* param_string = "A:c:C:d:D:qt:";
00083 
00084     bool  a_flag = FALSE;
00085     bool  d_flag = FALSE;
00086     bool  D_flag = FALSE;
00087     bool  q_flag = FALSE;
00088     bool  t_flag = FALSE;
00089 
00090     while ((c = pgetopt(argc, argv, param_string)) != -1)
00091         switch(c)
00092             {
00093             case 'A': a_flag = TRUE;
00094                       eta = atof(poptarg);
00095                       break;
00096             case 'c': cpu_time_check = atof(poptarg);
00097                       break;
00098             case 'C': snap_cube_size = atof(poptarg);
00099                       break;
00100             case 'd': d_flag = TRUE;
00101                       dt_out = atof(poptarg);
00102                       break;
00103             case 'D': D_flag = TRUE;
00104                       dt_snap = atof(poptarg);
00105                       break;
00106             case 'q': q_flag = TRUE;
00107                       break;
00108             case 't': t_flag = TRUE;
00109                       delta_t = atof(poptarg);
00110                       break;
00111             case '?': params_to_usage(cerr, argv[0], param_string);
00112                       get_help();
00113                       exit(1);
00114             }            
00115 
00116     if (!q_flag) {
00117 
00118         // Check input arguments and echo defaults.
00119 
00120         if (!t_flag) cerr << "default delta_t = " << delta_t << "\n";
00121         if (!a_flag) cerr << "default eta = " << eta << "\n";
00122         if (!d_flag) cerr << "default dt_out = " << dt_out << "\n";
00123     }
00124 
00125     if (!D_flag) dt_snap = delta_t;
00126 
00127     b = get_sdyn3(cin);
00128     
00129     b->log_history(argc, argv);
00130 
00131     tree3_evolve(b, delta_t, dt_out,
00132                  dt_snap, snap_cube_size,
00133                  eta, cpu_time_check);
00134 }
00135 
00136 #endif

Generated at Sun Feb 24 09:57:19 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001