1 #ifndef __CS_EQUATION_ASSEMBLE_H__ 2 #define __CS_EQUATION_ASSEMBLE_H__ 3 4 /*============================================================================ 5 * Functions to handle the assembly process of equatino discretized with CDO 6 * schemes 7 *============================================================================*/ 8 9 /* 10 This file is part of Code_Saturne, a general-purpose CFD tool. 11 12 Copyright (C) 1998-2021 EDF S.A. 13 14 This program is free software; you can redistribute it and/or modify it under 15 the terms of the GNU General Public License as published by the Free Software 16 Foundation; either version 2 of the License, or (at your option) any later 17 version. 18 19 This program is distributed in the hope that it will be useful, but WITHOUT 20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 21 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 22 details. 23 24 You should have received a copy of the GNU General Public License along with 25 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 26 Street, Fifth Floor, Boston, MA 02110-1301, USA. 27 */ 28 29 /*---------------------------------------------------------------------------- 30 * Local headers 31 *----------------------------------------------------------------------------*/ 32 33 #include "cs_cdo_connect.h" 34 #include "cs_matrix.h" 35 #include "cs_matrix_assembler.h" 36 #include "cs_param_cdo.h" 37 #include "cs_param_types.h" 38 #include "cs_sdm.h" 39 40 /*----------------------------------------------------------------------------*/ 41 42 BEGIN_C_DECLS 43 44 /*============================================================================ 45 * Macro definitions 46 *============================================================================*/ 47 48 /*============================================================================ 49 * Type definitions 50 *============================================================================*/ 51 52 typedef struct _cs_equation_assemble_t cs_equation_assemble_t; 53 54 /*============================================================================ 55 * Function pointer type definitions 56 *============================================================================*/ 57 58 /*----------------------------------------------------------------------------*/ 59 /*! 60 * \brief Assemble a cellwise matrix into the global matrix 61 * Block or no block versions are handled 62 * 63 * \param[in] m cellwise view of the algebraic system 64 * \param[in] dof_ids local DoF numbering 65 * \param[in] rset pointer to a cs_range_set_t structure 66 * \param[in, out] eqa pointer to an equation assembly structure 67 * \param[in, out] mav pointer to a matrix assembler structure 68 */ 69 /*----------------------------------------------------------------------------*/ 70 71 typedef void 72 (cs_equation_assembly_t)(const cs_sdm_t *m, 73 const cs_lnum_t *dof_ids, 74 const cs_range_set_t *rset, 75 cs_equation_assemble_t *eqa, 76 cs_matrix_assembler_values_t *mav); 77 78 /*============================================================================ 79 * Public function prototypes 80 *============================================================================*/ 81 82 /*----------------------------------------------------------------------------*/ 83 /*! 84 * \brief Retrieve the pointer to a requested \ref cs_matrix_structure_t 85 * structure 86 * 87 * \param[in] flag_id id in the array of matrix structures 88 * 89 * \return a pointer to a cs_matrix_structure_t 90 */ 91 /*----------------------------------------------------------------------------*/ 92 93 cs_matrix_structure_t * 94 cs_equation_get_matrix_structure(int flag); 95 96 /*----------------------------------------------------------------------------*/ 97 /*! 98 * \brief Get a pointer to a cs_equation_assemble_t structure related 99 * to a given thread 100 * 101 * \param[in] t_id id in the array of pointer 102 * 103 * \return a pointer to a cs_equation_assemble_t structure 104 */ 105 /*----------------------------------------------------------------------------*/ 106 107 cs_equation_assemble_t * 108 cs_equation_assemble_get(int t_id); 109 110 /*----------------------------------------------------------------------------*/ 111 /*! 112 * \brief Allocate and initialize matrix-related structures according to 113 * the type of discretization used for this simulation 114 * 115 * \param[in] connect pointer to a cs_cdo_connect_t structure 116 * \param[in] time_step pointer to a time step structure 117 * \param[in] eb_flag metadata for Edge-based schemes 118 * \param[in] fb_flag metadata for Face-based schemes 119 * \param[in] vb_flag metadata for Vertex-based schemes 120 * \param[in] vcb_flag metadata for Vertex+Cell-basde schemes 121 * \param[in] hho_flag metadata for HHO schemes 122 */ 123 /*----------------------------------------------------------------------------*/ 124 125 void 126 cs_equation_assemble_init(const cs_cdo_connect_t *connect, 127 cs_flag_t eb_flag, 128 cs_flag_t fb_flag, 129 cs_flag_t vb_flag, 130 cs_flag_t vcb_flag, 131 cs_flag_t hho_flag); 132 133 /*----------------------------------------------------------------------------*/ 134 /*! 135 * \brief Free matrix-related structures used during the simulation. 136 * Display overall statistic about the assembly stage for CDO schemes 137 */ 138 /*----------------------------------------------------------------------------*/ 139 140 void 141 cs_equation_assemble_finalize(void); 142 143 /*----------------------------------------------------------------------------*/ 144 /*! 145 * \brief Define the function pointer used to assemble the algebraic system 146 * 147 * \param[in] scheme space discretization scheme 148 * \param[in] ma_id id in the array of matrix assembler 149 * 150 * \return a function pointer cs_equation_assembly_t 151 */ 152 /*----------------------------------------------------------------------------*/ 153 154 cs_equation_assembly_t * 155 cs_equation_assemble_set(cs_param_space_scheme_t scheme, 156 int ma_id); 157 158 #if defined(HAVE_MPI) 159 160 /*----------------------------------------------------------------------------*/ 161 /*! 162 * \brief Assemble a cellwise matrix into the global matrix 163 * Scalar-valued case. Parallel and with openMP threading. 164 * 165 * \param[in] m cellwise view of the algebraic system 166 * \param[in] dof_ids local DoF numbering 167 * \param[in] rset pointer to a cs_range_set_t structure 168 * \param[in, out] eqa pointer to a matrix assembler buffers 169 * \param[in, out] mav pointer to a matrix assembler structure 170 */ 171 /*----------------------------------------------------------------------------*/ 172 173 void 174 cs_equation_assemble_matrix_mpit(const cs_sdm_t *m, 175 const cs_lnum_t *dof_ids, 176 const cs_range_set_t *rset, 177 cs_equation_assemble_t *eqa, 178 cs_matrix_assembler_values_t *mav); 179 180 /*----------------------------------------------------------------------------*/ 181 /*! 182 * \brief Assemble a cellwise matrix into the global matrix 183 * Scalar-valued case. Parallel without openMP threading. 184 * 185 * \param[in] m cellwise view of the algebraic system 186 * \param[in] dof_ids local DoF numbering 187 * \param[in] rset pointer to a cs_range_set_t structure 188 * \param[in, out] eqa pointer to a matrix assembler buffers 189 * \param[in, out] mav pointer to a matrix assembler structure 190 */ 191 /*----------------------------------------------------------------------------*/ 192 193 void 194 cs_equation_assemble_matrix_mpis(const cs_sdm_t *m, 195 const cs_lnum_t *dof_ids, 196 const cs_range_set_t *rset, 197 cs_equation_assemble_t *eqa, 198 cs_matrix_assembler_values_t *mav); 199 200 #endif /* defined(HAVE_MPI) */ 201 202 /*----------------------------------------------------------------------------*/ 203 /*! 204 * \brief Assemble a cellwise matrix into the global matrix 205 * Scalar-valued case. Sequential and with openMP threading. 206 * 207 * \param[in] m cellwise view of the algebraic system 208 * \param[in] dof_ids local DoF numbering 209 * \param[in] rset pointer to a cs_range_set_t structure 210 * \param[in, out] eqa pointer to a matrix assembler buffers 211 * \param[in, out] mav pointer to a matrix assembler structure 212 */ 213 /*----------------------------------------------------------------------------*/ 214 215 void 216 cs_equation_assemble_matrix_seqt(const cs_sdm_t *m, 217 const cs_lnum_t *dof_ids, 218 const cs_range_set_t *rset, 219 cs_equation_assemble_t *eqa, 220 cs_matrix_assembler_values_t *mav); 221 222 /*----------------------------------------------------------------------------*/ 223 /*! 224 * \brief Assemble a cellwise matrix into the global matrix 225 * Scalar-valued case. Sequential and without openMP. 226 * 227 * \param[in] m cellwise view of the algebraic system 228 * \param[in] dof_ids local DoF numbering 229 * \param[in] rset pointer to a cs_range_set_t structure 230 * \param[in, out] eqa pointer to a matrix assembler buffers 231 * \param[in, out] mav pointer to a matrix assembler structure 232 */ 233 /*----------------------------------------------------------------------------*/ 234 235 void 236 cs_equation_assemble_matrix_seqs(const cs_sdm_t *m, 237 const cs_lnum_t *dof_ids, 238 const cs_range_set_t *rset, 239 cs_equation_assemble_t *eqa, 240 cs_matrix_assembler_values_t *mav); 241 242 /*----------------------------------------------------------------------------*/ 243 /*! 244 * \brief Assemble a cellwise matrix into the global matrix 245 * Case of a block 3x3 entries. Expand each row. 246 * Sequential run without openMP threading. 247 * 248 * \param[in] m cellwise view of the algebraic system 249 * \param[in] dof_ids local DoF numbering 250 * \param[in] rset pointer to a cs_range_set_t structure 251 * \param[in, out] eqa pointer to an equation assembly structure 252 * \param[in, out] mav pointer to a matrix assembler structure 253 */ 254 /*----------------------------------------------------------------------------*/ 255 256 void 257 cs_equation_assemble_eblock33_matrix_seqs(const cs_sdm_t *m, 258 const cs_lnum_t *dof_ids, 259 const cs_range_set_t *rset, 260 cs_equation_assemble_t *eqa, 261 cs_matrix_assembler_values_t *mav); 262 263 /*----------------------------------------------------------------------------*/ 264 /*! 265 * \brief Assemble a cellwise matrix into the global matrix 266 * Case of a block 3x3 entries. Expand each row. 267 * Sequential run with openMP threading. 268 * 269 * \param[in] m cellwise view of the algebraic system 270 * \param[in] dof_ids local DoF numbering 271 * \param[in] rset pointer to a cs_range_set_t structure 272 * \param[in, out] eqa pointer to an equation assembly structure 273 * \param[in, out] mav pointer to a matrix assembler structure 274 */ 275 /*----------------------------------------------------------------------------*/ 276 277 void 278 cs_equation_assemble_eblock33_matrix_seqt(const cs_sdm_t *m, 279 const cs_lnum_t *dof_ids, 280 const cs_range_set_t *rset, 281 cs_equation_assemble_t *eqa, 282 cs_matrix_assembler_values_t *mav); 283 284 #if defined(HAVE_MPI) 285 286 /*----------------------------------------------------------------------------*/ 287 /*! 288 * \brief Assemble a cellwise matrix into the global matrix 289 * Case of a block 3x3 entries. Expand each row. 290 * Parallel run without openMP threading. 291 * 292 * \param[in] m cellwise view of the algebraic system 293 * \param[in] dof_ids local DoF numbering 294 * \param[in] rset pointer to a cs_range_set_t structure 295 * \param[in, out] eqa pointer to an equation assembly structure 296 * \param[in, out] mav pointer to a matrix assembler structure 297 */ 298 /*----------------------------------------------------------------------------*/ 299 300 void 301 cs_equation_assemble_eblock33_matrix_mpis(const cs_sdm_t *m, 302 const cs_lnum_t *dof_ids, 303 const cs_range_set_t *rset, 304 cs_equation_assemble_t *eqa, 305 cs_matrix_assembler_values_t *mav); 306 307 /*----------------------------------------------------------------------------*/ 308 /*! 309 * \brief Assemble a cellwise matrix into the global matrix 310 * Case of a block 3x3 entries. Expand each row. 311 * Parallel run with openMP threading. 312 * 313 * \param[in] m cellwise view of the algebraic system 314 * \param[in] dof_ids local DoF numbering 315 * \param[in] rset pointer to a cs_range_set_t structure 316 * \param[in, out] eqa pointer to an equation assembly structure 317 * \param[in, out] mav pointer to a matrix assembler structure 318 */ 319 /*----------------------------------------------------------------------------*/ 320 321 void 322 cs_equation_assemble_eblock33_matrix_mpit(const cs_sdm_t *m, 323 const cs_lnum_t *dof_ids, 324 const cs_range_set_t *rset, 325 cs_equation_assemble_t *eqa, 326 cs_matrix_assembler_values_t *mav); 327 328 #endif /* defined(HAVE_MPI) */ 329 330 /*----------------------------------------------------------------------------*/ 331 /*! 332 * \brief Assemble a cellwise matrix into the global matrix 333 * Case of a block NxN entries. Expand each row. 334 * Sequential run without openMP threading. 335 * 336 * \param[in] m cellwise view of the algebraic system 337 * \param[in] dof_ids local DoF numbering 338 * \param[in] rset pointer to a cs_range_set_t structure 339 * \param[in, out] eqa pointer to an equation assembly structure 340 * \param[in, out] mav pointer to a matrix assembler structure 341 */ 342 /*----------------------------------------------------------------------------*/ 343 344 void 345 cs_equation_assemble_eblock_matrix_seqs(const cs_sdm_t *m, 346 const cs_lnum_t *dof_ids, 347 const cs_range_set_t *rset, 348 cs_equation_assemble_t *eqa, 349 cs_matrix_assembler_values_t *mav); 350 351 /*----------------------------------------------------------------------------*/ 352 /*! 353 * \brief Assemble a cellwise system into the global algebraic system. 354 * Case of a block NxN entries. Expand each row. 355 * Sequential run with openMP threading. 356 * 357 * \param[in] m cellwise view of the algebraic system 358 * \param[in] dof_ids local DoF numbering 359 * \param[in] rset pointer to a cs_range_set_t structure 360 * \param[in, out] eqa pointer to an equation assembly structure 361 * \param[in, out] mav pointer to a matrix assembler structure 362 */ 363 /*----------------------------------------------------------------------------*/ 364 365 void 366 cs_equation_assemble_eblock_matrix_seqt(const cs_sdm_t *m, 367 const cs_lnum_t *dof_ids, 368 const cs_range_set_t *rset, 369 cs_equation_assemble_t *eqa, 370 cs_matrix_assembler_values_t *mav); 371 372 #if defined(HAVE_MPI) 373 374 /*----------------------------------------------------------------------------*/ 375 /*! 376 * \brief Assemble a cellwise matrix into the global matrix 377 * Case of a block NxN entries. Expand each row. 378 * Parallel run without openMP threading. 379 * 380 * \param[in] m cellwise view of the algebraic system 381 * \param[in] dof_ids local DoF numbering 382 * \param[in] rset pointer to a cs_range_set_t structure 383 * \param[in, out] eqa pointer to an equation assembly structure 384 * \param[in, out] mav pointer to a matrix assembler structure 385 */ 386 /*----------------------------------------------------------------------------*/ 387 388 void 389 cs_equation_assemble_eblock_matrix_mpis(const cs_sdm_t *m, 390 const cs_lnum_t *dof_ids, 391 const cs_range_set_t *rset, 392 cs_equation_assemble_t *eqa, 393 cs_matrix_assembler_values_t *mav); 394 395 /*----------------------------------------------------------------------------*/ 396 /*! 397 * \brief Assemble a cellwise matrix into the global matrix 398 * Case of a block NxN entries. Expand each row. 399 * Parallel run with openMP threading. 400 * 401 * \param[in] m cellwise view of the algebraic system 402 * \param[in] dof_ids local DoF numbering 403 * \param[in] rset pointer to a cs_range_set_t structure 404 * \param[in, out] eqa pointer to an equation assembly structure 405 * \param[in, out] mav pointer to a matrix assembler structure 406 */ 407 /*----------------------------------------------------------------------------*/ 408 409 void 410 cs_equation_assemble_eblock_matrix_mpit(const cs_sdm_t *m, 411 const cs_lnum_t *dof_ids, 412 const cs_range_set_t *rset, 413 cs_equation_assemble_t *eqa, 414 cs_matrix_assembler_values_t *mav); 415 416 #endif /* defined(HAVE_MPI) */ 417 418 /*----------------------------------------------------------------------------*/ 419 420 END_C_DECLS 421 422 #endif /* __CS_EQUATION_ASSEMBLE_H__ */ 423