8.0
general documentation
Boundary conditions definition by remapping with medcoupling

Local definitions

/* Variables needed for boundary condition sub-selection */
/* 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";
#define BFT_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: bft_mem.h:62

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 */
}
int cs_medcoupling_remapper_initialize(const char *name, int elt_dim, const char *select_criteria, const char *medfile_path, int n_fields, const char **field_names, int iteration, int order)
initialize a remapper based on a set of given arguments
Definition: cs_medcoupling_remapper.cxx:679
cs_medcoupling_remapper_t * cs_medcoupling_remapper_by_id(int r_id)
get a remapper by its id
Definition: cs_medcoupling_remapper.cxx:613
cs_medcoupling_remapper_t * cs_medcoupling_remapper_by_name_try(const char *name)
get a remapper by its name
Definition: cs_medcoupling_remapper.cxx:640
void cs_medcoupling_remapper_setup(cs_medcoupling_remapper_t *r)
update the interpolation matrix of the remapper
Definition: cs_medcoupling_remapper.cxx:816
struct _cs_medcoupling_remapper_t cs_medcoupling_remapper_t
Definition: cs_medcoupling_remapper.h:44

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 */
}
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
void cs_medcoupling_remapper_rotate(cs_medcoupling_remapper_t *r, cs_real_t invariant[3], cs_real_t axis[3], cs_real_t angle)
Rotate the mesh using a center point, axis and angle.
Definition: cs_medcoupling_remapper.cxx:913
void cs_medcoupling_remapper_translate(cs_medcoupling_remapper_t *r, cs_real_t translation[3])
translate the mesh using a given vector
Definition: cs_medcoupling_remapper.cxx:887

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" */
cs_real_t * cs_medcoupling_remapper_copy_values(cs_medcoupling_remapper_t *r, int field_id, double default_val)
Interpolate values for a given field.
Definition: cs_medcoupling_remapper.cxx:856

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

const cs_zone_t *z = cs_boundary_zone_by_name("inlet");
cs_field_t *scalar = cs_field_by_name_try("scalar1");
int *icodcl = scalar->bc_coeffs->icodcl;
cs_real_t *rcodcl1 = scalar->bc_coeffs->rcodcl1;
for (cs_lnum_t ielt = 0; ielt < z->n_elts; ielt++) {
cs_lnum_t f_id = z->elt_ids[ielt];
icodcl[f_id] = 1;
rcodcl1[f_id] = bc_scalar[ielt];
}
const cs_zone_t * cs_boundary_zone_by_name(const char *name)
Return a pointer to a boundary zone based on its name if present.
Definition: cs_boundary_zone.c:711
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
cs_field_t * cs_field_by_name_try(const char *name)
Return a pointer to a field based on its name if present.
Definition: cs_field.c:2366
cs_real_t * rcodcl1
Definition: cs_field.h:109
int * icodcl
Definition: cs_field.h:108
Field descriptor.
Definition: cs_field.h:130
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:158
Definition: cs_zone.h:55
const cs_lnum_t * elt_ids
Definition: cs_zone.h:65
cs_lnum_t n_elts
Definition: cs_zone.h:64