Skip to content
Snippets Groups Projects
Commit a8c8e99d authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Fixed the single test

parent 6c4933a2
No related branches found
No related tags found
2 merge requests!136Master,!93Missing files and other small bugs
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
* This file is part of SWIFT. * This file is part of SWIFT.
* Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk), * Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
* Matthieu Schaller (matthieu.schaller@durham.ac.uk) * Matthieu Schaller (matthieu.schaller@durham.ac.uk)
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published * it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or * by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
******************************************************************************/ ******************************************************************************/
/* Config parameters. */ /* Config parameters. */
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
/* Conditional headers. */ /* Conditional headers. */
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
#include <zlib.h> #include <zlib.h>
#endif #endif
/* Local headers. */ /* Local headers. */
...@@ -42,88 +42,111 @@ ...@@ -42,88 +42,111 @@
/* Ticks per second on this machine. */ /* Ticks per second on this machine. */
#ifndef CPU_TPS #ifndef CPU_TPS
#define CPU_TPS 2.67e9 #define CPU_TPS 2.67e9
#endif #endif
/* Engine policy flags. */ /* Engine policy flags. */
#ifndef ENGINE_POLICY #ifndef ENGINE_POLICY
#define ENGINE_POLICY engine_policy_none #define ENGINE_POLICY engine_policy_none
#endif #endif
#ifdef DEFAULT_SPH
/** /**
* @brief Main routine that loads a few particles and generates some output. * @brief Main routine that loads a few particles and generates some output.
* *
*/ */
int main ( int argc , char *argv[] ) { int main(int argc, char *argv[]) {
int k, N = 100; int k, N = 100;
struct part p1, p2; struct part p1, p2;
float x, w, dwdx, r2, dx[3] = { 0.0f , 0.0f , 0.0f }, gradw[3]; float x, w, dwdx, r2, dx[3] = {0.0f, 0.0f, 0.0f}, gradw[3];
/* Greeting message */ /* Greeting message */
printf( "This is %s\n", package_description() ); printf("This is %s\n", package_description());
/* Init the particles. */ /* Init the particles. */
for ( k = 0 ; k < 3 ; k++ ) { for (k = 0; k < 3; k++) {
p1.a[k] = 0.0f; p1.v[k] = 0.0f; p1.x[k] = 0.0; p1.a_hydro[k] = 0.0f;
p2.a[k] = 0.0f; p2.v[k] = 0.0f; p2.x[k] = 0.0; p1.v[k] = 0.0f;
} p1.x[k] = 0.0;
p1.v[0] = 100.0f; p2.a_hydro[k] = 0.0f;
p1.id = 0; p2.id = 1; p2.v[k] = 0.0f;
p1.density.wcount = 48.0f; p2.density.wcount = 48.0f; p2.x[k] = 0.0;
p1.rho = 1.0f; p1.mass = 9.7059e-4; p1.h = 0.222871287 / 2; }
p2.rho = 1.0f; p2.mass = 9.7059e-4; p2.h = 0.222871287 / 2; p1.v[0] = 100.0f;
p1.force.c = 0.0040824829f; p1.force.balsara = 0.0f; p1.id = 0;
p2.force.c = 58.8972740361f; p2.force.balsara = 0.0f; p2.id = 1;
p1.u = 1.e-5 / ((const_hydro_gamma - 1.)*p1.rho); p1.density.wcount = 48.0f;
p2.u = 1.e-5 / ((const_hydro_gamma - 1.)*p2.rho) + 100.0f / ( 33 * p2.mass ); p2.density.wcount = 48.0f;
p1.force.POrho2 = p1.u * ( const_hydro_gamma - 1.0f ) / p1.rho; p1.rho = 1.0f;
p2.force.POrho2 = p2.u * ( const_hydro_gamma - 1.0f ) / p2.rho; p1.mass = 9.7059e-4;
p1.h = 0.222871287 / 2;
/* Dump a header. */ p2.rho = 1.0f;
printParticle_single( &p1 ); p2.mass = 9.7059e-4;
printParticle_single( &p2 ); p2.h = 0.222871287 / 2;
printf( "# r a_1 udt_1 a_2 udt_2\n" ); p1.force.c = 0.0040824829f;
p1.force.balsara = 0.0f;
/* Loop over the different radii. */ p2.force.c = 58.8972740361f;
for ( k = 1 ; k <= N ; k++ ) { p2.force.balsara = 0.0f;
p1.u = 1.e-5 / ((const_hydro_gamma - 1.) * p1.rho);
/* Set the distance/radius. */ p2.u = 1.e-5 / ((const_hydro_gamma - 1.) * p2.rho) + 100.0f / (33 * p2.mass);
dx[0] = -((float)k)/N * fmaxf( p1.h , p2.h ) * kernel_gamma; p1.force.POrho2 = p1.u * (const_hydro_gamma - 1.0f) / p1.rho;
r2 = dx[0]*dx[0]; p2.force.POrho2 = p2.u * (const_hydro_gamma - 1.0f) / p2.rho;
/* Clear the particle fields. */ /* Dump a header. */
p1.a[0] = 0.0f; p1.force.u_dt = 0.0f; printParticle_single(&p1);
p2.a[0] = 0.0f; p2.force.u_dt = 0.0f; printParticle_single(&p2);
printf("# r a_1 udt_1 a_2 udt_2\n");
/* Interact the particles. */
runner_iact_force( r2 , dx , p1.h , p2.h , &p1 , &p2 ); /* Loop over the different radii. */
for (k = 1; k <= N; k++) {
/* Clear the particle fields. */
/* p1.rho = 0.0f; p1.density.wcount = 0.0f; /* Set the distance/radius. */
p2.rho = 0.0f; p2.density.wcount = 0.0f; */ dx[0] = -((float)k) / N * fmaxf(p1.h, p2.h) * kernel_gamma;
r2 = dx[0] * dx[0];
/* Interact the particles. */
// runner_iact_density( r2 , dx , p1.h , p2.h , &p1 , &p2 ); /* Clear the particle fields. */
p1.a[0] = 0.0f;
/* Evaluate just the kernel. */ p1.force.u_dt = 0.0f;
x = fabsf( dx[0] ) / p1.h; p2.a[0] = 0.0f;
kernel_deval( x , &w , &dwdx ); p2.force.u_dt = 0.0f;
gradw[0] = dwdx / (p1.h*p1.h*p1.h*p1.h) * dx[0] / sqrtf( dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2] );
gradw[1] = dwdx / (p1.h*p1.h*p1.h*p1.h) * dx[1] / sqrtf( dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2] ); /* Interact the particles. */
gradw[2] = dwdx / (p1.h*p1.h*p1.h*p1.h) * dx[2] / sqrtf( dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2] ); runner_iact_force(r2, dx, p1.h, p2.h, &p1, &p2);
/* Output the results. */ /* Clear the particle fields. */
printf( "%.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e\n" , /* p1.rho = 0.0f; p1.density.wcount = 0.0f;
-dx[0] , p1.a[0] , p1.a[1] , p1.a[2] , p1.force.u_dt , p2.rho = 0.0f; p2.density.wcount = 0.0f; */
/// -dx[0] , p1.rho , p1.density.wcount , p2.rho , p2.density.wcount ,
w , dwdx , gradw[0] , gradw[1] , gradw[2] ); /* Interact the particles. */
// runner_iact_density( r2 , dx , p1.h , p2.h , &p1 , &p2 );
} /* loop over radii. */
/* Evaluate just the kernel. */
/* All is calm, all is bright. */ x = fabsf(dx[0]) / p1.h;
return 0; kernel_deval(x, &w, &dwdx);
gradw[0] = dwdx / (p1.h * p1.h * p1.h * p1.h) * dx[0] /
} sqrtf(dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]);
gradw[1] = dwdx / (p1.h * p1.h * p1.h * p1.h) * dx[1] /
sqrtf(dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]);
gradw[2] = dwdx / (p1.h * p1.h * p1.h * p1.h) * dx[2] /
sqrtf(dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]);
/* Output the results. */
printf(
"%.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e\n", -dx[0], p1.a[0],
p1.a[1], p1.a[2], p1.force.u_dt,
/// -dx[0] , p1.rho , p1.density.wcount , p2.rho , p2.density.wcount ,
w, dwdx, gradw[0], gradw[1], gradw[2]);
} /* loop over radii. */
/* All is calm, all is bright. */
return 0;
}
#else
int main() { return 0; }
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment