8.0
general documentation
cs_probe.c File Reference

Probes and profiles management. More...

#include "cs_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "bft_printf.h"
#include "fvm_nodal.h"
#include "fvm_point_location.h"
#include "cs_base.h"
#include "cs_map.h"
#include "cs_math.h"
#include "cs_mesh.h"
#include "cs_mesh_connect.h"
#include "cs_mesh_location.h"
#include "cs_mesh_quantities.h"
#include "cs_mesh_intersect.h"
#include "cs_order.h"
#include "cs_parall.h"
#include "cs_selector.h"
#include "cs_timer.h"
#include "cs_probe.h"
+ Include dependency graph for cs_probe.c:

Functions

int cs_probe_get_n_sets (void)
 Retrieve the number of probe sets defined. More...
 
cs_probe_set_tcs_probe_set_get (const char *name)
 Retrieve a cs_probe_set_t structure. More...
 
cs_probe_set_tcs_probe_set_get_by_id (int pset_id)
 Retrieve a cs_probe_set_t structure from its id. More...
 
const char * cs_probe_set_get_name (cs_probe_set_t *pset)
 Retrieve the name related to a cs_probe_set_t structure. More...
 
void cs_probe_set_get_post_info (const cs_probe_set_t *pset, bool *time_varying, bool *on_boundary, bool *on_curve, bool *auto_variables, bool *auto_curve_coo, bool *auto_cart_coo, int *n_writers, int *writer_ids[])
 Retrieve information useful for the postprocessing step. More...
 
const char * cs_probe_set_get_location_criteria (cs_probe_set_t *pset)
 Return the location filter selection criteria string for a given probe set. More...
 
int cs_probe_set_get_interpolation (cs_probe_set_t *pset)
 Return the interpolation option for a given probe set. More...
 
cs_probe_set_tcs_probe_set_create (const char *name)
 Create a new set of probes. More...
 
void cs_probe_set_add_probe (cs_probe_set_t *pset, cs_real_t x, cs_real_t y, cs_real_t z, const char *label)
 Add a new probe to an existing set of probes. More...
 
cs_probe_set_tcs_probe_set_create_from_array (const char *name, int n_probes, const cs_real_3_t *coords, const char **labels)
 Define a new set of probes from an array of coordinates. More...
 
cs_probe_set_tcs_probe_set_create_from_segment (const char *name, int n_probes, const cs_real_t start_coords[3], const cs_real_t end_coords[3])
 Define a new set of probes from the segment spanned by two points. More...
 
cs_probe_set_tcs_probe_set_create_from_local (const char *name, cs_probe_set_define_local_t *p_define_func, void *p_define_input)
 Define a new set of probes from rank-local definition function. More...
 
void cs_probe_set_allow_overwrite (const char *name)
 allow overwriting the definition of a given probe set. More...
 
void cs_probe_set_assign_curvilinear_abscissa (cs_probe_set_t *pset, const cs_real_t *s)
 Assign curvilinear abscissa for the given probe set. More...
 
void cs_probe_set_associate_writers (cs_probe_set_t *pset, int n_writers, const int *writer_ids)
 Associate a list of writers to a probe set. More...
 
void cs_probe_set_associate_field (cs_probe_set_t *pset, int writer_id, int field_id, int comp_id)
 Associate a field to a probe set. More...
 
void cs_probe_set_auto_var (cs_probe_set_t *pset, bool mode)
 Set to true or false the automatic post-processing of variables. More...
 
void cs_probe_set_auto_curvilinear_coords (cs_probe_set_t *pset, bool mode)
 Set automatic output of curvilinear coordinates. More...
 
void cs_probe_set_auto_cartesian_coords (cs_probe_set_t *pset, bool mode)
 Set automatic output of cartesian coordinates. More...
 
void cs_probe_set_snap_mode (cs_probe_set_t *pset, cs_probe_snap_t snap_mode)
 Set snap mode related to the management of a set of probes. More...
 
void cs_probe_set_option (cs_probe_set_t *pset, const char *keyname, const char *keyval)
 Set optional parameters related to the management of a set of probes. More...
 
void cs_probe_set_locate (cs_probe_set_t *pset, const fvm_nodal_t *location_mesh)
 Try to locate each probe and define the coordinate really used for the postprocessing step. More...
 
fvm_nodal_t * cs_probe_set_export_mesh (cs_probe_set_t *pset, const char *mesh_name)
 Define a fvm_nodal_t structure from the set of probes. More...
 
fvm_nodal_t * cs_probe_set_unlocated_export_mesh (cs_probe_set_t *pset, const char *mesh_name)
 Define a fvm_nodal_t structure from the set of unlocated probes. More...
 
void cs_probe_set_dump (const cs_probe_set_t *pset)
 Dump a cs_probe_set_t structure. More...
 
