src/base/cs_coupling.c File Reference

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
cs_coupling.c File Reference
`#include "cs_defs.h"`
`#include <assert.h>`
`#include <ple_coupling.h>`
`#include "bft_mem.h"`
`#include "bft_printf.h"`
`#include "fvm_nodal_extract.h"`
`#include "fvm_point_location.h"`
`#include "cs_coupling.h"`
Include dependency graph for cs_coupling.c:

## Functions
void | cplsyn (cs_int_t *ntmabs, const cs_int_t *ntcabs, cs_real_t *dtref)
void | cplact (cs_int_t *isync)
void | cs_coupling_discover_mpi_apps (const char *app_name)
| Discover other applications in the same MPI root communicator. More...
void | cs_coupling_finalize (void)
| Finalize MPI coupling helper structures. More...
const ple_coupling_mpi_set_t * | cs_coupling_get_mpi_apps (void)
| Return info on other applications in the same MPI root communicator. More...
int | cs_coupling_get_sync_flag (void)
| Return the optional synchronization flag for external couplings. More...
void | cs_coupling_set_sync_flag (int flag)
| Define an optional synchronization flag for external couplings. More...
double | cs_coupling_get_ts_multiplier (void)
| Return the time step multiplier for external couplings. More...
void | cs_coupling_set_ts_multiplier (double m)
| Define a time step multiplier for external couplings. More...
void | cs_coupling_sync_apps (int flags, int current_ts_id, int *max_ts_id, double *ts)
| Synchronize with applications in the same PLE coupling group. More...
bool | cs_coupling_is_sync_active (void)
| Indicate is synchronization with applications in the same PLE group is active. More...
ple_lnum_t | cs_coupling_mesh_extents (const void *mesh, ple_lnum_t n_max_extents, double tolerance, double extents[])
| Compute extents of a mesh representation. More...
void | cs_coupling_point_in_mesh (const void *mesh, double tolerance, ple_lnum_t n_points, const ple_coord_t point_coords[], ple_lnum_t location[], float distance[])
| Find elements in a given mesh containing points: updates the location[] and distance[] arrays associated with a set of points for points that are in an element of this mesh, or closer to one than to previously encountered elements. More...
void | cs_coupling_point_in_mesh_p (const void *mesh, double tolerance, ple_lnum_t n_points, const ple_coord_t point_coords[], ple_lnum_t location[], float distance[])
| Find elements in a given mesh containing points: updates the location[] and distance[] arrays associated with a set of points for points that are in an element of this mesh, or closer to one than to previously encountered elements. More...
void | cs_coupling_point_closest_mesh (const void *mesh, ple_lnum_t n_points, const ple_coord_t point_coords[], ple_lnum_t location[], float distance[])
| Find elements in a given mesh closest to points: updates the location[] and distance[] arrays associated with a set of points for points that are closer to an element of this mesh than to previously encountered elements. More...
void | cs_coupling_point_closest_mesh_p (const void *mesh, ple_lnum_t n_points, const ple_coord_t point_coords[], ple_lnum_t location[], float distance[])
| Find elements in a given mesh closest to points: updates the location[] and distance[] arrays associated with a set of points for points that are closer to an element of this mesh than to previously encountered elements. More...

## Function Documentation

void cplact | ( | cs_int_t * | isync | ) |

void cplsyn | ( | cs_int_t * | ntmabs,
|  | const cs_int_t * | ntcabs,
|  | cs_real_t * | dtref
| ) |  |

void cs_coupling_discover_mpi_apps | ( | const char * | app_name | ) |

Discover other applications in the same MPI root communicator.

Parameters

  [in] | app_name | name of this instance of Code_Saturne

void cs_coupling_finalize | ( | void |  | ) |

Finalize MPI coupling helper structures.

const ple_coupling_mpi_set_t* cs_coupling_get_mpi_apps | ( | void |  | ) |

Return info on other applications in the same MPI root communicator.

Returns
  info on other applications structure

int cs_coupling_get_sync_flag | ( | void |  | ) |

Return the optional synchronization flag for external couplings.

See cs_coupling_set_sync_flag for details.

Returns
  synchronization flag to apply to couplings

double cs_coupling_get_ts_multiplier | ( | void |  | ) |

Return the time step multiplier for external couplings.

See cs_coupling_get_ts_multiplier for details.

Returns
  time step multiplier for external couplings

bool cs_coupling_is_sync_active | ( | void |  | ) |

Indicate is synchronization with applications in the same PLE group is active.

Returns
  true if synchronization is required, false otherwise

ple_lnum_t cs_coupling_mesh_extents | ( | const void * | mesh,
|  | ple_lnum_t | n_max_extents,
|  | double | tolerance,
|  | double | extents[]
| ) |  |

Compute extents of a mesh representation.

Parameters

  [in] | mesh | pointer to mesh representation structure
  [in] | n_max_extents | maximum number of sub-extents (such as element extents) to compute, or -1 to query
  [in] | tolerance | addition to local extents of each element: extent = base_extent * (1 + tolerance)
  [in,out] | extents | extents associated with mesh: x_min, y_min, ..., x_max, y_max, ... (size: 2*dim)

Returns
  the number of extents computed

void cs_coupling_point_closest_mesh | ( | const void * | mesh,
|  | ple_lnum_t | n_points,
|  | const ple_coord_t | point_coords[],
|  | ple_lnum_t | location[],
|  | float | distance[]
| ) |  |

Find elements in a given mesh closest to points: updates the location[] and distance[] arrays associated with a set of points for points that are closer to an element of this mesh than to previously encountered elements.

