My Project
programmer's documentation
Functions
cs_interface.c File Reference
#include "cs_defs.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "bft_error.h"
#include "bft_mem.h"
#include "bft_printf.h"
#include "cs_all_to_all.h"
#include "cs_base.h"
#include "cs_block_dist.h"
#include "cs_order.h"
#include "fvm_periodicity.h"
#include "cs_interface.h"
Include dependency graph for cs_interface.c:

Functions

int cs_interface_rank (const cs_interface_t *itf)
 Return process rank associated with an interface's distant elements. More...
 
cs_lnum_t cs_interface_size (const cs_interface_t *itf)
 Return number of local and distant elements defining an interface. More...
 
const cs_lnum_tcs_interface_get_elt_ids (const cs_interface_t *itf)
 Return pointer to array of local element ids defining an interface. More...
 
const cs_lnum_tcs_interface_get_match_ids (const cs_interface_t *itf)
 Return pointer to array of matching element ids defining an interface. More...
 
cs_lnum_t cs_interface_get_tr_index_size (const cs_interface_t *itf)
 Return size of index of sub-sections for different transformations. More...
 
const cs_lnum_tcs_interface_get_tr_index (const cs_interface_t *itf)
 Return pointer to index of sub-sections for different transformations. More...
 
cs_interface_set_tcs_interface_set_create (cs_lnum_t n_elts, const cs_lnum_t parent_element_id[], const cs_gnum_t global_number[], const fvm_periodicity_t *periodicity, int n_periodic_lists, const int periodicity_num[], const cs_lnum_t n_periodic_couples[], const cs_gnum_t *const periodic_couples[])
 Creation of a list of interfaces between elements of a same type. More...
 
void cs_interface_set_destroy (cs_interface_set_t **ifs)
 Destruction of an interface set. More...
 
int cs_interface_set_size (const cs_interface_set_t *ifs)
 Return number of interfaces associated with an interface set. More...
 
cs_lnum_t cs_interface_set_n_elts (const cs_interface_set_t *ifs)
 Return total number of elements in interface set. More...
 
const cs_interface_tcs_interface_set_get (const cs_interface_set_t *ifs, int interface_id)
 Return pointer to a given interface in an interface set. More...
 
const fvm_periodicity_tcs_interface_set_periodicity (const cs_interface_set_t *ifs)
 Return pointer to the periocicity structure associated of an interface set. More...
 
void cs_interface_set_renumber (cs_interface_set_t *ifs, const cs_lnum_t old_to_new[])
 Apply renumbering of elements referenced by an interface set. More...
 
void cs_interface_set_copy_array (const cs_interface_set_t *ifs, cs_datatype_t datatype, int stride, bool src_on_parent, const void *src, void *dest)
 Copy array from distant or matching interface elements to local elements. More...
 
void cs_interface_set_copy_indexed (const cs_interface_set_t *ifs, cs_datatype_t datatype, bool src_on_parent, const cs_lnum_t src_index[], const cs_lnum_t dest_index[], const void *src, void *dest)
 Copy indexed array from distant or matching interface elements to local elements. More...
 
void cs_interface_set_sum (const cs_interface_set_t *ifs, cs_lnum_t n_elts, cs_lnum_t stride, bool interlace, cs_datatype_t datatype, void *var)
 Update the sum of values for elements associated with an interface set. More...
 
void cs_interface_set_min (const cs_interface_set_t *ifs, cs_lnum_t n_elts, cs_lnum_t stride, bool interlace, cs_datatype_t datatype, void *var)
 Update to minimum value for elements associated with an interface set. More...
 
void cs_interface_set_max (const cs_interface_set_t *ifs, cs_lnum_t n_elts, cs_lnum_t stride, bool interlace, cs_datatype_t datatype, void *var)
 Update to maximum value for elements associated with an interface set. More...
 
void cs_interface_set_add_match_ids (cs_interface_set_t *ifs)
 Add matching element id information to an interface set. More...
 
