stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

test_sdis_contact_resistance.h (5149B)


      1 /* Copyright (C) 2016-2025 |Méso|Star> (contact@meso-star.com)
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 3 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     15 
     16 
     17 /*
     18  * The scene is composed of a solid cube/square of size L. The cube/square
     19  * is made of 2 solids that meet at x=e in ]0 L[.
     20  * 
     21  *             3D                    2D
     22  *
     23  *          /////////(L,L,L)     /////////(L,L)
     24  *          +-------+            +-------+
     25  *         /'  /   /|            |   !   |
     26  *        +-------+ TL          T0   r   TL
     27  *        | | !   | |            |   !   |
     28  *       T0 +.r...|.+            +-------+
     29  *        |,  !   |/         (0,0)///x=X0///
     30  *        +-------+
     31  * (0,0,0)///x=X0///
     32  */
     33 
     34 #define L 4.0
     35 #define X0 3.0
     36 
     37  /*******************************************************************************
     38   * Box geometry
     39   ******************************************************************************/
     40 static const double model3d_vertices[12/*#vertices*/*3/*#coords per vertex*/] = {
     41   0, 0, 0,
     42   X0, 0, 0,
     43   L, 0, 0,
     44   0, L, 0,
     45   X0, L, 0,
     46   L, L, 0,
     47   0, 0, L,
     48   X0, 0, L,
     49   L, 0, L,
     50   0, L, L,
     51   X0, L, L,
     52   L, L, L
     53 };
     54 static const size_t model3d_nvertices = sizeof(model3d_vertices)/(sizeof(double)*3);
     55 
     56 /* The following array lists the indices toward the 3D vertices of each
     57  * triangle.
     58  *        ,3---,4---,5          ,3----4----5        ,4
     59  *      ,' | ,' | ,'/|        ,'/| \  | \  |      ,'/|
     60  *    9----10---11 / |      9' / |  \ |  \ |    10 / |          Y
     61  *    |',  |',  | / ,2      | / ,0---,1---,2    | / ,1          |
     62  *    |  ',|  ',|/,'        |/,' | ,' | ,'      |/,'         o--X
     63  *    6----7----8'          6----7'---8'        7              /
     64  *  Front, right         Back, left and       Internal        Z
     65  * and Top faces          bottom faces         face */
     66 static const size_t model3d_indices[22/*#triangles*/*3/*#indices per triangle*/] = {
     67   0, 3, 1, 1, 3, 4,     1, 4, 2, 2, 4, 5,    /* -Z */
     68   0, 6, 3, 3, 6, 9,                          /* -X */
     69   6, 7, 9, 9, 7, 10,    7, 8, 10, 10, 8, 11, /* +Z */
     70   5, 11, 8, 8, 2, 5,                         /* +X */
     71   3, 9, 10, 10, 4, 3,   4, 10, 11, 11, 5, 4, /* +Y */
     72   0, 1, 7, 7, 6, 0,     1, 2, 8, 8, 7, 1,    /* -Y */
     73   4, 10, 7, 7, 1, 4                          /* Inside */
     74 };
     75 static const size_t model3d_ntriangles = sizeof(model3d_indices)/(sizeof(size_t)*3);
     76 
     77 static INLINE void
     78 model3d_get_indices(const size_t itri, size_t ids[3], void* context)
     79 {
     80   (void)context;
     81   CHK(ids);
     82   CHK(itri < model3d_ntriangles);
     83   ids[0] = model3d_indices[itri * 3 + 0];
     84   ids[1] = model3d_indices[itri * 3 + 1];
     85   ids[2] = model3d_indices[itri * 3 + 2];
     86 }
     87 
     88 static INLINE void
     89 model3d_get_position(const size_t ivert, double pos[3], void* context)
     90 {
     91   (void)context;
     92   CHK(pos);
     93   CHK(ivert < model3d_nvertices);
     94   pos[0] = model3d_vertices[ivert * 3 + 0];
     95   pos[1] = model3d_vertices[ivert * 3 + 1];
     96   pos[2] = model3d_vertices[ivert * 3 + 2];
     97 }
     98 
     99 static INLINE void
    100 model3d_get_interface(const size_t itri, struct sdis_interface** bound, void* context)
    101 {
    102   struct sdis_interface** interfaces = context;
    103   CHK(context && bound);
    104   CHK(itri < model3d_ntriangles);
    105   *bound = interfaces[itri];
    106 }
    107 
    108 /*******************************************************************************
    109  * Square geometry
    110  ******************************************************************************/
    111 static const double model2d_vertices[6/*#vertices*/*2/*#coords per vertex*/] = {
    112   L, 0,
    113   X0, 0,
    114   0, 0,
    115   0, L,
    116   X0, L,
    117   L, L
    118 };
    119 static const size_t model2d_nvertices = sizeof(model2d_vertices)/(sizeof(double)*2);
    120 
    121 static const size_t model2d_indices[7/*#segments*/ * 2/*#indices per segment*/] = {
    122   0, 1, 1, 2, /* Bottom */
    123   2, 3,       /* Left */
    124   3, 4, 4, 5, /* Top */
    125   5, 0,       /* Right */
    126   4, 1        /* Inside */
    127 };
    128 static const size_t model2d_nsegments = sizeof(model2d_indices) / (sizeof(size_t)*2);
    129 
    130 static INLINE void
    131 model2d_get_indices(const size_t iseg, size_t ids[2], void* context)
    132 {
    133   (void)context;
    134   CHK(ids);
    135   CHK(iseg < model2d_nsegments);
    136   ids[0] = model2d_indices[iseg * 2 + 0];
    137   ids[1] = model2d_indices[iseg * 2 + 1];
    138 }
    139 
    140 static INLINE void
    141 model2d_get_position(const size_t ivert, double pos[2], void* context)
    142 {
    143   (void)context;
    144   CHK(pos);
    145   CHK(ivert < model2d_nvertices);
    146   pos[0] = model2d_vertices[ivert * 2 + 0];
    147   pos[1] = model2d_vertices[ivert * 2 + 1];
    148 }
    149 
    150 static INLINE void
    151 model2d_get_interface
    152 (const size_t iseg, struct sdis_interface** bound, void* context)
    153 {
    154   struct sdis_interface** interfaces = context;
    155   CHK(context && bound);
    156   CHK(iseg < model2d_nsegments);
    157   *bound = interfaces[iseg];
    158 }