programmer's documentation
Functions | Variables
cs_domain.c File Reference
#include "cs_defs.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <locale.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <bft_mem.h>
#include "cs_domain_post.h"
#include "cs_evaluate.h"
#include "cs_equation_common.h"
#include "cs_gwf.h"
#include "cs_hodge.h"
#include "cs_log.h"
#include "cs_log_iteration.h"
#include "cs_mesh_location.h"
#include "cs_parall.h"
#include "cs_prototypes.h"
#include "cs_restart.h"
#include "cs_restart_default.h"
#include "cs_source_term.h"
#include "cs_walldistance.h"
#include "cs_domain.h"
Include dependency graph for cs_domain.c:

Functions

static cs_domain_boundary_t * _create_domain_boundaries (void)
 Allocate a new cs_domain_boundary_t structure. More...
 
static void _build_domain_boundaries (cs_lnum_t n_b_faces, cs_domain_boundary_t *dby)
 Allocate and initialize a cs_domain_boundary_t structure. More...
 
static cs_domain_boundary_t * _free_domain_boundaries (cs_domain_boundary_t *dby)
 Destroy a cs_domain_boundary_t structure. More...
 
static void _compute_steady_user_equations (cs_domain_t *domain)
 Compute equations which user-defined and steady-state. More...
 
static void _compute_unsteady_user_equations (cs_domain_t *domain, int nt_cur)
 Compute user-defined equation which are time-dependent. More...
 
cs_domain_tcs_domain_create (void)
 Create and initialize by default a cs_domain_t structure. More...
 
cs_domain_tcs_domain_free (cs_domain_t *domain)
 Free a cs_domain_t structure. More...
 
void cs_domain_set_default_boundary (cs_domain_t *domain, cs_param_boundary_type_t type)
 Add a boundary type defined on a mesh location. More...
 
void cs_domain_add_boundary (cs_domain_t *domain, cs_param_boundary_type_t type, const char *ml_name)
 Add a boundary type defined on a mesh location. More...
 
void cs_domain_set_time_param (cs_domain_t *domain, int nt_max, double t_max)
 Set parameters for unsteady computations: the max number of time steps or the final physical time of the simulation. More...
 
void cs_domain_set_output_param (cs_domain_t *domain, int nt_list, int verbosity)
 Set auxiliary parameters related to the way output is done. More...
 
void cs_domain_update_advfield (cs_domain_t *domain)
 Set to true the automatic update of all advection fields. More...
 
void cs_domain_set_advanced_param (cs_domain_t *domain, cs_domain_key_t key, const char *keyval)
 Set auxiliary parameters related to a cs_domain_t structure. More...
 
void cs_domain_def_time_step_by_function (cs_domain_t *domain, cs_timestep_func_t *func)
 Define the value of the time step thanks to a predefined function. More...
 
void cs_domain_def_time_step_by_value (cs_domain_t *domain, double dt)
 Define the value of the time step. More...
 
cs_property_tcs_domain_add_property (cs_domain_t *domain, const char *pty_name, const char *type_name, int n_subdomains)
 Add a new property to the current computational domain. More...
 
cs_adv_field_tcs_domain_add_advection_field (cs_domain_t *domain, const char *adv_name)
 Add a new advection field to the current computational domain. More...
 
cs_equation_t * cs_domain_activate_wall_distance (cs_domain_t *domain)
 Activate the computation of the wall distance Define a new equation called "WallDistance" and its related field named "WallDistance". More...
 
cs_gwf_t * cs_domain_activate_gwf (cs_domain_t *domain, const char *kw_type, const char *kw_time, int n_soils, int n_tracers)
 Activate the computation of the Richards' equation This activation yields severals consequences: More...
 
void cs_domain_add_gwf_tracer_eq (cs_domain_t *domain, const char *eq_name, const char *var_name)
 Add a new equation related to the groundwater flow module This equation is a particular type of unsteady advection-diffusion reaction eq. Tracer is advected thanks to the darcian velocity and diffusion/reaction parameters result from a physical modelling. More...
 
