My Project
programmer's documentation
cs_matrix_assembler.h
Go to the documentation of this file.
1 #ifndef __CS_MATRIX_ASSEMBLER_H__
2 #define __CS_MATRIX_ASSEMBLER_H__
3 
4 /*============================================================================
5  * Incremental or general construction of matrix.
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2019 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_defs.h"
35 
36 #include "cs_halo.h"
37 #include "cs_log.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*============================================================================
44  * Macro definitions
45  *============================================================================*/
46 
51 #define CS_MATRIX_DISTANT_ROW_USE_COL_IDX (1 << 0)
52 #define CS_MATRIX_DISTANT_ROW_USE_COL_G_ID (1 << 1)
53 #define CS_MATRIX_EXTERNAL_HALO (1 << 2)
54 
55 /*============================================================================
56  * Type definitions
57  *============================================================================*/
58 
61 typedef struct _cs_matrix_assembler_t cs_matrix_assembler_t;
62 
65 typedef struct _cs_matrix_assembler_values_t cs_matrix_assembler_values_t;
66 
67 /*----------------------------------------------------------------------------*/
81 /*----------------------------------------------------------------------------*/
82 
83 typedef void
85  const cs_lnum_t *db_size,
86  const cs_lnum_t *eb_size);
87 
88 /*----------------------------------------------------------------------------*/
113 /*----------------------------------------------------------------------------*/
114 
115 typedef void
117  cs_lnum_t n,
119  const cs_lnum_t row_id[],
120  const cs_lnum_t col_idx[],
121  const cs_real_t vals[]);
122 
123 /*----------------------------------------------------------------------------*/
152 /*----------------------------------------------------------------------------*/
153 
154 typedef void
156  cs_lnum_t row_id,
158  cs_lnum_t n_cols,
159  const cs_real_t diag_val[],
160  const cs_lnum_t col_idx[],
161  const cs_real_t vals[]);
162 
163 /*----------------------------------------------------------------------------*/
185 /*----------------------------------------------------------------------------*/
186 
187 typedef void
189  cs_lnum_t n,
191  const cs_gnum_t row_g_id[],
192  const cs_gnum_t col_g_id[],
193  const cs_real_t vals[]);
194 
195 /*----------------------------------------------------------------------------*/
206 /*----------------------------------------------------------------------------*/
207 
208 typedef void
210 
211 /*----------------------------------------------------------------------------*/
223 /*----------------------------------------------------------------------------*/
224 
225 typedef void
227 
228 /*============================================================================
229  * Global variables
230  *============================================================================*/
231 
232 /*=============================================================================
233  * Public function prototypes
234  *============================================================================*/
235 
236 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
252 cs_matrix_assembler_create(const cs_gnum_t l_range[2],
253  bool separate_diag);
254 
255 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
277  bool separate_diag,
278  const cs_lnum_t row_idx[],
279  const cs_lnum_t col_id[],
280  const cs_halo_t *halo);
281 
282 /*----------------------------------------------------------------------------*/
288 /*----------------------------------------------------------------------------*/
289 
290 void
292 
293 /*----------------------------------------------------------------------------*/
304 /*----------------------------------------------------------------------------*/
305 
306 void
308  cs_lnum_t n,
309  const cs_gnum_t g_row_id[],
310  const cs_gnum_t g_col_id[]);
311 
312 /*----------------------------------------------------------------------------*/
322 /*----------------------------------------------------------------------------*/
323 
324 void
326 
327 /*----------------------------------------------------------------------------*/
359 /*----------------------------------------------------------------------------*/
360 
361 void
363  int flags);
364 
365 /*----------------------------------------------------------------------------*/
376 /*----------------------------------------------------------------------------*/
377 
378 int
380 
381 #if defined(HAVE_MPI)
382 
383 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 void
395 cs_matrix_assembler_set_comm(cs_matrix_assembler_t *ma,
396  MPI_Comm comm);
397 
398 #endif /* HAVE_MPI */
399 
400 /*----------------------------------------------------------------------------*/
409 /*----------------------------------------------------------------------------*/
410 
411 const cs_gnum_t *
413 
414 /*----------------------------------------------------------------------------*/
423 /*----------------------------------------------------------------------------*/
424 
425 const cs_halo_t *
427 
428 /*----------------------------------------------------------------------------*/
437 /*----------------------------------------------------------------------------*/
438 
439 bool
441 
442 /*----------------------------------------------------------------------------*/
450 /*----------------------------------------------------------------------------*/
451 
452 cs_lnum_t
454 
455 /*----------------------------------------------------------------------------*/
463 /*----------------------------------------------------------------------------*/
464 
465 cs_lnum_t
467 
468 /*----------------------------------------------------------------------------*/
484 /*----------------------------------------------------------------------------*/
485 
486 const cs_lnum_t *
488 
489 /*----------------------------------------------------------------------------*/
507 /*----------------------------------------------------------------------------*/
508 
509 const cs_lnum_t *
511 
512 /*----------------------------------------------------------------------------*/
526 /*----------------------------------------------------------------------------*/
527 
528 void
530  int rc[4]);
531 
532 /*----------------------------------------------------------------------------*/
540 /*----------------------------------------------------------------------------*/
541 
542 void
544  cs_log_t log_id,
545  const char *name);
546 
547 /*----------------------------------------------------------------------------*/
586 /*----------------------------------------------------------------------------*/
587 
590  bool sep_diag,
591  const cs_lnum_t *db_size,
592  const cs_lnum_t *eb_size,
593  void *matrix,
599 
600 /*----------------------------------------------------------------------------*/
610 /*----------------------------------------------------------------------------*/
611 
612 void
614 
615 /*----------------------------------------------------------------------------*/
640 /*----------------------------------------------------------------------------*/
641 
642 void
644  cs_lnum_t n,
645  const cs_lnum_t row_id[],
646  const cs_lnum_t col_id[],
647  const cs_real_t val[]);
648 
649 /*----------------------------------------------------------------------------*/
674 /*----------------------------------------------------------------------------*/
675 
676 void
678  cs_lnum_t n,
679  const cs_gnum_t g_row_id[],
680  const cs_gnum_t g_col_id[],
681  const cs_real_t val[]);
682 
683 /*----------------------------------------------------------------------------*/
701 /*----------------------------------------------------------------------------*/
702 
703 void
705 
706 /*----------------------------------------------------------------------------*/
707 
709 
710 #endif /* __CS_MATRIX_ASSEMBLER_H__ */
cs_matrix_assembler_get_n_rows
cs_lnum_t cs_matrix_assembler_get_n_rows(const cs_matrix_assembler_t *ma)
Return the number of rows associated with a matrix assembler.
Definition: cs_matrix_assembler.c:2871
cs_defs.h
cs_log.h
cs_matrix_assembler_get_l_range
const cs_gnum_t * cs_matrix_assembler_get_l_range(const cs_matrix_assembler_t *ma)
Return a pointer to local global row range associated with a matrix assembler.
Definition: cs_matrix_assembler.c:2821
cs_matrix_assembler_values_add_g
void cs_matrix_assembler_values_add_g(cs_matrix_assembler_values_t *mav, cs_lnum_t n, const cs_gnum_t g_row_id[], const cs_gnum_t g_col_id[], const cs_real_t val[])
Add values to a matrix assembler values structure using global row and column ids.
Definition: cs_matrix_assembler.c:3298
cs_matrix_assembler_compute
void cs_matrix_assembler_compute(cs_matrix_assembler_t *ma)
Compute internal structures required by a matrix assembler.
Definition: cs_matrix_assembler.c:2765
cs_matrix_assembler_values_add_t
void() cs_matrix_assembler_values_add_t(void *matrix, cs_lnum_t n, cs_lnum_t stride, const cs_lnum_t row_id[], const cs_lnum_t col_idx[], const cs_real_t vals[])
Function pointer for addition to matrix coefficients using local row ids and column indexes.
Definition: cs_matrix_assembler.h:116
cs_matrix_assembler_values_t
struct _cs_matrix_assembler_values_t cs_matrix_assembler_values_t
Definition: cs_matrix_assembler.h:65
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_matrix_assembler_add_g_ids
void cs_matrix_assembler_add_g_ids(cs_matrix_assembler_t *ma, cs_lnum_t n, const cs_gnum_t g_row_id[], const cs_gnum_t g_col_id[])
Add entries to a matrix assembler structure.
Definition: cs_matrix_assembler.c:2704
cs_matrix_assembler_create
cs_matrix_assembler_t * cs_matrix_assembler_create(const cs_gnum_t l_range[2], bool separate_diag)
Create a matrix assembler structure.
Definition: cs_matrix_assembler.c:2397
cs_matrix_assembler_values_create
cs_matrix_assembler_values_t * cs_matrix_assembler_values_create(const cs_matrix_assembler_t *ma, bool sep_diag, const cs_lnum_t *db_size, const cs_lnum_t *eb_size, void *matrix, cs_matrix_assembler_values_init_t *init, cs_matrix_assembler_values_add_t *add, cs_matrix_assembler_values_add_g_t *add_g, cs_matrix_assembler_values_begin_t *begin, cs_matrix_assembler_values_end_t *end)
Create and initialize a matrix assembler values structure.
Definition: cs_matrix_assembler.c:3068
stride
void const cs_int_t const cs_int_t const cs_int_t const cs_int_t * stride
Definition: cs_sat_coupling.h:325
cs_matrix_assembler_log_rank_counts
void cs_matrix_assembler_log_rank_counts(const cs_matrix_assembler_t *ma, cs_log_t log_id, const char *name)
Log rank counts for a given matrix assembler.
Definition: cs_matrix_assembler.c:2991
cs_matrix_assembler_get_n_columns
cs_lnum_t cs_matrix_assembler_get_n_columns(const cs_matrix_assembler_t *ma)
Return the number of columns associated with a matrix assembler.
Definition: cs_matrix_assembler.c:2887
cs_halo.h
cs_gnum_t
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:286
cs_matrix_assembler_values_init_t
void() cs_matrix_assembler_values_init_t(void *matrix, const cs_lnum_t *db_size, const cs_lnum_t *eb_size)
Function pointer for initialization of matrix coefficients using local row ids and column indexes.
Definition: cs_matrix_assembler.h:84
cs_matrix_assembler_get_separate_diag
bool cs_matrix_assembler_get_separate_diag(const cs_matrix_assembler_t *ma)
Indicate if the matrix assembler is based on a separate diagonal.
Definition: cs_matrix_assembler.c:2855
cs_matrix_assembler_get_halo
const cs_halo_t * cs_matrix_assembler_get_halo(const cs_matrix_assembler_t *ma)
Return a pointer to the halo structure associated with a matrix assembler.
Definition: cs_matrix_assembler.c:2838
cs_matrix_assembler_values_add
void cs_matrix_assembler_values_add(cs_matrix_assembler_values_t *mav, cs_lnum_t n, const cs_lnum_t row_id[], const cs_lnum_t col_id[], const cs_real_t val[])
Add values to a matrix assembler values structure using local row and column ids.
Definition: cs_matrix_assembler.c:3188
cs_matrix_assembler_values_end_t
void() cs_matrix_assembler_values_end_t(void *matrix)
Function pointer to complete the final assembly of matrix coefficients.
Definition: cs_matrix_assembler.h:226
cs_matrix_assembler_destroy
void cs_matrix_assembler_destroy(cs_matrix_assembler_t **ma)
Destroy a matrix assembler structure.
Definition: cs_matrix_assembler.c:2586
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_matrix_assembler_get_rank_counts
void cs_matrix_assembler_get_rank_counts(const cs_matrix_assembler_t *ma, int rc[4])
Return info on the number of neighbor ranks a matrix assembler may communicate with.
Definition: cs_matrix_assembler.c:2963
cs_matrix_assembler_get_col_ids
const cs_lnum_t * cs_matrix_assembler_get_col_ids(const cs_matrix_assembler_t *ma)
Return a column ids associated with a matrix assembler.
Definition: cs_matrix_assembler.c:2941
init
void const cs_int_t *const init
Definition: cs_convection_diffusion.h:5386
cs_matrix_assembler_get_options
int cs_matrix_assembler_get_options(const cs_matrix_assembler_t *ma)
Return the option flags for a given matrix assembler structure.
Definition: cs_matrix_assembler.c:2685
cs_halo_t
Definition: cs_halo.h:71
cs_matrix_assembler_values_begin_t
void() cs_matrix_assembler_values_begin_t(void *matrix)
Function pointer to start the final assembly of matrix coefficients.
Definition: cs_matrix_assembler.h:209
cs_log_t
cs_log_t
Definition: cs_log.h:48
cs_matrix_assembler_t
struct _cs_matrix_assembler_t cs_matrix_assembler_t
Definition: cs_matrix_assembler.h:61
cs_matrix_assembler_values_cdo_add_t
void() cs_matrix_assembler_values_cdo_add_t(void *matrix, cs_lnum_t row_id, cs_lnum_t stride, cs_lnum_t n_cols, const cs_real_t diag_val[], const cs_lnum_t col_idx[], const cs_real_t vals[])
Function pointer for addition to matrix coefficients using local row ids and column indexes in case o...
Definition: cs_matrix_assembler.h:155
cs_matrix_assembler_values_done
void cs_matrix_assembler_values_done(cs_matrix_assembler_values_t *mav)
Start assembly of matrix values structure.
Definition: cs_matrix_assembler.c:3532
cs_matrix_assembler_values_finalize
void cs_matrix_assembler_values_finalize(cs_matrix_assembler_values_t **mav)
Finalize matrix assembler values structure.
Definition: cs_matrix_assembler.c:3143
cs_matrix_assembler_values_add_g_t
void() cs_matrix_assembler_values_add_g_t(void *matrix, cs_lnum_t n, cs_lnum_t stride, const cs_gnum_t row_g_id[], const cs_gnum_t col_g_id[], const cs_real_t vals[])
Function pointer for addition to matrix coefficients using global row ids and column indexes.
Definition: cs_matrix_assembler.h:188
cs_matrix_assembler_set_options
void cs_matrix_assembler_set_options(cs_matrix_assembler_t *ma, int flags)
Set option flags for a given matrix assembler structure.
Definition: cs_matrix_assembler.c:2659
cs_matrix_assembler_create_from_shared
cs_matrix_assembler_t * cs_matrix_assembler_create_from_shared(cs_lnum_t n_rows, bool separate_diag, const cs_lnum_t row_idx[], const cs_lnum_t col_id[], const cs_halo_t *halo)
Create a matrix assembler structure based on a given connectivity and associated halo structure.
Definition: cs_matrix_assembler.c:2484
cs_matrix_assembler_get_row_index
const cs_lnum_t * cs_matrix_assembler_get_row_index(const cs_matrix_assembler_t *ma)
Return a row index associated with a matrix assembler.
Definition: cs_matrix_assembler.c:2915