8.0
general documentation
cs_paramedmem_coupling.cxx File Reference
#include "cs_defs.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <mpi.h>
#include <string>
#include <vector>
#include <ple_coupling.h>
#include "bft_error.h"
#include "bft_mem.h"
#include "bft_printf.h"
#include "cs_mesh.h"
#include "cs_mesh_connect.h"
#include "cs_parall.h"
#include "cs_prototypes.h"
#include "cs_selector.h"
#include "cs_timer.h"
#include "cs_coupling.h"
#include "fvm_defs.h"
#include "fvm_nodal_from_desc.h"
#include "cs_medcoupling_mesh.hxx"
#include "cs_paramedmem_coupling.h"
#include <MEDCouplingField.hxx>
#include <MEDCouplingFieldDouble.hxx>
#include <ParaFIELD.hxx>
#include <ParaMESH.hxx>
#include <InterpKernelDEC.hxx>
+ Include dependency graph for cs_paramedmem_coupling.cxx:

Macros

#define USE_PARAFIELD
 

Functions

static void _generate_coupling_mesh (cs_paramedmem_coupling_t *c, const char *select_criteria, int elt_dim)
 Generate mesh structure from user's defintion. More...
 
static void _generate_coupling_mesh_from_ids (cs_paramedmem_coupling_t *c, cs_lnum_t n_elts, const cs_lnum_t elt_ids[], int elt_dim)
 Generate mesh structure from user's defintion. More...
 
static int _add_paramedmem_coupling (const std::string cpl_name, ple_coupling_mpi_set_info_t apps[2])
 Create a paramedmem coupling based on an InterpKernelDEC. More...
 
static int _add_paramedmem_coupling_dry_run (const std::string cpl_name)
 Create a paramedmem coupling for "dry run" mode. More...
 
cs_paramedmem_coupling_t * cs_paramedmem_coupling_by_id (int cpl_id)
 Retrieve coupling struct pointer by id. More...
 
cs_paramedmem_coupling_t * cs_paramedmem_coupling_by_name (const char *name)
 Retrieve coupling struct pointer by name. More...
 
cs_paramedmem_coupling_t * cs_paramedmem_coupling_create (const char *app1_name, const char *app2_name, const char *cpl_name)
 Create a new ParaMEDMEM coupling. More...
 
cs_paramedmem_coupling_t * cs_paramedmem_coupling_create_uncoupled (const char *cpl_name)
 Create a new ParaMEDMEM handler structure with no actual coupling. More...
 
void cs_paramedmem_coupling_destroy (cs_paramedmem_coupling_t *c)
 Destroy a given ParaMEDMEM coupling structure. More...
 
void cs_paramedmem_coupling_all_finalize (void)
 Destroy all coupling structures. More...
 
void cs_paramedmem_add_mesh_from_criteria (cs_paramedmem_coupling_t *c, const char *sel_crit, int elt_dim)
 Define coupled mesh based on a selection criteria. More...
 
void cs_paramedmem_add_mesh_from_zone (cs_paramedmem_coupling_t *c, const cs_zone_t *zone)
 Define coupled mesh based on a cs_zone_t pointer. More...
 
void cs_paramedmem_add_mesh_from_ids (cs_paramedmem_coupling_t *c, cs_lnum_t n_elts, const cs_lnum_t elt_ids[], int elt_dim)
 Define coupled mesh based on a cs_zone_t pointer. More...
 
int cs_paramedmem_get_number_of_couplings (void)
 Get number of defined couplings. More...
 
cs_lnum_t cs_paramedmem_mesh_get_n_elts (const cs_paramedmem_coupling_t *coupling)
 Get number of elements of coupled mesh. More...
 
const cs_lnum_tcs_paramedmem_mesh_get_elt_list (const cs_paramedmem_coupling_t *coupling)
 Get indirection list for elements in coupled mesh. More...
 