void cs_domain_set_gwf_tracer_eq (cs_domain_t *domain, const char *eq_name, const char *ml_name, double wmd, double alpha_l, double alpha_t, double distrib_coef, double reaction_rate)
 Set the parameters related to a tracer equation used in the groundwater flow module. More...
 
void cs_domain_update_mesh_locations (cs_domain_t *domain)
 Add new mesh locations related to domain boundaries from existing mesh locations. More...
 
void cs_domain_setup_predefined_equations (cs_domain_t *domain)
 Setup predefined equations which are activated. More...
 
void cs_domain_add_user_equation (cs_domain_t *domain, const char *eqname, const char *varname, const char *key_type, const char *key_bc)
 Add a new user equation to a domain. More...
 
cs_property_tcs_domain_get_property (const cs_domain_t *domain, const char *ref_name)
 Find the related property definition from its name. More...
 
cs_adv_field_tcs_domain_get_advection_field (const cs_domain_t *domain, const char *ref_name)
 Find the related advection field definition from its name. More...
 
cs_equation_t * cs_domain_get_equation (const cs_domain_t *domain, const char *eqname)
 Find the cs_equation_t structure whith name eqname Return NULL if not find. More...
 
cs_gwf_t * cs_domain_get_gwf_struct (const cs_domain_t *domain)
 Retrieve the pointer to a cs_gwf_t structure related to this domain. More...
 
void cs_domain_create_fields (cs_domain_t *domain)
 Create cs_field_t structures attached to equation unknowns and advection fields. More...
 
void cs_domain_set_scheme_flag (cs_domain_t *domain)
 Define the scheme flag for the current computational domain. More...
 
void cs_domain_initialize (cs_domain_t *domain, cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
 Build a cs_domain_t structure. More...
 
bool cs_domain_needs_iterate (cs_domain_t *domain)
 Check if one needs to continue iterations in time. More...
 
bool cs_domain_needs_log (const cs_domain_t *domain)
 Check if an ouput is requested according to the domain setting. More...
 
void cs_domain_define_current_time_step (cs_domain_t *domain)
 Set the current time step for this new time iteration. More...
 
void cs_domain_increment_time (cs_domain_t *domain)
 Update time step after one temporal iteration. More...
 
void cs_domain_solve (cs_domain_t *domain)
 Solve all the equations of a computational domain for one time step. More...
 
void cs_domain_process_after_solve (cs_domain_t *domain)
 Process the computational domain after the resolution. More...
 
void cs_domain_write_restart (const cs_domain_t *domain)
 Write a restart file for the CDO module. More...
 
void cs_domain_summary (const cs_domain_t *domain)
 Summary of a cs_domain_t structure. More...
 

Variables

cs_domain_tcs_glob_domain = NULL
 
static const char _err_empty_domain []
 
static const char _domain_boundary_ml_name [CS_PARAM_N_BOUNDARY_TYPES][CS_BASE_STRING_LEN]
 
static double cs_domain_kahan_time_compensation = 0.0
 

Function Documentation

◆ _build_domain_boundaries()

static void _build_domain_boundaries ( cs_lnum_t  n_b_faces,
cs_domain_boundary_t *  dby 
)
static

Allocate and initialize a cs_domain_boundary_t structure.

Parameters
[in]n_b_facesnumber of boundary faces
Returns
a pointer to a new allocated cs_domain_boundary_t structure

◆ _compute_steady_user_equations()

static void _compute_steady_user_equations ( cs_domain_t domain)
static

Compute equations which user-defined and steady-state.

Parameters
[in,out]domainpointer to a cs_domain_t structure

◆ _compute_unsteady_user_equations()

static void _compute_unsteady_user_equations ( cs_domain_t domain,
int  nt_cur 
)
static

Compute user-defined equation which are time-dependent.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]nt_curcurrent number of iteration done

◆ _create_domain_boundaries()

