1 #ifndef __CS_XDEF_CW_EVAL_H__
2 #define __CS_XDEF_CW_EVAL_H__
3
4 /*============================================================================
5 * Manage the (generic) evaluation of extended definitions
6 *============================================================================*/
7
8 /*
9 This file is part of Code_Saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2021 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
30 /*----------------------------------------------------------------------------
31 * Local headers
32 *----------------------------------------------------------------------------*/
33
34 #include "cs_cdo_connect.h"
35 #include "cs_cdo_local.h"
36 #include "cs_cdo_quantities.h"
37 #include "cs_mesh.h"
38 #include "cs_quadrature.h"
39 #include "cs_xdef.h"
40
41 /*----------------------------------------------------------------------------*/
42
43 BEGIN_C_DECLS
44
45 /*=============================================================================
46 * Local macro definition (unset at the end of file)
47 *============================================================================*/
48
49 /* Redefined the name of functions from cs_math to get shorter names */
50 #define _dp3 cs_math_3_dot_product
51
52 /*============================================================================
53 * Function pointer type definitions
54 *============================================================================*/
55
56 /*----------------------------------------------------------------------------*/
57 /*!
58 * \brief Function pointer for evaluating a quantity defined through a
59 * descriptor (\ref cs_xdef_t structure) by a cellwise process (usage
60 * of a \ref cs_cell_mesh_t structure)
61 *
62 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
63 * \param[in] time_eval physical time at which one evaluates the term
64 * \param[in] input NULL or pointer to an input structure
65 * \param[out] eval result of the evaluation
66 */
67 /*----------------------------------------------------------------------------*/
68
69 typedef void
70 (cs_xdef_cw_eval_t) (const cs_cell_mesh_t *cm,
71 cs_real_t time_eval,
72 void *input,
73 cs_real_t *eval);
74
75 /*----------------------------------------------------------------------------*/
76 /*!
77 * \brief Function pointer for evaluating a quantity at several locations in a
78 * cell defined through a descriptor (\ref cs_xdef_t structure).
79 * The algorithm may use a \ref cs_cell_mesh_t structure.
80 *
81 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
82 * \param[in] n_points number of points where to compute the evaluation
83 * \param[in] xyz where to compute the evaluation
84 * \param[in] time_eval physical time at which one evaluates the term
85 * \param[in] input pointer to an input structure
86 * \param[out] eval result of the evaluation
87 */
88 /*----------------------------------------------------------------------------*/
89
90 typedef void
91 (cs_xdef_cw_eval_xyz_t) (const cs_cell_mesh_t *cm,
92 cs_lnum_t n_points,
93 const cs_real_t *xyz,
94 cs_real_t time_eval,
95 void *input,
96 cs_real_t *eval);
97
98 /*----------------------------------------------------------------------------*/
99 /*!
100 * \brief Function pointer for evaluating a quantity defined through a
101 * descriptor (\ref cs_xdef_t structure) by a cellwise process (usage
102 * of a \ref cs_cell_mesh_t structure) which is hinged on integrals
103 *
104 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
105 * \param[in] time_eval physical time at which one evaluates the term
106 * \param[in] qtype quadrature type
107 * \param[in] input pointer to an input structure
108 * \param[out] eval result of the evaluation
109 */
110 /*----------------------------------------------------------------------------*/
111
112 typedef void
113 (cs_xdef_cw_eval_int_t) (const cs_cell_mesh_t *cm,
114 cs_real_t time_eval,
115 void *input,
116 cs_quadrature_type_t qtype,
117 cs_real_t *eval);
118
119 /*----------------------------------------------------------------------------*/
120 /*!
121 * \brief Function pointer for evaluating a quantity defined through a
122 * descriptor (\ref cs_xdef_t structure) by a cellwise process (usage
123 * of a \ref cs_cell_mesh_t structure)
124 *
125 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
126 * \param[in] f local face id
127 * \param[in] time_eval physical time at which one evaluates the term
128 * \param[in] qtype quadrature type
129 * \param[in] input pointer to an input structure
130 * \param[out] eval result of the evaluation
131 */
132 /*----------------------------------------------------------------------------*/
133
134 typedef void
135 (cs_xdef_cw_eval_face_t) (const cs_cell_mesh_t *cm,
136 short int f,
137 cs_real_t time_eval,
138 void *input,
139 cs_quadrature_type_t qtype,
140 cs_real_t *eval);
141
142 /*============================================================================
143 * Static inline public function prototypes
144 *============================================================================*/
145
146 /*----------------------------------------------------------------------------*/
147 /*!
148 * \brief Evaluate a scalar-valued quantity by a cellwise process
149 *
150 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
151 * \param[in] time_eval physical time at which one evaluates the term
152 * \param[in] input pointer to an input structure
153 * \param[out] eval result of the evaluation
154 */
155 /*----------------------------------------------------------------------------*/
156
157 static inline void
cs_xdef_cw_eval_scalar_by_val(const cs_cell_mesh_t * cm,cs_real_t time_eval,void * input,cs_real_t * eval)158 cs_xdef_cw_eval_scalar_by_val(const cs_cell_mesh_t *cm,
159 cs_real_t time_eval,
160 void *input,
161 cs_real_t *eval)
162 {
163 CS_UNUSED(cm);
164 CS_UNUSED(time_eval);
165
166 cs_real_t *constant_val = (cs_real_t *)input;
167 *eval = constant_val[0];
168 }
169
170 /*----------------------------------------------------------------------------*/
171 /*!
172 * \brief Evaluate a vector-valued quantity by a cellwise process
173 *
174 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
175 * \param[in] time_eval physical time at which one evaluates the term
176 * \param[in] input pointer to an input structure
177 * \param[out] eval result of the evaluation
178 */
179 /*----------------------------------------------------------------------------*/
180
181 static inline void
cs_xdef_cw_eval_vector_by_val(const cs_cell_mesh_t * cm,cs_real_t time_eval,void * input,cs_real_t * eval)182 cs_xdef_cw_eval_vector_by_val(const cs_cell_mesh_t *cm,
183 cs_real_t time_eval,
184 void *input,
185 cs_real_t *eval)
186 {
187 CS_UNUSED(cm);
188 CS_UNUSED(time_eval);
189
190 const cs_real_t *constant_val = (cs_real_t *)input;
191
192 eval[0] = constant_val[0];
193 eval[1] = constant_val[1];
194 eval[2] = constant_val[2];
195 }
196
197 /*----------------------------------------------------------------------------*/
198 /*!
199 * \brief Evaluate a tensor-valued quantity with a symmetric storage by a
200 * cellwise process
201 *
202 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
203 * \param[in] time_eval physical time at which one evaluates the term
204 * \param[in] input pointer to an input structure
205 * \param[out] eval result of the evaluation
206 */
207 /*----------------------------------------------------------------------------*/
208
209 static inline void
cs_xdef_cw_eval_symtens_by_val(const cs_cell_mesh_t * cm,cs_real_t time_eval,void * input,cs_real_t * eval)210 cs_xdef_cw_eval_symtens_by_val(const cs_cell_mesh_t *cm,
211 cs_real_t time_eval,
212 void *input,
213 cs_real_t *eval)
214 {
215 CS_UNUSED(cm);
216 CS_UNUSED(time_eval);
217
218 const cs_real_t *constant_val = (const cs_real_t *)input;
219 for (int k = 0; k < 6; k++)
220 eval[k] = constant_val[k];
221 }
222
223 /*----------------------------------------------------------------------------*/
224 /*!
225 * \brief Evaluate a tensor-valued quantity by a cellwise process
226 *
227 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
228 * \param[in] time_eval physical time at which one evaluates the term
229 * \param[in] input pointer to an input structure
230 * \param[out] eval result of the evaluation
231 */
232 /*----------------------------------------------------------------------------*/
233
234 static inline void
cs_xdef_cw_eval_tensor_by_val(const cs_cell_mesh_t * cm,cs_real_t time_eval,void * input,cs_real_t * eval)235 cs_xdef_cw_eval_tensor_by_val(const cs_cell_mesh_t *cm,
236 cs_real_t time_eval,
237 void *input,
238 cs_real_t *eval)
239 {
240 CS_UNUSED(cm);
241 CS_UNUSED(time_eval);
242
243 const cs_real_3_t *constant_val = (const cs_real_3_t *)input;
244 for (int ki = 0; ki < 3; ki++)
245 for (int kj = 0; kj < 3; kj++)
246 eval[3*ki+kj] = constant_val[ki][kj];
247 }
248
249 /*----------------------------------------------------------------------------*/
250 /*!
251 * \brief Function pointer for evaluating a quantity defined by analytic
252 * function at a precise location inside a cell
253 * Use of a \ref cs_cell_mesh_t structure.
254 *
255 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
256 * \param[in] n_points number of points where to compute the evaluation
257 * \param[in] xyz where to compute the evaluation
258 * \param[in] time_eval physical time at which one evaluates the term
259 * \param[in] input pointer to an input structure
260 * \param[in, out] eval result of the evaluation
261 */
262 /*----------------------------------------------------------------------------*/
263
264 static inline void
cs_xdef_cw_eval_vector_at_xyz_by_val(const cs_cell_mesh_t * cm,cs_lnum_t n_points,const cs_real_t * xyz,cs_real_t time_eval,void * input,cs_real_t * eval)265 cs_xdef_cw_eval_vector_at_xyz_by_val(const cs_cell_mesh_t *cm,
266 cs_lnum_t n_points,
267 const cs_real_t *xyz,
268 cs_real_t time_eval,
269 void *input,
270 cs_real_t *eval)
271 {
272 CS_UNUSED(cm);
273 CS_UNUSED(xyz);
274 CS_UNUSED(time_eval);
275
276 const cs_real_t *constant_val = (cs_real_t *)input;
277
278 for (int i = 0; i < n_points; i++) {
279 eval[3*i ] = constant_val[0];
280 eval[3*i + 1] = constant_val[1];
281 eval[2*i + 2] = constant_val[2];
282 }
283 }
284
285
286 /*----------------------------------------------------------------------------*/
287 /*!
288 * \brief Function pointer for evaluating the normal flux of a quantity
289 * defined by values.
290 * Use of a \ref cs_cell_mesh_t structure.
291 *
292 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
293 * \param[in] f local face id
294 * \param[in] time_eval physical time at which one evaluates the term
295 * \param[in] input pointer to an input structure
296 * \param[in, out] eval result of the evaluation (set inside)
297 */
298 /*----------------------------------------------------------------------------*/
299
300 static inline void
cs_xdef_cw_eval_flux_by_val(const cs_cell_mesh_t * cm,short int f,cs_real_t time_eval,void * input,cs_real_t * eval)301 cs_xdef_cw_eval_flux_by_val(const cs_cell_mesh_t *cm,
302 short int f,
303 cs_real_t time_eval,
304 void *input,
305 cs_real_t *eval)
306 {
307 CS_UNUSED(time_eval);
308
309 /* Sanity check */
310 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PFQ));
311
312 const cs_real_t *flux = (cs_real_t *)input;
313 const cs_quant_t fq = cm->face[f];
314
315 eval[f] = fq.meas * _dp3(fq.unitv, flux);
316 }
317
318 /*----------------------------------------------------------------------------*/
319 /*!
320 * \brief Function pointer for evaluating the normal flux of a quantity
321 * defined by values.
322 * Use of a \ref cs_cell_mesh_t structure.
323 *
324 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
325 * \param[in] f local face id
326 * \param[in] time_eval physical time at which one evaluates the term
327 * \param[in] input pointer to an input structure
328 * \param[in, out] eval result of the evaluation (set inside)
329 */
330 /*----------------------------------------------------------------------------*/
331
332 static inline void
cs_xdef_cw_eval_tensor_flux_by_val(const cs_cell_mesh_t * cm,short int f,cs_real_t time_eval,void * input,cs_real_t * eval)333 cs_xdef_cw_eval_tensor_flux_by_val(const cs_cell_mesh_t *cm,
334 short int f,
335 cs_real_t time_eval,
336 void *input,
337 cs_real_t *eval)
338 {
339 CS_UNUSED(time_eval);
340
341 cs_real_t *flux = (cs_real_t *)input;
342 const cs_quant_t fq = cm->face[f];
343
344 cs_math_33_3_product((const cs_real_t (*)[3])flux, fq.unitv, eval);
345 for (int k = 0; k < 3; k++)
346 eval[3*f+k] *= fq.meas;
347 }
348
349 /*----------------------------------------------------------------------------*/
350 /*!
351 * \brief Function pointer for evaluating the average on a face of a scalar
352 * function defined through a descriptor (\ref cs_xdef_t structure) by
353 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
354 *
355 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
356 * \param[in] f local face id
357 * \param[in] t_eval physical time at which one evaluates the term
358 * \param[in] input pointer to an input structure
359 * \param[in] qtype level of quadrature to use
360 * \param[in, out] eval result of the evaluation
361 */
362 /*----------------------------------------------------------------------------*/
363
364 static inline void
cs_xdef_cw_eval_scalar_face_avg_by_value(const cs_cell_mesh_t * cm,short int f,cs_real_t t_eval,void * input,cs_quadrature_type_t qtype,cs_real_t * eval)365 cs_xdef_cw_eval_scalar_face_avg_by_value(const cs_cell_mesh_t *cm,
366 short int f,
367 cs_real_t t_eval,
368 void *input,
369 cs_quadrature_type_t qtype,
370 cs_real_t *eval)
371 {
372 CS_UNUSED(cm);
373 CS_UNUSED(t_eval);
374 CS_UNUSED(f);
375 CS_UNUSED(qtype);
376
377 if (eval == NULL)
378 bft_error(__FILE__, __LINE__, 0,
379 " %s: Array storing the evaluation should be allocated before"
380 " the call to this function.", __func__);
381 assert(input != NULL);
382
383 eval[0] = ((const cs_real_t *)input)[0];
384 }
385
386 /*----------------------------------------------------------------------------*/
387 /*!
388 * \brief Function pointer for evaluating the average on a face of a vector
389 * function defined through a descriptor (\ref cs_xdef_t structure) by
390 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
391 *
392 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
393 * \param[in] f local face id
394 * \param[in] t_eval physical time at which one evaluates the term
395 * \param[in] input pointer to an input structure
396 * \param[in] qtype level of quadrature to use
397 * \param[in, out] eval result of the evaluation
398 */
399 /*----------------------------------------------------------------------------*/
400
401 static inline void
cs_xdef_cw_eval_scalar_face_avg_by_array(const cs_cell_mesh_t * cm,short int f,cs_real_t t_eval,void * input,cs_quadrature_type_t qtype,cs_real_t * eval)402 cs_xdef_cw_eval_scalar_face_avg_by_array(const cs_cell_mesh_t *cm,
403 short int f,
404 cs_real_t t_eval,
405 void *input,
406 cs_quadrature_type_t qtype,
407 cs_real_t *eval)
408 {
409 CS_UNUSED(t_eval);
410 CS_UNUSED(qtype);
411
412 if (eval == NULL)
413 bft_error(__FILE__, __LINE__, 0,
414 " %s: Array storing the evaluation should be allocated before"
415 " the call to this function.", __func__);
416
417 const cs_xdef_array_context_t *array_input
418 = (const cs_xdef_array_context_t *)input;
419
420 assert(input != NULL);
421 assert(cs_flag_test(array_input->loc, cs_flag_primal_face));
422
423 eval[0] = array_input->values[cm->f_ids[f]];
424 }
425
426 /*----------------------------------------------------------------------------*/
427 /*!
428 * \brief Function pointer for evaluating at the center of the face a scalar
429 * function defined through a descriptor (\ref cs_xdef_t structure) by
430 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
431 * Since it's only an evaluation, the functions works for any dimension
432 * (assuming that the function is well defined)
433 *
434 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
435 * \param[in] f local face id
436 * \param[in] t_eval physical time at which one evaluates the term
437 * \param[in] input pointer to an input structure
438 * \param[in] qtype level of quadrature to use
439 * \param[in, out] eval result of the evaluation
440 */
441 /*----------------------------------------------------------------------------*/
442
443 static inline void
cs_xdef_cw_eval_face_drhm_by_analytic(const cs_cell_mesh_t * cm,short int f,cs_real_t t_eval,void * input,cs_quadrature_type_t qtype,cs_real_t * eval)444 cs_xdef_cw_eval_face_drhm_by_analytic(const cs_cell_mesh_t *cm,
445 short int f,
446 cs_real_t t_eval,
447 void *input,
448 cs_quadrature_type_t qtype,
449 cs_real_t *eval)
450 {
451 CS_UNUSED(qtype);
452 cs_xdef_analytic_context_t *anai = (cs_xdef_analytic_context_t *)input;
453
454 anai->func(t_eval, 1, NULL, cm->face[f].center, false, anai->input, eval);
455 }
456
457 /*----------------------------------------------------------------------------*/
458 /*!
459 * \brief Function pointer for evaluating the average on a face of a vector
460 * function defined through a descriptor (cs_xdef_t structure) by a
461 * cellwise process (usage of a cs_cell_mesh_t structure)
462 *
463 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
464 * \param[in] f local face id
465 * \param[in] t_eval physical time at which one evaluates the term
466 * \param[in] input pointer to an input structure
467 * \param[in] qtype level of quadrature to use
468 * \param[in, out] eval result of the evaluation
469 */
470 /*----------------------------------------------------------------------------*/
471
472 static inline void
cs_xdef_cw_eval_vector_face_avg_by_value(const cs_cell_mesh_t * cm,short int f,cs_real_t t_eval,void * input,cs_quadrature_type_t qtype,cs_real_t * eval)473 cs_xdef_cw_eval_vector_face_avg_by_value(const cs_cell_mesh_t *cm,
474 short int f,
475 cs_real_t t_eval,
476 void *input,
477 cs_quadrature_type_t qtype,
478 cs_real_t *eval)
479 {
480 CS_UNUSED(cm);
481 CS_UNUSED(f);
482 CS_UNUSED(t_eval);
483 CS_UNUSED(qtype);
484
485 if (eval == NULL)
486 bft_error(__FILE__, __LINE__, 0,
487 " %s: Array storing the evaluation should be allocated before"
488 " the call to this function.", __func__);
489
490 assert(input != NULL);
491
492 memcpy(eval, (const cs_real_t *)input, 3*sizeof(cs_real_t));
493 }
494
495 /*----------------------------------------------------------------------------*/
496 /*!
497 * \brief Function pointer for evaluating the average on a face of a vector
498 * function defined through a descriptor (\ref cs_xdef_t structure) by
499 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
500 *
501 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
502 * \param[in] f local face id
503 * \param[in] t_eval physical time at which one evaluates the term
504 * \param[in] input pointer to an input structure
505 * \param[in] qtype level of quadrature to use
506 * \param[in, out] eval result of the evaluation
507 */
508 /*----------------------------------------------------------------------------*/
509
510 static inline void
cs_xdef_cw_eval_vector_face_avg_by_array(const cs_cell_mesh_t * cm,short int f,cs_real_t t_eval,void * input,cs_quadrature_type_t qtype,cs_real_t * eval)511 cs_xdef_cw_eval_vector_face_avg_by_array(const cs_cell_mesh_t *cm,
512 short int f,
513 cs_real_t t_eval,
514 void *input,
515 cs_quadrature_type_t qtype,
516 cs_real_t *eval)
517 {
518 CS_UNUSED(t_eval);
519 CS_UNUSED(qtype);
520
521 if (eval == NULL)
522 bft_error(__FILE__, __LINE__, 0,
523 " %s: Array storing the evaluation should be allocated before"
524 " the call to this function.", __func__);
525
526 const cs_xdef_array_context_t *array_input
527 = (const cs_xdef_array_context_t *)input;
528
529 assert(input != NULL);
530 assert(cs_flag_test(array_input->loc, cs_flag_primal_face));
531
532 memcpy(eval, array_input->values + 3*cm->f_ids[f], 3*sizeof(cs_real_t));
533 }
534
535 /*----------------------------------------------------------------------------*/
536 /*!
537 * \brief Function pointer for evaluating the average on a face of a tensor
538 * function defined through a descriptor (\ref cs_xdef_t structure) by
539 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
540 *
541 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
542 * \param[in] f local face id
543 * \param[in] t_eval physical time at which one evaluates the term
544 * \param[in] input pointer to an input structure
545 * \param[in] qtype level of quadrature to use
546 * \param[in, out] eval result of the evaluation
547 */
548 /*----------------------------------------------------------------------------*/
549
550 static inline void
cs_xdef_cw_eval_tensor_face_avg_by_value(const cs_cell_mesh_t * cm,short int f,cs_real_t t_eval,void * input,cs_quadrature_type_t qtype,cs_real_t * eval)551 cs_xdef_cw_eval_tensor_face_avg_by_value(const cs_cell_mesh_t *cm,
552 short int f,
553 cs_real_t t_eval,
554 void *input,
555 cs_quadrature_type_t qtype,
556 cs_real_t *eval)
557 {
558 CS_UNUSED(cm);
559 CS_UNUSED(f);
560 CS_UNUSED(t_eval);
561 CS_UNUSED(qtype);
562
563 assert(input != NULL);
564 if (eval == NULL)
565 bft_error(__FILE__, __LINE__, 0,
566 " %s: Array storing the evaluation should be allocated before"
567 " the call to this function.", __func__);
568
569 const cs_real_3_t *constant_val = (const cs_real_3_t *)input;
570 for (int ki = 0; ki < 3; ki++)
571 for (int kj = 0; kj < 3; kj++)
572 eval[3*ki+kj] = constant_val[ki][kj];
573 }
574
575 /*----------------------------------------------------------------------------*/
576 /*!
577 * \brief Function pointer for evaluating the average on a face of a tensor
578 * function defined through a descriptor (\ref cs_xdef_t structure) by
579 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
580 *
581 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
582 * \param[in] f local face id
583 * \param[in] t_eval physical time at which one evaluates the term
584 * \param[in] input pointer to an input structure
585 * \param[in] qtype level of quadrature to use
586 * \param[in, out] eval result of the evaluation
587 */
588 /*----------------------------------------------------------------------------*/
589
590 static inline void
cs_xdef_cw_eval_tensor_face_avg_by_array(const cs_cell_mesh_t * cm,short int f,cs_real_t t_eval,void * input,cs_quadrature_type_t qtype,cs_real_t * eval)591 cs_xdef_cw_eval_tensor_face_avg_by_array(const cs_cell_mesh_t *cm,
592 short int f,
593 cs_real_t t_eval,
594 void *input,
595 cs_quadrature_type_t qtype,
596 cs_real_t *eval)
597 {
598 CS_UNUSED(t_eval);
599 CS_UNUSED(qtype);
600
601 if (eval == NULL)
602 bft_error(__FILE__, __LINE__, 0,
603 " %s: Array storing the evaluation should be allocated before"
604 " the call to this function.", __func__);
605
606 const cs_xdef_array_context_t *array_input
607 = (const cs_xdef_array_context_t *)input;
608
609 assert(input != NULL);
610 assert(cs_flag_test(array_input->loc, cs_flag_primal_face));
611
612 memcpy(eval, array_input->values + 9*cm->f_ids[f], 9*sizeof(cs_real_t));
613 }
614
615 /*============================================================================
616 * Public function prototypes
617 *============================================================================*/
618
619 /*----------------------------------------------------------------------------*/
620 /*!
621 * \brief Integrate an analytic function over a face
622 *
623 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
624 * \param[in] t_eval time at which the function is evaluated
625 * \param[in] f face id in the local cell numbering
626 * \param[in] ana analytic function to integrate
627 * \param[in] input pointer to an input structure
628 * \param[in] qfunc quadrature function to use
629 * \param[in, out] eval result of the evaluation
630 */
631 /*----------------------------------------------------------------------------*/
632
633 void
634 cs_xdef_cw_eval_f_int_by_analytic(const cs_cell_mesh_t *cm,
635 double t_eval,
636 short int f,
637 cs_analytic_func_t *ana,
638 void *input,
639 cs_quadrature_tria_integral_t *qfunc,
640 cs_real_t *eval);
641
642 /*----------------------------------------------------------------------------*/
643 /*!
644 * \brief Integrate an analytic function over a cell
645 *
646 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
647 * \param[in] t_eval time at which the function is evaluated
648 * \param[in] ana analytic function to integrate
649 * \param[in] input pointer to an input structure
650 * \param[in] qfunc quadrature function to use
651 * \param[in, out] eval result of the evaluation
652 */
653 /*----------------------------------------------------------------------------*/
654
655 void
656 cs_xdef_cw_eval_c_int_by_analytic(const cs_cell_mesh_t *cm,
657 double t_eval,
658 cs_analytic_func_t *ana,
659 void *input,
660 cs_quadrature_tetra_integral_t *qfunc,
661 cs_real_t *eval);
662
663 /*----------------------------------------------------------------------------*/
664 /*!
665 * \brief Routine to integrate an analytic function over a cell and its faces
666 *
667 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
668 * \param[in] t_eval physical time at which one evaluates the term
669 * \param[in] ana analytic function to integrate
670 * \param[in] input pointer to an input structure
671 * \param[in] dim dimension of the function
672 * \param[in] q_tet quadrature function to use on tetrahedra
673 * \param[in] q_tri quadrature function to use on triangles
674 * \param[out] c_int result of the evaluation on the cell
675 * \param[out] f_int result of the evaluation on the faces
676 */
677 /*----------------------------------------------------------------------------*/
678
679 void
680 cs_xdef_cw_eval_fc_int_by_analytic(const cs_cell_mesh_t *cm,
681 cs_real_t t_eval,
682 cs_analytic_func_t *ana,
683 void *input,
684 const short int dim,
685 cs_quadrature_tetra_integral_t *q_tet,
686 cs_quadrature_tria_integral_t *q_tri,
687 cs_real_t *c_int,
688 cs_real_t *f_int);
689
690 /*----------------------------------------------------------------------------*/
691 /*!
692 * \brief Function pointer for evaluating the average on a face of a scalar
693 * function defined through a descriptor (\ref cs_xdef_t structure) by
694 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
695 *
696 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
697 * \param[in] f local face id
698 * \param[in] time_eval physical time at which one evaluates the term
699 * \param[in] input pointer to an input structure
700 * \param[in] qtype level of quadrature to use
701 * \param[in, out] eval result of the evaluation
702 */
703 /*----------------------------------------------------------------------------*/
704
705 void
706 cs_xdef_cw_eval_scalar_face_avg_by_analytic(const cs_cell_mesh_t *cm,
707 short int f,
708 cs_real_t time_eval,
709 void *input,
710 cs_quadrature_type_t qtype,
711 cs_real_t *eval);
712
713 /*----------------------------------------------------------------------------*/
714 /*!
715 * \brief Function pointer for evaluating the average on a face of a vector
716 * function defined through a descriptor (\ref cs_xdef_t structure) by
717 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
718 *
719 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
720 * \param[in] f local face id
721 * \param[in] t_eval physical time at which one evaluates the term
722 * \param[in] context pointer to a context structure
723 * \param[in] qtype level of quadrature to use
724 * \param[in, out] eval result of the evaluation
725 */
726 /*----------------------------------------------------------------------------*/
727
728 void
729 cs_xdef_cw_eval_vector_face_avg_by_analytic(const cs_cell_mesh_t *cm,
730 short int f,
731 cs_real_t t_eval,
732 void *context,
733 cs_quadrature_type_t qtype,
734 cs_real_t *eval);
735
736 /*----------------------------------------------------------------------------*/
737 /*!
738 * \brief Function pointer for evaluating the average on a face of a tensor
739 * function defined through a descriptor (\ref cs_xdef_t structure) by
740 * a cellwise process (usage of a \ref cs_cell_mesh_t structure)
741 *
742 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
743 * \param[in] f local face id
744 * \param[in] t_eval physical time at which one evaluates the term
745 * \param[in] context pointer to a context structure
746 * \param[in] qtype level of quadrature to use
747 * \param[in, out] eval result of the evaluation
748 */
749 /*----------------------------------------------------------------------------*/
750
751 void
752 cs_xdef_cw_eval_tensor_face_avg_by_analytic(const cs_cell_mesh_t *cm,
753 short int f,
754 cs_real_t t_eval,
755 void *context,
756 cs_quadrature_type_t qtype,
757 cs_real_t *eval);
758
759 /*----------------------------------------------------------------------------*/
760 /*!
761 * \brief Function pointer for evaluating a quantity defined through a
762 * descriptor (\ref cs_xdef_t structure) by a cellwise process (usage
763 * of a \ref cs_cell_mesh_t structure).
764 * This evaluation hinges on the computation of integrals
765 *
766 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
767 * \param[in] t_eval physical time at which one evaluates the term
768 * \param[in] qtype quadrature type
769 * \param[in] context pointer to a context structure
770 * \param[in, out] eval result of the evaluation
771 */
772 /*----------------------------------------------------------------------------*/
773
774 void
775 cs_xdef_cw_eval_scalar_avg_by_analytic(const cs_cell_mesh_t *cm,
776 cs_real_t t_eval,
777 void *context,
778 cs_quadrature_type_t qtype,
779 cs_real_t *eval);
780
781 /*----------------------------------------------------------------------------*/
782 /*!
783 * \brief Function pointer for evaluating a quantity defined through a
784 * descriptor (\ref cs_xdef_t structure) by a cellwise process (usage
785 * of a \ref cs_cell_mesh_t structure).
786 * This evaluation hinges on the computation of integrals
787 * Vector-valued case.
788 *
789 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
790 * \param[in] t_eval physical time at which one evaluates the term
791 * \param[in] qtype quadrature type
792 * \param[in] context pointer to a context structure
793 * \param[in, out] eval result of the evaluation
794 */
795 /*----------------------------------------------------------------------------*/
796
797 void
798 cs_xdef_cw_eval_vector_avg_by_analytic(const cs_cell_mesh_t *cm,
799 cs_real_t t_eval,
800 void *context,
801 cs_quadrature_type_t qtype,
802 cs_real_t *eval);
803
804 /*----------------------------------------------------------------------------*/
805 /*!
806 * \brief Function pointer for evaluating a quantity defined through a
807 * descriptor (\ref cs_xdef_t structure) by a cellwise process (usage
808 * of a \ref cs_cell_mesh_t structure).
809 * This evaluation hinges on the computation of integrals
810 * Tensor-valued case.
811 *
812 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
813 * \param[in] t_eval physical time at which one evaluates the term
814 * \param[in] qtype quadrature type
815 * \param[in] context pointer to a context structure
816 * \param[in, out] eval result of the evaluation
817 */
818 /*----------------------------------------------------------------------------*/
819
820 void
821 cs_xdef_cw_eval_tensor_avg_by_analytic(const cs_cell_mesh_t *cm,
822 cs_real_t t_eval,
823 void *context,
824 cs_quadrature_type_t qtype,
825 cs_real_t *eval);
826
827 /*----------------------------------------------------------------------------*/
828 /*!
829 * \brief Evaluate a quantity by a cellwise process using a definition by
830 * time function
831 *
832 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
833 * \param[in] time_eval physical time at which one evaluates the term
834 * \param[in] context pointer to a context structure
835 * \param[out] eval result of the evaluation
836 */
837 /*----------------------------------------------------------------------------*/
838
839 void
840 cs_xdef_cw_eval_by_time_func(const cs_cell_mesh_t *cm,
841 cs_real_t time_eval,
842 void *context,
843 cs_real_t *eval);
844
845 /*----------------------------------------------------------------------------*/
846 /*!
847 * \brief Evaluate a quantity defined using an analytic function by a
848 * cellwise process (usage of a \ref cs_cell_mesh_t structure)
849 *
850 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
851 * \param[in] time_eval physical time at which one evaluates the term
852 * \param[in] context pointer to a context structure
853 * \param[in, out] eval result of the evaluation at cell center
854 */
855 /*----------------------------------------------------------------------------*/
856
857 void
858 cs_xdef_cw_eval_by_analytic(const cs_cell_mesh_t *cm,
859 cs_real_t time_eval,
860 void *context,
861 cs_real_t *eval);
862
863 /*----------------------------------------------------------------------------*/
864 /*!
865 * \brief Evaluate a quantity at cells defined by an array.
866 * Array is assumed to be interlaced.
867 * Variation using a \ref cs_cell_mesh_t structure
868 *
869 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
870 * \param[in] time_eval physical time at which one evaluates the term
871 * \param[in] context pointer to a context structure
872 * \param[in, out] eval result of the evaluation at cell center
873 */
874 /*----------------------------------------------------------------------------*/
875
876 void
877 cs_xdef_cw_eval_by_array(const cs_cell_mesh_t *cm,
878 cs_real_t time_eval,
879 void *context,
880 cs_real_t *eval);
881
882 /*----------------------------------------------------------------------------*/
883 /*!
884 * \brief Evaluate a quantity inside a cell defined using a field
885 * Variation using a \ref cs_cell_mesh_t structure
886 *
887 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
888 * \param[in] time_eval physical time at which one evaluates the term
889 * \param[in] context pointer to a context structure
890 * \param[in, out] eval value of the property at the cell center
891 */
892 /*----------------------------------------------------------------------------*/
893
894 void
895 cs_xdef_cw_eval_by_field(const cs_cell_mesh_t *cm,
896 cs_real_t time_eval,
897 void *context,
898 cs_real_t *eval);
899
900 /*----------------------------------------------------------------------------*/
901 /*!
902 * \brief Function pointer for evaluating a quantity defined by analytic
903 * function at a precise location (x, y, z) inside a cell
904 * Use of a \ref cs_cell_mesh_t structure.
905 *
906 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
907 * \param[in] n_points number of points where to compute the evaluation
908 * \param[in] xyz where to compute the evaluation
909 * \param[in] time_eval physical time at which one evaluates the term
910 * \param[in] context pointer to a context structure
911 * \param[in, out] eval result of the evaluation
912 */
913 /*----------------------------------------------------------------------------*/
914
915 void
916 cs_xdef_cw_eval_at_xyz_by_analytic(const cs_cell_mesh_t *cm,
917 cs_lnum_t n_points,
918 const cs_real_t *xyz,
919 cs_real_t time_eval,
920 void *context,
921 cs_real_t *eval);
922
923 /*----------------------------------------------------------------------------*/
924 /*!
925 * \brief Function pointer for evaluating a quantity defined by analytic
926 * function at a precise location inside a cell
927 * Use of a \ref cs_cell_mesh_t structure.
928 * Vector-valued case.
929 *
930 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
931 * \param[in] n_points number of points where to compute the evaluation
932 * \param[in] xyz where to compute the evaluation
933 * \param[in] time_eval physical time at which one evaluates the term
934 * \param[in] context pointer to a context structure
935 * \param[in, out] eval result of the evaluation
936 */
937 /*----------------------------------------------------------------------------*/
938
939 void
940 cs_xdef_cw_eval_vector_at_xyz_by_array(const cs_cell_mesh_t *cm,
941 cs_lnum_t n_points,
942 const cs_real_t *xyz,
943 cs_real_t time_eval,
944 void *context,
945 cs_real_t *eval);
946
947 /*----------------------------------------------------------------------------*/
948 /*!
949 * \brief Function pointer for evaluating a quantity defined by a field
950 * at a precise location inside a cell
951 * Use of a \ref cs_cell_mesh_t structure.
952 * Vector-valued case.
953 *
954 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
955 * \param[in] n_points number of points where to compute the evaluation
956 * \param[in] xyz where to compute the evaluation
957 * \param[in] time_eval physical time at which one evaluates the term
958 * \param[in] context pointer to a context structure
959 * \param[in, out] eval result of the evaluation
960 */
961 /*----------------------------------------------------------------------------*/
962
963 void
964 cs_xdef_cw_eval_vector_at_xyz_by_field(const cs_cell_mesh_t *cm,
965 cs_lnum_t n_points,
966 const cs_real_t *xyz,
967 cs_real_t time_eval,
968 void *context,
969 cs_real_t *eval);
970
971 /*----------------------------------------------------------------------------*/
972 /*!
973 * \brief Function pointer for evaluating the normal flux of a quantity
974 * defined by values. The normal flux is then added to each portion of
975 * face related to a vertex.
976 * Use of a \ref cs_cell_mesh_t structure.
977 *
978 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
979 * \param[in] f local face id
980 * \param[in] time_eval physical time at which one evaluates the term
981 * \param[in] context pointer to a context structure
982 * \param[in, out] eval result of the evaluation (updated inside)
983 */
984 /*----------------------------------------------------------------------------*/
985
986 void
987 cs_xdef_cw_eval_flux_at_vtx_by_val(const cs_cell_mesh_t *cm,
988 short int f,
989 cs_real_t time_eval,
990 void *context,
991 cs_real_t *eval);
992
993 /*----------------------------------------------------------------------------*/
994 /*!
995 * \brief Function pointer for evaluating the normal flux of a quantity
996 * defined by analytic function. The normal flux is then added to each
997 * portion of face related to a vertex.
998 * Use of a \ref cs_cell_mesh_t structure.
999 *
1000 * \param[in] cm pointer to a cs_cell_mesh_t structure
1001 * \param[in] f local face id
1002 * \param[in] time_eval physical time at which one evaluates the term
1003 * \param[in] context pointer to a context structure
1004 * \param[in] qtype level of quadrature to use
1005 * \param[in, out] eval result of the evaluation (updated inside)
1006 */
1007 /*----------------------------------------------------------------------------*/
1008
1009 void
1010 cs_xdef_cw_eval_flux_at_vtx_by_analytic(const cs_cell_mesh_t *cm,
1011 short int f,
1012 cs_real_t time_eval,
1013 void *context,
1014 cs_quadrature_type_t qtype,
1015 cs_real_t *eval);
1016
1017 /*----------------------------------------------------------------------------*/
1018 /*!
1019 * \brief Function pointer for evaluating the normal flux of a quantity
1020 * defined by analytic function.
1021 * Use of a \ref cs_cell_mesh_t structure.
1022 *
1023 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
1024 * \param[in] f local face id
1025 * \param[in] time_eval physical time at which one evaluates the term
1026 * \param[in] context pointer to a context structure
1027 * \param[in] qtype level of quadrature to use
1028 * \param[in, out] eval result of the evaluation (set inside)
1029 */
1030 /*----------------------------------------------------------------------------*/
1031
1032 void
1033 cs_xdef_cw_eval_flux_by_analytic(const cs_cell_mesh_t *cm,
1034 short int f,
1035 cs_real_t time_eval,
1036 void *context,
1037 cs_quadrature_type_t qtype,
1038 cs_real_t *eval);
1039
1040 /*----------------------------------------------------------------------------*/
1041 /*!
1042 * \brief Function pointer for evaluating the normal flux of a quantity
1043 * defined by analytic function.
1044 * Use of a \ref cs_cell_mesh_t structure.
1045 * Case of tensor-valued quantities.
1046 *
1047 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
1048 * \param[in] f local face id
1049 * \param[in] time_eval physical time at which one evaluates the term
1050 * \param[in] context pointer to a context structure
1051 * \param[in] qtype level of quadrature to use
1052 * \param[in, out] eval result of the evaluation (set inside)
1053 */
1054 /*----------------------------------------------------------------------------*/
1055
1056 void
1057 cs_xdef_cw_eval_tensor_flux_by_analytic(const cs_cell_mesh_t *cm,
1058 short int f,
1059 cs_real_t time_eval,
1060 void *context,
1061 cs_quadrature_type_t qtype,
1062 cs_real_t *eval);
1063
1064 /*----------------------------------------------------------------------------*/
1065 /*!
1066 * \brief Function pointer for evaluating the reduction by averages of a
1067 * analytic function by a cellwise process (usage of a
1068 * \ref cs_cell_mesh_t structure).
1069 * This evaluation hinges on the computation of integrals (faces first,
1070 * then cell)
1071 * Scalar-valued case.
1072 *
1073 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
1074 * \param[in] t_eval physical time at which one evaluates the term
1075 * \param[in] qtype quadrature type
1076 * \param[in] context pointer to a context structure
1077 * \param[in, out] eval result of the evaluation
1078 */
1079 /*----------------------------------------------------------------------------*/
1080
1081 void
1082 cs_xdef_cw_eval_scal_avg_reduction_by_analytic(const cs_cell_mesh_t *cm,
1083 cs_real_t t_eval,
1084 void *context,
1085 cs_quadrature_type_t qtype,
1086 cs_real_t *eval);
1087
1088 /*----------------------------------------------------------------------------*/
1089 /*!
1090 * \brief Function pointer for evaluating the reduction by averages of a
1091 * analytic function by a cellwise process (usage of a
1092 * \ref cs_cell_mesh_t structure).
1093 * This evaluation hinges on the computation of integrals (faces first,
1094 * then cell)
1095 * Vector-valued case.
1096 *
1097 * \param[in] cm pointer to a \ref cs_cell_mesh_t structure
1098 * \param[in] t_eval physical time at which one evaluates the term
1099 * \param[in] qtype quadrature type
1100 * \param[in] context pointer to a context structure
1101 * \param[in, out] eval result of the evaluation
1102 */
1103 /*----------------------------------------------------------------------------*/
1104
1105 void
1106 cs_xdef_cw_eval_vect_avg_reduction_by_analytic(const cs_cell_mesh_t *cm,
1107 cs_real_t t_eval,
1108 void *context,
1109 cs_quadrature_type_t qtype,
1110 cs_real_t *eval);
1111
1112 /*----------------------------------------------------------------------------*/
1113
1114 #undef _dp3
1115
1116 END_C_DECLS
1117
1118 #endif /* __CS_XDEF_CW_EVAL_H__ */
1119