cs_lnum_t cs_paramedmem_mesh_get_n_vertices (const cs_paramedmem_coupling_t *coupling)
 Get number of vertices of coupled mesh. More...
 
const cs_lnum_tcs_paramedmem_mesh_get_vertex_list (const cs_paramedmem_coupling_t *coupling)
 Get indirection list for vertices in coupled mesh. More...
 
int cs_paramedmem_def_coupled_field (cs_paramedmem_coupling_t *c, const char *name, int dim, cs_medcpl_field_nature_t field_nature, cs_medcpl_space_discr_t space_discr, cs_medcpl_time_discr_t time_discr)
 Define a coupled field. More...
 
int cs_paramedmem_def_coupled_field_from_cs_field (cs_paramedmem_coupling_t *c, cs_field_t *f, cs_medcpl_field_nature_t fn, cs_medcpl_time_discr_t td)
 Define a coupled field based on a cs_field_t pointer. More...
 
void cs_paramedmem_field_export (cs_paramedmem_coupling_t *c, const char *name, const double values[])
 Assign values based on parent mesh location to associated ParaFIELD objects. More...
 
void cs_paramedmem_field_export_l (cs_paramedmem_coupling_t *c, const char *name, const double values[])
 Assign values based on mesh location corresponding to coupled elements (and associated ParaMESH) to associated ParaFIELD objects. More...
 
void cs_paramedmem_field_import (cs_paramedmem_coupling_t *c, const char *name, double values[])
 Copy values from associated ParaFIELD object to array defined parent mesh location. More...
 
void cs_paramedmem_field_import_l (cs_paramedmem_coupling_t *c, const char *name, double values[])
 Copy values from associated ParaFIELD structure to array defined on mesh location corresponding to coupled elements (and associated ParaMESH). More...
 
void cs_paramedmem_sync_dec (cs_paramedmem_coupling_t *c)
 Sync the coupling's InterpKernelDEC. More...
 
void cs_paramedmem_send_data (cs_paramedmem_coupling_t *c)
 Send values of field attached to DEC. More...
 
void cs_paramedmem_recv_data (cs_paramedmem_coupling_t *c)
 Recieve values of field attached to DEC. More...
 
void cs_paramedmem_attach_field_by_id (cs_paramedmem_coupling_t *c, int field_id)
 Attach a field to InterpKernelDEC for send operation using its index. More...
 
void cs_paramedmem_attach_field_by_name (cs_paramedmem_coupling_t *c, const char *name)
 Attach a field to InterpKernelDEC for send operation using its name. More...
 
void cs_paramedmem_send_field_vals (cs_paramedmem_coupling_t *c, const char *name, const double *vals)
 Send values of a field. If vals pointer is non-null, values are updated before send. More...
 
void cs_paramedmem_recv_field_vals (cs_paramedmem_coupling_t *c, const char *name, double *vals)
 Recieve values of a field. More...
 
void cs_paramedmem_coupling_log_setup (void)
 Log ParaMEDMEM coupling setup information. More...
 
void cs_paramedmem_coupling_all_init (void)
 initialize couplings based on user functions. More...
 
void cs_paramedmem_coupling_define_mesh_fields (void)
 initialize coupled mesh and fields based on user functions. More...
 

Variables

static std::vector< cs_paramedmem_coupling_t * > _paramed_couplers
 

Macro Definition Documentation

◆ USE_PARAFIELD

#define USE_PARAFIELD
Value:
1 /* 1 to use <ParaFIELD> fields,
0 to directly use MEDCouplingFieldDouble */

Function Documentation

◆ _add_paramedmem_coupling()

static int _add_paramedmem_coupling ( const std::string  cpl_name,
ple_coupling_mpi_set_info_t  apps[2] 
)
static

Create a paramedmem coupling based on an InterpKernelDEC.

The latter is created using the the lists of ranks provided as input to this function.

Parameters
[in]cpl_namecoupling name
[in]appsarray containing ple_coupling_mpi_set_info_t

