YetAnotherCoupler 3.2.0
Loading...
Searching...
No Matches
test_proc_sphere_part_parallel.c

This contains a test of the proc_sphere_part grid search algorithm.

// Copyright (c) 2024 The YAC Authors
//
// SPDX-License-Identifier: BSD-3-Clause
#include <stdlib.h>
#include <mpi.h>
#include "tests.h"
#include "test_common.h"
#include "geometry.h"
#include "yac_mpi.h"
int main(void) {
MPI_Init(NULL, NULL);
int comm_rank, comm_size;
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
YAC_ASSERT(comm_size == 5, "ERROR wrong number of processes (has to be 5)")
{
// one process has no data
double x_vertices[18] = {0,20,40,60,80,
100,120,140,160,180,
200,220,240,260,280,
300,320,340};
double y_vertices[9] = {-80,-60,-40,-20,0,20,40,60,80};
size_t local_start[5][2] = {{0,0},{7,0},{0,0},{0,3},{7,3}};
size_t local_count[5][2] = {{10,6},{10,6},{0,0},{10,6},{10,6}};
size_t num_cells = local_count[comm_rank][0] * local_count[comm_rank][1];
struct dist_cell * cells = xmalloc(num_cells * sizeof(*cells));
for (size_t i = 0, k = 0; i < local_count[comm_rank][1]; ++i)
for (size_t j = 0; j < local_count[comm_rank][0]; ++j, ++k)
x_vertices[local_start[comm_rank][0]+j],
y_vertices[local_start[comm_rank][1]+i], cells[k].coord);
struct proc_sphere_part_node * proc_sphere_part =
yac_redistribute_cells(&cells, &num_cells, MPI_COMM_WORLD);
free(cells);
}
{
double coords[5][2][3] =
{{{1,0,0},{-1,0,0}},
{{0,1,0}},
{{0,-1,0}},
{{0,0,1}},
{{0,0,-1}}};
size_t num_cells[5] = {2,1,1,1,1};
struct dist_cell * cells = xmalloc(2 * sizeof(*cells));
for (size_t i = 0; i < num_cells[comm_rank]; ++i)
for (int j = 0; j < 3; ++j)
cells[i].coord[j] = coords[comm_rank][i][j];
struct proc_sphere_part_node * proc_sphere_part =
yac_redistribute_cells(&cells, &num_cells[comm_rank], MPI_COMM_WORLD);
free(cells);
}
{
size_t num_cells = 0;
struct proc_sphere_part_node * proc_sphere_part =
yac_redistribute_cells(NULL, &num_cells, MPI_COMM_WORLD);
}
MPI_Finalize();
return TEST_EXIT_CODE;
}
static void LLtoXYZ_deg(double lon, double lat, double p_out[])
Definition geometry.h:304
#define xmalloc(size)
Definition ppm_xfuncs.h:66
void yac_proc_sphere_part_node_delete(struct proc_sphere_part_node *node)
struct proc_sphere_part_node * yac_redistribute_cells(struct dist_cell **cells, size_t *num_cells, MPI_Comm comm)
double coord[3]
int main(int argc, char **argv)
#define YAC_ASSERT(exp, msg)
Definition yac_assert.h:16