void cs_probe_set_get_members (const cs_probe_set_t *pset, cs_probe_snap_t *snap_mode, int *n_probes, cs_real_3_t *coords[])
 Retrieve the main members of a cs_probe_set_t structure. More...
 
int cs_probe_set_get_n_local (const cs_probe_set_t *pset)
 Return the number probes in the local domain. More...
 
const cs_real_tcs_probe_set_get_curvilinear_abscissa (const cs_probe_set_t *pset)
 Return the list of curvilinear abscissa for the given probe set. More...
 
cs_real_tcs_probe_set_get_loc_curvilinear_abscissa (const cs_probe_set_t *pset)
 Return the list of curvilinear abscissa of probes located on the local ranks for the given probe set. More...
 
const cs_lnum_tcs_probe_set_get_elt_ids (const cs_probe_set_t *pset, int mesh_location_id)
 Return the ids of a probe set's local matching elements, relative to a given mesh location. More...
 

Detailed Description

Probes and profiles management.

Function Documentation

◆ cs_probe_get_n_sets()

int cs_probe_get_n_sets ( void  )

Retrieve the number of probe sets defined.

Returns
the number of probe sets defined

◆ cs_probe_set_add_probe()

void cs_probe_set_add_probe ( cs_probe_set_t pset,
cs_real_t  x,
cs_real_t  y,
cs_real_t  z,
const char *  label 
)

Add a new probe to an existing set of probes.

Parameters
[in,out]psetset of probes
[in]xx coordinate of the point to add
[in]yy coordinate of the point to add
[in]zz coordinate of the point to add
[in]labelNULL or the name of the point (optional)

◆ cs_probe_set_allow_overwrite()

void cs_probe_set_allow_overwrite ( const char *  name)

allow overwriting the definition of a given probe set.

If no a probe set of the given name exists, the operation is ignored.

Parameters
[in]namename of the probe set

◆ cs_probe_set_assign_curvilinear_abscissa()

void cs_probe_set_assign_curvilinear_abscissa ( cs_probe_set_t pset,
const cs_real_t s 
)

Assign curvilinear abscissa for the given probe set.

This is effective only when using probe sets to which curvilinear coordinates have not already been assigned.

So this may be used following cs_probe_set_create (and probe additions) or cs_probe_set_create_from_array, but will be ignored for probe sets defined using cs_probe_set_create_from_segment and cs_probe_set_create_from_local.

If provided, the array of curvilinear absicssa must match the size of the probe set. If set to NULL, it is assumed a uniform spacing is provided between points.

Parameters
[in]psetpointer to a cs_probe_set_t structure
[in]sarray of curvilinear abscissa, or NULL

◆ cs_probe_set_associate_field()

void cs_probe_set_associate_field ( cs_probe_set_t pset,
int  writer_id,
int  field_id,
int  comp_id 
)

Associate a field to a probe set.

This function must be called during the postprocessing output definition stage, before any output actually occurs.

If the field should already be output automatically based on the mesh category and field output keywords, it will be filtered at a later stage.

Parameters
[in]psetpointer to a cs_probe_set_t structure
[in]writer_idid of specified associated writer, or 0 (CS_POST_WRITER_ALL_ASSOCIATED) for all
[in]field_idid of field to attach
[in]comp_idid of field component (-1 for all)

◆ cs_probe_set_associate_writers()

void cs_probe_set_associate_writers ( cs_probe_set_t pset,
int  n_writers,
const int *  writer_ids 
)

Associate a list of writers to a probe set.

Parameters
[in,out]psetpointer to a cs_probe_set_t structure to set
[in]n_writersnumber of writers assocuated to this probe set
[in]writer_idslist of writer ids

◆ cs_probe_set_auto_cartesian_coords()

void cs_probe_set_auto_cartesian_coords ( cs_probe_set_t pset,
bool  mode 
)

Set automatic output of cartesian coordinates.

Parameters
[in,out]psetpointer to a cs_probe_set_t structure
[in]modetrue or false

◆ cs_probe_set_auto_curvilinear_coords()

void cs_probe_set_auto_curvilinear_coords ( cs_probe_set_t pset,
bool  mode 
)

Set automatic output of curvilinear coordinates.

Parameters
[in,out]psetpointer to a cs_probe_set_t structure
[in]modetrue or false

◆ cs_probe_set_auto_var()

void cs_probe_set_auto_var ( cs_probe_set_t pset,
bool  mode 
)

Set to true or false the automatic post-processing of variables.

Set automatic output of variables behavior.

Parameters
[in,out]psetpointer to a cs_probe_set_t structure
[in]modetrue or false

◆ cs_probe_set_create()

cs_probe_set_t* cs_probe_set_create ( const char *  name)

Create a new set of probes.

