00001 #include <stdio.h> 00002 #include <stdlib.h> 00003 #include <string.h> 00004 #include <math.h> 00005 #include <mpi.h> 00006 00007 #include "allvars.h" 00008 #include "proto.h" 00009 00024 void compute_accelerations(int mode) 00025 { 00026 double tstart, tend; 00027 00028 if(ThisTask == 0) 00029 { 00030 printf("Start force computation...\n"); 00031 fflush(stdout); 00032 } 00033 00034 #ifdef PMGRID 00035 if(All.PM_Ti_endstep == All.Ti_Current) 00036 { 00037 tstart = second(); 00038 long_range_force(); 00039 tend = second(); 00040 All.CPU_PM += timediff(tstart, tend); 00041 } 00042 #endif 00043 00044 tstart = second(); /* measure the time for the full force computation */ 00045 00046 gravity_tree(); /* computes gravity accel. */ 00047 00048 if(All.TypeOfOpeningCriterion == 1 && All.Ti_Current == 0) 00049 gravity_tree(); /* For the first timestep, we redo it 00050 * to allow usage of relative opening 00051 * criterion for consistent accuracy. 00052 */ 00053 tend = second(); 00054 All.CPU_Gravity += timediff(tstart, tend); 00055 00056 #ifdef FORCETEST 00057 gravity_forcetest(); 00058 #endif 00059 00060 if(All.TotN_gas > 0) 00061 { 00062 if(ThisTask == 0) 00063 { 00064 printf("Start density computation...\n"); 00065 fflush(stdout); 00066 } 00067 00068 tstart = second(); 00069 density(); /* computes density, and pressure */ 00070 tend = second(); 00071 All.CPU_Hydro += timediff(tstart, tend); 00072 00073 tstart = second(); 00074 force_update_hmax(); /* tell the tree nodes the new SPH smoothing length such that they are guaranteed to hold the correct max(Hsml) */ 00075 tend = second(); 00076 All.CPU_Predict += timediff(tstart, tend); 00077 00078 00079 if(ThisTask == 0) 00080 { 00081 printf("Start hydro-force computation...\n"); 00082 fflush(stdout); 00083 } 00084 00085 tstart = second(); 00086 hydro_force(); /* adds hydrodynamical accelerations and computes viscous entropy injection */ 00087 tend = second(); 00088 All.CPU_Hydro += timediff(tstart, tend); 00089 } 00090 00091 if(ThisTask == 0) 00092 { 00093 printf("force computation done.\n"); 00094 fflush(stdout); 00095 } 00096 }