Rewrite user defined boundary condition from Fortran to C

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Tsubasa
Posts: 175
Joined: Fri Nov 20, 2020 4:09 am

Rewrite user defined boundary condition from Fortran to C

Post by Tsubasa »

Hello everyone,

So far I've used "cs_user_boundary_condition.f90" to set up the pressure intlet boundary condition;

Code: Select all

call getfbr('inlet', nlelt, lstelt)
do ilelt = 1, nlelt
   ifac = lstelt(ilelt)
   itypfb(ifac) = ientre

!Dirichlet B.C for pressure:
   icodcl(ifac,ipr) = 1
   rcodcl(ifac,ipr,1) = 101325.633

!Neumann B.C for velocity:
   icodcl(ifac,iu)= 3
   icodcl(ifac,iv)= 3
   icodcl(ifac,iw)= 3
enddo


call getfbr('outlet', nlelt, lstelt)
do ilelt = 1, nlelt
   ifac = lstelt(ilelt)
   itypfb(ifac) = isolib

!Dirichlet B.C for pressure:
   icodcl(ifac,ipr) = 1
   rcodcl(ifac,ipr,1) = 101325.000

!Neumann B.C for velocity:
   icodcl(ifac,iu)= 3
   icodcl(ifac,iv)= 3
   icodcl(ifac,iw)= 3
enddo
For other subroutines, I am using "C" files such as "cs_user_initialization.c" and "cs_user_parameters.c".
Therefore, I want to rewrite "cs_user_boundary_condition.f90" to "cs_user_boundary_condition.c" to be consiste with C, not Fortran.

It looks like that coding C in "cs_user_boundary_condition.c" is more complicated than that of Fortran ("cs_user_boundary_condition.f90").

Although I checked "cs_user_boundary_condition-notebook.c", I am confused by new words, which I have never seen in CodeSaturn so far.
Is there other samples of conding or guides?

Best regards,
Tsubasa
Yvan Fournier
Posts: 4077
Joined: Mon Feb 20, 2012 3:25 pm

Re: Rewrite user defined boundary condition from Fortran to C

Post by Yvan Fournier »

Hello,

Most of our examples for boundary conditions are still in Fortran, because we are working on a new API (shared with the CDO models) which you can see in the following example https://github.com/code-saturne/code_sa ... nditions.c but is not yet complete.

The existing cs_user_boundary_conditions.c examples should remain usable for a while, and may be a good intermediate step, but you may also opt to wait for the new API (which should be in v7.1, and may be backported to future v7.0.z releases).

The notebook aspect is something completely orthogonal to boundary conditions (and so may be composed). It allows defining a value in the GUI (and even on the run command line starting with v7.0.1), and using that value elsewhere in the code. It is specifically oriented to parametric studies, or controlling some values interactively (through the control_file mechanism, also used by the FMI API). It is accessible only from C if I remember correctly.

Best regards,

Yvan
Post Reply