This function currently only handles elements of lower dimension than the spatial dimension.

Location is relative to the id of a given element + 1 in concatenated sections of same element dimension.

Parameters

  [in] | mesh | pointer to mesh representation structure
  [in] | n_points | number of points to locate
  [in] | point_coords | point coordinates
  [in,out] | location | number of element containing or closest to each point (size: n_points)
  [in,out] | distance | distance from point to element indicated by location[]: < 0 if unlocated, or absolute distance to a surface element (size: n_points)

void cs_coupling_point_closest_mesh_p | ( | const void * | mesh,
|  | ple_lnum_t | n_points,
|  | const ple_coord_t | point_coords[],
|  | ple_lnum_t | location[],
|  | float | distance[]
| ) |  |

Find elements in a given mesh closest to points: updates the location[] and distance[] arrays associated with a set of points for points that are closer to an element of this mesh than to previously encountered elements.

This function currently only handles elements of lower dimension than the spatial dimension.

Location is relative to parent element numbers.

Parameters

  [in] | mesh | pointer to mesh representation structure
  [in] | n_points | number of points to locate
  [in] | point_coords | point coordinates
  [in,out] | location | number of element containing or closest to each point (size: n_points)
  [in,out] | distance | distance from point to element indicated by location[]: < 0 if unlocated, or absolute distance to a surface element (size: n_points)

void cs_coupling_point_in_mesh | ( | const void * | mesh,
|  | double | tolerance,
|  | ple_lnum_t | n_points,
|  | const ple_coord_t | point_coords[],
|  | ple_lnum_t | location[],
|  | float | distance[]
| ) |  |

Find elements in a given mesh containing points: updates the location[] and distance[] arrays associated with a set of points for points that are in an element of this mesh, or closer to one than to previously encountered elements.

Location is relative to the id of a given element + 1 in concatenated sections of same element dimension.

Parameters

  [in] | mesh | pointer to mesh representation structure
  [in] | tolerance | associated tolerance
  [in] | n_points | number of points to locate
  [in] | point_coords | point coordinates
  [in,out] | location | number of element containing or closest to each point (size: n_points)
  [in,out] | distance | distance from point to element indicated by location[]: < 0 if unlocated, 0 - 1 if inside, and > 1 if outside a volume element, or absolute distance to a surface element (size: n_points)

void cs_coupling_point_in_mesh_p | ( | const void * | mesh,
|  | double | tolerance,
|  | ple_lnum_t | n_points,
|  | const ple_coord_t | point_coords[],
|  | ple_lnum_t | location[],
|  | float | distance[]
| ) |  |

Find elements in a given mesh containing points: updates the location[] and distance[] arrays associated with a set of points for points that are in an element of this mesh, or closer to one than to previously encountered elements.

Location is relative to parent element numbers.

Parameters

  [in] | mesh | pointer to mesh representation structure
  [in] | tolerance | associated tolerance
  [in] | n_points | number of points to locate
  [in] | point_coords | point coordinates
  [in,out] | location | number of element containing or closest to each point (size: n_points)
  [in,out] | distance | distance from point to element indicated by location[]: < 0 if unlocated, 0 - 1 if inside, and > 1 if outside a volume element, or absolute distance to a surface element (size: n_points)

void cs_coupling_set_sync_flag | ( | int | flag | ) |

Define an optional synchronization flag for external couplings.

This flag is used by all couplings based on the PLE (Parallel Location and Exchange) group synchronization mechanism, which include couplings with SYRTHES 4, Code_Saturne, and NEPTUNE_CFD.

It is defined by a mask, so for example flags f1, f2, and f3 may be combined using the "f1 | f2 | f2" syntax.

Note also that for Code_Saturne, in the case of a variable time step, the reference time step is synchronized at the beginning of each iteration, but the actual time step is recomputed later.

Possible flags are: PLE_COUPLING_TS_MIN Use smallest time step PLE_COUPLING_TS_LEADER Prescribe time step for the group (only one member may set this flag) PLE_COUPLING_UNSTEADY Inform others that this instance is using an unsteady solution approach PLE_COUPLING_STEADY Inform others that this instance is using a teady solution approach PLE_COUPLING_USER_1 User definable flag PLE_COUPLING_USER_2 User definable flag PLE_COUPLING_USER_3 User definable flag PLE_COUPLING_USER_4 User definable flag

To force stopping, PLE_COUPLING_STOP may be set. In this case, the calculation will stop at the first synchronization, even if this function is called again with another flag.

Parameters

  [in] | flag | synchronization flag to apply to couplings

void cs_coupling_set_ts_multiplier | ( | double | m | ) |

Define a time step multiplier for external couplings.

The apparent time step for the current instance times (as viewed by coupled codes) is equal to the true time step times this multiplier.

If the synchronization flag contains "time step min" (PLE_COUPLING_TS_MIN), the apparent time step is used to determine which code has the smallest time step.

Parameters

  [in] | m | time step multipier to aply to couplings

void cs_coupling_sync_apps | ( | int | flags,
|  | int | current_ts_id,
|  | int * | max_ts_id,
|  | double * | ts
| ) |  |

Synchronize with applications in the same PLE coupling group.

This function should be called before starting a new time step. The current time step id is that of the last finished time step, or 0 at initialization.

Default synchronization flags indicating a new iteration or end of calculation are set automatically, but the user may set additional flags to this function if necessary.

Parameters

  [in] | flags | optional additional synchronization flags
  [in] | current_ts_id | current time step id
  [in,out] | max_ts_id | maximum time step id
  [in,out] | ts | suggested time step value