8.0
general documentation
Loading...
Searching...
No Matches
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-2023 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
33#include "cs_defs.h"
34
35/*----------------------------------------------------------------------------
36 * Standard C library headers
37 *----------------------------------------------------------------------------*/
38
39/*----------------------------------------------------------------------------
40 * Local headers
41 *----------------------------------------------------------------------------*/
42
43#include "cs_cdo_assembly.h"
44#include "cs_cdo_connect.h"
45#include "cs_param_types.h"
46#include "cs_matrix.h"
47#include "cs_matrix_assembler.h"
48#include "cs_range_set.h"
49
50/*----------------------------------------------------------------------------*/
51
53
54/*============================================================================
55 * Macro definitions
56 *============================================================================*/
57
58/*============================================================================
59 * Type definitions
60 *============================================================================*/
61
69
90
101
118
129
130
131typedef struct {
132
133 /* If the block is associated to one or several matrices, one keeps
134 * the information about the class of the matrix
135 */
136
138
139 /* An element is for instance a vertex, edge, face or cell */
140
143 int stride;
144
145 /* Description how is stored the matrix values for this block.
146 *
147 * When stride > 1, there are several options to store the matrix
148 * (all possibilities are not available up to now)
149 *
150 * unrolled: True means that a vector-valued DoF for instance is treated as
151 * a scalar-valued DoF which is three times larger.
152 *
153 * interlaced: True means that a vector-valued DoF is stored as follows:
154 * U0x U0y U0z U1x U1y U1z ... UNx UNy UNz
155 * false means that its representation is as follows:
156 * U0x U1x ... UNx U0y U1y ... UNy U0z U1z ... UNz
157 */
158
161
163
164
173
174typedef struct {
175
176 /*
177 * \var matrix
178 * matrix of the system to solve
179 *
180 * \var matrix_class
181 * class of the matrix
182 *
183 * \var mav
184 * structure to manage the assembly of matrix values
185 *
186 * \var assembly_func
187 * function pointer to operate the assembly stage
188 *
189 * \var slave_assembly_func
190 * function pointer to operate the assembly stage when the system helper
191 * is declared as slave (this is the same for all matrices). Useful for
192 * coupled systems.
193 */
194
199
200 /* The following structures can be shared if the same block configuration
201 is requested */
202
207
209
210
217
218typedef struct {
219
220 /*
221 * \var n_matrices
222 * number of matrices to consider
223 *
224 * \var matrices
225 * matrix of the system to solve (the matrix id in the list of matrices
226 * corresponding to the matrix at row i and column j is i*n_matrices+j)
227 *
228 * \var mav_array
229 * array of structures to manage the assembly of matrix values
230 *
231 * \var assembly_func
232 * function pointer to operate the assembly stage (this is the same for
233 * all matrices)
234 *
235 * \var slave_assembly_func
236 * function pointer to operate the assembly stage when the system helper
237 * is declared as slave (this is the same for all matrices)
238 */
239
245
246 /* The two following structures are always shared. They correspond to the
247 scalar-valued version. */
248
251
255
257
265
266typedef struct {
267
283
286
288
289 /* The following structures can be shared if the same block configuration is
290 requested. In this case, shared_structures is set to true. By default,
291 there is no sharing. */
292
296
298
299
306
307typedef struct {
308
309 /*
310 * \var matrix
311 * matrix of the system to solve
312 *
313 * \var mav
314 * structure to manage the assembly of matrix values
315 */
316
319
320 /* Private structures */
321
326
328
329
334
335typedef struct {
336
337 /* \var info
338 * Set of metadata to describe the block
339 */
340
342
352
354
355 bool owner;
356
357 int id;
358
364
366
368
376
429
430/*============================================================================
431 * Inline public function prototypes
432 *============================================================================*/
433
434/*----------------------------------------------------------------------------*/
442/*----------------------------------------------------------------------------*/
443
446{
447 switch (solver_class) {
448
451 break;
452
454#if defined(HAVE_HYPRE)
456#else
458#endif
459 break;
460
461 default:
463 break;
464
465 }
466}
467
468/*============================================================================
469 * Public function prototypes
470 *============================================================================*/
471
472/*----------------------------------------------------------------------------*/
480/*----------------------------------------------------------------------------*/
481
482void
484 cs_cdo_connect_t *connect);
485
486/*----------------------------------------------------------------------------*/
499/*----------------------------------------------------------------------------*/
500
503 int n_col_blocks,
504 const cs_lnum_t *col_block_sizes,
505 int n_blocks);
506
507/*----------------------------------------------------------------------------*/
523/*----------------------------------------------------------------------------*/
524
527 int block_id,
529 cs_flag_t location,
530 cs_lnum_t n_elements,
531 int stride,
532 bool interlaced,
533 bool unrolled);
534
535/*----------------------------------------------------------------------------*/
549/*----------------------------------------------------------------------------*/
550
553 int block_id,
555 cs_flag_t location,
556 cs_lnum_t n_elements,
557 int stride);
558
559/*----------------------------------------------------------------------------*/
574/*----------------------------------------------------------------------------*/
575
578 int block_id,
579 const cs_adjacency_t *adjacency,
580 cs_flag_t location,
581 cs_lnum_t n_elements,
582 int stride,
583 bool interlaced);
584
585/*----------------------------------------------------------------------------*/
596/*----------------------------------------------------------------------------*/
597
600 int block_id,
601 cs_lnum_t n_dofs);
602
603/*----------------------------------------------------------------------------*/
612/*----------------------------------------------------------------------------*/
613
616 int block_id);
617
618/*----------------------------------------------------------------------------*/
632/*----------------------------------------------------------------------------*/
633
636 int block_id);
637
638/*----------------------------------------------------------------------------*/
652/*----------------------------------------------------------------------------*/
653
656 int block_id,
657 int sub_id);
658
659/*----------------------------------------------------------------------------*/
667/*----------------------------------------------------------------------------*/
668
669void
671 int block_id);
672
673/*----------------------------------------------------------------------------*/
681/*----------------------------------------------------------------------------*/
682
683void
685 cs_real_t **p_rhs);
686
687/*----------------------------------------------------------------------------*/
693/*----------------------------------------------------------------------------*/
694
695void
697
698/*----------------------------------------------------------------------------*/
704/*----------------------------------------------------------------------------*/
705
706void
708
709/*----------------------------------------------------------------------------*/
715/*----------------------------------------------------------------------------*/
716
717void
719
720/*----------------------------------------------------------------------------*/
725/*----------------------------------------------------------------------------*/
726
727void
729
730/*----------------------------------------------------------------------------*/
734/*----------------------------------------------------------------------------*/
735
736void
738
739/*----------------------------------------------------------------------------*/
740
742
743#endif /* __CS_CDO_SYSTEM_H__ */
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
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:1564
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:1174
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:1131
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:1975
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:1054
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:1406
cs_cdo_system_block_type_t
type of block composing a (block) matrix
Definition cs_cdo_system.h:91
@ CS_CDO_SYSTEM_BLOCK_UNASS
Definition cs_cdo_system.h:95
@ CS_CDO_SYSTEM_BLOCK_SPLIT
Definition cs_cdo_system.h:94
@ CS_CDO_SYSTEM_N_BLOCK_TYPES
Definition cs_cdo_system.h:98
@ CS_CDO_SYSTEM_BLOCK_DEFAULT
Definition cs_cdo_system.h:93
@ CS_CDO_SYSTEM_BLOCK_EXT
Definition cs_cdo_system.h:96
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:2036
void cs_cdo_system_allocate_assembly(void)
Initialize shared assembly structures from the existing helper structures.
Definition cs_cdo_system.c:2101
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:1494
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:1275
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:1079
cs_cdo_system_matrix_class_t
Class of matrices to consider.
Definition cs_cdo_system.h:119
@ CS_CDO_SYSTEM_MATRIX_PETSC
Definition cs_cdo_system.h:123
@ CS_CDO_SYSTEM_N_MATRIX_CLASSES
Definition cs_cdo_system.h:126
@ CS_CDO_SYSTEM_MATRIX_HYPRE
Definition cs_cdo_system.h:124
@ CS_CDO_SYSTEM_MATRIX_CS
Definition cs_cdo_system.h:122
@ CS_CDO_SYSTEM_MATRIX_NONE
Definition cs_cdo_system.h:121
void cs_cdo_system_destroy_all(void)
Free all members associated to system helpers.
Definition cs_cdo_system.c:2158
cs_cdo_system_type_t
Definition cs_cdo_system.h:62
@ CS_CDO_SYSTEM_COUPLED
Definition cs_cdo_system.h:65
@ CS_CDO_SYSTEM_SADDLE_POINT
Definition cs_cdo_system.h:66
@ CS_CDO_SYSTEM_DEFAULT
Definition cs_cdo_system.h:64
static cs_cdo_system_matrix_class_t cs_cdo_system_get_matrix_class(cs_param_sles_class_t solver_class)
Get the best available class of matrix w.r.t. the solver class.
Definition cs_cdo_system.h:445
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:1630
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:1802
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:1723
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:1682
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
#define END_C_DECLS
Definition cs_defs.h:510
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
unsigned short int cs_flag_t
Definition cs_defs.h:321
struct _cs_interface_set_t cs_interface_set_t
Definition cs_interface.h:61
struct _cs_matrix_structure_t cs_matrix_structure_t
Definition cs_matrix.h:106
struct _cs_matrix_t cs_matrix_t
Definition cs_matrix.h:110
struct _cs_matrix_assembler_t cs_matrix_assembler_t
Definition cs_matrix_assembler.h:61
struct _cs_matrix_assembler_values_t cs_matrix_assembler_values_t
Definition cs_matrix_assembler.h:65
cs_param_sles_class_t
Class of iterative solvers to consider for solver the linear system.
Definition cs_param_types.h:585
@ CS_PARAM_SLES_CLASS_HYPRE
Definition cs_param_types.h:588
@ CS_PARAM_SLES_CLASS_CS
Definition cs_param_types.h:587
Definition mesh.f90:26
Definition cs_mesh_adjacencies.h:68
Definition cs_cdo_connect.h:61
Definition cs_cdo_system.h:131
int stride
Definition cs_cdo_system.h:143
cs_cdo_system_matrix_class_t matrix_class
Definition cs_cdo_system.h:137
cs_flag_t location
Definition cs_cdo_system.h:141
bool interlaced
Definition cs_cdo_system.h:160
cs_lnum_t n_elements
Definition cs_cdo_system.h:142
bool unrolled
Definition cs_cdo_system.h:159
Definition cs_cdo_system.h:335
cs_cdo_system_block_type_t type
Definition cs_cdo_system.h:353
cs_cdo_system_block_info_t info
Definition cs_cdo_system.h:341
int id
Definition cs_cdo_system.h:357
void * block_pointer
Definition cs_cdo_system.h:365
bool owner
Definition cs_cdo_system.h:355
Structure associated to the default type of block.
Definition cs_cdo_system.h:174
cs_matrix_t * matrix
Definition cs_cdo_system.h:195
cs_cdo_assembly_func_t * slave_assembly_func
Definition cs_cdo_system.h:198
cs_interface_set_t * interface_set
Definition cs_cdo_system.h:204
cs_matrix_assembler_values_t * mav
Definition cs_cdo_system.h:196
cs_range_set_t * range_set
Definition cs_cdo_system.h:203
cs_matrix_assembler_t * matrix_assembler
Definition cs_cdo_system.h:205
cs_cdo_assembly_func_t * assembly_func
Definition cs_cdo_system.h:197
cs_matrix_structure_t * matrix_structure
Definition cs_cdo_system.h:206
Definition cs_cdo_system.h:377
cs_real_t ** rhs_array
Definition cs_cdo_system.h:423
cs_real_t * rhs
Definition cs_cdo_system.h:421
cs_lnum_t * col_block_sizes
Definition cs_cdo_system.h:417
cs_lnum_t full_rhs_size
Definition cs_cdo_system.h:420
cs_cdo_system_type_t type
Definition cs_cdo_system.h:414
int n_blocks
Definition cs_cdo_system.h:425
cs_real_t * _rhs
Definition cs_cdo_system.h:422
cs_cdo_system_block_t ** blocks
Definition cs_cdo_system.h:426
cs_lnum_t * max_col_block_sizes
Definition cs_cdo_system.h:418
int n_col_blocks
Definition cs_cdo_system.h:416
Structure associated to the split type of block.
Definition cs_cdo_system.h:218
bool matrix_struct_ownership
Definition cs_cdo_system.h:252
cs_cdo_assembly_func_t * slave_assembly_func
Definition cs_cdo_system.h:244
cs_interface_set_t * interface_set
Definition cs_cdo_system.h:250
int n_matrices
Definition cs_cdo_system.h:240
cs_matrix_assembler_values_t ** mav_array
Definition cs_cdo_system.h:242
cs_matrix_t ** matrices
Definition cs_cdo_system.h:241
cs_range_set_t * range_set
Definition cs_cdo_system.h:249
cs_matrix_assembler_t * matrix_assembler
Definition cs_cdo_system.h:253
cs_cdo_assembly_func_t * assembly_func
Definition cs_cdo_system.h:243
cs_matrix_structure_t * matrix_structure
Definition cs_cdo_system.h:254
Structure associated to the unassembled type of block.
Definition cs_cdo_system.h:266
bool shared_structures
Definition cs_cdo_system.h:293
cs_real_t * values
Definition cs_cdo_system.h:284
cs_interface_set_t * interface_set
Definition cs_cdo_system.h:295
const cs_adjacency_t * adjacency
Definition cs_cdo_system.h:287
cs_range_set_t * range_set
Definition cs_cdo_system.h:294
cs_real_t * _values
Definition cs_cdo_system.h:285
Structure associated to the extended type of block.
Definition cs_cdo_system.h:307
cs_matrix_t * matrix
Definition cs_cdo_system.h:317
cs_interface_set_t * interface_set
Definition cs_cdo_system.h:323
cs_matrix_assembler_values_t * mav
Definition cs_cdo_system.h:318
cs_range_set_t * range_set
Definition cs_cdo_system.h:322
cs_matrix_assembler_t * matrix_assembler
Definition cs_cdo_system.h:324
cs_matrix_structure_t * matrix_structure
Definition cs_cdo_system.h:325
Definition cs_mesh.h:85
Definition cs_range_set.h:57