1 #ifndef __CS_GRADIENT_CUDA_H__
2 #define __CS_GRADIENT_CUDA_H__
3 
4 /*============================================================================
5  * Private functions for gradient reconstruction.
6  *============================================================================*/
7 
8 /*
9   This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11   Copyright (C) 1998-2021 EDF S.A.
12 
13   This program is free software; you can redistribute it and/or modify it under
14   the terms of the GNU General Public License as published by the Free Software
15   Foundation; either version 2 of the License, or (at your option) any later
16   version.
17 
18   This program is distributed in the hope that it will be useful, but WITHOUT
19   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
21   details.
22 
23   You should have received a copy of the GNU General Public License along with
24   this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25   Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_base.h"
35 #include "cs_base_accel.h"
36 #include "cs_halo.h"
37 #include "cs_internal_coupling.h"
38 #include "cs_mesh.h"
39 #include "cs_mesh_quantities.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
43 BEGIN_C_DECLS
44 
45 /*! \cond DOXYGEN_SHOULD_SKIP_THIS */
46 
47 /*============================================================================
48  * Macro definitions
49  *============================================================================*/
50 
51 /*=============================================================================
52  * Local type definitions
53  *============================================================================*/
54 
55 /* Type for symmetric least-squares covariance matrices
56    as they are adimensional, single-precision should be usable here */
57 
58 typedef cs_real_t  cs_cocg_t;
59 typedef cs_real_t  cs_cocg_6_t[6];
60 typedef cs_real_t  cs_cocg_33_t[3][3];
61 
62 /*============================================================================
63  *  Global variables
64  *============================================================================*/
65 
66 /*=============================================================================
67  * Semi-private function prototypes
68  *============================================================================*/
69 
70 #if defined(HAVE_CUDA)
71 
72 /*----------------------------------------------------------------------------
73  * Compute cell gradient using least-squares reconstruction for non-orthogonal
74  * meshes (nswrgp > 1).
75  *
76  * Optionally, a volume force generating a hydrostatic pressure component
77  * may be accounted for.
78  *
79  * cocg is computed to account for variable B.C.'s (flux).
80  *
81  * parameters:
82  *   m              <-- pointer to associated mesh structure
83  *   fvq            <-- pointer to associated finite volume quantities
84  *   halo_type      <-- halo type (extended or not)
85  *   recompute_cocg <-- flag to recompute cocg
86  *   hyd_p_flag     <-- flag for hydrostatic pressure
87  *   inc            <-- if 0, solve on increment; 1 otherwise
88  *   fext           <-- exterior force generating pressure
89  *   coefap         <-- B.C. coefficients for boundary face normals
90  *   coefbp         <-- B.C. coefficients for boundary face normals
91  *   pvar           <-- variable
92  *   c_weight       <-- weighted gradient coefficient variable,
93  *                      or NULL
94  *   cocg           <-> associated cell covariance array (on device)
95  *   cocgb          <-> saved boundary cell covariance array (on device)
96  *   grad           <-> gradient of pvar (halo prepared for periodicity
97  *                      of rotation)
98  *----------------------------------------------------------------------------*/
99 
100 void
101 cs_gradient_scalar_lsq_cuda(const cs_mesh_t              *m,
102                             const cs_mesh_quantities_t   *fvq,
103                             cs_halo_type_t                halo_type,
104                             bool                          recompute_cocg,
105                             int                           hyd_p_flag,
106                             cs_real_t                     inc,
107                             const cs_real_3_t             f_ext[],
108                             const cs_real_t               coefap[],
109                             const cs_real_t               coefbp[],
110                             const cs_real_t               pvar[],
111                             const cs_real_t     *restrict c_weight,
112                             cs_cocg_6_t         *restrict cocg,
113                             cs_cocg_6_t         *restrict cocgb,
114                             cs_real_3_t         *restrict grad);
115 
116 #endif /* defined(HAVE_CUDA) */
117 
118 /*----------------------------------------------------------------------------*/
119 
120 END_C_DECLS
121 
122 #endif /* __CS_GRADIENT_CUDA_H__ */
123