8.3
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-2024 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 "cs_cdo_connect.h"
37#include "cs_cdo_local.h"
38#include "cs_cdo_quantities.h"
39#include "cs_param_cdo.h"
40#include "cs_property.h"
41#include "cs_sdm.h"
42
43/*----------------------------------------------------------------------------*/
44
46
47/*============================================================================
48 * Macro and type definitions
49 *============================================================================*/
50
84typedef enum {
85
94
96
98
133typedef enum {
134
140
142
144
151typedef struct {
152
154
165 double coef;
166
174
175/* DISCRETE HODGE OPERATORS */
176/* ======================== */
177
183typedef struct {
184
188
195 cs_sdm_t *matrix;
197} cs_hodge_t;
198
199/*----------------------------------------------------------------------------*/
215/*----------------------------------------------------------------------------*/
216
217typedef bool
219 cs_hodge_t *hodge,
221
222/*============================================================================
223 * Static inline public function definitions
224 *============================================================================*/
225
226/*----------------------------------------------------------------------------*/
236/*----------------------------------------------------------------------------*/
237
238static inline bool
240 const cs_hodge_param_t h2_info)
241{
242 if (h1_info.type != h2_info.type)
243 return false;
244 if (h1_info.algo != h2_info.algo)
245 return false;
246 if (h1_info.algo == CS_HODGE_ALGO_COST ||
247 h1_info.algo == CS_HODGE_ALGO_BUBBLE) {
248 if (fabs(h1_info.coef - h2_info.coef) > 0)
249 return false;
250 else
251 return true;
252 }
253 else
254 return true;
255}
256
257/*============================================================================
258 * Public function definitions
259 *============================================================================*/
260
261/*----------------------------------------------------------------------------*/
273/*----------------------------------------------------------------------------*/
274
276cs_hodge_create(const cs_cdo_connect_t *connect,
277 const cs_property_t *property,
278 const cs_hodge_param_t *hp,
279 bool need_tensor,
280 bool need_eigen);
281
282/*----------------------------------------------------------------------------*/
296/*----------------------------------------------------------------------------*/
297
298cs_hodge_t **
300 const cs_property_t *property,
301 const cs_hodge_param_t *hp,
302 bool need_tensor,
303 bool need_eigen);
304
305/*----------------------------------------------------------------------------*/
311/*----------------------------------------------------------------------------*/
312
313void
314cs_hodge_free(cs_hodge_t **p_hodge);
315
316/*----------------------------------------------------------------------------*/
322/*----------------------------------------------------------------------------*/
323
324void
326
327/*----------------------------------------------------------------------------*/
336/*----------------------------------------------------------------------------*/
337
339cs_hodge_get_func(const char *calling_func,
340 const cs_hodge_param_t hp);
341
342/*----------------------------------------------------------------------------*/
355/*----------------------------------------------------------------------------*/
356
358cs_hodge_set_mass_algo(const char *eqname,
359 cs_hodge_algo_t reac_algo,
360 cs_hodge_algo_t time_algo);
361
362/*----------------------------------------------------------------------------*/
370/*----------------------------------------------------------------------------*/
371
372void
373cs_hodge_param_log(const char *prefix,
374 const cs_property_t *property,
375 const cs_hodge_param_t hp);
376
377/*----------------------------------------------------------------------------*/
385/*----------------------------------------------------------------------------*/
386
387void
389 cs_hodge_param_t *h_cpy);
390
391/*----------------------------------------------------------------------------*/
402/*----------------------------------------------------------------------------*/
403
404void
406 const cs_real_t t_eval,
407 const cs_flag_t c_flag,
408 cs_hodge_t *hodge);
409
410/*----------------------------------------------------------------------------*/
422/*----------------------------------------------------------------------------*/
423
424void
426 const cs_real_t t_eval,
427 const cs_flag_t c_flag,
428 cs_hodge_t *hodge);
429
430/*----------------------------------------------------------------------------*/
443/*----------------------------------------------------------------------------*/
444
445bool
447 cs_hodge_t *hodge,
449
450/*----------------------------------------------------------------------------*/
464/*----------------------------------------------------------------------------*/
465
466bool
468 cs_hodge_t *hodge,
470
471/*----------------------------------------------------------------------------*/
484/*----------------------------------------------------------------------------*/
485
486bool
488 cs_hodge_t *hodge,
490
491/*----------------------------------------------------------------------------*/
504/*----------------------------------------------------------------------------*/
505
506bool
508 cs_hodge_t *hodge,
510
511/*----------------------------------------------------------------------------*/
524/*----------------------------------------------------------------------------*/
525
526bool
528 cs_hodge_t *hodge,
530
531/*----------------------------------------------------------------------------*/
544/*----------------------------------------------------------------------------*/
545
546bool
548 cs_hodge_t *hodge,
550
551/*----------------------------------------------------------------------------*/
564/*----------------------------------------------------------------------------*/
565
566bool
568 cs_hodge_t *hodge,
570
571/*----------------------------------------------------------------------------*/
584/*----------------------------------------------------------------------------*/
585
586bool
588 cs_hodge_t *hodge,
590
591/*----------------------------------------------------------------------------*/
604/*----------------------------------------------------------------------------*/
605
606bool
608 cs_hodge_t *hodge,
610
611/*----------------------------------------------------------------------------*/
623/*----------------------------------------------------------------------------*/
624
625bool
627 cs_hodge_t *hodge,
629
630/*----------------------------------------------------------------------------*/
642/*----------------------------------------------------------------------------*/
643
644bool
646 cs_hodge_t *hodge,
648
649/*----------------------------------------------------------------------------*/
662/*----------------------------------------------------------------------------*/
663
664bool
666 cs_hodge_t *hodge,
668
669/*----------------------------------------------------------------------------*/
682/*----------------------------------------------------------------------------*/
683
684bool
686 cs_hodge_t *hodge,
688
689/*----------------------------------------------------------------------------*/
701/*----------------------------------------------------------------------------*/
702
703bool
705 cs_hodge_t *hodge,
707
708/*----------------------------------------------------------------------------*/
721/*----------------------------------------------------------------------------*/
722
723bool
725 cs_hodge_t *hodge,
727
728/*----------------------------------------------------------------------------*/
741/*----------------------------------------------------------------------------*/
742
743bool
745 cs_hodge_t *hodge,
747
748/*----------------------------------------------------------------------------*/
761/*----------------------------------------------------------------------------*/
762
763bool
765 cs_hodge_t *hodge,
767
768/*----------------------------------------------------------------------------*/
781/*----------------------------------------------------------------------------*/
782
783bool
785 cs_hodge_t *hodge,
787
788/*----------------------------------------------------------------------------*/
802/*----------------------------------------------------------------------------*/
803
804bool
806 cs_hodge_t *hodge,
808
809/*----------------------------------------------------------------------------*/
822/*----------------------------------------------------------------------------*/
823
824bool
826 cs_hodge_t *hodge,
828
829/*----------------------------------------------------------------------------*/
842/*----------------------------------------------------------------------------*/
843
844bool
846 cs_hodge_t *hodge,
848
849/*----------------------------------------------------------------------------*/
862/*----------------------------------------------------------------------------*/
863
864bool
866 cs_hodge_t *hodge,
868
869/*----------------------------------------------------------------------------*/
882/*----------------------------------------------------------------------------*/
883
884bool
886 cs_hodge_t *hodge,
888
889/*----------------------------------------------------------------------------*/
901/*----------------------------------------------------------------------------*/
902
903bool
905 cs_hodge_t *hodge,
907
908/*----------------------------------------------------------------------------*/
921/*----------------------------------------------------------------------------*/
922
923bool
925 cs_hodge_t *hodge,
927
928/*----------------------------------------------------------------------------*/
940/*----------------------------------------------------------------------------*/
941
942bool
944 cs_hodge_t *hodge,
946
947/*----------------------------------------------------------------------------*/
960/*----------------------------------------------------------------------------*/
961
962bool
964 cs_hodge_t *hodge,
966
967/*----------------------------------------------------------------------------*/
980/*----------------------------------------------------------------------------*/
981
982void
983cs_hodge_matvec(const cs_cdo_connect_t *connect,
984 const cs_cdo_quantities_t *quant,
985 const cs_hodge_param_t hodgep,
986 const cs_property_t *pty,
987 const cs_real_t in_vals[],
988 cs_real_t t_eval,
989 cs_real_t result[]);
990
991/*----------------------------------------------------------------------------*/
1004/*----------------------------------------------------------------------------*/
1005
1006void
1008 const cs_cdo_quantities_t *quant,
1009 cs_real_t t_eval,
1010 const cs_hodge_param_t hodgep,
1011 const cs_property_t *pty,
1012 const cs_real_t flux[],
1013 cs_real_t circul[]);
1014
1015/*----------------------------------------------------------------------------*/
1024/*----------------------------------------------------------------------------*/
1025
1026void
1028 cs_sdm_t *hf);
1029
1030/*----------------------------------------------------------------------------*/
1031
1033
1034#endif /* __CS_HODGE_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
#define END_C_DECLS
Definition: cs_defs.h:543
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
unsigned short int cs_flag_t
Definition: cs_defs.h:344
@ fm
Definition: cs_field_pointer.h:129
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:218
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:2969
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:1459
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:4474
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:1535
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:239
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:2121
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:3299
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:3557
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:3976
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:3633
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:4062
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:1934
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:3724
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:1223
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:3887
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:1158
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:3108
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:1795
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:2651
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:2889
void cs_hodge_free_context(cs_hodge_t ***p_hodges)
Free a set of cs_hodge_t structures.
Definition: cs_hodge.cpp:1288
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:4148
cs_hodge_algo_t
Type of algorithm to build a discrete Hodge operator.
Definition: cs_hodge.h:133
@ CS_HODGE_ALGO_WBS
Definition: cs_hodge.h:136
@ CS_HODGE_ALGO_AUTO
Definition: cs_hodge.h:139
@ CS_HODGE_ALGO_BUBBLE
Definition: cs_hodge.h:138
@ CS_HODGE_ALGO_VORONOI
Definition: cs_hodge.h:135
@ CS_HODGE_N_ALGOS
Definition: cs_hodge.h:141
@ CS_HODGE_ALGO_COST
Definition: cs_hodge.h:137
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:1997
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:1724
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:1865
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:3473
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:4369
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:1643
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:2183
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:1561
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:3381
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:2514
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:1321
cs_hodge_type_t
Type of discrete Hodge operators.
Definition: cs_hodge.h:84
@ CS_HODGE_N_TYPES
Definition: cs_hodge.h:95
@ CS_HODGE_TYPE_VPCD
Definition: cs_hodge.h:86
@ CS_HODGE_TYPE_EDFP
Definition: cs_hodge.h:89
@ CS_HODGE_TYPE_VDCP
Definition: cs_hodge.h:91
@ CS_HODGE_TYPE_VC
Definition: cs_hodge.h:93
@ CS_HODGE_TYPE_FPED
Definition: cs_hodge.h:88
@ CS_HODGE_TYPE_CPVD
Definition: cs_hodge.h:90
@ CS_HODGE_TYPE_EPFD
Definition: cs_hodge.h:87
@ CS_HODGE_TYPE_FB
Definition: cs_hodge.h:92
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:2803
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:3237
void cs_hodge_free(cs_hodge_t **p_hodge)
Free a cs_hodge_t structure.
Definition: cs_hodge.cpp:1262
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:3810
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:2408
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:1499
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:2059
Definition: cs_cdo_connect.h:61
Definition: cs_cdo_quantities.h:139
Set of local and temporary buffers.
Definition: cs_cdo_local.h:60
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:203
Set of local quantities and connectivities related to a mesh face Structure used to get a better memo...
Definition: cs_cdo_local.h:280
Structure storing all metadata/parameters related to the usage of a discrete Hodge operator.
Definition: cs_hodge.h:151
double coef
Scaling coefficient value.
Definition: cs_hodge.h:165
cs_hodge_type_t type
Definition: cs_hodge.h:162
bool inv_pty
Inversion of the property evaluation or not.
Definition: cs_hodge.h:153
cs_hodge_algo_t algo
Definition: cs_hodge.h:163
Structure associated to a discrete Hodge operator *.
Definition: cs_hodge.h:183
cs_sdm_t * matrix
Definition: cs_hodge.h:195
const cs_hodge_param_t * param
Definition: cs_hodge.h:185
cs_property_data_t * pty_data
Data evaluation.
Definition: cs_hodge.h:187
Structure storing the evaluation of a property and its related data.
Definition: cs_property.h:223
Structure associated to the definition of a property relying on the cs_xdef_t structure.