◆ _add_paramedmem_coupling_dry_run()

static int _add_paramedmem_coupling_dry_run ( const std::string  cpl_name)
static

Create a paramedmem coupling for "dry run" mode.

Parameters
[in]cpl_namecoupling name

◆ _generate_coupling_mesh()

static void _generate_coupling_mesh ( cs_paramedmem_coupling_t *  c,
const char *  select_criteria,
int  elt_dim 
)
static

Generate mesh structure from user's defintion.

Parameters
[in]cpointer to cs_paramedmem_coupling_t struct
[in]select_criteriaselection criteria (string)
[in]elt_dimmesh dimension (2 or 3)

◆ _generate_coupling_mesh_from_ids()

static void _generate_coupling_mesh_from_ids ( cs_paramedmem_coupling_t *  c,
cs_lnum_t  n_elts,
const cs_lnum_t  elt_ids[],
int  elt_dim 
)
static

Generate mesh structure from user's defintion.

Parameters
[in]cpointer to cs_paramedmem_coupling_t struct
[in]n_eltslocal number of elements
[in]elt_idslist of local elements
[in]elt_dimdimension of elements (2: faces, 3: cells)

◆ cs_paramedmem_add_mesh_from_criteria()

void cs_paramedmem_add_mesh_from_criteria ( cs_paramedmem_coupling_t *  c,
const char *  sel_crit,
int  elt_dim 
)

Define coupled mesh based on a selection criteria.

Parameters
[in]cpointer to cs_paramedmem_coupling_t struct
[in]sel_critgeometrical selection criteria (string)
[in]elt_dimdimension of coupled elements

◆ cs_paramedmem_add_mesh_from_ids()

void cs_paramedmem_add_mesh_from_ids ( cs_paramedmem_coupling_t *  c,
cs_lnum_t  n_elts,
const cs_lnum_t  elt_ids[],
int  elt_dim 
)

Define coupled mesh based on a cs_zone_t pointer.

Parameters
[in]cpointer to cs_paramedmem_coupling_t struct
[in]n_eltslocal number of elements
[in]elt_idslist of local elements
[in]elt_dimdimension of elements (2: faces, 3: cells)

◆ cs_paramedmem_add_mesh_from_zone()

void cs_paramedmem_add_mesh_from_zone ( cs_paramedmem_coupling_t *  c,
const cs_zone_t zone 
)

Define coupled mesh based on a cs_zone_t pointer.

Parameters
[in]cpointer to cs_paramedmem_coupling_t struct
[in]zonepointer to cs_zone_t struct

◆ cs_paramedmem_attach_field_by_id()

void cs_paramedmem_attach_field_by_id ( cs_paramedmem_coupling_t *  c,
int  field_id 
)

Attach a field to InterpKernelDEC for send operation using its index.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure
[in]field_idindex of field in storing vector

◆ cs_paramedmem_attach_field_by_name()

void cs_paramedmem_attach_field_by_name ( cs_paramedmem_coupling_t *  c,
const char *  name 
)

Attach a field to InterpKernelDEC for send operation using its name.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure
[in]namename of field (string)

◆ cs_paramedmem_coupling_all_finalize()

void cs_paramedmem_coupling_all_finalize ( void  )

Destroy all coupling structures.

◆ cs_paramedmem_coupling_all_init()

void cs_paramedmem_coupling_all_init ( void  )

initialize couplings based on user functions.

initialize couplings based on user functions

◆ cs_paramedmem_coupling_by_id()

cs_paramedmem_coupling_t* cs_paramedmem_coupling_by_id ( int  cpl_id)

Retrieve coupling struct pointer by id.

Parameters
[in]cpl_idindex of the sought coupling
Returns
pointer to cs_paramedmem_coupling_t struct. Raise an error if the coupling does not exist.

◆ cs_paramedmem_coupling_by_name()

cs_paramedmem_coupling_t* cs_paramedmem_coupling_by_name ( const char *  name)

