00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <math.h>
00005 #include <mpi.h>
00006 #include <gsl/gsl_math.h>
00007
00008 #include "allvars.h"
00009 #include "proto.h"
00010
00011
00031 void move_particles(int time0, int time1)
00032 {
00033 int i, j;
00034 double dt_drift, dt_gravkick, dt_hydrokick, dt_entr;
00035 double t0, t1;
00036
00037
00038 t0 = second();
00039
00040 if(All.ComovingIntegrationOn)
00041 {
00042 dt_drift = get_drift_factor(time0, time1);
00043 dt_gravkick = get_gravkick_factor(time0, time1);
00044 dt_hydrokick = get_hydrokick_factor(time0, time1);
00045 }
00046 else
00047 {
00048 dt_drift = dt_gravkick = dt_hydrokick = (time1 - time0) * All.Timebase_interval;
00049 }
00050
00051 for(i = 0; i < NumPart; i++)
00052 {
00053 for(j = 0; j < 3; j++)
00054 P[i].Pos[j] += P[i].Vel[j] * dt_drift;
00055
00056 if(P[i].Type == 0)
00057 {
00058 #ifdef PMGRID
00059 for(j = 0; j < 3; j++)
00060 SphP[i].VelPred[j] +=
00061 (P[i].GravAccel[j] + P[i].GravPM[j]) * dt_gravkick + SphP[i].HydroAccel[j] * dt_hydrokick;
00062 #else
00063 for(j = 0; j < 3; j++)
00064 SphP[i].VelPred[j] += P[i].GravAccel[j] * dt_gravkick + SphP[i].HydroAccel[j] * dt_hydrokick;
00065 #endif
00066 SphP[i].Density *= exp(-SphP[i].DivVel * dt_drift);
00067 SphP[i].Hsml *= exp(0.333333333333 * SphP[i].DivVel * dt_drift);
00068
00069 if(SphP[i].Hsml < All.MinGasHsml)
00070 SphP[i].Hsml = All.MinGasHsml;
00071
00072 dt_entr = (All.Ti_Current - (P[i].Ti_begstep + P[i].Ti_endstep) / 2) * All.Timebase_interval;
00073
00074 SphP[i].Pressure = (SphP[i].Entropy + SphP[i].DtEntropy * dt_entr) * pow(SphP[i].Density, GAMMA);
00075 }
00076 }
00077
00078
00079 if(All.NumForcesSinceLastDomainDecomp < All.TotNumPart * All.TreeDomainUpdateFrequency)
00080 {
00081 for(i = 0; i < Numnodestree; i++)
00082 for(j = 0; j < 3; j++)
00083 Nodes[All.MaxPart + i].u.d.s[j] += Extnodes[All.MaxPart + i].vs[j] * dt_drift;
00084
00085 force_update_len();
00086
00087 force_update_pseudoparticles();
00088 }
00089
00090 t1 = second();
00091
00092 All.CPU_Predict += timediff(t0, t1);
00093 }
00094
00095
00096
00102 #ifdef PERIODIC
00103 void do_box_wrapping(void)
00104 {
00105 int i, j;
00106 double boxsize[3];
00107
00108 for(j = 0; j < 3; j++)
00109 boxsize[j] = All.BoxSize;
00110
00111 #ifdef LONG_X
00112 boxsize[0] *= LONG_X;
00113 #endif
00114 #ifdef LONG_Y
00115 boxsize[1] *= LONG_Y;
00116 #endif
00117 #ifdef LONG_Z
00118 boxsize[2] *= LONG_Z;
00119 #endif
00120
00121 for(i = 0; i < NumPart; i++)
00122 for(j = 0; j < 3; j++)
00123 {
00124 while(P[i].Pos[j] < 0)
00125 P[i].Pos[j] += boxsize[j];
00126
00127 while(P[i].Pos[j] >= boxsize[j])
00128 P[i].Pos[j] -= boxsize[j];
00129 }
00130 }
00131 #endif