Compatible Discrete Operator (CDO) and Hybrid High-Order (HHO) schemes are available in code_saturne as alternative space discretizations to the legacy Finite Volumes (FV) schemes. These are new generation of space discretizations dedicated to polyhedral meshes. The capabilities of these schemes in terms of physical modelling are limited compared to the legacy FV schemes.
With CDO schemes, the resolution of the following models/equations are available:
Moreover, it is possible to setup advanced SLES (Sparse Linear Equation Solver) settings. More details are available here
A simple example relying on the resolution of the Laplace equation (steady isotropic diffusion equation with Dirichlet boundary conditions) in a cube with CDO schemes is available here. This is a good starting point for beginers.
To set-up a CDO computation, one has to update the cs_user_parameters.c file and edit successively the following functions
In addition, volume or boundary zones useful to set properties, equations, etc. are defined either thanks to the GUI or by editing the function cs_user_zones for more advanced definitions from the file cs_user_zones.c. This is similar to what is done with the legacy FV schemes.
More precisely, in each function above-mentioned the following settings can be done:
The very first step is to activate the CDO module in the function cs_user_model There are two ways to switch on CDO/HHO schemes:
CDO/HHO schemes can be activated within this function as follows:
Domain boundaries are useful for the (Navier-)Stokes equations or for the computation of the wall distance. Several types of domain boundaries can be defined. They are gathered in cs_boundary_type_t (a flag built from a set of predefined bits)
The definition of the domain boundaries for CDO/HHO schemes is performed in two steps: (1) set the default boundary and then add other boundaries which do not fit the default one. The two possible default domain boundaries are CS_BOUNDARY_WALL or CS_BOUNDARY_SYMMETRY Here is a first example.
Here is a second example.
Several predefined models are available (and thus equation or set of equations). When activating a predefined module, this implies:
Please refer to the dedicated documentation available here.
Please refer to the dedicated documentation available here.
Please refer to the dedicated documentation available here.
The activation of the thermal module yields the following actions:
For the thermal equation, the default boundary condition is a no flux (i.e. a homogeneous Neumann boundary condition). Here is the simplest example to activate the thermal module.
The first parameter is a flag to describe the thermal model to consider. This flag can be built from the following tags (cs_thermal_model_type_bit_t)
To specify the choice of the variable used in the thermal model (by default, the temperature in Kelvin). This can be modified by adding the tag
and to change the main variable use the one of the following tag
The two previous options are not fully implemented.
The second parameter is a flag related to the numerical aspects. There is no tag available up to now.
The third parameter is a flag related to the activation of automatic post-processings.
It is possible to activate the computation of the distance to the wall using CDO schemes (CDO vertex-based schemes are used) as follows:
User-defined properties are added thanks to a call to the function cs_property_add in cs_user_model Here are several examples:
The function cs_property_add returns a pointer to a cs_property_t structure which can be used to set advanced parameters. If the pointer to a cs_property_t structure is not available, this can be easily recover thanks to a call to the function cs_property_by_name
To enable the computation of the Fourier number related to a given property in an unsteady simulation proceed as follows:
The definition of an advection field allows one to handle flows with a frozen velocity field or the transport of scalar quantities without solving the Navier-Stokes system. The add of a new user-defined advection field with CDO/HHO schemes is specified as follows:
When an advection field is defined, it is possible to retrieve it and then set a post-processing operation. For instance, to activate the post-processing of the CFL number proceed as follows:
User-defined equation with CDO/HHO schemes are added thanks to a call to the function cs_equation_add_user in cs_user_model Here are several examples:
There is an other way to add a user-defined equation relying on the function cs_equation_add_user_tracer which combines (1) the add of a user-defined equation and (2) its association with properties for the unsteady and/or the diffusion term along with the association with an advection field.
The mechanism is the same as for user-defined equations. The name of the equation is defined in the macro CS_THERMAL_EQNAME
The mechanism is detailed for the thermal system but the same mechanism can be used for user-defined equations. In our example, the name of the equation is defined in the macro CS_THERMAL_EQNAME
where the function _initial_temperature has a predefined prototype (cf. the definition of the function pointer cs_analytic_func_t)
Here is another example extracted from the file cs_user_parameters-cdo-gwf.c (in src/user_examples) but this is readily applicable to any equation.
where the function get_tracer_ic has a predefined prototype (cf. the definition of the function pointer cs_analytic_func_t)
When a property has been added, the second step is to define this property. According to the type of property (isotropic, orthotropic or anisotropic) definitions differ. Here are two examples:
The mechanism is the same as for user-defined properties. The named are predefined and associated to the following macros:
When an advection field has been added, the second step is to define this advection field. Here are is an example of definition using an anlytic function and the activation of optional features:
A first simple example.
The second example shows an advanced usage relying on an analytic function and an input structure. Moreover, a more accurate quadrature rule is specified.
The user-defined function to compute the source term is specified as follows
and the function for the memory management of a cs_xdef_t structure is
Add terms to an equation like a diffusion term, an advection term, unsteady term, reaction terms.
In some cases, one can also add less common terms such as a
The management of the level and frequency of details written by the solver can be specified for CDO/HHO schemes as follows:
The management of the time step with CDO/HHO schemes can be specified as follows:
This can be completed with numerical options to specify the time scheme. See the next section)
To modify the numerical settings, the mechanism relies on a (key, value) rationale. The function to use is cs_equation_param_set For instance, with an equation called "MyEquation", and a key called CS_EQKEY_PARAM_TO_SET with the value "value_to_set".
If one wants to modify the settings for all equations, this is possible using the function cs_equation_set_default_param
All available keys are listed and described with cs_equation_key_t One gives some examples for some of them.
The key is CS_EQKEY_SPACE_SCHEME with the possible value gathered in the following table
key_value | description |
---|---|
"cdo_vb" or "cdovb" | Switch to a CDO vertex-based discretization (degrees of freedom are located at the mesh vertices). One value per vertex in the case of scalar-valued equation and three values per vertex in the case of a vector-valued equation. |
"cdo_vcb" or "cdovcb" | Switch to a CDO vertex+cell-based discretization (degrees of freedom are located at the mesh vertices and at the mesh cells). One value per vertex and per cell in the case of scalar-valued equation and three values per vertex and pêr cell in the case of a vector-valued equation. Thanks to a static condensation operation, the algebraic system is reduced to only vertex unknows. |
"cdo_fb" or "cdofb" | Switch to a CDO face-based discretization (degrees of freedom are located at interior and boundary faces and at mesh cell). One value per face and mesh cell in the case of scalar-valued equation and three values per face and mesh cell in the case of a vector-valued equation. Thanks to a static condensation operation, the algebraic system is reduced to only face unknows. |
"cdo_cb" or "cdocb" | Switch to a CDO cell-based discretization (degrees of freedom are located at mesh cells for the potential and at faces for the flux). Only scalar-valued equation are possible. One value per cell for the potential. One value per face for the flux unknown (the normal component of the flux). |
"cdo_eb" or "cdoeb" | Switch to CDO edge-based discretization (degrees of freedom are located at mesh edges, one scalar per edge corresponding to the circulation). Only vector-valued equation are handled with this discretization. |
"hho_p0" | Switch to a HHO(k=0) discretization relying on ![]() |
"hho_p1" | Switch to a HHO(k=1) discretization relying on ![]() |
"hho_p2" | Switch to a HHO(k=2) discretization relying on ![]() |
An example of usage:
More details can be found in [4] for CDO-Vb, CDO-Fb, CDO-Cb and CDO-Eb. CDO-Fb are also detailed in [15]. CDO-VCb are detailed in [7]
The available advection schemes are listed in the description of the key CS_EQKEY_ADV_SCHEME
key value | description | type | available with |
---|---|---|---|
"upwind" | first order upwind scheme (convergence rate is equal to 0.5 on pure advection problem with a solution having a low regularity). This is the most robust choice. This yields a high-level of numerical diffusion. Thus, when the Péclet number (ratio between convection and diffusion) is low, a centered scheme or a scheme with less upwinding is a better choice in terms of accuracy | CS_PARAM_ADVECTION_SCHEME_UPWIND | CDO vb, CDO fb |
"centered" | second-order scheme on sufficiently regular solution. Dispersivity issue can occur with this scheme. This is not a good choice when the problem is dominated by the convection term. | CS_PARAM_ADVECTION_SCHEME_CENTERED | CDO vb, CDO fb |
"mix_centered_upwind", "hybrid_centered_upwind" | This is a hybrid advection scheme mixing an upwind and a centered advection scheme. The portion of upwinding (between 0. and 1.) is set thanks to the key CS_EQKEY_ADV_UPWIND_PORTION By default, the value 0.15 is used (0.25 when the GWF module is activated). | CS_PARAM_ADVECTION_SCHEME_HYBRID_CENTERED_UPWIND | CDO vb |
"cip" | "Continuous Interior Penalty" scheme detailed in [7] This scheme is only available with a non conservative or gradient formulation of the advective term. A switch to this formulation is automatically done. This a second-order scheme on regular solutions with a built-in stabilization relying on the jump of the gradient. The scaling in front of the stabilization term is computed automatically but it can be modified by the user thanks to the key CS_EQKEY_ADV_CIP_COEF | CS_PARAM_ADVECTION_SCHEME_CIP | CDO vcb |
"cip_cw" | Same as the "cip" but the advective field is assumed to be constant in each cell. This enables further optimizations when building the advection matrix. | CS_PARAM_ADVECTION_SCHEME_CIP_CW | CDO vcb |
"samarskii" | This scheme shares some similarities with a "hybrid_centered_upwind" scheme since a portion of upwinding is added to a centered scheme. This portion smoothly varies between mesh cells according to the evaluation of a local Péclet number. A function (the samarskii one) relates the Péclet number to the level of upwinding. | CS_PARAM_ADVECTION_SCHEME_SAMARSKII | CDO vb |
"sg" | SG means "Scharfetter Gummel". This is as a Samarskii scheme. The difference holds in the function computing the portion of upwinding from a local Péclet number. | CS_PARAM_ADVECTION_SCHEME_SG | CDO vb |
Here is a second set of examples
There is no advection scheme available with HHO schemes or CDO cb and CDO eb schemes up to now.
When the equation to solve is unsteady, one has to specify a time discretization scheme. Available time schemes are listed in the description of the key CS_EQKEY_TIME_SCHEME By default, a first order implicit Euler scheme is used. To modify this default settings, please proceed as follows:
The mass matrix associated to the unsteady term is also a parameter. One can use either a mass matrix like in FV scheme using a "voronoi" algorithm (default) or the "wbs" algorithm like in Finite Element (FE) schemes.
Several algorithms are available to build the diffusion term. They are all listed in the description of the key CS_EQKEY_HODGE_DIFF_ALGO Please refer to [4] for more details In the case of the cost (or ocs), one can specify the value of the scaling coefficient in front of the stabilization part. This is done using the key CS_EQKEY_HODGE_DIFF_COEF
Many options are available in code_saturne to specify the way to solve a linear system. This is detailed here for the CDO/HHO part.
The detailed description of CDO schemes, the mathmatical analysis and numerical results on benchmarks are available in the following PhD thesis:
Additional publications :