void cs_interface_set_free_match_ids (cs_interface_set_t *ifs)
 Free matching element id information of an interface set. More...
 
void cs_interface_set_dump (const cs_interface_set_t *ifs)
 Dump printout of an interface list. More...
 

Function Documentation

◆ cs_interface_get_elt_ids()

const cs_lnum_t* cs_interface_get_elt_ids ( const cs_interface_t itf)

Return pointer to array of local element ids defining an interface.

The size of the array may be obtained by cs_interface_size(). The array is owned by the interface structure, and is not copied (hence the constant qualifier for the return value).

Parameters
[in]itfpointer to interface structure
Returns
pointer to array of local element ids (0 to n-1) defining the interface

◆ cs_interface_get_match_ids()

const cs_lnum_t* cs_interface_get_match_ids ( const cs_interface_t itf)

Return pointer to array of matching element ids defining an interface.

This array is only available if cs_interface_set_add_match_ids() has been called for the containing interface set.

The size of the array may be obtained by cs_interface_size(). The array is owned by the interface structure, and is not copied (hence the constant qualifier for the return value).

Parameters
[in]itfpointer to interface structure
Returns
pointer to array of local element ids (0 to n-1) defining the interface

◆ cs_interface_get_tr_index()

const cs_lnum_t* cs_interface_get_tr_index ( const cs_interface_t itf)

Return pointer to index of sub-sections for different transformations.

The index is applicable to both local_num and distant_num arrays, with purely parallel equivalences appearing at position 0, and equivalences through periodic transform i at position i+1; In absence of periodicity, it may be NULL, as it is not needed.

Parameters
[in]itfpointer to interface structure
Returns
pointer to transform index for the interface

◆ cs_interface_get_tr_index_size()

cs_lnum_t cs_interface_get_tr_index_size ( const cs_interface_t itf)

Return size of index of sub-sections for different transformations.

The index is applicable to both local_num and distant_num arrays, with purely parallel equivalences appearing at position 0, and equivalences through periodic transform i at position i+1; Its size should thus be equal to 1 + number of periodic transforms + 1, In absence of periodicity, it may be 0, as the index is not needed.

Parameters
[in]itfpointer to interface structure
Returns
transform index size for the interface

◆ cs_interface_rank()

int cs_interface_rank ( const cs_interface_t itf)

Return process rank associated with an interface's distant elements.

Parameters
[in]itfpointer to interface structure
Returns
process rank associated with the interface's distant elements

◆ cs_interface_set_add_match_ids()

void cs_interface_set_add_match_ids ( cs_interface_set_t ifs)

Add matching element id information to an interface set.

This information is required by calls to cs_interface_get_dist_ids(), and may be freed using cs_interface_set_free_match_ids().

Parameters
[in]ifspointer to interface set structure

◆ cs_interface_set_copy_array()

void cs_interface_set_copy_array ( const cs_interface_set_t ifs,
cs_datatype_t  datatype,
int  stride,
bool  src_on_parent,
const void *  src,
void *  dest 
)

Copy array from distant or matching interface elements to local elements.

