/*----------------------------------------------------------------------------*/
/*
  This file is generated by code_saturne, a general-purpose CFD tool.
*/
/*----------------------------------------------------------------------------*/

#include "cs_defs.h"

/*----------------------------------------------------------------------------
 * Standard C library headers
 *----------------------------------------------------------------------------*/

#include <assert.h>
#include <math.h>

#if defined(HAVE_MPI)
#include <mpi.h>
#endif

/*----------------------------------------------------------------------------
 *  Local headers
 *----------------------------------------------------------------------------*/

#include "cs_headers.h"

/*----------------------------------------------------------------------------*/

BEGIN_C_DECLS

/*----------------------------------------------------------------------------*/

void
cs_meg_volume_function(const char      *zone_name,
                       const cs_lnum_t  n_elts,
                       const cs_lnum_t *elt_ids,
                       const cs_real_t  xyz[][3],
                       cs_field_t       *f[])
{
  /* User defined formula for variable(s) density over zone all_cells
    ----------------------------------------------------------------- */

  if (strcmp(f[0]->name, "density") == 0 &&
      strcmp(zone_name, "all_cells") == 0) {
    const cs_real_t *temperature_vals = cs_field_by_name("temperature")->val;

    cs_real_t A = -1.;
    cs_real_t B = -1.;
    cs_real_t C = -1.;
    for (cs_lnum_t e_id = 0; e_id < n_elts; e_id++) {
      cs_lnum_t c_id = elt_ids[e_id];
      const cs_real_t temperature = temperature_vals[c_id];

      A = - 4.0668e-3;
      B = - 5.0754e-2;
      C = 1000.9;
      f[0]->val[c_id] = temperature * (A * temperature + B) + C;
    }
  }

  /* User defined formula for variable(s) molecular_viscosity over zone all_cells
    ----------------------------------------------------------------------------- */

  if (strcmp(f[0]->name, "molecular_viscosity") == 0 &&
      strcmp(zone_name, "all_cells") == 0) {
    const cs_real_t *temperature_vals = cs_field_by_name("temperature")->val;

    cs_real_t AM = -1.;
    cs_real_t BM = -1.;
    cs_real_t CM = -1.;
    cs_real_t DM = -1.;
    for (cs_lnum_t e_id = 0; e_id < n_elts; e_id++) {
      cs_lnum_t c_id = elt_ids[e_id];
      const cs_real_t temperature = temperature_vals[c_id];

      AM = - 3.4016e-9;
      BM = 6.2332e-7;
      CM = - 4.5577e-5;
      DM = 1.6935e-3;
      f[0]->val[c_id] = temperature * (temperature * (AM * temperature + BM) + CM) + DM;
    }
  }
}

/*----------------------------------------------------------------------------*/

END_C_DECLS

