Commit ea7af0ef authored by Rainer Weinberger's avatar Rainer Weinberger

clang-format applied also to src/*/*/*.c and src/*/*/*.h files

parent 1b54e20b
......@@ -37,8 +37,8 @@
#include "../main/allvars.h"
#include "../main/proto.h"
#include "add_bggrid.h"
#include "../domain/domain.h"
#include "add_bggrid.h"
#ifdef ADDBACKGROUNDGRID
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -46,22 +46,18 @@
* - 21.05.2018 Prepared file for public release -- Rainer Weinberger
*/
#include <gmp.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <gmp.h>
#include "../../main/allvars.h"
#include "../../main/proto.h"
#include "voronoi.h"
#if defined (ONEDIMS) && !defined (ONEDIMS_SPHERICAL) /* will only be compiled in 1D case */
#if defined(ONEDIMS) && !defined(ONEDIMS_SPHERICAL) /* will only be compiled in 1D case */
/*! \brief Output of Voroioi mesh to file.
*
......@@ -69,12 +65,11 @@
*
* \return void
*/
void write_voronoi_mesh(tessellation * T, char *fname, int writeTask, int lastTask)
void write_voronoi_mesh(tessellation *T, char *fname, int writeTask, int lastTask)
{
terminate("write_voronoi_mesh not supported in 1d case!");
}
/*! \brief Initialises 1d tessellation and create all-enclosing segment.
*
* \param[out] T Pointer to tessllation structure which is set and its arrays
......@@ -82,7 +77,7 @@ void write_voronoi_mesh(tessellation * T, char *fname, int writeTask, int lastTa
*
* \return void
*/
void initialize_and_create_first_tetra(tessellation * T)
void initialize_and_create_first_tetra(tessellation *T)
{
char msg[200];
......@@ -106,7 +101,6 @@ void initialize_and_create_first_tetra(tessellation * T)
T->Nvf = 0;
T->Ndt = 0;
T->VF = mymalloc_movable(&T->VF, "VF", T->MaxNvf * sizeof(face));
T->DP = mymalloc_movable(&T->DP, "DP", (T->MaxNdp + 5) * sizeof(point));
......@@ -115,7 +109,6 @@ void initialize_and_create_first_tetra(tessellation * T)
T->DT = mymalloc_movable(&T->DT, "DT", T->MaxNdt * sizeof(tetra));
}
/*! \brief Computes circumcircles in 1d.
*
* Not necessary in 1d. However, this function has to exist for the 1d code
......@@ -125,10 +118,7 @@ void initialize_and_create_first_tetra(tessellation * T)
*
* \return void
*/
void compute_circumcircles(tessellation * T)
{
}
void compute_circumcircles(tessellation *T) {}
/*! \brief Empty funciton in 1d case.
*
......@@ -137,10 +127,7 @@ void compute_circumcircles(tessellation * T)
*
* \return void
*/
void set_integers_for_point(tessellation * T, int pp)
{
}
void set_integers_for_point(tessellation *T, int pp) {}
/*! \brief Empty funciton in 1d case.
*
......@@ -149,11 +136,7 @@ void set_integers_for_point(tessellation * T, int pp)
*
* \return 0
*/
int insert_point(tessellation * T, int pp, int ttstart)
{
return 0;
}
int insert_point(tessellation *T, int pp, int ttstart) { return 0; }
/*! \brief Wrapper routine to search for ghost cells for boundary cells.
*
......@@ -161,11 +144,7 @@ int insert_point(tessellation * T, int pp, int ttstart)
*
* \return 0
*/
int voronoi_ghost_search(tessellation * T)
{
return voronoi_ghost_search_alternative(T);
}
int voronoi_ghost_search(tessellation *T) { return voronoi_ghost_search_alternative(T); }
/*! \brief Empty funciton in 1d case.
*
......@@ -174,11 +153,7 @@ int voronoi_ghost_search(tessellation * T)
*
* \return 0
*/
int count_undecided_tetras(tessellation * T)
{
return 0;
}
int count_undecided_tetras(tessellation *T) { return 0; }
/*! \brief Searches for ghost cells in 1d Voronoi mesh.
*
......@@ -188,7 +163,7 @@ int count_undecided_tetras(tessellation * T)
*
* \return 0
*/
int voronoi_ghost_search_alternative(tessellation * T)
int voronoi_ghost_search_alternative(tessellation *T)
{
double xl, xr;
int index_l, index_r;
......@@ -217,7 +192,7 @@ int voronoi_ghost_search_alternative(tessellation * T)
DP[-1].index = index_l + NumGas; /* this is a mirrored local point */
#if defined(REFLECTIVE_X)
DP[-1].image_flags = REFL_X_FLAGS;
#if (REFLECTIVE_X == 2)
#if(REFLECTIVE_X == 2)
DP[-1].image_flags |= OUTFLOW_X;
#endif /* #if (REFLECTIVE_X == 2) */
#endif /* #if defined(REFLECTIVE_X) */
......@@ -229,14 +204,13 @@ int voronoi_ghost_search_alternative(tessellation * T)
DP[NumGas].index = index_r + NumGas; /* this is a mirrored local point */
#if defined(REFLECTIVE_X)
DP[NumGas].image_flags = REFL_X_FLAGS;
#if (REFLECTIVE_X == 2)
#if(REFLECTIVE_X == 2)
DP[NumGas].image_flags |= OUTFLOW_X;
#endif /* #if (REFLECTIVE_X == 2) */
#endif /* #if defined(REFLECTIVE_X) */
return 0;
}
/*! \brief Computes faces and volume of cells in 1d Voronoi mesh.
*
* Also computes the center of mass.
......@@ -278,20 +252,16 @@ void compute_voronoi_faces_and_volumes(void)
}
}
/*! \brief Data for 1d Voronoi mesh.
*/
static struct voronoi_1D_data
{
double x;
int index;
}
*mp;
} * mp;
static int *Id;
/*! \brief Sort cells by their position and reorder in P and SphP array.
*
* \return void
......@@ -304,8 +274,8 @@ void voronoi_1D_order(void)
if(NumGas)
{
mp = (struct voronoi_1D_data *) mymalloc("mp", sizeof(struct voronoi_1D_data) * NumGas);
Id = (int *) mymalloc("Id", sizeof(int) * NumGas);
mp = (struct voronoi_1D_data *)mymalloc("mp", sizeof(struct voronoi_1D_data) * NumGas);
Id = (int *)mymalloc("Id", sizeof(int) * NumGas);
for(i = 0; i < NumGas; i++)
{
......@@ -315,7 +285,6 @@ void voronoi_1D_order(void)
mysort(mp, NumGas, sizeof(struct voronoi_1D_data), voronoi_1D_compare_key);
for(i = 0; i < NumGas; i++)
Id[mp[i].index] = i;
......@@ -328,7 +297,6 @@ void voronoi_1D_order(void)
mpi_printf("1D order done.\n");
}
/*! \brief Compare x value of voronoi_1D_data objects.
*
* \param[in] a Pointer to first voronoi_1D_data object.
......@@ -338,16 +306,15 @@ void voronoi_1D_order(void)
*/
int voronoi_1D_compare_key(const void *a, const void *b)
{
if(((struct voronoi_1D_data *) a)->x < (((struct voronoi_1D_data *) b)->x))
if(((struct voronoi_1D_data *)a)->x < (((struct voronoi_1D_data *)b)->x))
return -1;
if(((struct voronoi_1D_data *) a)->x > (((struct voronoi_1D_data *) b)->x))
if(((struct voronoi_1D_data *)a)->x > (((struct voronoi_1D_data *)b)->x))
return +1;
return 0;
}
/*! \brief Order the gas cells according to the index given in the ID array.
*
* \return void
......@@ -393,5 +360,4 @@ void voronoi_1D_reorder_gas(void)
}
}
#endif /* #if defined (ONEDIMS) && !defined (ONEDIMS_SPHERICAL) */
......@@ -46,22 +46,18 @@
* - 21.05.2018 Prepared file for public release -- Rainer Weinberger
*/
#include <gmp.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <gmp.h>
#include "../../main/allvars.h"
#include "../../main/proto.h"
#include "voronoi.h"
#if defined (ONEDIMS) && defined (ONEDIMS_SPHERICAL) /* will only be compiled in 1D spherical case */
#if defined(ONEDIMS) && defined(ONEDIMS_SPHERICAL) /* will only be compiled in 1D spherical case */
/*! \brief Output of Voroioi mesh to file.
*
......@@ -69,12 +65,11 @@
*
* \retur void
*/
void write_voronoi_mesh(tessellation * T, char *fname, int writeTask, int lastTask)
void write_voronoi_mesh(tessellation *T, char *fname, int writeTask, int lastTask)
{
terminate("write_voronoi_mesh not supported in 1d spherical case!");
}
/*! \brief Initialises spherical 1d tesslation and create all-enclosing
* segment.
*
......@@ -83,7 +78,7 @@ void write_voronoi_mesh(tessellation * T, char *fname, int writeTask, int lastTa
*
* \return void
*/
void initialize_and_create_first_tetra(tessellation * T)
void initialize_and_create_first_tetra(tessellation *T)
{
char msg[200];
......@@ -106,7 +101,6 @@ void initialize_and_create_first_tetra(tessellation * T)
T->Nvf = 0;
T->Ndt = 0;
T->VF = mymalloc("VF", T->MaxNvf * sizeof(face));
T->DP = mymalloc("DP", (T->MaxNdp + 5) * sizeof(point));
......@@ -115,7 +109,6 @@ void initialize_and_create_first_tetra(tessellation * T)
T->DT = mymalloc("DT", T->MaxNdt * sizeof(tetra));
}
/*! \brief Computes circumcircles in 1d spherical coordinates.
*
* Not necessary in 1d spherical. However, this function has to exist for
......@@ -125,10 +118,7 @@ void initialize_and_create_first_tetra(tessellation * T)
*
* \return void
*/
void compute_circumcircles(tessellation * T)
{
}
void compute_circumcircles(tessellation *T) {}
/*! \brief Empty funciton in 1d spherical case.
*
......@@ -137,10 +127,7 @@ void compute_circumcircles(tessellation * T)
*
* \return void
*/
void set_integers_for_point(tessellation * T, int pp)
{
}
void set_integers_for_point(tessellation *T, int pp) {}
/*! \brief Empty funciton in 1d spherical case.
*
......@@ -149,11 +136,7 @@ void set_integers_for_point(tessellation * T, int pp)
*
* \return 0
*/
int insert_point(tessellation * T, int pp, int ttstart)
{
return 0;
}
int insert_point(tessellation *T, int pp, int ttstart) { return 0; }
/*! \brief Wrapper routine to search for ghost cells for boundary cells.
*
......@@ -161,11 +144,7 @@ int insert_point(tessellation * T, int pp, int ttstart)
*
* \return 0
*/
int voronoi_ghost_search(tessellation * T)
{
return voronoi_ghost_search_alternative(T);
}
int voronoi_ghost_search(tessellation *T) { return voronoi_ghost_search_alternative(T); }
/*! \brief Empty funciton in 1d spherical case.
*
......@@ -174,11 +153,7 @@ int voronoi_ghost_search(tessellation * T)
*
* \return 0
*/
int count_undecided_tetras(tessellation * T)
{
return 0;
}
int count_undecided_tetras(tessellation *T) { return 0; }
/*! \brief Searches for ghost cells in 1d spherical Voronoi mesh.
*
......@@ -188,7 +163,7 @@ int count_undecided_tetras(tessellation * T)
*
* \return 0
*/
int voronoi_ghost_search_alternative(tessellation * T)
int voronoi_ghost_search_alternative(tessellation *T)
{
point *DP = T->DP;
......@@ -211,7 +186,6 @@ int voronoi_ghost_search_alternative(tessellation * T)
return 0;
}
/*! \brief Compute faces and volume of cells in 1d spherical Voronoi mesh.
*
* Also computes the center of mass.
......@@ -253,19 +227,16 @@ void compute_voronoi_faces_and_volumes(void)
}
}
/*! \brief Structure for 1d spherical Voronoi mesh.
*/
static struct voronoi_1D_data
{
double x;
int index;
}
*mp;
} * mp;
static int *Id;
/*! \brief Sort cells by their position (i.e. radius) and reorder in P and
* SphP array.
*
......@@ -279,8 +250,8 @@ void voronoi_1D_order(void)
if(NumGas)
{
mp = (struct voronoi_1D_data *) mymalloc("mp", sizeof(struct voronoi_1D_data) * NumGas);
Id = (int *) mymalloc("Id", sizeof(int) * NumGas);
mp = (struct voronoi_1D_data *)mymalloc("mp", sizeof(struct voronoi_1D_data) * NumGas);
Id = (int *)mymalloc("Id", sizeof(int) * NumGas);
for(i = 0; i < NumGas; i++)
{
......@@ -302,7 +273,6 @@ void voronoi_1D_order(void)
mpi_printf("1D order done.\n");
}
/*! \brief Compare x value of voronoi_1D_data objects.
*
* \param[in] a Pointer to first voronoi_1D_data object.
......@@ -312,16 +282,15 @@ void voronoi_1D_order(void)
*/
int voronoi_1D_compare_key(const void *a, const void *b)
{
if(((struct voronoi_1D_data *) a)->x < (((struct voronoi_1D_data *) b)->x))
if(((struct voronoi_1D_data *)a)->x < (((struct voronoi_1D_data *)b)->x))
return -1;
if(((struct voronoi_1D_data *) a)->x > (((struct voronoi_1D_data *) b)->x))
if(((struct voronoi_1D_data *)a)->x > (((struct voronoi_1D_data *)b)->x))
return +1;
return 0;
}
/*! \brief Order the gas cells according to the index given in the ID array.
*
* \return void
......@@ -367,5 +336,4 @@ void voronoi_1D_reorder_gas(void)
}
}
#endif /* #if defined (ONEDIMS) && defined (ONEDIMS_SPHERICAL) */
This diff is collapsed.
This diff is collapsed.
......@@ -37,23 +37,20 @@
* - 22.05.2018 Prepared file for public release -- Rainer Weinberger
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../../main/allvars.h"
#include "../../main/proto.h"
#include "voronoi.h"
#if !defined(TWODIMS) && !defined(ONEDIMS) /* three-dimensional test code */
int points_compare(const void *a, const void *b);
/*! \brief Checks minimum distance between Delaunay points making sure it is
* nonzero.
*
......@@ -61,7 +58,7 @@ int points_compare(const void *a, const void *b);
*
* \return void
*/
void check_for_min_distance(tessellation * T)
void check_for_min_distance(tessellation *T)
{
point *DP = T->DP;
int i, j;
......@@ -74,28 +71,29 @@ void check_for_min_distance(tessellation * T)
for(j = i + 1; j < T->Ndp; j++)
{
r2 = (DP[i].x - DP[j].x) * (DP[i].x - DP[j].x) + (DP[i].y - DP[j].y) * (DP[i].y - DP[j].y) + (DP[i].z - DP[j].z) * (DP[i].z - DP[j].z);
r2 = (DP[i].x - DP[j].x) * (DP[i].x - DP[j].x) + (DP[i].y - DP[j].y) * (DP[i].y - DP[j].y) +
(DP[i].z - DP[j].z) * (DP[i].z - DP[j].z);
if(r2 < r2min)
r2min = r2;
if(r2min == 0)
{
sprintf(msg, "i=%d j=%d equal. DP[i].index=%d DP[j].index=%d\n", i, j, DP[i].index, DP[j].index);
terminate(msg)}
terminate(msg)
}
}
}
printf("min distance=%g\n", sqrt(r2min));
}
/*! \brief Checks if tessellation links are correct.
*
* \param[in] T Pointer to tessellation.
*
* \return void
*/
void check_links(tessellation * T)
void check_links(tessellation *T)
{
tetra *DT = T->DT;
int i, j, s, c, flag = 0;
......@@ -111,7 +109,7 @@ void check_links(tessellation * T)
{
if(DT[DT[i].t[j]].t[DT[i].s[j]] != i)
{
printf("LINK for tetra=%d j=%d DT[i].s[j]=%d incorrect %d\n", i, j, DT[i].s[j], (int) (DT[DT[i].t[j]].t[DT[i].s[j]]));
printf("LINK for tetra=%d j=%d DT[i].s[j]=%d incorrect %d\n", i, j, DT[i].s[j], (int)(DT[DT[i].t[j]].t[DT[i].s[j]]));
}
}
......@@ -147,14 +145,13 @@ void check_links(tessellation * T)
printf("links ok\n");
}
/*! \brief Checks if orientations of tetrahedra are positive.
*
* \param[in] T Pointer to tessellation.
*
* \return void
*/
void check_orientations(tessellation * T)
void check_orientations(tessellation *T)
{
tetra *DT = T->DT;
point *DP = T->DP;
......@@ -182,7 +179,8 @@ void check_orientations(tessellation * T)
if(ivol <= 0)
{
sprintf(msg, "Tetra %d is NEGATIVE (%d %d %d %d) oriented or FLAT: ivol=%d vol=%g\n", i, (int) (t->p[0]), (int) (t->p[1]), (int) (t->p[2]), (int) (t->p[3]), ivol, vol);
sprintf(msg, "Tetra %d is NEGATIVE (%d %d %d %d) oriented or FLAT: ivol=%d vol=%g\n", i, (int)(t->p[0]), (int)(t->p[1]),
(int)(t->p[2]), (int)(t->p[3]), ivol, vol);
terminate(msg);
}
......@@ -193,7 +191,6 @@ void check_orientations(tessellation * T)
printf("orientations ok, volmin=%g\n", volmin);
}
/*! \brief Checks if tetrahedra are valid.
*
* \param[in] T pointer to tessellation.
......@@ -201,7 +198,7 @@ void check_orientations(tessellation * T)
*
* \return void
*/
void check_tetras(tessellation * T, int npoints)
void check_tetras(tessellation *T, int npoints)
{
tetra *DT = T->DT;
point *DP = T->DP;
......@@ -235,7 +232,6 @@ void check_tetras(tessellation * T, int npoints)
terminate(msg);
}
for(j = 0; j < npoints; j++)
{
if(t->p[0] != j)
......@@ -251,8 +247,8 @@ void check_tetras(tessellation * T, int npoints)
if(res_exact > 0)
{
sprintf(msg, "ERROR tetra=%d: point=%d in tetra with edges=%d|%d|%d|%d res=%d|%d\n",
i, j, (int) (t->p[0]), (int) (t->p[1]), (int) (t->p[2]), (int) (t->p[3]), res, res_exact);
sprintf(msg, "ERROR tetra=%d: point=%d in tetra with edges=%d|%d|%d|%d res=%d|%d\n", i, j,
(int)(t->p[0]), (int)(t->p[1]), (int)(t->p[2]), (int)(t->p[3]), res, res_exact);
terminate(msg);
}
}
......@@ -263,7 +259,6 @@ void check_tetras(tessellation * T, int npoints)
printf("Tetrahedra OK\n");
}
/*! \brief Compare integer value of two variables.
*
* \param[in] a Pointer to first value.
......@@ -273,22 +268,19 @@ void check_tetras(tessellation * T, int npoints)
*/
int points_compare(const void *a, const void *b)
{
if(*((int *) a) < *((int *) b))
if(*((int *)a) < *((int *)b))
return -1;
if(*((int *) a) > *((int *) b))
if(*((int *)a) > *((int *)b))
return +1;
return 0;
}
#endif /* #if !defined(TWODIMS) && !defined(ONEDIMS) */
#ifdef TWODIMS /* two-dimensional test code */
/*! \brief Check 2d Voronoi mesh triangles.
*
* \param[in] T Pointer to tessellation.
......@@ -296,7 +288,7 @@ int points_compare(const void *a, const void *b)
*
* \return void
*/
void check_triangles(tessellation * T, int npoints)
void check_triangles(tessellation *T, int npoints)
{
int i, j, res, res_exact;
char msg[200];
......@@ -332,7 +324,8 @@ void check_triangles(tessellation * T, int npoints)
if(res_exact > 0)
{
sprintf(msg, "ERROR: point=%d lies in triangle=%d with edges=%d|%d|%d res=%d|%d\n", j, i, (int) (DT[i].p[0]), (int) (DT[i].p[1]), (int) (DT[i].p[2]), res, res_exact);
sprintf(msg, "ERROR: point=%d lies in triangle=%d with edges=%d|%d|%d res=%d|%d\n", j, i,
(int)(DT[i].p[0]), (int)(DT[i].p[1]), (int)(DT[i].p[2]), res, res_exact);
terminate(msg);
}
}
......@@ -343,14 +336,13 @@ void check_triangles(tessellation * T, int npoints)
printf("triangles ok\n");
}
/*! \brief Check the orientations of triangles in 2d Voronoi mesh.
*
* \param[in] T Pointer to tessellation.
*
* \return void
*/
void check_orientations(tessellation * T)
void check_orientations(tessellation *T)
{
int i, ivol;
double vol, volmin = 1.0e30;
......@@ -374,7 +366,8 @@ void check_orientations(tessellation * T)
{
double vol2 = Orient2d_Quick(T, DT[i].p[0], DT[i].p[1], DT[i].p[2]);