My Project
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 /*----------------------------------------------------------------------------*/
92 /*----------------------------------------------------------------------------*/
93 
94 static inline cs_cdofb_navsto_builder_t
96 {
97  cs_cdofb_navsto_builder_t nsb = {.div_op = NULL,
98  .bf_type = NULL,
99  .pressure_bc_val = NULL };
100 
101  if (connect == NULL)
102  return nsb;
103 
104  BFT_MALLOC(nsb.div_op, 3*connect->n_max_fbyc, cs_real_t);
107 
108  return nsb;
109 }
110 
111 /*----------------------------------------------------------------------------*/
117 /*----------------------------------------------------------------------------*/
118 
119 static inline void
121 {
122  if (nsb != NULL) {
123  BFT_FREE(nsb->div_op);
124  BFT_FREE(nsb->bf_type);
126  }
127 }
128 
129 /*----------------------------------------------------------------------------*/
138 /*----------------------------------------------------------------------------*/
139 
140 static inline void
142  cs_real_t div[])
143 {
144  /* D(\hat{u}) = \frac{1}{|c|} \sum_{f_c} \iota_{fc} u_f.f
145  * But, when integrating [[ p, q ]]_{P_c} = |c| p_c q_c
146  * Thus, the volume in the divergence drops
147  */
148 
149  for (short int f = 0; f < cm->n_fc; f++) {
150 
151  const cs_quant_t pfq = cm->face[f];
152  const cs_real_t i_f = cm->f_sgn[f] * pfq.meas;
153 
154  cs_real_t *_div_f = div + 3*f;
155  _div_f[0] = i_f * pfq.unitv[0];
156  _div_f[1] = i_f * pfq.unitv[1];
157  _div_f[2] = i_f * pfq.unitv[2];
158 
159  } /* Loop on cell faces */
160 }
161 
162 /*============================================================================
163  * Public function prototypes
164  *============================================================================*/
165 
166 /*----------------------------------------------------------------------------*/
178 /*----------------------------------------------------------------------------*/
179 
180 void
182  const cs_navsto_param_t *nsp,
183  const cs_cell_mesh_t *cm,
184  const cs_cell_sys_t *csys,
185  const cs_cdo_bc_face_t *pr_bc,
186  const cs_boundary_type_t *bf_type,
188 
189 /*----------------------------------------------------------------------------*/
201 /*----------------------------------------------------------------------------*/
202 
203 cs_real_t
205  const cs_cdo_quantities_t *quant,
206  const cs_adjacency_t *c2f,
207  const cs_real_t *f_vals);
208 
209 /*----------------------------------------------------------------------------*/
219 /*----------------------------------------------------------------------------*/
220 
221 void
222 cs_cdofb_navsto_add_grad_div(short int n_fc,
223  const cs_real_t zeta,
224  const cs_real_t div[],
225  cs_sdm_t *mat);
226 
227 /*----------------------------------------------------------------------------*/
236 /*----------------------------------------------------------------------------*/
237 
238 void
240  const cs_cdo_quantities_t *quant,
241  const cs_time_step_t *ts,
242  cs_field_t *pr);
243 
244 /*----------------------------------------------------------------------------*/
254 /*----------------------------------------------------------------------------*/
255 
256 void
258  const cs_cdo_quantities_t *quant,
259  const cs_time_step_t *ts,
260  cs_real_t *pr_f);
261 
262 /*----------------------------------------------------------------------------*/
270 /*----------------------------------------------------------------------------*/
271 
272 void
274  cs_real_t values[]);
275 
276 /*----------------------------------------------------------------------------*/
287 /*----------------------------------------------------------------------------*/
288 
289 void
291  const cs_cdo_quantities_t *quant,
292  const cs_cdo_connect_t *connect,
293  const cs_adv_field_t *adv_field);
294 
295 /*----------------------------------------------------------------------------*/
310 /*----------------------------------------------------------------------------*/
311 
312 void
314  const cs_equation_param_t *eqp,
315  const cs_cell_mesh_t *cm,
316  cs_cell_builder_t *cb,
317  cs_cell_sys_t *csys);
318 
319 /*----------------------------------------------------------------------------*/
334 /*----------------------------------------------------------------------------*/
335 
336 void
338  const cs_equation_param_t *eqp,
339  const cs_cell_mesh_t *cm,
340  cs_cell_builder_t *cb,
341  cs_cell_sys_t *csys);
342 
343 /*----------------------------------------------------------------------------*/
358 /*----------------------------------------------------------------------------*/
359 
360 void
362  const cs_equation_param_t *eqp,
363  const cs_cell_mesh_t *cm,
364  cs_cell_builder_t *cb,
365  cs_cell_sys_t *csys);
366 
367 /*----------------------------------------------------------------------------*/
382 /*----------------------------------------------------------------------------*/
383 
384 void
386  const cs_equation_param_t *eqp,
387  const cs_cell_mesh_t *cm,
388  cs_cell_builder_t *cb,
389  cs_cell_sys_t *csys);
390 
391 /*----------------------------------------------------------------------------*/
405 /*----------------------------------------------------------------------------*/
406 
407 void
408 cs_cdofb_symmetry(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 /*----------------------------------------------------------------------------*/
426 /*----------------------------------------------------------------------------*/
427 
428 void
429 cs_cdofb_fixed_wall(short int f,
430  const cs_equation_param_t *eqp,
431  const cs_cell_mesh_t *cm,
432  cs_cell_builder_t *cb,
433  cs_cell_sys_t *csys);
434 
435 /*----------------------------------------------------------------------------*/
436 
438 
439 #endif /* __CS_CDOFB_NAVSTO_H__ */
cs_cdofb_navsto_extra_op
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:659
cs_cdofb_navsto_add_grad_div
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:366
cs_cdofb_symmetry
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:1121
cs_boundary_type_t
cs_boundary_type_t
Definition: cs_boundary.h:51
cs_defs.h
cs_cdofb_block_dirichlet_alge
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:790
cs_cdofb_navsto_free_builder
static 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.h:120
cs_navsto_param_t
Structure storing the parameters related to the resolution of the Navier-Stokes system.
Definition: cs_navsto_param.h:255
cs_cdofb_block_dirichlet_weak
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:948
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_quant_t::meas
double meas
Definition: cs_cdo_quantities.h:88
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_cdofb_navsto_builder_t::bf_type
cs_boundary_type_t * bf_type
Definition: cs_cdofb_navsto.h:75
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_cdofb_fixed_wall
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:1222
cs_navsto_param.h
cs_cdo_quantities.h
cs_cdofb_navsto_set_zero_mean_pressure
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:611
cs_cdofb_navsto_define_builder
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:185
cs_sdm.h
cs_cdofb_navsto_builder_t::div_op
cs_real_t * div_op
Definition: cs_cdofb_navsto.h:71
cs_mesh.h
cs_equation_param_t
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:148
cs_math.h
cs_cdofb_navsto_init_face_pressure
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:532
cs_cdofb_navsto_init_pressure
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:436
cs_cdofb_block_dirichlet_pena
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:886
BFT_MALLOC
#define BFT_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: bft_mem.h:62
cs_time_step_t
time step descriptor
Definition: cs_time_step.h:51
BFT_FREE
#define BFT_FREE(_ptr)
Free allocated memory.
Definition: bft_mem.h:101
cs_cdo_bc_face_t
Definition: cs_cdo_bc.h:86
cs_quant_t::unitv
double unitv[3]
Definition: cs_cdo_quantities.h:89
cs_field.h
ts
void cs_int_t cs_int_t cs_int_t cs_real_t * ts
Definition: cs_at_plugin.h:63
cs_cdo_quantities_t
Definition: cs_cdo_quantities.h:94
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_cdo_connect_t
Definition: cs_cdo_connect.h:74
cs_cell_builder_t
Set of local and temporary buffers useful for building the algebraic system with a cellwise process....
Definition: cs_cdo_local.h:56
cs_adjacency_t
Definition: cs_mesh_adjacencies.h:90
cs_cell_mesh_t::n_fc
short int n_fc
Definition: cs_cdo_local.h:175
cs_cdo_connect.h
cs_time_step.h
cs_cell_mesh_t::face
cs_quant_t * face
Definition: cs_cdo_local.h:182
cs_cdo_connect_t::n_max_fbyc
int n_max_fbyc
Definition: cs_cdo_connect.h:108
cpincl::zeta
double precision, dimension(ncharm), save zeta
Definition: cpincl.f90:99
cs_cell_mesh_t::f_sgn
short int * f_sgn
Definition: cs_cdo_local.h:178
cs_cdofb_navsto_divergence_vect
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:141
cs_cdofb_navsto_cell_divergence
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:322
cs_cdofb_navsto_builder_t
Definition: cs_cdofb_navsto.h:68
cs_quant_t
Definition: cs_cdo_quantities.h:86
cs_matrix.h
cs_cdofb_navsto_create_builder
static 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.h:95
cs_cell_sys_t
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
cs_cdofb_block_dirichlet_wsym
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:1027
cs_adv_field_t
Definition: cs_advection_field.h:149
cs_field_t
Field descriptor.
Definition: cs_field.h:124
cs_cell_mesh_t
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
cs_base.h
cs_cdofb_navsto_builder_t::pressure_bc_val
cs_real_t * pressure_bc_val
Definition: cs_cdofb_navsto.h:76