Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

longrange.c

Go to the documentation of this file.
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 
00010 
00015 #ifdef PMGRID
00016 
00020 void long_range_init(void)
00021 {
00022 #ifdef PERIODIC
00023   pm_init_periodic();
00024 #ifdef PLACEHIGHRESREGION
00025   pm_init_nonperiodic();
00026 #endif
00027 #else
00028   pm_init_nonperiodic();
00029 #endif
00030 }
00031 
00032 
00036 void long_range_init_regionsize(void)
00037 {
00038 #ifdef PERIODIC
00039 #ifdef PLACEHIGHRESREGION
00040   if(RestartFlag != 1)
00041     pm_init_regionsize();
00042   pm_setup_nonperiodic_kernel();
00043 #endif
00044 #else
00045   if(RestartFlag != 1)
00046     pm_init_regionsize();
00047   pm_setup_nonperiodic_kernel();
00048 #endif
00049 }
00050 
00051 
00056 void long_range_force(void)
00057 {
00058   int i;
00059 
00060 #ifndef PERIODIC
00061   int j;
00062   double fac;
00063 #endif
00064 
00065 
00066   for(i = 0; i < NumPart; i++)
00067     P[i].GravPM[0] = P[i].GravPM[1] = P[i].GravPM[2] = 0;
00068 
00069 #ifdef NOGRAVITY
00070   return;
00071 #endif
00072 
00073 
00074 #ifdef PERIODIC
00075   pmforce_periodic();
00076 #ifdef PLACEHIGHRESREGION
00077   i = pmforce_nonperiodic(1);
00078   if(i == 1)                    /* this is returned if a particle lied outside allowed range */
00079     {
00080       pm_init_regionsize();
00081       pm_setup_nonperiodic_kernel();
00082       i = pmforce_nonperiodic(1);       /* try again */
00083     }
00084   if(i == 1)
00085     endrun(68686);
00086 #endif
00087 #else
00088   i = pmforce_nonperiodic(0);
00089   if(i == 1)                    /* this is returned if a particle lied outside allowed range */
00090     {
00091       pm_init_regionsize();
00092       pm_setup_nonperiodic_kernel();
00093       i = pmforce_nonperiodic(0);       /* try again */
00094     }
00095   if(i == 1)
00096     endrun(68687);
00097 #ifdef PLACEHIGHRESREGION
00098   i = pmforce_nonperiodic(1);
00099   if(i == 1)                    /* this is returned if a particle lied outside allowed range */
00100     {
00101       pm_init_regionsize();
00102       pm_setup_nonperiodic_kernel();
00103 
00104       /* try again */
00105 
00106       for(i = 0; i < NumPart; i++)
00107         P[i].GravPM[0] = P[i].GravPM[1] = P[i].GravPM[2] = 0;
00108 
00109       i = pmforce_nonperiodic(0) + pmforce_nonperiodic(1);
00110     }
00111   if(i != 0)
00112     endrun(68688);
00113 #endif
00114 #endif
00115 
00116 
00117 #ifndef PERIODIC
00118   if(All.ComovingIntegrationOn)
00119     {
00120       fac = 0.5 * All.Hubble * All.Hubble * All.Omega0;
00121 
00122       for(i = 0; i < NumPart; i++)
00123         for(j = 0; j < 3; j++)
00124           P[i].GravPM[j] += fac * P[i].Pos[j];
00125     }
00126 
00127 
00128   /* Finally, the following factor allows a computation of cosmological simulation 
00129      with vacuum energy in physical coordinates */
00130 
00131   if(All.ComovingIntegrationOn == 0)
00132     {
00133       fac = All.OmegaLambda * All.Hubble * All.Hubble;
00134 
00135       for(i = 0; i < NumPart; i++)
00136         for(j = 0; j < 3; j++)
00137           P[i].GravPM[j] += fac * P[i].Pos[j];
00138     }
00139 #endif
00140 
00141 }
00142 
00143 
00144 #endif

Generated on Sat Apr 22 15:29:41 2006 for GADGET-2 by  doxygen 1.3.9.1