Parameters
[in]namename of the set of probes
Returns
a pointer to a new allocated cs_probe_set_t structure

◆ cs_probe_set_create_from_array()

cs_probe_set_t* cs_probe_set_create_from_array ( const char *  name,
int  n_probes,
const cs_real_3_t coords,
const char **  labels 
)

Define a new set of probes from an array of coordinates.

Parameters
[in]namename of the set of probes
[in]n_probesnumber of probes in coords and labels
[in]coordslist of coordinates related to each probe
[in]labelslist of label related to each probe (optional)
Returns
a pointer to a new allocated cs_probe_set_t structure

◆ cs_probe_set_create_from_local()

cs_probe_set_t* cs_probe_set_create_from_local ( const char *  name,
cs_probe_set_define_local_t p_define_func,
void *  p_define_input 
)

Define a new set of probes from rank-local definition function.

The local definition function given by the p_define_func pointer is called just before locating probes on the parent mesh, so this allows building probe sets based on subsets of the computational mesh.

Note: if the p_define_input pointer is non-NULL, it must point to valid data when the selection function is called, so that value or structure should not be temporary (i.e. local);

Parameters
[in]namename of the set of probes
[in]p_define_funcfunction used for local definition
[in]p_define_inputoptional input for local definition function
Returns
a pointer to a new allocated cs_probe_set_t structure

◆ cs_probe_set_create_from_segment()

cs_probe_set_t* cs_probe_set_create_from_segment ( const char *  name,
int  n_probes,
const cs_real_t  start_coords[3],
const cs_real_t  end_coords[3] 
)

Define a new set of probes from the segment spanned by two points.

If n_probes > 0, the given number of probes will be used for sampling, and will be evenly distributed along the segment.

If n_probes <= 0, one probe will be defined for each cell intersected by the line segment, and its position based on the projection of those cell centers on the given segment.

In both cases, using cs_probe_set_snap_mode can further modify this behavior.

Parameters
[in]namename of the set of probes
[in]n_probesnumber of probes, or <= 0 for mesh intersection
[in]start_coordscoordinates of the starting point
[in]end_coordscoordinates of the ending point
Returns
a pointer to a new allocated cs_probe_set_t structure

◆ cs_probe_set_dump()

void cs_probe_set_dump ( const cs_probe_set_t pset)

Dump a cs_probe_set_t structure.

Parameters
[in]psetpointer to a cs_probe_set_t structure

◆ cs_probe_set_export_mesh()

fvm_nodal_t* cs_probe_set_export_mesh ( cs_probe_set_t pset,
const char *  mesh_name 
)

Define a fvm_nodal_t structure from the set of probes.

Parameters
[in,out]psetpointer to a cs_probe_set_t structure
[in]mesh_namename of the mesh to export
Returns
a pointer to a fvm_nodal_t structure

◆ cs_probe_set_get()

cs_probe_set_t* cs_probe_set_get ( const char *  name)

Retrieve a cs_probe_set_t structure.

Parameters
[in]namename of the set of probes to find
Returns
a pointer to a cs_probes_t structure or NULL if not found

◆ cs_probe_set_get_by_id()

cs_probe_set_t* cs_probe_set_get_by_id ( int  pset_id)

Retrieve a cs_probe_set_t structure from its id.

Parameters
[in]pset_idid related to the set of probes to find
Returns
a pointer to a cs_probes_t structure or NULL if not found

◆ cs_probe_set_get_curvilinear_abscissa()

const cs_real_t* cs_probe_set_get_curvilinear_abscissa ( const cs_probe_set_t pset)

Return the list of curvilinear abscissa for the given probe set.

Parameters
[in]psetpointer to a cs_probe_set_t structure
Returns
NULL or the pointer to the array of abscissa

◆ cs_probe_set_get_elt_ids()

const cs_lnum_t* cs_probe_set_get_elt_ids ( const cs_probe_set_t pset,
int  mesh_location_id 
)

Return the ids of a probe set's local matching elements, relative to a given mesh location.

The mesh_location id must match one of CS_MESH_LOCATION_CELLS, CS_MESH_LOCATION_BOUNDARY_FACES, or CS_MESH_LOCATION_VERTICES.

Parameters
[in]psetpointer to a cs_probe_set_t structure
[in]mesh_location_idid of parent mesh location

◆ cs_probe_set_get_interpolation()

int cs_probe_set_get_interpolation ( cs_probe_set_t pset)

Return the interpolation option for a given probe set.

Interpolation will be applied only where possible.

Parameters
[in]psetpointer to a cs_probe_set_t structure
Returns
interpolation option value

◆ cs_probe_set_get_loc_curvilinear_abscissa()

cs_real_t* cs_probe_set_get_loc_curvilinear_abscissa ( const cs_probe_set_t pset)

