programmer's documentation
cs_cdofb_navsto.h
Go to the documentation of this file.
1 #ifndef __CS_CDOFB_NAVSTO_H__
2 #define __CS_CDOFB_NAVSTO_H__
3 
4 /*============================================================================
5  * Routines shared among all face-based schemes for the discretization of the
6  * Navier--Stokes system
7  *============================================================================*/
8 
9 /*
10  This file is part of Code_Saturne, a general-purpose CFD tool.
11 
12  Copyright (C) 1998-2019 EDF S.A.
13 
14  This program is free software; you can redistribute it and/or modify it under
15  the terms of the GNU General Public License as published by the Free Software
16  Foundation; either version 2 of the License, or (at your option) any later
17  version.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22  details.
23 
24  You should have received a copy of the GNU General Public License along with
25  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26  Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28 
29 /*----------------------------------------------------------------------------*/
30 
31 #include "cs_defs.h"
32 
33 /*----------------------------------------------------------------------------
34  * Standard C library headers
35  *----------------------------------------------------------------------------*/
36 
37 /*----------------------------------------------------------------------------
38  * Local headers
39  *----------------------------------------------------------------------------*/
40 
41 #include "cs_base.h"
42 #include "cs_cdo_connect.h"
43 #include "cs_cdo_quantities.h"
44 #include "cs_field.h"
45 #include "cs_math.h"
46 #include "cs_matrix.h"
47 #include "cs_mesh.h"
48 #include "cs_navsto_param.h"
49 #include "cs_time_step.h"
50 #include "cs_sdm.h"
51 
52 /*----------------------------------------------------------------------------*/
53 
55 
56 /*============================================================================
57  * Macro definitions
58  *============================================================================*/
59 
60 /*============================================================================
61  * Type definitions
62  *============================================================================*/
63 
64 /* Structure storing additional arrays related to the building of the system in
65  case of CDO Face-based scheme. This structure is associated to a cell-wise
66  building */
67 
68 typedef struct {
69 
70  /* Operator */
71  cs_real_t *div_op; /* Size: 3*n_fc
72  div_op = -|c|div */
73 
74  /* Boundary conditions */
75  cs_boundary_type_t *bf_type; /* Size: n_fc */
76  cs_real_t *pressure_bc_val; /* Size: n_fc */
77 
79 
80 /*============================================================================
81  * Static inline public function prototypes
82  *============================================================================*/
83 
84 /*----------------------------------------------------------------------------*/
93 /*----------------------------------------------------------------------------*/
94 
95 static inline void
97  cs_real_t div[])
98 {
99  /* D(\hat{u}) = \frac{1}{|c|} \sum_{f_c} \iota_{fc} u_f.f
100  * But, when integrating [[ p, q ]]_{P_c} = |c| p_c q_c
101  * Thus, the volume in the divergence drops
102  */
103 
104  for (short int f = 0; f < cm->n_fc; f++) {
105 
106  const cs_quant_t pfq = cm->face[f];
107  const cs_real_t i_f = cm->f_sgn[f] * pfq.meas;
108 
109  cs_real_t *_div_f = div + 3*f;
110  _div_f[0] = i_f * pfq.unitv[0];
111  _div_f[1] = i_f * pfq.unitv[1];
112  _div_f[2] = i_f * pfq.unitv[2];
113 
114  } /* Loop on cell faces */
115 }
116 
117 /*============================================================================
118  * Public function prototypes
119  *============================================================================*/
120 
121 /*----------------------------------------------------------------------------*/
129 /*----------------------------------------------------------------------------*/
130 
133 
134 /*----------------------------------------------------------------------------*/
140 /*----------------------------------------------------------------------------*/
141 
142 void
144 
145 /*----------------------------------------------------------------------------*/
157 /*----------------------------------------------------------------------------*/
158 
159 void
161  const cs_navsto_param_t *nsp,
162  const cs_cell_mesh_t *cm,
163  const cs_cell_sys_t *csys,
164  const cs_cdo_bc_face_t *pr_bc,
165  const cs_boundary_type_t *bf_type,
167 
168 /*----------------------------------------------------------------------------*/
180 /*----------------------------------------------------------------------------*/
181 
182 cs_real_t
184  const cs_cdo_quantities_t *quant,
185  const cs_adjacency_t *c2f,
186  const cs_real_t *f_vals);
187 
188 /*----------------------------------------------------------------------------*/
198 /*----------------------------------------------------------------------------*/
199 
200 void
201 cs_cdofb_navsto_add_grad_div(short int n_fc,
202  const cs_real_t zeta,
203  const cs_real_t div[],
204  cs_sdm_t *mat);
205 
206 /*----------------------------------------------------------------------------*/
215 /*----------------------------------------------------------------------------*/
216 
217 void
219  const cs_cdo_quantities_t *quant,
220  const cs_time_step_t *ts,
221  cs_field_t *pr);
222 
223 /*----------------------------------------------------------------------------*/
233 /*----------------------------------------------------------------------------*/
234 
235 void
237  const cs_cdo_quantities_t *quant,
238  const cs_time_step_t *ts,
239  cs_real_t *pr_f);
240 
241 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
251 void
253  cs_real_t values[]);
254 
255 /*----------------------------------------------------------------------------*/
266 /*----------------------------------------------------------------------------*/
267 
268 void
270  const cs_cdo_quantities_t *quant,
271  const cs_cdo_connect_t *connect,
272  const cs_adv_field_t *adv_field);
273 
274 /*----------------------------------------------------------------------------*/
289 /*----------------------------------------------------------------------------*/
290 
291 void
293  const cs_equation_param_t *eqp,
294  const cs_cell_mesh_t *cm,
295  cs_cell_builder_t *cb,
296  cs_cell_sys_t *csys);
297 
298 /*----------------------------------------------------------------------------*/
313 /*----------------------------------------------------------------------------*/
314 
315 void
317  const cs_equation_param_t *eqp,
318  const cs_cell_mesh_t *cm,
319  cs_cell_builder_t *cb,
320  cs_cell_sys_t *csys);
321 
322 /*----------------------------------------------------------------------------*/
337 /*----------------------------------------------------------------------------*/
338 
339 void
341  const cs_equation_param_t *eqp,
342  const cs_cell_mesh_t *cm,
343  cs_cell_builder_t *cb,
344  cs_cell_sys_t *csys);
345 
346 /*----------------------------------------------------------------------------*/
361 /*----------------------------------------------------------------------------*/
362 
363 void
365  const cs_equation_param_t *eqp,
366  const cs_cell_mesh_t *cm,
367  cs_cell_builder_t *cb,
368  cs_cell_sys_t *csys);
369 
370 /*----------------------------------------------------------------------------*/
384 /*----------------------------------------------------------------------------*/
385 
386 void
387 cs_cdofb_symmetry(short int f,
388  const cs_equation_param_t *eqp,
389  const cs_cell_mesh_t *cm,
390  cs_cell_builder_t *cb,
391  cs_cell_sys_t *csys);
392 
393 /*----------------------------------------------------------------------------*/
405 /*----------------------------------------------------------------------------*/
406 
407 void
408 cs_cdofb_fixed_wall(short int f,
409  const cs_equation_param_t *eqp,
410  const cs_cell_mesh_t *cm,
411  cs_cell_builder_t *cb,
412  cs_cell_sys_t *csys);
413 
414 /*----------------------------------------------------------------------------*/
415 
417 
418 #endif /* __CS_CDOFB_NAVSTO_H__ */
void cs_cdofb_navsto_define_builder(cs_real_t t_eval, const cs_navsto_param_t *nsp, const cs_cell_mesh_t *cm, const cs_cell_sys_t *csys, const cs_cdo_bc_face_t *pr_bc, const cs_boundary_type_t *bf_type, cs_cdofb_navsto_builder_t *nsb)
Set the members of the cs_cdofb_navsto_builder_t structure.
Definition: cs_cdofb_navsto.c:230
time step descriptor
Definition: cs_time_step.h:51
cs_boundary_type_t
Definition: cs_boundary.h:51
Definition: cs_advection_field.h:149
Field descriptor.
Definition: cs_field.h:124
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:148
void cs_cdofb_navsto_add_grad_div(short int n_fc, const cs_real_t zeta, const cs_real_t div[], cs_sdm_t *mat)
Add the grad-div part to the local matrix (i.e. for the current cell)
Definition: cs_cdofb_navsto.c:411
cs_real_t * pressure_bc_val
Definition: cs_cdofb_navsto.h:76
Definition: cs_mesh_adjacencies.h:90
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
double meas
Definition: cs_cdo_quantities.h:88
Set of local quantities and connectivities related to a mesh cell This is a key structure for all cel...
Definition: cs_cdo_local.h:146
void cs_cdofb_navsto_free_builder(cs_cdofb_navsto_builder_t *nsb)
Destroy the given cs_cdofb_navsto_builder_t structure.
Definition: cs_cdofb_navsto.c:206
Definition: cs_cdo_connect.h:74
Structure storing the parameters related to the resolution of the Navier-Stokes system.
Definition: cs_navsto_param.h:255
cs_real_t * div_op
Definition: cs_cdofb_navsto.h:71
void cs_cdofb_navsto_init_face_pressure(const cs_navsto_param_t *nsp, const cs_cdo_quantities_t *quant, const cs_time_step_t *ts, cs_real_t *pr_f)
Initialize the pressure values when the pressure is defined at faces.
Definition: cs_cdofb_navsto.c:577
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
Definition: cs_cdo_quantities.h:94
void cs_cdofb_navsto_extra_op(const cs_navsto_param_t *nsp, const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect, const cs_adv_field_t *adv_field)
Perform extra-operation related to Fb schemes when solving Navier-Stokes.
Definition: cs_cdofb_navsto.c:704
Set of arrays and local (small) dense matrices related to a mesh cell This is a key structure for bui...
Definition: cs_cdo_local.h:93
void cs_cdofb_symmetry(short int f, const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Take into account a symmetric boundary (treated as a sliding BCs on the three velocity components...
Definition: cs_cdofb_navsto.c:1166
void cs_cdofb_navsto_init_pressure(const cs_navsto_param_t *nsp, const cs_cdo_quantities_t *quant, const cs_time_step_t *ts, cs_field_t *pr)
Initialize the pressure values.
Definition: cs_cdofb_navsto.c:481
short int * f_sgn
Definition: cs_cdo_local.h:178
cs_real_t cs_cdofb_navsto_cell_divergence(const cs_lnum_t c_id, const cs_cdo_quantities_t *quant, const cs_adjacency_t *c2f, const cs_real_t *f_vals)
Compute the divergence of a cell using the cs_cdo_quantities_t structure.
Definition: cs_cdofb_navsto.c:367
short int n_fc
Definition: cs_cdo_local.h:175
Definition: cs_cdo_bc.h:86
static void cs_cdofb_navsto_divergence_vect(const cs_cell_mesh_t *cm, cs_real_t div[])
Compute the divergence vector associated to the current cell. WARNING: mind that, differently form th...
Definition: cs_cdofb_navsto.h:96
Set of local and temporary buffers useful for building the algebraic system with a cellwise process...
Definition: cs_cdo_local.h:56
cs_quant_t * face
Definition: cs_cdo_local.h:182
void cs_cdofb_block_dirichlet_pena(short int f, const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Take into account a Dirichlet BCs on the three velocity components. For instance for a velocity inlet...
Definition: cs_cdofb_navsto.c:931
Definition: cs_cdo_quantities.h:86
void cs_cdofb_block_dirichlet_alge(short int f, const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Take into account a Dirichlet BCs on the three velocity components. For instance for a velocity inlet...
Definition: cs_cdofb_navsto.c:835
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
double unitv[3]
Definition: cs_cdo_quantities.h:89
void cs_cdofb_block_dirichlet_wsym(short int f, const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Take into account a Dirichlet BCs on the three velocity components. For instance for a velocity inlet...
Definition: cs_cdofb_navsto.c:1072
#define END_C_DECLS
Definition: cs_defs.h:468
void cs_cdofb_block_dirichlet_weak(short int f, const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Take into account a Dirichlet BCs on the three velocity components. For instance for a velocity inlet...
Definition: cs_cdofb_navsto.c:993
void cs_cdofb_fixed_wall(short int f, const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Take into account a wall BCs by a weak enforcement using Nitsche technique plus a symmetric treatment...
Definition: cs_cdofb_navsto.c:1267
cs_boundary_type_t * bf_type
Definition: cs_cdofb_navsto.h:75
double precision, dimension(ncharm), save zeta
Definition: cpincl.f90:99
cs_cdofb_navsto_builder_t cs_cdofb_navsto_create_builder(const cs_cdo_connect_t *connect)
Create and allocate a local NavSto builder when Fb schemes are used.
Definition: cs_cdofb_navsto.c:181
Definition: cs_cdofb_navsto.h:68
void cs_cdofb_navsto_set_zero_mean_pressure(const cs_cdo_quantities_t *quant, cs_real_t values[])
Update the pressure field in order to get a field with a zero-mean average.
Definition: cs_cdofb_navsto.c:656