Retrieve coupling struct pointer by name.

Parameters
[in]namename of the coupling
Returns
pointer to cs_paramedmem_coupling_t struct or NULL if not found.

◆ cs_paramedmem_coupling_create()

cs_paramedmem_coupling_t* cs_paramedmem_coupling_create ( const char *  app1_name,
const char *  app2_name,
const char *  cpl_name 
)

Create a new ParaMEDMEM coupling.

Parameters
[in]app1_nameName of app n°1 or NULL if calling app is app1
[in]app2_nameName of app n°2 or NULL if calling app is app2
[in]cpl_nameName of the coupling. If NULL an automatic name is generated.
Returns
pointer to newly created cs_paramedmem_coupling_t structure.

◆ cs_paramedmem_coupling_create_uncoupled()

cs_paramedmem_coupling_t* cs_paramedmem_coupling_create_uncoupled ( const char *  cpl_name)

Create a new ParaMEDMEM handler structure with no actual coupling.

This can be useful for a "dry run" when setting up a coupling, so as to first debug local commands before actually running in coupled mode.

In this case, data "received" matches the initialized values.

Parameters
[in]app1_nameName of app n°1 or NULL if calling app is app1
[in]app2_nameName of app n°2 or NULL if calling app is app2
[in]cpl_nameName of the coupling. If NULL an automatic name is generated.
Returns
pointer to newly created cs_paramedmem_coupling_t structure.

◆ cs_paramedmem_coupling_define_mesh_fields()

void cs_paramedmem_coupling_define_mesh_fields ( void  )

initialize coupled mesh and fields based on user functions.

initialize coupled mesh and fields based on user functions

◆ cs_paramedmem_coupling_destroy()

void cs_paramedmem_coupling_destroy ( cs_paramedmem_coupling_t *  c)

Destroy a given ParaMEDMEM coupling structure.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure

◆ cs_paramedmem_coupling_log_setup()

void cs_paramedmem_coupling_log_setup ( void  )

Log ParaMEDMEM coupling setup information.

◆ cs_paramedmem_def_coupled_field()

int cs_paramedmem_def_coupled_field ( cs_paramedmem_coupling_t *  c,
const char *  name,
int  dim,
cs_medcpl_field_nature_t  field_nature,
cs_medcpl_space_discr_t  space_discr,
cs_medcpl_time_discr_t  time_discr 
)

Define a coupled field.

Parameters
[in]cpointer to cs_paramedmem_coupling_t struct
[in]namename of field
[in]dimfield dimension
[in]field_naturefield nature flag
[in]space_discrfield space discretisation (nodes or cells)
[in]time_discrfield coupling time discretisation
Returns
index of field within the storing vector

◆ cs_paramedmem_def_coupled_field_from_cs_field()

int cs_paramedmem_def_coupled_field_from_cs_field ( cs_paramedmem_coupling_t *  c,
cs_field_t f,
cs_medcpl_field_nature_t  fn,
cs_medcpl_time_discr_t  td 
)

Define a coupled field based on a cs_field_t pointer.

Parameters
[in]cpointer to cs_paramedmem_coupling_t struct
[in]fpointer to cs_field_t struct
[in]fnfield nature flag
[in]time_discrfield coupling time discretisation
Returns
index of field within the storing vector

◆ cs_paramedmem_field_export()

void cs_paramedmem_field_export ( cs_paramedmem_coupling_t *  c,
const char *  name,
const double  values[] 
)

Assign values based on parent mesh location to associated ParaFIELD objects.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure
[in]namename of field
[in]valuesarray of values to write (defined on parent mesh location)

◆ cs_paramedmem_field_export_l()

void cs_paramedmem_field_export_l ( cs_paramedmem_coupling_t *  c,
const char *  name,
const double  values[] 
)

Assign values based on mesh location corresponding to coupled elements (and associated ParaMESH) to associated ParaFIELD objects.

