7.1
general documentation
Boundary conditions definition by remapping with medcoupling

Local definitions

/* Variables needed for boundary condition sub-selection */
const cs_lnum_t n_b_faces = cs_glob_mesh->n_b_faces;
/* MEDCoupling Remapper structure:
* ------------------------------- */
/* Number of fields to interpolate from the MED file */
const int nremapper_fields = 1;
/* Names of the fields to read */
const char **field_names = NULL;
BFT_MALLOC(field_names, nremapper_fields, const char *);
field_names[0] = "TEMPERATURE";

Initialization of some variables

/* Indexes needed to read the time step from the
* file (-1, -1 if only one exists) */
int it0 = -1;
int it1 = -1;

Create a medcoupling remapper

/* We request a remapper with a given name. If it does not exist,
* the function returns a NULL pointer. */
/* If the returned pointer is NULL (first call), we create the
* corresponding remapper */
if (r == NULL) {
/* Space dimension of the elements (2 for faces, 3 for cells) */
int elts_dim = 2;
/* Path to file */
const char file_name[] = "/home/myname/study/2Dmap_Tfluid.med";
/* The remapper is created. We retrieve its id from the function.
* The function inputs are:
* 1) Name of the remapper
* 2) dimension of the mesh elements
* 3) selection criteria for the boundary condition zone
* 4) path to the med file
* 5) number of fields to interpolate
* 6) names of the fields to interpolate
* 7 + 8) time iteration index and order */
int r_id = cs_medcoupling_remapper_initialize("scalar_bc",
elts_dim,
"inlet",
file_name,
nremapper_fields,
field_names,
it0,
it1);
/* Retrieve the pointer */
/* We create the interpolation matrix => Here it is only called once
* since the mesh is not moving */
}

Translate or rotate med data if needed

if (false) {
/* Translation using a tranlsation vector. Here it is (1, 0, 0) */
cs_real_t translation_vector[3] = {1.0, 0.0, 0.0};
cs_medcoupling_remapper_translate(r, translation_vector);
/* Rotation using an invariant point, the rotation axis and rotation angle
Here, center is O=(0,0,0) and z-axis (0,0,1). Angle is in radians, here
it is ~pi/4 */
cs_real_t rot_center[3] = {0.0, 0.0, 0.0};
cs_real_t rot_axis[3] = {0.0, 0.0, 1.0};
cs_real_t rot_angle = 0.7853981;
cs_medcoupling_remapper_rotate(r, rot_center, rot_axis, rot_angle);
/* Update of the interpolation matrix */
}

We retrieve an array containing the interpolated values.

/* We retrieve an array containing the interpolated values.
* Inputs are:
* 1) remapper
* 2) id of the field to interpolate
* 3) a default value (if no intersection is obtained) */
/* We impose a dirichlet condition on all the faces of the boundary condition
* related to the zone "inlet" */

We prescribe for the inlet a Dirichlet condition on the scalar "scalar1":

const int keyvar = cs_field_key_id("variable_id");
cs_field_t *scalar = cs_field_by_name_try("scalar1");
int iscal = cs_field_get_key_int(scalar, keyvar) - 1;
cs_lnum_t nelts = 0;
cs_lnum_t *lstelt = NULL;
BFT_MALLOC(lstelt, n_b_faces, cs_lnum_t);
cs_selector_get_b_face_list("inlet", &nelts, lstelt);
for (cs_lnum_t ielt = 0; ielt < nelts; ielt++) {
cs_lnum_t f_id = lstelt[ielt];
icodcl[iscal*n_b_faces + f_id] = 1;
rcodcl[iscal*n_b_faces + f_id] = bc_scalar[ielt];
}
BFT_FREE(lstelt);