TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
face_to_elem_VDF.h
1/****************************************************************************
2* Copyright (c) 2024, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef face_to_elem_VDF_included
17#define face_to_elem_VDF_included
18
19#include <Domaine_VF.h>
20
21/*! @brief Interpolates a face-based field (nf_tot, N) to an element-based
22 * field (ne_tot, N, D) using face normals and surfaces.
23 * Each element value is the average of the contributions from its faces.
24 */
25inline void face_to_elem_VDF(const Domaine_VF& domaine, const DoubleTab& tab_faces, DoubleTab& tab_elems)
26{
27 const IntTab& elem_faces = domaine.elem_faces();
28 const DoubleTab& nf = domaine.face_normales();
29 const DoubleVect& fs = domaine.face_surfaces();
30 const int nb_face_elem = elem_faces.line_size();
31 const int ne_tot = domaine.nb_elem_tot();
32 const int N = tab_faces.line_size();
33 const int D = Objet_U::dimension;
34 assert(tab_elems.dimension_tot(0) == ne_tot && tab_faces.dimension_tot(0) == domaine.nb_faces_tot());
35
36 tab_elems = 0.;
37 for (int ele = 0; ele < ne_tot; ele++)
38 for (int n = 0; n < N; n++)
39 for (int d = 0; d < D; d++)
40 for (int s = 0; s < nb_face_elem; s++)
41 {
42 const int f = elem_faces(ele, s);
43 if (fs[f] > 1.e-12)
44 tab_elems(ele, n, d) += tab_faces(f, n) * nf(f, d) / fs[f];
45 }
46
47 tab_elems *= 0.5;
48}
49
50#endif /* face_to_elem_VDF_included */
class Domaine_VF
Definition Domaine_VF.h:44
static int dimension
Definition Objet_U.h:99
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
int line_size() const
Definition TRUSTVect.tpp:67