static cs_domain_boundary_t* _create_domain_boundaries ( void  )
static

Allocate a new cs_domain_boundary_t structure.

Returns
a pointer to a new allocated cs_domain_boundary_t structure

◆ _free_domain_boundaries()

static cs_domain_boundary_t* _free_domain_boundaries ( cs_domain_boundary_t *  dby)
static

Destroy a cs_domain_boundary_t structure.

Parameters
[in,out]dbypointer to the cs_domain_t structure to free
Returns
a NULL pointer

◆ cs_domain_activate_gwf()

cs_gwf_t* cs_domain_activate_gwf ( cs_domain_t domain,
const char *  kw_type,
const char *  kw_time,
int  n_soils,
int  n_tracers 
)

Activate the computation of the Richards' equation This activation yields severals consequences:

  • Add a new equation named "Richards" along with an associated field named "hydraulic_head". Default boundary condition is set to "zero_flux".
  • Define a new advection field named "darcian_flux"
  • Define a new property called "permeability".
  • Define a new property called "soil_capacity" if "unsteady" is chosen
Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]kw_type"isotropic", "orthotropic or "anisotropic" \param[in] kw_time Richards equation is "steady" or "unsteady"
[in]n_soilsnumber of soils to consider
[in]n_tracersnumber of tracer equations
Returns
a pointer to a cs_grounwater_t structure

◆ cs_domain_activate_wall_distance()

cs_equation_t* cs_domain_activate_wall_distance ( cs_domain_t domain)

Activate the computation of the wall distance Define a new equation called "WallDistance" and its related field named "WallDistance".

Parameters
[in,out]domainpointer to a cs_domain_t structure
Returns
a pointer to a cs_equation_t structure

◆ cs_domain_add_advection_field()

cs_adv_field_t* cs_domain_add_advection_field ( cs_domain_t domain,
const char *  adv_name 
)

Add a new advection field to the current computational domain.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]adv_namename of the advection field to add
Returns
a pointer to the new cs_adv_field_t structure

◆ cs_domain_add_boundary()

void cs_domain_add_boundary ( cs_domain_t domain,
cs_param_boundary_type_t  type,
const char *  ml_name 
)

Add a boundary type defined on a mesh location.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]typetype of boundary to set
[in]ml_namemesh location name

◆ cs_domain_add_gwf_tracer_eq()

void cs_domain_add_gwf_tracer_eq ( cs_domain_t domain,
const char *  eq_name,
const char *  var_name 
)

Add a new equation related to the groundwater flow module This equation is a particular type of unsteady advection-diffusion reaction eq. Tracer is advected thanks to the darcian velocity and diffusion/reaction parameters result from a physical modelling.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]eqnamename of the equation
[in]varnamename of the related variable

◆ cs_domain_add_property()

cs_property_t* cs_domain_add_property ( cs_domain_t domain,
const char *  pty_name,
const char *  type_name,
int  n_subdomains 
)

Add a new property to the current computational domain.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]pty_namename of the property to add
[in]type_namekey name related to the type of property
[in]n_subdomainsspecify a definition in n_subdomains
Returns
a pointer to the new cs_property_t structure

◆ cs_domain_add_user_equation()

void cs_domain_add_user_equation ( cs_domain_t domain,
const char *  eqname,
const char *  varname,
const char *  key_type,
const char *  key_bc 
)

Add a new user equation to a domain.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]eqnamename of the equation
[in]varnamename of the related variable
[in]key_typetype of equation: "scalar", "vector", "tensor"
[in]key_bctype of boundary condition set by default "zero_value" or "zero_flux"

◆ cs_domain_create()

cs_domain_t* cs_domain_create ( void  )

Create and initialize by default a cs_domain_t structure.

Returns
a pointer to a cs_domain_t structure

◆ cs_domain_create_fields()

void cs_domain_create_fields ( cs_domain_t domain)

Create cs_field_t structures attached to equation unknowns and advection fields.

Create a cs_field_t structure for each equation defined in the domain.

