1!-------------------------------------------------------------------------------
2
3! This file is part of Code_Saturne, a general-purpose CFD tool.
4!
5! Copyright (C) 1998-2021 EDF S.A.
6!
7! This program is free software; you can redistribute it and/or modify it under
8! the terms of the GNU General Public License as published by the Free Software
9! Foundation; either version 2 of the License, or (at your option) any later
10! version.
11!
12! This program is distributed in the hope that it will be useful, but WITHOUT
13! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14! FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15! details.
16!
17! You should have received a copy of the GNU General Public License along with
18! this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
19! Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21!-------------------------------------------------------------------------------
22
23!> \file cdomod.f90
24!> \brief Store the mode of activation of CDO-HHO schemes
25!>
26!------------------------------------------------------------------------------
27
28module cdomod
29
30  !===========================================================================
31
32  use, intrinsic :: iso_c_binding
33
34  !=============================================================================
35
36  implicit none
37
38  !=============================================================================
39
40  !> Activated (=1 or =2) or not (=0)
41  !> If icdo=1 (CDO and FV)
42  !> If icdo=2 (CDO only)
43  integer, save :: icdo
44
45  interface
46
47    ! Interface to C function to solve the unsteady state for related CDO
48    ! equations
49
50    subroutine cs_f_cdo_solve_unsteady_state_domain()  &
51      bind(C, name='cs_f_cdo_solve_unsteady_state_domain')
52      use, intrinsic :: iso_c_binding
53      implicit none
54    end subroutine cs_f_cdo_solve_unsteady_state_domain
55
56    ! Interface to C function to solve the steady state for related CDO
57    ! equations
58
59    subroutine cs_f_cdo_solve_steady_state_domain()  &
60      bind(C, name='cs_f_cdo_solve_steady_state_domain')
61      use, intrinsic :: iso_c_binding
62      implicit none
63    end subroutine cs_f_cdo_solve_steady_state_domain
64
65    ! Interface to C function related to the initialization CDO systems
66
67    subroutine cs_f_initialize_cdo_systems()  &
68      bind(C, name='cs_f_initialize_cdo_systems')
69      use, intrinsic :: iso_c_binding
70      implicit none
71    end subroutine cs_f_initialize_cdo_systems
72
73    ! Interface to C function to postprocess data related to CDO schemes
74
75    subroutine cs_f_cdo_post_domain()  &
76      bind(C, name='cs_f_cdo_post_domain')
77      use, intrinsic :: iso_c_binding
78      implicit none
79    end subroutine cs_f_cdo_post_domain
80
81    ! Interface to C function to force the resolution of steady equation
82
83    subroutine cs_equation_solve_steady_state_wrapper(eqname) &
84      bind(C, name='cs_equation_solve_steady_state_wrapper')
85      use, intrinsic :: iso_c_binding
86      implicit none
87      character(kind=c_char, len=1), dimension(*), intent(in) :: eqname
88    end subroutine cs_equation_solve_steady_state_wrapper
89
90    ! Interface to C function to force the resolution of an unsteady equation
91
92    subroutine solve_cdo_equation(cur2prev, eqname) &
93      bind(C, name='cs_equation_solve_wrapper')
94      use, intrinsic :: iso_c_binding
95      implicit none
96      logical(c_bool), value :: cur2prev
97      character(kind=c_char, len=1), dimension(*), intent(in) :: eqname
98    end subroutine solve_cdo_equation
99
100 end interface
101
102  !=============================================================================
103
104contains
105
106  !=============================================================================
107
108  subroutine solve_steady_state_cdo_equation(eqname)
109    use, intrinsic :: iso_c_binding
110    implicit none
111
112    ! Arguments
113
114    character(len=*), intent(in) :: eqname
115
116    ! Local variables
117
118    character(len=len_trim(eqname)+1, kind=c_char) :: c_eqname
119
120    c_eqname = trim(eqname)//c_null_char
121
122    call cs_equation_solve_steady_state_wrapper(c_eqname)
123
124    return
125
126  end subroutine solve_steady_state_cdo_equation
127
128end module cdomod
129
130!=============================================================================
131
132subroutine cs_f_set_cdo_mode(icdoval)  &
133  bind(C, name='cs_f_set_cdo_mode')
134
135  !===========================================================================
136  ! Module files
137  !===========================================================================
138
139  use cdomod
140
141  !===========================================================================
142
143  implicit none
144
145  ! Arguments
146
147  integer(c_int), value :: icdoval
148
149  !===========================================================================
150
151  icdo = icdoval
152
153  return
154end subroutine cs_f_set_cdo_mode
155