Source and destination arrays define values for all elements in the interface set (i.e. all elements listed by cs_interface_get_elt_ids() when looping over interfaces of a set.

Parameters
[in]ifspointer to interface set structure
[in]datatypetype of data considered
[in]stridenumber of values per entity (interlaced)
[in]src_on_parenttrue if source array is defined on the elements defined by ifs->elt_ids, false if source array defined directly on cs_interface_set_n_elts(ifs)
[in]srcsource array (size: cs_interface_set_n_elts(ifs)*stride or parent array size * stride)
[out]destdestination array (size: cs_interface_set_n_elts(ifs)*stride)

◆ cs_interface_set_copy_indexed()

void cs_interface_set_copy_indexed ( const cs_interface_set_t ifs,
cs_datatype_t  datatype,
bool  src_on_parent,
const cs_lnum_t  src_index[],
const cs_lnum_t  dest_index[],
const void *  src,
void *  dest 
)

Copy indexed array from distant or matching interface elements to local elements.

Source and destination arrays define values for all elements in the interface set (i.e. all elements listed by cs_interface_get_elt_ids() when looping over interfaces of a set.

Note that when copying the same type of data to all matching elements, the source and destination index may be the same, if src_on_parent is true. To avoid requiring a separate destination index, the dest_index argument may be set to NULL, in which case it is assumed that source and destination are symmetric, and src_index is sufficient to determine sizes (whether src_on_parent is true or not).

In some use cases, for example when copying values only in one direction, the copying is not symmetric, so both a source and destination buffer must be provided.

Parameters
[in]ifspointer to interface set structure
[in]datatypetype of data considered
[in]src_on_parenttrue if source array is defined on the elements defined by ifs->elt_ids, false if source array defined directly on cs_interface_set_n_elts(ifs)
[in]src_indexindex for source array
[in]dest_indexindex for destination array, or NULL
[in]srcsource array (size: src_index[cs_interface_set_n_elts(ifs)] or parent array size)
[out]destdestination array (size: src_index[cs_interface_set_n_elts(ifs)] or dest_index[cs_interface_set_n_elts(ifs)])

◆ cs_interface_set_create()

cs_interface_set_t* cs_interface_set_create ( cs_lnum_t  n_elts,
const cs_lnum_t  parent_element_id[],
const cs_gnum_t  global_number[],
const fvm_periodicity_t periodicity,
int  n_periodic_lists,
const int  periodicity_num[],
const cs_lnum_t  n_periodic_couples[],
const cs_gnum_t *const  periodic_couples[] 
)

Creation of a list of interfaces between elements of a same type.

These interfaces may be used to identify equivalent vertices or faces using domain splitting, as well as periodic elements (on the same or on distant ranks).

Note that periodicity information will be completed and made consistent based on the input, so that if a periodic couple is defined on a given rank, the reverse couple wil be defined, whether it is also defined on the same or a different rank.

In addition, multiple periodicity interfaces will be built automatically if the periodicity structure provides for composed periodicities, so they need not be defined prior to this function being called.

Parameters
[in]n_eltsnumber of local elements considered (size of parent_element_id[])
[in]parent_element_idpointer to list of selected elements local ids (0 to n-1), or NULL if all first n_elts elements are used
[in]global_numberpointer to list of global (i.e. domain splitting independent) element numbers
[in]periodicityperiodicity information (NULL if none)
[in]n_periodic_listsnumber of periodic lists (may be local)
[in]periodicity_numperiodicity number (1 to n) associated with each periodic list (primary periodicities only)
[in]n_periodic_couplesnumber of periodic couples associated with each periodic list
[in]periodic_couplesarray indicating periodic couples (interlaced, using global numberings) for each list
Returns
pointer to list of interfaces (possibly NULL in serial mode)

◆ cs_interface_set_destroy()

void cs_interface_set_destroy ( cs_interface_set_t **  ifs)

Destruction of an interface set.

Parameters
[in,out]ifspointer to pointer to structure to destroy

◆ cs_interface_set_dump()

void cs_interface_set_dump ( const cs_interface_set_t ifs)

Dump printout of an interface list.

Parameters
[in]ifspointer to structure that should be dumped

◆ cs_interface_set_free_match_ids()

void cs_interface_set_free_match_ids ( cs_interface_set_t ifs)

Free matching element id information of an interface set.

This information is used by calls to cs_interface_get_dist_ids(), and may be defined using cs_interface_set_add_match_ids().

Parameters
[in]ifspointer to interface set structure

◆ cs_interface_set_get()

const cs_interface_t* cs_interface_set_get ( const cs_interface_set_t ifs,
int  interface_id 
)

Return pointer to a given interface in an interface set.

Parameters
[in]ifs<– pointer to interface set structure
[in]interface_id<– index of interface in set (0 to n-1)
Returns
pointer to interface structure

◆ cs_interface_set_max()

void cs_interface_set_max ( const cs_interface_set_t ifs,
cs_lnum_t  n_elts,
cs_lnum_t  stride,
bool  interlace,
cs_datatype_t  datatype,
void *  var 
)

Update to maximum value for elements associated with an interface set.

On input, the variable array should contain local contributions. On output, contributions from matching elements on parallel or periodic boundaries have been added.

Only the values of elements belonging to the interfaces are modified.

Parameters
[in]ifspointer to a fvm_interface_set_t structure
[in]n_eltsnumber of elements in var buffer
[in]stridenumber of values (non interlaced) by entity
[in]interlacetrue if variable is interlaced (for stride > 1)
[in]datatypetype of data considered
[in,out]varvariable buffer

◆ cs_interface_set_min()

void cs_interface_set_min ( const cs_interface_set_t ifs,
cs_lnum_t  n_elts,
cs_lnum_t  stride,
bool  interlace,
cs_datatype_t  datatype,
void *  var 
)

Update to minimum value for elements associated with an interface set.

On input, the variable array should contain local contributions. On output, contributions from matching elements on parallel or periodic boundaries have been added.

Only the values of elements belonging to the interfaces are modified.

Parameters
[in]ifspointer to a fvm_interface_set_t structure
[in]n_eltsnumber of elements in var buffer
[in]stridenumber of values (non interlaced) by entity
[in]interlacetrue if variable is interlaced (for stride > 1)
[in]datatypetype of data considered
[in,out]varvariable buffer

◆ cs_interface_set_n_elts()

cs_lnum_t cs_interface_set_n_elts ( const cs_interface_set_t ifs)

Return total number of elements in interface set.

This is equal to the sum of cs_interface_size() on the cs_interface_size() interfaces of a set.

Parameters
[in]ifspointer to interface set structure
Returns
number of interfaces in set

◆ cs_interface_set_periodicity()

const fvm_periodicity_t* cs_interface_set_periodicity ( const cs_interface_set_t ifs)

Return pointer to the periocicity structure associated of an interface set.

Parameters
[in]ifspointer to interface set structure
Returns
pointer to periodicity structure, or NULL

◆ cs_interface_set_renumber()

void cs_interface_set_renumber ( cs_interface_set_t ifs,
const cs_lnum_t  old_to_new[] 
)

Apply renumbering of elements referenced by an interface set.

For any given element i, a negative old_to_new[i] value means that that element does not appear anymore in the new numbering.

Parameters
[in,out]ifspointer to interface set structure
[in]old_to_newrenumbering array (0 to n-1 numbering)

◆ cs_interface_set_size()

int cs_interface_set_size ( const cs_interface_set_t ifs)

Return number of interfaces associated with an interface set.

Parameters
[in]ifspointer to interface set structure
Returns
number of interfaces in set

◆ cs_interface_set_sum()

void cs_interface_set_sum ( const cs_interface_set_t ifs,
cs_lnum_t  n_elts,
cs_lnum_t  stride,
bool  interlace,
cs_datatype_t  datatype,
void *  var 
)

Update the sum of values for elements associated with an interface set.

On input, the variable array should contain local contributions. On output, contributions from matching elements on parallel or periodic boundaries have been added.

Only the values of elements belonging to the interfaces are modified.

Parameters
[in]ifspointer to a fvm_interface_set_t structure
[in]n_eltsnumber of elements in var buffer
[in]stridenumber of values (non interlaced) by entity
[in]interlacetrue if variable is interlaced (for stride > 1)
[in]datatypetype of data considered
[in,out]varvariable buffer

◆ cs_interface_size()

cs_lnum_t cs_interface_size ( const cs_interface_t itf)

Return number of local and distant elements defining an interface.

Parameters
[in]itfpointer to interface structure
Returns
number of local and distant elements defining the interface