Parameters
[in,out]domainpointer to a cs_domain_t structure

◆ cs_domain_def_time_step_by_function()

void cs_domain_def_time_step_by_function ( cs_domain_t domain,
cs_timestep_func_t func 
)

Define the value of the time step thanks to a predefined function.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]funcpointer to a cs_timestep_func_t function

◆ cs_domain_def_time_step_by_value()

void cs_domain_def_time_step_by_value ( cs_domain_t domain,
double  dt 
)

Define the value of the time step.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]dtvalue of the constant time step

◆ cs_domain_define_current_time_step()

void cs_domain_define_current_time_step ( cs_domain_t domain)

Set the current time step for this new time iteration.

Parameters
[in,out]domainpointer to a cs_domain_t structure

◆ cs_domain_free()

cs_domain_t* cs_domain_free ( cs_domain_t domain)

Free a cs_domain_t structure.

Parameters
[in,out]domainpointer to the cs_domain_t structure to free
Returns
a NULL pointer

◆ cs_domain_get_advection_field()

cs_adv_field_t* cs_domain_get_advection_field ( const cs_domain_t domain,
const char *  ref_name 
)

Find the related advection field definition from its name.

Parameters
[in]domainpointer to a domain structure
[in]ref_namename of the adv_field to find
Returns
NULL if not found otherwise the associated pointer

◆ cs_domain_get_equation()

cs_equation_t* cs_domain_get_equation ( const cs_domain_t domain,
const char *  eqname 
)

Find the cs_equation_t structure whith name eqname Return NULL if not find.

Parameters
[in]domainpointer to a cs_domain_t structure
[in]eqnamename of the equation to find
Returns
a pointer to a cs_equation_t structure or NULL if not found

◆ cs_domain_get_gwf_struct()

cs_gwf_t* cs_domain_get_gwf_struct ( const cs_domain_t domain)

Retrieve the pointer to a cs_gwf_t structure related to this domain.

Parameters
[in]domainpointer to a cs_domain_t structure
Returns
a pointer to a cs_gwf_t structure

◆ cs_domain_get_property()

cs_property_t* cs_domain_get_property ( const cs_domain_t domain,
const char *  ref_name 
)

Find the related property definition from its name.

Parameters
[in]domainpointer to a domain structure
[in]ref_namename of the property to find
Returns
NULL if not found otherwise the associated pointer

◆ cs_domain_increment_time()

void cs_domain_increment_time ( cs_domain_t domain)

Update time step after one temporal iteration.

Parameters
[in,out]domainpointer to a cs_domain_t structure

◆ cs_domain_initialize()

void cs_domain_initialize ( cs_domain_t domain,
cs_mesh_t mesh,
const cs_mesh_quantities_t mesh_quantities 
)

Build a cs_domain_t structure.

Parameters
[in,out]domainpointer to a cs_domain_t struct.
[in,out]meshpointer to a cs_mesh_t struct.
[in]mesh_quantitiespointer to a cs_mesh_quantities_t struct.

◆ cs_domain_needs_iterate()

bool cs_domain_needs_iterate ( cs_domain_t domain)

Check if one needs to continue iterations in time.

Parameters
[in,out]domainpointer to a cs_domain_t structure
Returns
true or false

◆ cs_domain_needs_log()

bool cs_domain_needs_log ( const cs_domain_t domain)

Check if an ouput is requested according to the domain setting.

Parameters
[in]domainpointer to a cs_domain_t structure
Returns
true or false

◆ cs_domain_process_after_solve()

void cs_domain_process_after_solve ( cs_domain_t domain)

Process the computational domain after the resolution.

Parameters
[in]domainpointer to a cs_domain_t structure

◆ cs_domain_set_advanced_param()

void cs_domain_set_advanced_param ( cs_domain_t domain,
cs_domain_key_t  key,
const char *  keyval 
)

Set auxiliary parameters related to a cs_domain_t structure.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]keykey related to the parameter to set
[in]keyvalvalue related to the parameter to set