If the whole mesh is coupled, the behavior is the sames as that of cs_paramedmem_field_export.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure
[in]namename of field
[in]valuesarray of values to write (defined on selected mesh subset)

◆ cs_paramedmem_field_import()

void cs_paramedmem_field_import ( cs_paramedmem_coupling_t *  c,
const char *  name,
double  values[] 
)

Copy values from associated ParaFIELD object to array defined parent mesh location.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure
[in]namename of field
[in]valuesarray in which values will be stored

◆ cs_paramedmem_field_import_l()

void cs_paramedmem_field_import_l ( cs_paramedmem_coupling_t *  c,
const char *  name,
double  values[] 
)

Copy values from associated ParaFIELD structure to array defined on mesh location corresponding to coupled elements (and associated ParaMESH).

If the whole mesh is coupled, the behavior is the sames as that of cs_paramedmem_field_import.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure
[in]namename of field
[in]valuesarray in which values will be stored

◆ cs_paramedmem_get_number_of_couplings()

int cs_paramedmem_get_number_of_couplings ( void  )

Get number of defined couplings.

Returns
number of defined couplings (int)

◆ cs_paramedmem_mesh_get_elt_list()

const cs_lnum_t* cs_paramedmem_mesh_get_elt_list ( const cs_paramedmem_coupling_t *  coupling)

Get indirection list for elements in coupled mesh.

Parameters
[in]couplingpointer to cs_paramedmem_coupling_t struct
Returns
cs_lnum_t pointer to indirection list

◆ cs_paramedmem_mesh_get_n_elts()

cs_lnum_t cs_paramedmem_mesh_get_n_elts ( const cs_paramedmem_coupling_t *  coupling)

Get number of elements of coupled mesh.

Parameters
[in]couplingpointer to cs_paramedmem_coupling_t struct
Returns
number of elements in mesh associated to coupling

◆ cs_paramedmem_mesh_get_n_vertices()

cs_lnum_t cs_paramedmem_mesh_get_n_vertices ( const cs_paramedmem_coupling_t *  coupling)

Get number of vertices of coupled mesh.

Parameters
[in]couplingpointer to cs_paramedmem_coupling_t struct
Returns
number of elements in mesh associated to coupling

◆ cs_paramedmem_mesh_get_vertex_list()

const cs_lnum_t* cs_paramedmem_mesh_get_vertex_list ( const cs_paramedmem_coupling_t *  coupling)

Get indirection list for vertices in coupled mesh.

Parameters
[in]couplingpointer to cs_paramedmem_coupling_t struct
Returns
pointer to indirection list; NULL if locally contiguous or empty

◆ cs_paramedmem_recv_data()

void cs_paramedmem_recv_data ( cs_paramedmem_coupling_t *  c)

Recieve values of field attached to DEC.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure

◆ cs_paramedmem_recv_field_vals()

void cs_paramedmem_recv_field_vals ( cs_paramedmem_coupling_t *  c,
const char *  name,
double *  vals 
)

Recieve values of a field.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure
[in]namename of field
[in]valsarray of values to read

◆ cs_paramedmem_send_data()

void cs_paramedmem_send_data ( cs_paramedmem_coupling_t *  c)

Send values of field attached to DEC.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure

◆ cs_paramedmem_send_field_vals()

void cs_paramedmem_send_field_vals ( cs_paramedmem_coupling_t *  c,
const char *  name,
const double *  vals 
)

Send values of a field. If vals pointer is non-null, values are updated before send.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure
[in]namename of field
[in]valsarray of values to write

◆ cs_paramedmem_sync_dec()

void cs_paramedmem_sync_dec ( cs_paramedmem_coupling_t *  c)

Sync the coupling's InterpKernelDEC.

Parameters
[in]cpointer to cs_paramedmem_coupling_t structure

Variable Documentation

◆ _paramed_couplers

std::vector<cs_paramedmem_coupling_t *> _paramed_couplers
static