Return the list of curvilinear abscissa of probes located on the local ranks for the given probe set.

The caller is responsible for freeing the returned array.

Parameters
[in]psetpointer to a cs_probe_set_t structure
Returns
NULL or the pointer to the array of abscissa

◆ cs_probe_set_get_location_criteria()

const char* cs_probe_set_get_location_criteria ( cs_probe_set_t pset)

Return the location filter selection criteria string for a given probe set.

Parameters
[in]psetpointer to a cs_probe_set_t structure
Returns
selection criteria string, or NULL if no filter defined

◆ cs_probe_set_get_members()

void cs_probe_set_get_members ( const cs_probe_set_t pset,
cs_probe_snap_t snap_mode,
int *  n_probes,
cs_real_3_t coords[] 
)

Retrieve the main members of a cs_probe_set_t structure.

Parameters
[in]psetpointer to a cs_probe_set_t structure
[in,out]snap_modemode of location
[in,out]n_probesnumber of probes
[in,out]coordsprobe coordinates

◆ cs_probe_set_get_n_local()

int cs_probe_set_get_n_local ( const cs_probe_set_t pset)

Return the number probes in the local domain.

Parameters
[in]psetpointer to a cs_probe_set_t structure
Returns
number of probes in local domain

◆ cs_probe_set_get_name()

const char* cs_probe_set_get_name ( cs_probe_set_t pset)

Retrieve the name related to a cs_probe_set_t structure.

Parameters
[in]psetpointer to a cs_probe_set_t structure
Returns
the name of the cs_probes_t structure or NULL if not found

◆ cs_probe_set_get_post_info()

void cs_probe_set_get_post_info ( const cs_probe_set_t pset,
bool *  time_varying,
bool *  on_boundary,
bool *  on_curve,
bool *  auto_variables,
bool *  auto_curve_coo,
bool *  auto_cart_coo,
int *  n_writers,
int *  writer_ids[] 
)

Retrieve information useful for the postprocessing step.

Output arguments may be set to NULL if we do not need to query them.

Parameters
[in]psetpointer to a cs_probe_set_t structure
[out]time_varyingtrue if probe locations may change with time
[out]on_boundarytrue if probes are located on boundary
[out]on_curvetrue if the probe set has cuvilinear coordinates
[out]auto_variablestrue if set of variables to output is predefined
[out]auto_curve_cootrue if curvilinear coordinates should be output
[out]auto_cart_cootrue if cartesian coordinates should be output
[out]n_writersnumber of associated user-defined writers, or -1 if default unchanged
[out]writer_idspointer to a list of writer ids

◆ cs_probe_set_locate()

void cs_probe_set_locate ( cs_probe_set_t pset,
const fvm_nodal_t *  location_mesh 
)

Try to locate each probe and define the coordinate really used for the postprocessing step.

For better performance when using multiple probe sets, a pointer to an existing location mesh may be passed to this function. The caller is responsible for ensuring this mesh matches selection criteria for the probe set.

Parameters
[in,out]psetpointer to a cs_probe_set_t structure
[in]location_meshoptional pointer to mesh relative to which probe set should be located, or NULL

◆ cs_probe_set_option()

void cs_probe_set_option ( cs_probe_set_t pset,
const char *  keyname,
const char *  keyval 
)

Set optional parameters related to the management of a set of probes.

Available option key names accepting true or false:

  • transient_location if true, relocate probes relative to deforming or moving mesh (default: false)
  • boundary if \ c true, locate on boundary mesh; if false, locate on volume mesh (default)

Other options:

  • selection_criteria where keyval is selection criteria string
  • tolerance where keyval is for instance "0.05" (default "0.10")
  • interpolation if \ c 0, P0 interpolation (default); if 1, simple gradient-based interpolation for volume probes (ignored for boundaries). Other interpolation options might be added in the future.
Parameters
[in,out]psetpointer to a cs_probe_set_t structure to set
[in]keynamename of the keyword related to the parameter to set
[in]keyvalvalue of the keyword to set

◆ cs_probe_set_snap_mode()

void cs_probe_set_snap_mode ( cs_probe_set_t pset,
cs_probe_snap_t  snap_mode 
)

Set snap mode related to the management of a set of probes.

Parameters
[in,out]psetpointer to a cs_probe_set_t structure
[in]snap_modesnap mode to set

◆ cs_probe_set_unlocated_export_mesh()

fvm_nodal_t* cs_probe_set_unlocated_export_mesh ( cs_probe_set_t pset,
const char *  mesh_name 
)

Define a fvm_nodal_t structure from the set of unlocated probes.

Parameters
[in,out]psetpointer to a cs_probe_set_t structure
[in]mesh_namename of the mesh to export
Returns
a pointer to a fvm_nodal_t structure