00001
00005
00006 #include "sdyn.h"
00007 #include "util_io.h"
00008
00009 #ifndef TOOLBOX
00010
00011 istream & sdyn::scan_dyn_story(istream& s)
00012 {
00013 char input_line[MAX_INPUT_LINE_LENGTH];
00014
00015 while(get_line(s,input_line), strcmp(END_DYNAMICS, input_line)){
00016 char keyword[MAX_INPUT_LINE_LENGTH];
00017 char *val = getequals(input_line, keyword);
00018
00019 if(0){
00020 }else if(!strcmp("m",keyword)){
00021 mass = strtod(val, &val);
00022 }else if(!strcmp("r",keyword)){
00023 set_vector_from_input_line(pos,input_line);
00024 }else if(!strcmp("v",keyword)){
00025 set_vector_from_input_line(vel,input_line);
00026 }else if(!strcmp("t",keyword)){
00027 time = strtod(val, &val);
00028 }else if(!strcmp("dt",keyword)){
00029 timestep = strtod(val, &val);
00030 }else if(!strcmp("a",keyword)){
00031 set_vector_from_input_line(acc,input_line);
00032 }else if(!strcmp("j",keyword)){
00033 set_vector_from_input_line(jerk,input_line);
00034 }else if(!strcmp("pot",keyword)){
00035 pot = strtod(val, &val);
00036 }else{
00037 add_story_line(dyn_story, input_line);
00038 }
00039 }
00040 return s;
00041 }
00042
00043 ostream& sdyn::print_dyn_story(ostream& s,
00044 bool print_xreal,
00045 int short_output)
00046
00047 {
00048 put_story_header(s, DYNAMICS_ID);
00049
00050 put_real_number(s, " t = ", time);
00051 put_real_number(s, " m = ", mass);
00052 put_real_vector(s, " r = ", pos);
00053 put_real_vector(s, " v = ", vel);
00054 put_real_vector(s, " a = ", acc);
00055
00056 if (!short_output) {
00057 put_real_vector(s, " j = ", jerk);
00058 put_real_number(s, " pot = ", pot);
00059
00060 put_real_number(s, " min_nn_dr2 = ", min_nn_dr2);
00061 put_integer(s, " min_nn_label = ", min_nn_label);
00062 put_real_number(s, " n_steps = ", n_steps);
00063 put_real_number(s, " e_tot_init = ", e_tot_init);
00064 put_real_number(s, " de_tot_abs_max = ", de_tot_abs_max);
00065
00066 if (dyn_story)
00067 put_story_contents(s, *dyn_story);
00068 }
00069
00070 put_story_footer(s, DYNAMICS_ID);
00071
00072 return s;
00073 }
00074
00075 #else
00076
00077 main(int argc, char** argv)
00078 {
00079 check_help();
00080
00081 sdyn * b;
00082 while (b = (sdyn *) get_node(cin, new_sdyn)){
00083 put_node(cout,*b);
00084 pp2(b);
00085 }
00086 cerr << "Normal exit\n";
00087 }
00088
00089 #endif