7.2
general documentation
cs_cdo_system.h
Go to the documentation of this file.
1 #ifndef __CS_CDO_SYSTEM_H__
2 #define __CS_CDO_SYSTEM_H__
3 
4 /*============================================================================
5  * Structure and functions used to manipulate elementary structures related to
6  * the definition/usage of linear systems (objects manipulated with this
7  * structure are matrices, matrix strcutures and assemblers, range set and
8  * interface set for parallel synchronization/operations)
9  *============================================================================*/
10 
11 /*
12  This file is part of code_saturne, a general-purpose CFD tool.
13 
14  Copyright (C) 1998-2022 EDF S.A.
15 
16  This program is free software; you can redistribute it and/or modify it under
17  the terms of the GNU General Public License as published by the Free Software
18  Foundation; either version 2 of the License, or (at your option) any later
19  version.
20 
21  This program is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
24  details.
25 
26  You should have received a copy of the GNU General Public License along with
27  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
28  Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 */
30 
31 /*----------------------------------------------------------------------------
32  * Local headers
33  *----------------------------------------------------------------------------*/
34 
35 #include "cs_cdo_assembly.h"
36 #include "cs_cdo_connect.h"
37 #include "cs_matrix.h"
38 #include "cs_matrix_assembler.h"
39 #include "cs_range_set.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /*============================================================================
50  * Type definitions
51  *============================================================================*/
52 
53 typedef enum {
54 
60 
82 typedef enum {
83 
88 
90 
92 
110 typedef enum {
111 
116 
118 
120 
121 
122 typedef struct {
123 
124  /* If the block is associated to one or several matrices, one keeps
125  * the information about the class of the matrix
126  */
127 
129 
130  /* An element is for instance a vertex, edge, face or cell */
131 
134  int stride;
136  /* Description how is stored the matrix values for this block.
137  *
138  * When stride > 1, there are several options to store the matrix
139  * (all possibilities are not available up to now)
140  *
141  * unrolled: True means that a vector-valued DoF for instance is treated as
142  * a scalar-valued DoF which is three times larger.
143  *
144  * interlaced: True means that a vector-valued DoF is stored as follows:
145  * U0x U0y U0z U1x U1y U1z ... UNx UNy UNz
146  * false means that its representation is as follows:
147  * U0x U1x ... UNx U0y U1y ... UNy U0z U1z ... UNz
148  */
149 
150  bool unrolled;
152 
154 
155 
165 typedef struct {
166 
167  /*
168  * \var matrix
169  * matrix of the system to solve
170  *
171  * \var matrix_class
172  * class of the matrix
173  *
174  * \var mav
175  * structure to manage the assembly of matrix values
176  *
177  * \var assembly_func
178  * function pointer to operate the assembly stage
179  *
180  * \var slave_assembly_func
181  * function pointer to operate the assembly stage when the system helper
182  * is declared as slave (this is the same for all matrices). Useful for
183  * coupled systems.
184  */
185 
190 
191  /* The following structures can be shared if the same block configuration
192  is requested */
193 
198 
200 
201 
209 typedef struct {
210 
211  /*
212  * \var n_matrices
213  * number of matrices to consider
214  *
215  * \var matrices
216  * matrix of the system to solve (the matrix id in the list of matrices
217  * corresponding to the matrix at row i and column j is i*n_matrices+j)
218  *
219  * \var mav_array
220  * array of structures to manage the assembly of matrix values
221  *
222  * \var assembly_func
223  * function pointer to operate the assembly stage (this is the same for
224  * all matrices)
225  *
226  * \var slave_assembly_func
227  * function pointer to operate the assembly stage when the system helper
228  * is declared as slave (this is the same for all matrices)
229  */
230 
236 
237  /* The two following structures are always shared. They correspond to the
238  scalar-valued version. */
239 
242 
246 
248 
257 typedef struct {
258 
277 
279 
280  /* The following structures can be shared if the same block configuration is
281  requested. In this case, shared_structures is set to true. By default,
282  there is no sharing. */
283 
287 
289 
290 
298 typedef struct {
299 
300  /*
301  * \var matrix
302  * matrix of the system to solve
303  *
304  * \var mav
305  * structure to manage the assembly of matrix values
306  */
307 
310 
311  /* Private structures */
312 
317 
319 
320 
326 typedef struct {
327 
328  /* \var info
329  * Set of metadata to describe the block
330  */
331 
333 
345 
346  bool owner;
347 
348  int id;
349 
357 
359 
368 typedef struct {
369 
406 
410 
412  cs_real_t *rhs; /* shared */
413  cs_real_t *_rhs; /* private */
415 
416  int n_blocks;
418 
420 
421 /*============================================================================
422  * Public function prototypes
423  *============================================================================*/
424 
425 /*----------------------------------------------------------------------------*/
433 /*----------------------------------------------------------------------------*/
434 
435 void
437  cs_cdo_connect_t *connect);
438 
439 /*----------------------------------------------------------------------------*/
452 /*----------------------------------------------------------------------------*/
453 
456  int n_col_blocks,
457  const cs_lnum_t *col_block_sizes,
458  int n_blocks);
459 
460 /*----------------------------------------------------------------------------*/
476 /*----------------------------------------------------------------------------*/
477 
480  int block_id,
482  cs_flag_t location,
483  cs_lnum_t n_elements,
484  int stride,
485  bool interlaced,
486  bool unrolled);
487 
488 /*----------------------------------------------------------------------------*/
502 /*----------------------------------------------------------------------------*/
503 
506  int block_id,
508  cs_flag_t location,
509  cs_lnum_t n_elements,
510  int stride);
511 
512 /*----------------------------------------------------------------------------*/
527 /*----------------------------------------------------------------------------*/
528 
531  int block_id,
532  const cs_adjacency_t *adjacency,
533  cs_flag_t location,
534  cs_lnum_t n_elements,
535  int stride,
536  bool interlaced);
537 
538 /*----------------------------------------------------------------------------*/
549 /*----------------------------------------------------------------------------*/
550 
553  int block_id,
554  cs_lnum_t n_dofs);
555 
556 /*----------------------------------------------------------------------------*/
565 /*----------------------------------------------------------------------------*/
566 
569  int block_id);
570 
571 /*----------------------------------------------------------------------------*/
585 /*----------------------------------------------------------------------------*/
586 
587 cs_matrix_t *
589  int block_id);
590 
591 /*----------------------------------------------------------------------------*/
604 /*----------------------------------------------------------------------------*/
605 
606 cs_matrix_t *
608  int block_id,
609  int sub_id);
610 
611 /*----------------------------------------------------------------------------*/
619 /*----------------------------------------------------------------------------*/
620 
621 void
623  int block_id);
624 
625 /*----------------------------------------------------------------------------*/
633 /*----------------------------------------------------------------------------*/
634 
635 void
637  cs_real_t **p_rhs);
638 
639 /*----------------------------------------------------------------------------*/
645 /*----------------------------------------------------------------------------*/
646 
647 void
649 
650 /*----------------------------------------------------------------------------*/
656 /*----------------------------------------------------------------------------*/
657 
658 void
660 
661 /*----------------------------------------------------------------------------*/
667 /*----------------------------------------------------------------------------*/
668 
669 void
671 
672 /*----------------------------------------------------------------------------*/
677 /*----------------------------------------------------------------------------*/
678 
679 void
681 
682 /*----------------------------------------------------------------------------*/
686 /*----------------------------------------------------------------------------*/
687 
688 void
690 
691 /*----------------------------------------------------------------------------*/
692 
694 
695 #endif /* __CS_CDO_SYSTEM_H__ */
void * block_pointer
Definition: cs_cdo_system.h:356
cs_matrix_assembler_t * matrix_assembler
Definition: cs_cdo_system.h:196
void cs_cdo_system_destroy_all(void)
Free all members associated to system helpers.
Definition: cs_cdo_system.c:2151
cs_cdo_system_type_t
Definition: cs_cdo_system.h:53
cs_matrix_t ** matrices
Definition: cs_cdo_system.h:232
cs_interface_set_t * interface_set
Definition: cs_cdo_system.h:195
int n_col_blocks
Definition: cs_cdo_system.h:407
cs_matrix_assembler_values_t * mav
Definition: cs_cdo_system.h:187
cs_real_t ** rhs_array
Definition: cs_cdo_system.h:414
bool unrolled
Definition: cs_cdo_system.h:150
cs_cdo_system_block_t * cs_cdo_system_add_xblock(cs_cdo_system_helper_t *sh, int block_id, cs_lnum_t n_dofs)
Add an external block definition at position "block_id" in the helper structure. Only metadata are se...
Definition: cs_cdo_system.c:1483
void() cs_cdo_assembly_func_t(const cs_sdm_t *m, const cs_lnum_t *dof_ids, const cs_range_set_t *rset, cs_cdo_assembly_t *eqa, cs_matrix_assembler_values_t *mav)
Assemble a cellwise matrix into the global matrix Block or no block versions are handled.
Definition: cs_cdo_assembly.h:72
Definition: cs_cdo_system.h:84
cs_matrix_t * cs_cdo_system_get_matrix(const cs_cdo_system_helper_t *sh, int block_id)
Retrieve the matrix associated to the given block_id. If the type of block is either CS_CDO_SYSTEM_BL...
Definition: cs_cdo_system.c:1619
struct _cs_matrix_assembler_values_t cs_matrix_assembler_values_t
Definition: cs_matrix_assembler.h:65
cs_cdo_system_type_t type
Definition: cs_cdo_system.h:405
Definition: cs_mesh_adjacencies.h:68
cs_range_set_t * range_set
Definition: cs_cdo_system.h:285
cs_cdo_system_block_t ** blocks
Definition: cs_cdo_system.h:417
cs_real_t * _rhs
Definition: cs_cdo_system.h:413
int n_blocks
Definition: cs_cdo_system.h:416
cs_lnum_t n_elements
Definition: cs_cdo_system.h:133
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
Definition: cs_cdo_system.h:55
bool shared_structures
Definition: cs_cdo_system.h:284
cs_cdo_assembly_func_t * assembly_func
Definition: cs_cdo_system.h:188
cs_matrix_t * matrix
Definition: cs_cdo_system.h:186
Definition: cs_cdo_system.h:368
Definition: cs_cdo_system.h:85
Definition: cs_cdo_connect.h:61
int stride
Definition: cs_cdo_system.h:134
cs_real_t * _values
Definition: cs_cdo_system.h:276
cs_real_t * values
Definition: cs_cdo_system.h:275
cs_interface_set_t * interface_set
Definition: cs_cdo_system.h:286
void cs_cdo_system_helper_free(cs_cdo_system_helper_t **p_helper)
Free a cs_cdo_system_helper_t structure.
Definition: cs_cdo_system.c:1120
cs_cdo_assembly_func_t * slave_assembly_func
Definition: cs_cdo_system.h:235
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:110
void cs_cdo_system_allocate_assembly(void)
Initialize shared assembly structures from the existing helper structures.
Definition: cs_cdo_system.c:2094
Definition: cs_mesh.h:84
cs_interface_set_t * interface_set
Definition: cs_cdo_system.h:241
Structure associated to the extended type of block.
Definition: cs_cdo_system.h:298
bool matrix_struct_ownership
Definition: cs_cdo_system.h:243
Structure associated to the unassembled type of block.
Definition: cs_cdo_system.h:257
Definition: cs_cdo_system.h:57
Structure associated to the split type of block.
Definition: cs_cdo_system.h:209
void cs_cdo_system_build_block(cs_cdo_system_helper_t *sh, int block_id)
Build the associated structures for the given system_helper structure If a member is already allocate...
Definition: cs_cdo_system.c:1711
cs_cdo_assembly_func_t * slave_assembly_func
Definition: cs_cdo_system.h:189
Structure associated to the default type of block.
Definition: cs_cdo_system.h:165
Definition: cs_cdo_system.h:115
cs_matrix_t * matrix
Definition: cs_cdo_system.h:308
cs_range_set_t * range_set
Definition: cs_cdo_system.h:240
cs_cdo_system_block_t * cs_cdo_system_add_sblock(cs_cdo_system_helper_t *sh, int block_id, cs_cdo_system_matrix_class_t matclass, cs_flag_t location, cs_lnum_t n_elements, int stride)
Add a split block definition at position "block_id" in the helper structure. Only metadata are set at...
Definition: cs_cdo_system.c:1264
cs_matrix_structure_t * matrix_structure
Definition: cs_cdo_system.h:316
cs_matrix_t * cs_cdo_system_get_sub_matrix(cs_cdo_system_helper_t *sh, int block_id, int sub_id)
Retrieve the (sub-)matrix associated to a split block with id equal to block_id. sub_id is the id in ...
Definition: cs_cdo_system.c:1670
cs_cdo_system_block_type_t type
Definition: cs_cdo_system.h:344
Definition: cs_cdo_system.h:89
bool interlaced
Definition: cs_cdo_system.h:151
cs_matrix_assembler_t * matrix_assembler
Definition: cs_cdo_system.h:315
cs_lnum_t * max_col_block_sizes
Definition: cs_cdo_system.h:409
cs_cdo_system_matrix_class_t matrix_class
Definition: cs_cdo_system.h:128
cs_range_set_t * range_set
Definition: cs_cdo_system.h:313
void cs_cdo_system_init_sharing(cs_mesh_t *mesh, cs_cdo_connect_t *connect)
Allocate and initialize matrix-related structures according to the type of discretization used for th...
Definition: cs_cdo_system.c:1043
Definition: cs_range_set.h:57
int id
Definition: cs_cdo_system.h:348
cs_matrix_assembler_values_t * mav
Definition: cs_cdo_system.h:309
Definition: cs_cdo_system.h:326
void cs_cdo_system_helper_reset(cs_cdo_system_helper_t *sh)
Free matrix and rhs after the solve step.
Definition: cs_cdo_system.c:2029
Definition: cs_cdo_system.h:112
struct _cs_interface_set_t cs_interface_set_t
Definition: cs_interface.h:61
cs_lnum_t * col_block_sizes
Definition: cs_cdo_system.h:408
cs_cdo_system_block_t * cs_cdo_system_add_dblock(cs_cdo_system_helper_t *sh, int block_id, cs_cdo_system_matrix_class_t matclass, cs_flag_t location, cs_lnum_t n_elements, int stride, bool interlaced, bool unrolled)
Add an unassembled block definition at position "block_id" in the helper structure Only metadata are ...
Definition: cs_cdo_system.c:1163
Definition: cs_cdo_system.h:87
int n_matrices
Definition: cs_cdo_system.h:231
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
void cs_cdo_system_helper_init_system(cs_cdo_system_helper_t *sh, cs_real_t **p_rhs)
Allocate and initialize the matrix, rhs and the matrix assembler values.
Definition: cs_cdo_system.c:1790
Definition: cs_cdo_system.h:122
cs_cdo_system_helper_t * cs_cdo_system_helper_create(cs_cdo_system_type_t type, int n_col_blocks, const cs_lnum_t *col_block_sizes, int n_blocks)
Create a system_helper structure from its set of metadata. n_col_blocks and n_blocks may differ accor...
Definition: cs_cdo_system.c:1068
cs_cdo_system_block_type_t
type of block composing a (block) matrix
Definition: cs_cdo_system.h:82
#define END_C_DECLS
Definition: cs_defs.h:511
unsigned short int cs_flag_t
Definition: cs_defs.h:324
cs_cdo_assembly_func_t * assembly_func
Definition: cs_cdo_system.h:234
Definition: cs_cdo_system.h:117
struct _cs_matrix_assembler_t cs_matrix_assembler_t
Definition: cs_matrix_assembler.h:61
cs_matrix_structure_t * matrix_structure
Definition: cs_cdo_system.h:197
bool owner
Definition: cs_cdo_system.h:346
void cs_cdo_system_helper_finalize_assembly(cs_cdo_system_helper_t *sh)
Finalize the assembly after the cellwise building and assembly.
Definition: cs_cdo_system.c:1968
cs_matrix_assembler_t * matrix_assembler
Definition: cs_cdo_system.h:244
Definition: cs_cdo_system.h:113
cs_range_set_t * range_set
Definition: cs_cdo_system.h:194
const cs_adjacency_t * adjacency
Definition: cs_cdo_system.h:278
cs_cdo_system_block_info_t info
Definition: cs_cdo_system.h:332
cs_matrix_structure_t * matrix_structure
Definition: cs_cdo_system.h:245
cs_flag_t location
Definition: cs_cdo_system.h:132
Definition: cs_cdo_system.h:56
Definition: cs_cdo_system.h:114
cs_cdo_system_matrix_class_t
Class of matrices to consider.
Definition: cs_cdo_system.h:110
struct _cs_matrix_structure_t cs_matrix_structure_t
Definition: cs_matrix.h:106
Definition: mesh.f90:26
cs_matrix_assembler_values_t ** mav_array
Definition: cs_cdo_system.h:233
cs_real_t * rhs
Definition: cs_cdo_system.h:412
cs_lnum_t full_rhs_size
Definition: cs_cdo_system.h:411
cs_cdo_system_block_t * cs_cdo_system_add_ublock(cs_cdo_system_helper_t *sh, int block_id, const cs_adjacency_t *adjacency, cs_flag_t location, cs_lnum_t n_elements, int stride, bool interlaced)
Add an unassembled block definition at position "block_id" in the helper structure Only metadata are ...
Definition: cs_cdo_system.c:1395
cs_range_set_t * cs_cdo_system_get_range_set(const cs_cdo_system_helper_t *sh, int block_id)
Retrieve the range set structure associated to the given block_id.
Definition: cs_cdo_system.c:1553
Definition: cs_cdo_system.h:86
cs_interface_set_t * interface_set
Definition: cs_cdo_system.h:314