9.2
general documentation
cs_hodge.h
Go to the documentation of this file.
1#ifndef CS_HODGE_H
2#define CS_HODGE_H
3
4/*============================================================================
5 * Manage discrete Hodge operators and closely related operators
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 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 * Standard C library headers
30 *----------------------------------------------------------------------------*/
31
32/*----------------------------------------------------------------------------
33 * Local headers
34 *----------------------------------------------------------------------------*/
35
36#include "cdo/cs_cdo_connect.h"
37#include "cdo/cs_cdo_local.h"
39#include "cdo/cs_param_cdo.h"
40#include "cdo/cs_property.h"
41#include "cdo/cs_sdm.h"
42
43/*============================================================================
44 * Macro and type definitions
45 *============================================================================*/
46
80typedef enum {
81
90
92
94
129typedef enum {
130
136
138
140
147typedef struct {
148
150
161 double coef;
162
170
171/* DISCRETE HODGE OPERATORS */
172/* ======================== */
173
179typedef struct {
180
184
191 cs_sdm_t *matrix;
193} cs_hodge_t;
194
195/*----------------------------------------------------------------------------*/
211/*----------------------------------------------------------------------------*/
212
213typedef bool
215 cs_hodge_t *hodge,
217
218/*============================================================================
219 * Static inline public function definitions
220 *============================================================================*/
221
222/*----------------------------------------------------------------------------*/
232/*----------------------------------------------------------------------------*/
233
234static inline bool
236 const cs_hodge_param_t h2_info)
237{
238 if (h1_info.type != h2_info.type)
239 return false;
240 if (h1_info.algo != h2_info.algo)
241 return false;
242 if (h1_info.algo == CS_HODGE_ALGO_COST ||
243 h1_info.algo == CS_HODGE_ALGO_BUBBLE) {
244 if (cs::abs(h1_info.coef - h2_info.coef) > 0)
245 return false;
246 else
247 return true;
248 }
249 else
250 return true;
251}
252
253/*============================================================================
254 * Public function definitions
255 *============================================================================*/
256
257/*----------------------------------------------------------------------------*/
269/*----------------------------------------------------------------------------*/
270
272cs_hodge_create(const cs_cdo_connect_t *connect,
273 const cs_property_t *property,
274 const cs_hodge_param_t *hp,
275 bool need_tensor,
276 bool need_eigen);
277
278/*----------------------------------------------------------------------------*/
292/*----------------------------------------------------------------------------*/
293
294cs_hodge_t **
296 const cs_property_t *property,
297 const cs_hodge_param_t *hp,
298 bool need_tensor,
299 bool need_eigen);
300
301/*----------------------------------------------------------------------------*/
307/*----------------------------------------------------------------------------*/
308
309void
310cs_hodge_free(cs_hodge_t **p_hodge);
311
312/*----------------------------------------------------------------------------*/
318/*----------------------------------------------------------------------------*/
319
320void
322
323/*----------------------------------------------------------------------------*/
332/*----------------------------------------------------------------------------*/
333
335cs_hodge_get_func(const char *calling_func,
336 const cs_hodge_param_t hp);
337
338/*----------------------------------------------------------------------------*/
351/*----------------------------------------------------------------------------*/
352
354cs_hodge_set_mass_algo(const char *eqname,
355 cs_hodge_algo_t reac_algo,
356 cs_hodge_algo_t time_algo);
357
358/*----------------------------------------------------------------------------*/
366/*----------------------------------------------------------------------------*/
367
368void
369cs_hodge_param_log(const char *prefix,
370 const cs_property_t *property,
371 const cs_hodge_param_t hp);
372
373/*----------------------------------------------------------------------------*/
381/*----------------------------------------------------------------------------*/
382
383void
385 cs_hodge_param_t *h_cpy);
386
387/*----------------------------------------------------------------------------*/
398/*----------------------------------------------------------------------------*/
399
400void
402 const cs_real_t t_eval,
403 const cs_flag_t c_flag,
404 cs_hodge_t *hodge);
405
406/*----------------------------------------------------------------------------*/
418/*----------------------------------------------------------------------------*/
419
420void
422 const cs_real_t t_eval,
423 const cs_flag_t c_flag,
424 cs_hodge_t *hodge);
425
426/*----------------------------------------------------------------------------*/
439/*----------------------------------------------------------------------------*/
440
441bool
443 cs_hodge_t *hodge,
445
446/*----------------------------------------------------------------------------*/
460/*----------------------------------------------------------------------------*/
461
462bool
464 cs_hodge_t *hodge,
466
467/*----------------------------------------------------------------------------*/
480/*----------------------------------------------------------------------------*/
481
482bool
484 cs_hodge_t *hodge,
486
487/*----------------------------------------------------------------------------*/
500/*----------------------------------------------------------------------------*/
501
502bool
504 cs_hodge_t *hodge,
506
507/*----------------------------------------------------------------------------*/
520/*----------------------------------------------------------------------------*/
521
522bool
524 cs_hodge_t *hodge,
526
527/*----------------------------------------------------------------------------*/
540/*----------------------------------------------------------------------------*/
541
542bool
544 cs_hodge_t *hodge,
546
547/*----------------------------------------------------------------------------*/
560/*----------------------------------------------------------------------------*/
561
562bool
564 cs_hodge_t *hodge,
566
567/*----------------------------------------------------------------------------*/
580/*----------------------------------------------------------------------------*/
581
582bool
584 cs_hodge_t *hodge,
586
587/*----------------------------------------------------------------------------*/
600/*----------------------------------------------------------------------------*/
601
602bool
604 cs_hodge_t *hodge,
606
607/*----------------------------------------------------------------------------*/
619/*----------------------------------------------------------------------------*/
620
621bool
623 cs_hodge_t *hodge,
625
626/*----------------------------------------------------------------------------*/
638/*----------------------------------------------------------------------------*/
639
640bool
642 cs_hodge_t *hodge,
644
645/*----------------------------------------------------------------------------*/
658/*----------------------------------------------------------------------------*/
659
660bool
662 cs_hodge_t *hodge,
664
665/*----------------------------------------------------------------------------*/
678/*----------------------------------------------------------------------------*/
679
680bool
682 cs_hodge_t *hodge,
684
685/*----------------------------------------------------------------------------*/
697/*----------------------------------------------------------------------------*/
698
699bool
701 cs_hodge_t *hodge,
703
704/*----------------------------------------------------------------------------*/
717/*----------------------------------------------------------------------------*/
718
719bool
721 cs_hodge_t *hodge,
723
724/*----------------------------------------------------------------------------*/
737/*----------------------------------------------------------------------------*/
738
739bool
741 cs_hodge_t *hodge,
743
744/*----------------------------------------------------------------------------*/
757/*----------------------------------------------------------------------------*/
758
759bool
761 cs_hodge_t *hodge,
763
764/*----------------------------------------------------------------------------*/
777/*----------------------------------------------------------------------------*/
778
779bool
781 cs_hodge_t *hodge,
783
784/*----------------------------------------------------------------------------*/
798/*----------------------------------------------------------------------------*/
799
800bool
802 cs_hodge_t *hodge,
804
805/*----------------------------------------------------------------------------*/
818/*----------------------------------------------------------------------------*/
819
820bool
822 cs_hodge_t *hodge,
824
825/*----------------------------------------------------------------------------*/
838/*----------------------------------------------------------------------------*/
839
840bool
842 cs_hodge_t *hodge,
844
845/*----------------------------------------------------------------------------*/
858/*----------------------------------------------------------------------------*/
859
860bool
862 cs_hodge_t *hodge,
864
865/*----------------------------------------------------------------------------*/
878/*----------------------------------------------------------------------------*/
879
880bool
882 cs_hodge_t *hodge,
884
885/*----------------------------------------------------------------------------*/
897/*----------------------------------------------------------------------------*/
898
899bool
901 cs_hodge_t *hodge,
903
904/*----------------------------------------------------------------------------*/
917/*----------------------------------------------------------------------------*/
918
919bool
921 cs_hodge_t *hodge,
923
924/*----------------------------------------------------------------------------*/
936/*----------------------------------------------------------------------------*/
937
938bool
940 cs_hodge_t *hodge,
942
943/*----------------------------------------------------------------------------*/
956/*----------------------------------------------------------------------------*/
957
958bool
960 cs_hodge_t *hodge,
962
963/*----------------------------------------------------------------------------*/
976/*----------------------------------------------------------------------------*/
977
978void
979cs_hodge_matvec(const cs_cdo_connect_t *connect,
980 const cs_cdo_quantities_t *quant,
981 const cs_hodge_param_t hodgep,
982 const cs_property_t *pty,
983 const cs_real_t in_vals[],
984 cs_real_t t_eval,
985 cs_real_t result[]);
986
987/*----------------------------------------------------------------------------*/
1000/*----------------------------------------------------------------------------*/
1001
1002void
1004 const cs_cdo_quantities_t *quant,
1005 cs_real_t t_eval,
1006 const cs_hodge_param_t hodgep,
1007 const cs_property_t *pty,
1008 const cs_real_t flux[],
1009 cs_real_t circul[]);
1010
1011/*----------------------------------------------------------------------------*/
1020/*----------------------------------------------------------------------------*/
1021
1022void
1024 cs_sdm_t *hf);
1025
1026#endif /* CS_HODGE_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
unsigned short int cs_flag_t
Definition: cs_defs.h:334
@ fm
Definition: cs_field_pointer.h:126
bool() cs_hodge_compute_t(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a discrete Hodge operator or a related operator (such as the stiffmess matrix) for a given cell...
Definition: cs_hodge.h:214
bool cs_hodge_vcb_wbs_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the WBS algo. This function is specific for verte...
Definition: cs_hodge.cpp:2957
cs_hodge_algo_t cs_hodge_set_mass_algo(const char *eqname, cs_hodge_algo_t reac_algo, cs_hodge_algo_t time_algo)
Check the consistency of the settings between terms related to a mass matrix and define the common al...
Definition: cs_hodge.cpp:1451
void cs_hodge_compute_wbs_surfacic(const cs_face_mesh_t *fm, cs_sdm_t *hf)
Compute the hodge operator related to a face (i.e. a mass matrix with unity property) using a Whitney...
Definition: cs_hodge.cpp:4462
void cs_hodge_copy_parameters(const cs_hodge_param_t *h_ref, cs_hodge_param_t *h_cpy)
Copy the set of parameters associated to a discrete Hodge operator to another one.
Definition: cs_hodge.cpp:1527
static bool cs_hodge_param_is_similar(const cs_hodge_param_t h1_info, const cs_hodge_param_t h2_info)
Check if two sets of parameters related to how build a discrete Hodge operator are similar.
Definition: cs_hodge.h:235
bool cs_hodge_vb_bubble_get_aniso_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic Bubble algo. The computed matrix is stored in cb->lo...
Definition: cs_hodge.cpp:2109
bool cs_hodge_epfd_voro_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using VORONOI algo. Hodge op. from primal edges to dual...
Definition: cs_hodge.cpp:3287
bool cs_hodge_fped_voro_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using VORONOI algo. Hodge op. from primal faces to dual...
Definition: cs_hodge.cpp:3545
bool cs_hodge_edfp_cost_get_opt(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the COST algo. Hodge op. from dual edges to prima...
Definition: cs_hodge.cpp:3964
bool cs_hodge_fped_cost_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the COST algo. Hodge op. from primal faces to dua...
Definition: cs_hodge.cpp:3621
bool cs_hodge_edfp_bubble_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the Bubble algo. Hodge op. from dual edges to pri...
Definition: cs_hodge.cpp:4050
bool cs_hodge_vb_cost_get_iso_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic COST algo. The computed matrix is stored in cb->loc ...
Definition: cs_hodge.cpp:1922
bool cs_hodge_fped_bubble_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the Bubble algo. Hodge op. from primal faces to d...
Definition: cs_hodge.cpp:3712
cs_hodge_t ** cs_hodge_init_context(const cs_cdo_connect_t *connect, const cs_property_t *property, const cs_hodge_param_t *hp, bool need_tensor, bool need_eigen)
Create and initialize an array of pointers to a cs_hodge_t structures. This array is of size the numb...
Definition: cs_hodge.cpp:1215
bool cs_hodge_edfp_cost_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the COST algo. Hodge op. from dual edges to prima...
Definition: cs_hodge.cpp:3875
cs_hodge_t * cs_hodge_create(const cs_cdo_connect_t *connect, const cs_property_t *property, const cs_hodge_param_t *hp, bool need_tensor, bool need_eigen)
Create and initialize a pointer to a cs_hodge_t structure.
Definition: cs_hodge.cpp:1150
bool cs_hodge_vpcd_wbs_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using WBS algo. Hodge op. from primal vertices to dual ...
Definition: cs_hodge.cpp:3096
bool cs_hodge_fb_bubble_get_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic COST algo. with the usage of bubble stabilization....
Definition: cs_hodge.cpp:1783
bool cs_hodge_vcb_get_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic WBS algo. WBS means Whitney Barycentric Subdivision ...
Definition: cs_hodge.cpp:2639
bool cs_hodge_vcb_voro_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the Voronoi algo. This leads to a diagonal operat...
Definition: cs_hodge.cpp:2877
void cs_hodge_free_context(cs_hodge_t ***p_hodges)
Free a set of cs_hodge_t structures.
Definition: cs_hodge.cpp:1280
void cs_hodge_matvec(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_hodge_param_t hodgep, const cs_property_t *pty, const cs_real_t in_vals[], cs_real_t t_eval, cs_real_t result[])
Compute cellwise a discrete hodge operator and multiple it with a vector.
Definition: cs_hodge.cpp:4136
cs_hodge_algo_t
Type of algorithm to build a discrete Hodge operator.
Definition: cs_hodge.h:129
@ CS_HODGE_ALGO_WBS
Definition: cs_hodge.h:132
@ CS_HODGE_ALGO_AUTO
Definition: cs_hodge.h:135
@ CS_HODGE_ALGO_BUBBLE
Definition: cs_hodge.h:134
@ CS_HODGE_ALGO_VORONOI
Definition: cs_hodge.h:131
@ CS_HODGE_N_ALGOS
Definition: cs_hodge.h:137
@ CS_HODGE_ALGO_COST
Definition: cs_hodge.h:133
bool cs_hodge_vb_cost_get_aniso_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic COST algo. The computed matrix is stored in cb->loc ...
Definition: cs_hodge.cpp:1985
bool cs_hodge_fb_cost_get_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic COST algo. The computed matrix is stored in cb->loc ...
Definition: cs_hodge.cpp:1716
bool cs_hodge_fb_voro_get_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the Voronoi algorithm The computed matrix is stored in cb->loc a...
Definition: cs_hodge.cpp:1853
bool cs_hodge_epfd_bubble_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the COST algo. with a bubble stabilization....
Definition: cs_hodge.cpp:3461
void cs_hodge_circulation_from_flux(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, cs_real_t t_eval, const cs_hodge_param_t hodgep, const cs_property_t *pty, const cs_real_t flux[], cs_real_t circul[])
Compute cellwise a discrete hodge operator in order to define a circulation array from a flux array.
Definition: cs_hodge.cpp:4357
void cs_hodge_evaluate_property_cw(const cs_cell_mesh_t *cm, const cs_real_t t_eval, const cs_flag_t c_flag, cs_hodge_t *hodge)
Set the property value (scalar- or tensor-valued) related to a discrete Hodge operator inside a cell ...
Definition: cs_hodge.cpp:1635
bool cs_hodge_vb_cost_get_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic COST algo. The computed matrix is stored in cb->loc ...
Definition: cs_hodge.cpp:2171
void cs_hodge_evaluate_property(const cs_lnum_t c_id, const cs_real_t t_eval, const cs_flag_t c_flag, cs_hodge_t *hodge)
Set the property value (scalar- or tensor-valued) related to a discrete Hodge operator inside a cell ...
Definition: cs_hodge.cpp:1553
bool cs_hodge_epfd_cost_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using the COST algo. Hodge op. from primal edges to dua...
Definition: cs_hodge.cpp:3369
bool cs_hodge_vb_wbs_get_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic WBS algo. WBS means for Whitney Barycentric Subdivis...
Definition: cs_hodge.cpp:2502
cs_hodge_compute_t * cs_hodge_get_func(const char *calling_func, const cs_hodge_param_t hp)
Retrieve a function pointer to compute a discrete Hodge operator.
Definition: cs_hodge.cpp:1313
cs_hodge_type_t
Type of discrete Hodge operators.
Definition: cs_hodge.h:80
@ CS_HODGE_N_TYPES
Definition: cs_hodge.h:91
@ CS_HODGE_TYPE_VPCD
Definition: cs_hodge.h:82
@ CS_HODGE_TYPE_EDFP
Definition: cs_hodge.h:85
@ CS_HODGE_TYPE_VDCP
Definition: cs_hodge.h:87
@ CS_HODGE_TYPE_VC
Definition: cs_hodge.h:89
@ CS_HODGE_TYPE_FPED
Definition: cs_hodge.h:84
@ CS_HODGE_TYPE_CPVD
Definition: cs_hodge.h:86
@ CS_HODGE_TYPE_EPFD
Definition: cs_hodge.h:83
@ CS_HODGE_TYPE_FB
Definition: cs_hodge.h:88
bool cs_hodge_fb_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator on a given cell which is equivalent of a mass matrix....
Definition: cs_hodge.cpp:2791
bool cs_hodge_vpcd_voro_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using VORONOI algo. Hodge op. from primal vertices to d...
Definition: cs_hodge.cpp:3225
void cs_hodge_free(cs_hodge_t **p_hodge)
Free a cs_hodge_t structure.
Definition: cs_hodge.cpp:1254
bool cs_hodge_edfp_voro_get(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local Hodge operator for a given cell using VORONOI algo. Hodge op. from dual edges to primal...
Definition: cs_hodge.cpp:3798
bool cs_hodge_vb_voro_get_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the Voronoi algorithm The computed matrix is stored in cb->loc a...
Definition: cs_hodge.cpp:2396
void cs_hodge_param_log(const char *prefix, const cs_property_t *property, const cs_hodge_param_t hp)
Output the settings related to a cs_hodge_param_t structure.
Definition: cs_hodge.cpp:1491
bool cs_hodge_vb_bubble_get_iso_stiffness(const cs_cell_mesh_t *cm, cs_hodge_t *hodge, cs_cell_builder_t *cb)
Build a local stiffness matrix using the generic Bubble algo. The computed matrix is stored in cb->lo...
Definition: cs_hodge.cpp:2047
CS_F_HOST_DEVICE T abs(const T a)
Definition: cs_defs.h:690
Definition: cs_cdo_connect.h:57
Definition: cs_cdo_quantities.h:142
Set of local and temporary buffers.
Definition: cs_cdo_local.h:56
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:242
Set of local quantities and connectivities related to a mesh face Structure used to get a better memo...
Definition: cs_cdo_local.h:432
Structure storing all metadata/parameters related to the usage of a discrete Hodge operator.
Definition: cs_hodge.h:147
double coef
Scaling coefficient value.
Definition: cs_hodge.h:161
cs_hodge_type_t type
Definition: cs_hodge.h:158
bool inv_pty
Inversion of the property evaluation or not.
Definition: cs_hodge.h:149
cs_hodge_algo_t algo
Definition: cs_hodge.h:159
Structure associated to a discrete Hodge operator *.
Definition: cs_hodge.h:179
cs_sdm_t * matrix
Definition: cs_hodge.h:191
const cs_hodge_param_t * param
Definition: cs_hodge.h:181
cs_property_data_t * pty_data
Data evaluation.
Definition: cs_hodge.h:183
Structure storing the evaluation of a property and its related data.
Definition: cs_property.h:219
Structure associated to the definition of a property relying on the cs_xdef_t structure.