cs_meg_source_terms.c 1.82 KB
Newer Older
Alice MAISON's avatar
Alice MAISON committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
/*----------------------------------------------------------------------------*/
/*
  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

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

cs_real_t *
cs_meg_source_terms(const cs_zone_t *zone,
                    const char      *name,
                    const char      *source_type)
{
  cs_real_t *new_vals = NULL;

  /*----------------------------------------------------*/
  /* User defined source term for traceur over zone rue */
  if (strcmp(zone->name, "rue") == 0 &&
      strcmp(name, "traceur") == 0 && 
      strcmp(source_type, "scalar_source_term") == 0 ) {

    const int vals_size = zone->n_elts * 2;
    BFT_MALLOC(new_vals, vals_size, cs_real_t);

    const cs_real_t volume = zone->measure;

    for (cs_lnum_t e_id = 0; e_id < zone->n_elts; e_id++) {
      cs_lnum_t c_id = zone->elt_ids[e_id];

      new_vals[2 * e_id + 0] =  1 / volume ;
      new_vals[2 * e_id + 1] =  0 ;
    }
  }
  /*----------------------------------------------------*/

  return new_vals;
}

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

END_C_DECLS