00001
00005
00006 #include "sdyn3.h"
00007 #include "util_io.h"
00008
00009 #ifndef TOOLBOX
00010
00011 static bool read_xreal = false;
00012
00013 istream & sdyn3::scan_dyn_story(istream & s)
00014 {
00015 char input_line[MAX_INPUT_LINE_LENGTH];
00016 real last_real = false;
00017
00018 while (get_line(s, input_line), strcmp(END_DYNAMICS, input_line)) {
00019
00020 char keyword[MAX_INPUT_LINE_LENGTH];
00021 char *val = getequals(input_line, keyword);
00022
00023
00024
00025 if (!strcmp("real_system_time", keyword)) {
00026
00027 read_xreal = true;
00028 last_real = true;
00029
00030 } else if (!strcmp("system_time", keyword)) {
00031
00032
00033
00034 if (!last_real) read_xreal = false;
00035
00036 if (read_xreal)
00037 system_time = get_xreal_from_input_line(input_line);
00038 else
00039 system_time = strtod(val, &val);
00040
00041 } else {
00042
00043 last_real = false;
00044
00045 if (!strcmp("t", keyword)) {
00046
00047 if (read_xreal)
00048 time = get_xreal_from_input_line(input_line);
00049 else
00050 time = strtod(val, &val);
00051
00052 } else if (!strcmp("m", keyword))
00053 mass = strtod(val, &val);
00054 else if (!strcmp("r", keyword))
00055 set_vector_from_input_line(pos, input_line);
00056 else if (!strcmp("v", keyword))
00057 set_vector_from_input_line(vel, input_line);
00058 else if (!strcmp("dt", keyword))
00059 timestep = strtod(val, &val);
00060 else if (!strcmp("a", keyword))
00061 set_vector_from_input_line(acc, input_line);
00062 else if (!strcmp("j", keyword))
00063 set_vector_from_input_line(jerk, input_line);
00064 else if (!strcmp("pot", keyword))
00065 pot = strtod(val, &val);
00066 else
00067 add_story_line(dyn_story, input_line);
00068 }
00069 }
00070
00071 return s;
00072 }
00073
00074 ostream& sdyn3::print_dyn_story(ostream& s,
00075 bool print_xreal,
00076 int short_output)
00077 {
00078 put_story_header(s, DYNAMICS_ID);
00079
00080 if (!parent) {
00081
00082
00083
00084 #ifdef USE_XREAL
00085 if (print_xreal) {
00086
00087 put_real_number(s, " real_system_time = ", (real)system_time);
00088 put_real_number(s, " system_time = ", system_time);
00089
00090 } else
00091
00092 put_real_number(s, " system_time = ", (real)system_time);
00093 #else
00094
00095 put_real_number(s, " system_time = ", system_time);
00096
00097 #endif
00098 }
00099
00100 if (print_xreal)
00101 put_real_number(s, " t = ", time);
00102 else
00103 put_real_number(s, " t = ", (real)time);
00104
00105 put_real_number(s, " m = ", mass);
00106 put_real_vector(s, " r = ", pos);
00107 put_real_vector(s, " v = ", vel);
00108 put_real_vector(s, " a = ", acc);
00109 put_real_vector(s, " j = ", jerk);
00110
00111 if (!short_output) {
00112
00113 put_real_number(s, " pot = ", pot);
00114
00115 put_real_number(s, " min_nn_dr2 = ", min_nn_dr2);
00116 put_integer(s, " min_nn_label = ", min_nn_label);
00117 put_real_number(s, " min_min_ssd = ", min_min_ssd);
00118 put_integer(s, " n_ssd_osc = ", n_ssd_osc);
00119 put_real_number(s, " n_steps = ", n_steps);
00120 put_real_number(s, " e_tot_init = ", e_tot_init);
00121 put_real_number(s, " de_tot_abs_max = ", de_tot_abs_max);
00122
00123 if (dyn_story)
00124 put_story_contents(s, *dyn_story);
00125 }
00126
00127 put_story_footer(s, DYNAMICS_ID);
00128
00129 return s;
00130 }
00131
00132 #else
00133
00134 main(int argc, char** argv)
00135 {
00136 check_help();
00137
00138 sdyn3 * b;
00139 while (b = (sdyn3 *) get_node(cin, new_sdyn3)){
00140 put_node(cout,*b);
00141 pp2(b);
00142 }
00143 cerr << "Normal exit\n";
00144 }
00145
00146 #endif