Here is a minimalist example to solve a scalar-valued Laplacian problem (an isotropic diffusion equation). Since one considers the CDO framework to solve this problem, this enables a quick start with this framework. This simple example is performed in three steps:
For a very beginner, one strongly advises to read the page Case directory structure.
In a terminal, write the following syntax for the creation of a new study with a new case:
which creates a study directory STUDY
with case sub-directory CASE_NAME1
. If no case name is given, a default case directory called CASE1
is created.
One assumes that the mesh is a Cartesian mesh generated using the GUI but other ways are also possible. A more detail description of the different preprocessing possibilities is available here
The generated Cartesian is built with 6 mesh face groups collecting boundary faces and named X0
, X1
, Y0
, Y1
, Z0
and Z1
. These mesh face groups are used to define the two boundary zones needed for this example. One proceeds as detailed in the GUI screenshot.
The second step corresponds to the edition of the user source file named cs_user_parameters.c and especially the function cs_user_model
Click on the icon displayed just below in the GUI toolbar which corresponds to "Open the source file editor"
Then right-click on the file named REFERENCE/cs_user_parameters.c
and select Copy to SRC. Then, you can choose your favorite file editor to add in the function cs_user_model the following lines.
This first activates the CDO module (please refer to Activation of CDO/HHO schemes for more details) and then add a new scalar equation called Laplacian
with an unknown named potential
. This will be the name of the associated variable field. A default boundary condition is also defined and it corresponds to an homogeneous Neumann boundary condition. If no other boundary condition is defined, then all the boundary faces will be associated to this default definition.
The last step corresponds to the modification of the function cs_user_finalize_setup in the file cs_user_parameters.c
After having retrieved the structure cs_equation_param_t associated to the equation to solve, one first add a diffusion term which is associated to the default property named unity
. Then, one defines two Dirichlet boundary conditions: a first one on the left side (X0
) with a value equal to 0
and a second one on the right side (X1
) with a value equal to 1
.
For a very beginner, one strongly advises to read the page Running a calculation.
In a terminal, write the following syntax when your current directory corresponds to one of the sub-directories of a case.
In order to change the numerical settings related to an equation call the function cs_equation_param_set inside the user function named cs_user_parameters in the file cs_user_parameters.c
Here are some examples of numerical settings:
This relies on a key
value
principle. The available keys are listed here
For the reader willing to get a better understanding of the mathematical concepts underpinning the CDO schemes, one refers to the PhD thesis entitled Compatible Discrete Operator schemes on polyhedral meshes for elliptic and Stokes equations [3]