Commit 33247a51 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Modified the definition to the number of neighbours to be 'kernel shape...

Modified the definition to the number of neighbours to be 'kernel shape agnostic'. The kernel shape (i.e. equation) can now be changed without changing the resolution of the run. The number of neighbours will adapt automatically


Former-commit-id: c32db61f3ff959a957a596e5af23dc2695506a26
parent 94dd38e6
......@@ -28,5 +28,6 @@
#define const_ln_max_h_change log(1.26f) /* Particle can't change volume by more than a factor of 2=1.26^3 over one time step */
/* Neighbour search constants. */
#define const_nwneigh 48.f
/*#define const_nwneigh 48.f*/
#define const_eta_kernel 1.1272f /* Corresponds to 48 ngbs with the cubic spline kernel */
#define const_delta_nwneigh 1.f
......@@ -36,6 +36,7 @@
#define kernel_gamma2 4.0f
#define kernel_gamma3 8.0f
#define kernel_igamma 0.5f
#define kernel_nwneigh 4.0/3.0*M_PI*kernel_gamma3*const_eta_kernel*const_eta_kernel*const_eta_kernel
static float kernel_coeffs[ (kernel_degree + 1) * (kernel_ivals + 1) ] __attribute__ ((aligned (16))) =
{ 3.0/4.0*M_1_PI , -3.0/2.0*M_1_PI , 0.0 , M_1_PI ,
-0.25*M_1_PI , 3.0/2.0*M_1_PI , -3.0*M_1_PI , M_2_PI ,
......
......@@ -388,11 +388,11 @@ void runner_doghost ( struct runner *r , struct cell *c ) {
/* Otherwise, compute the smoothing length update (Newton step). */
else {
h_corr = ( const_nwneigh - wcount ) / wcount_dh;
h_corr = ( kernel_nwneigh - wcount ) / wcount_dh;
/* Truncate to the range [ -p->h/2 , p->h ]. */
h_corr = fminf( h_corr , h );
h_corr = fmaxf( h_corr , -h/2 );
h_corr = fmaxf( h_corr , -h/2.f );
}
......@@ -401,10 +401,10 @@ void runner_doghost ( struct runner *r , struct cell *c ) {
cp->h = p->h;
/* Did we get the right number density? */
if ( wcount > const_nwneigh + const_delta_nwneigh ||
wcount < const_nwneigh - const_delta_nwneigh ) {
if ( wcount > kernel_nwneigh + const_delta_nwneigh ||
wcount < kernel_nwneigh - const_delta_nwneigh ) {
// printf( "runner_doghost: particle %lli (h=%e,depth=%i) has bad wcount=%.3f.\n" , p->id , p->h , c->depth , wcount ); fflush(stdout);
// p->h += ( p->density.wcount + kernel_root - const_nwneigh ) / p->density.wcount_dh;
// p->h += ( p->density.wcount + kernel_root - kernel_nwneigh ) / p->density.wcount_dh;
pid[redo] = pid[i];
redo += 1;
p->density.wcount = 0.0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment