LCOV - code coverage report
Current view: top level - ugbase/lib_grid/algorithms - hexahedron_util.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 32 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2017:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Sebastian Reiter
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #include "hexahedron_util.h"
      34              : #include "../grid_objects/prism_rules.h"
      35              : #include "geom_obj_util/face_util.h"
      36              : 
      37              : namespace ug{
      38              : 
      39            0 : Hexahedron* CreateHexahedronFromPrisms(Grid& grid, Prism* p0, Prism* p1)
      40              : {
      41              : //      find the quad of p0 which is contained in p1
      42              :         const int* quadInds = prism_rules::QUADS;
      43              : 
      44            0 :         int iq[2] = {-1, -1};
      45            0 :         for(int iquad = 0; iquad < 3; ++iquad){
      46            0 :                 Face* q0 = grid.get_face(p0, quadInds[iquad]);
      47            0 :                 iq[1] = GetFaceIndex(p1, q0);
      48            0 :                 if(iq[1] != -1){
      49            0 :                         iq[0] = quadInds[iquad];
      50            0 :                         break;
      51              :                 }
      52              :         }
      53              : 
      54            0 :         if(iq[0] == -1)
      55              :                 return NULL;
      56              : 
      57              : //      we mark for both prisms which vertices are shared
      58            0 :         bool isShared[2][6]     = {     {false, false, false, false, false, false},
      59              :                                                         {false, false, false, false, false, false}};
      60              : 
      61            0 :         for(int iprism = 0; iprism < 2; ++iprism){
      62            0 :                 const int* vrts = prism_rules::FACE_VRT_INDS[iq[iprism]];
      63            0 :                 for(int ivrt = 0; ivrt < 4; ++ivrt)
      64            0 :                         isShared[iprism][vrts[ivrt]] = true;
      65              :         }
      66              : 
      67              : //      access the vertices of both prisms
      68            0 :         Prism::ConstVertexArray vrts0 = p0->vertices();
      69            0 :         Prism::ConstVertexArray vrts1 = p1->vertices();
      70              : 
      71              : //      mark the two shared vertices in the bottom face of p0
      72            0 :         grid.begin_marking();
      73              :         int ubv[2] = {-1, -1};  //      unmarked bottom vertex index
      74            0 :         for(int ivrt = 0; ivrt < 3; ++ivrt){
      75            0 :                 if(isShared[0][ivrt])
      76            0 :                         grid.mark(vrts0[ivrt]);
      77              :                 else
      78              :                         ubv[0] = ivrt;
      79              :         }
      80              : 
      81              : //      find the matching bottom face in p1
      82            0 :         for(int itri = 0; itri < 2; ++itri){
      83              :                 bool gotMarked = false;
      84              :                 int nonMarked = -1;
      85            0 :                 for(int ivrt = 0; ivrt < 3; ++ivrt){
      86            0 :                         int index = prism_rules::FACE_VRT_INDS[prism_rules::TRIS[itri]][ivrt];
      87            0 :                         if(grid.is_marked(vrts1[index]))
      88              :                                 gotMarked = true;
      89              :                         else
      90              :                                 nonMarked = index;
      91              :                 }
      92              : 
      93            0 :                 if(gotMarked){
      94              :                         ubv[1] = nonMarked;
      95              :                         break;
      96              :                 }
      97              :         }
      98              : 
      99            0 :         grid.end_marking();
     100              : 
     101            0 :         if(ubv[0] == -1 || ubv[1] == -1)
     102              :                 return NULL;
     103              : 
     104            0 :         const int base[4] = {ubv[0], (ubv[0] + 1) % 3, ubv[1], (ubv[0] + 2) % 3};
     105              : 
     106            0 :         return *grid.create<Hexahedron>(
     107            0 :                         HexahedronDescriptor(
     108            0 :                                 vrts0[base[0]], vrts0[base[1]], vrts1[base[2]], vrts0[base[3]],
     109            0 :                                 vrts0[base[0] + 3], vrts0[base[1] + 3], vrts1[(base[2] + 3) % 6], vrts0[base[3] + 3]),
     110              :                         p0);
     111              : }
     112              : 
     113              : }//     end of namespace
        

Generated by: LCOV version 2.0-1