◆ cs_domain_set_default_boundary()

void cs_domain_set_default_boundary ( cs_domain_t domain,
cs_param_boundary_type_t  type 
)

Add a boundary type defined on a mesh location.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]typetype of boundary to set
[in]ml_namemesh location name

◆ cs_domain_set_gwf_tracer_eq()

void cs_domain_set_gwf_tracer_eq ( cs_domain_t domain,
const char *  eq_name,
const char *  ml_name,
double  wmd,
double  alpha_l,
double  alpha_t,
double  distrib_coef,
double  reaction_rate 
)

Set the parameters related to a tracer equation used in the groundwater flow module.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]eqnamename of the equation
[in]ml_namename of the related mesh location
[in]wmdvalue of the water molecular diffusivity
[in]alpha_lvalue of the longitudinal dispersivity
[in]alpha_tvalue of the transversal dispersivity
[in]distrib_coefvalue of the distribution coefficient
[in]reaction_ratevalue of the first order rate of reaction

◆ cs_domain_set_output_param()

void cs_domain_set_output_param ( cs_domain_t domain,
int  nt_list,
int  verbosity 
)

Set auxiliary parameters related to the way output is done.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]nt_listoutput frequency into the listing
[in]verbositylevel of information displayed

◆ cs_domain_set_scheme_flag()

void cs_domain_set_scheme_flag ( cs_domain_t domain)

Define the scheme flag for the current computational domain.

Parameters
[in,out]domainpointer to a cs_domain_t struct.

◆ cs_domain_set_time_param()

void cs_domain_set_time_param ( cs_domain_t domain,
int  nt_max,
double  t_max 
)

Set parameters for unsteady computations: the max number of time steps or the final physical time of the simulation.

Parameters
[in,out]domainpointer to a cs_domain_t structure
[in]nt_maxmax. number of time step iterations
[in]t_maxfinal physical time of the simulation

◆ cs_domain_setup_predefined_equations()

void cs_domain_setup_predefined_equations ( cs_domain_t domain)

Setup predefined equations which are activated.

Parameters
[in,out]domainpointer to a cs_domain_t structure

◆ cs_domain_solve()

void cs_domain_solve ( cs_domain_t domain)

Solve all the equations of a computational domain for one time step.

Parameters
[in,out]domainpointer to a cs_domain_t structure

◆ cs_domain_summary()

void cs_domain_summary ( const cs_domain_t domain)

Summary of a cs_domain_t structure.

Parameters
[in]domainpointer to the cs_domain_t structure to summarize

◆ cs_domain_update_advfield()

void cs_domain_update_advfield ( cs_domain_t domain)

Set to true the automatic update of all advection fields.

Parameters
[in,out]domainpointer to a cs_domain_t structure

◆ cs_domain_update_mesh_locations()

void cs_domain_update_mesh_locations ( cs_domain_t domain)

Add new mesh locations related to domain boundaries from existing mesh locations.

Parameters
[in]domainpointer to a cs_domain_t structure

◆ cs_domain_write_restart()

void cs_domain_write_restart ( const cs_domain_t domain)

Write a restart file for the CDO module.

Parameters
[in]domainpointer to a cs_domain_t structure

Variable Documentation

◆ _domain_boundary_ml_name

const char _domain_boundary_ml_name[CS_PARAM_N_BOUNDARY_TYPES][CS_BASE_STRING_LEN]
static
Initial value:
=
{ N_("domain_walls"),
N_("domain_inlets"),
N_("domain_outlets"),
N_("domain_symmetries") }
#define N_(String)
Definition: cs_defs.h:56

◆ _err_empty_domain

const char _err_empty_domain[]
static
Initial value:
=
" Stop setting an empty cs_domain_t structure.\n"
" Please check your settings.\n"

◆ cs_domain_kahan_time_compensation

double cs_domain_kahan_time_compensation = 0.0
static

◆ cs_glob_domain

cs_domain_t* cs_glob_domain = NULL