7.0
general documentation
cs_block_to_part.c File Reference
#include "cs_defs.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "cs_all_to_all.h"
#include "cs_block_dist.h"
#include "cs_order.h"
#include "cs_block_to_part.h"
+ Include dependency graph for cs_block_to_part.c:

Functions

cs_all_to_all_tcs_block_to_part_create_by_adj_s (MPI_Comm comm, cs_block_dist_info_t block, cs_block_dist_info_t adjacent_block, int stride, const cs_gnum_t adjacency[], const int adjacent_ent_rank[], const int default_rank[], cs_lnum_t *n_part_elts, cs_gnum_t **part_gnum)
 Initialize block to partition distributor with block data using strided adjacency array. More...
 
void cs_block_to_part_global_to_local (cs_lnum_t n_ents, cs_lnum_t base, cs_lnum_t global_list_size, bool global_list_is_sorted, const cs_gnum_t global_list[], const cs_gnum_t global_number[], cs_lnum_t local_number[])
 Determine local references from references to global numbers. More...
 

Function Documentation

◆ cs_block_to_part_create_by_adj_s()

cs_all_to_all_t* cs_block_to_part_create_by_adj_s ( MPI_Comm  comm,
cs_block_dist_info_t  block,
cs_block_dist_info_t  adjacent_block,
int  stride,
const cs_gnum_t  adjacency[],
const int  adjacent_ent_rank[],
const int  default_rank[],
cs_lnum_t n_part_elts,
cs_gnum_t **  part_gnum 
)

Initialize block to partition distributor with block data using strided adjacency array.

The adjacency array uses 1-n based global numbers. 0 values are allowed and may be used to represent empty adjacencies.

For example, in a face -> element adjacency relation, each face is adjacent to 2 elements (thus a stride of 2), except for boundary faces which are adjacent to only 1 element; in this case, the adjacent element number for the exterior side of the face is 0.

It is also possible to define a default destination rank, so that elements with no adjacency are redistributed. If the default rank for a given element is < 0, or no default ranks are defined, elements with no adjacency are not distributed.

The returned all to all distributor should be used in reverse mode to copy data from the block to partition distribution.

If the part_gnum array is requested (i.e. passed an non-NULL pointer), the caller is responsible for freeing it.

Parameters
[in]commcommunicator
[in]blockblock size and range info
[in]adjacent_blockblock info for adjacent entities
[in]stridestride of adjacency array (1 or 2)
[in]adjacencyentity adjacency (1 to n numbering)
[in]adjacent_ent_rankdestination rank for adjacent entities, or NULL if based on block size and range only.
[in]default_rankdefault rank in case there is no adjacency, or NULL
[out]n_part_eltsnumber of elements in partition, or NULL
[out]part_gnumglobal elements numbers in partition, or NULL
Returns
initialized all to all block to partition distributor

◆ cs_block_to_part_global_to_local()

void cs_block_to_part_global_to_local ( cs_lnum_t  n_ents,
cs_lnum_t  base,
cs_lnum_t  global_list_size,
bool  global_list_is_sorted,
const cs_gnum_t  global_list[],
const cs_gnum_t  global_number[],
cs_lnum_t  local_number[] 
)

Determine local references from references to global numbers.

This is based on finding the local id of a given global number using a binary search.

Global numbers use a 1 to n numbering, while local numbers use a 0+base to n-1+base numbering. If an entity's global number does not appear in the global list, base-1 is assigned for that entity's local list.

If list contains duplicate values, any local id having a multiple global number (i.e not necessarily the smallest one) may be assigned to the corresponding local_number[] entry.

Parameters
[in]n_entsnumber of entities
[in]basebase numbering (typically 0 or 1)
[in]global_list_sizesize of global entity list
[in]global_list_is_sortedtrue if global entity list is guaranteed to be sorted
[in]global_listglobal entity list
[in]global_numberentity global numbers (size: n_ents)
[out]local_numberentity local numbers (size: n_ents)