LCOV - code coverage report
Current view: top level - ugbase/lib_disc/spatial_disc/constraints/continuity_constraints - p1_continuity_constraints.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 42 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2012-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Andreas Vogel
       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 "p1_continuity_constraints.h"
      34              : #include "lib_grid/algorithms/geom_obj_util/edge_util.h"
      35              : #include "lib_grid/algorithms/debug_util.h"
      36              : 
      37              : namespace ug{
      38              : 
      39              : 
      40              : /// returns the vertices of the object constraining a hanging vertex
      41            0 : void CollectConstraining(std::vector<Vertex*>& vConstrainingVrt,
      42              :                                                  const Grid& grid,
      43              :                          ConstrainedVertex* hgVrt,
      44              :                          bool bClearContainer)
      45              : {
      46              : //      clear container
      47            0 :         if(bClearContainer) vConstrainingVrt.clear();
      48              : 
      49              : //      switch constraining parent
      50            0 :         switch(hgVrt->get_parent_base_object_id())
      51              :         {
      52              :         case EDGE:
      53              :         {
      54              :         //      in a parallel environment, the parent may be missing...
      55              :                 GridObject* constrainingObject = hgVrt->get_constraining_object();
      56            0 :                 if(constrainingObject){
      57              :                 //      cast to constraining edge
      58              :                         ConstrainingEdge* constrainingEdge =
      59            0 :                                         dynamic_cast<ConstrainingEdge*>(constrainingObject);
      60              : 
      61              :                 //      check that edge is correct
      62            0 :                         if(constrainingEdge == NULL)
      63            0 :                                 UG_THROW("Parent element should be "
      64              :                                                         "constraining edge, but is not.");
      65              : 
      66              :                 //      get constraining vertices
      67            0 :                         for(size_t i_cde = 0; i_cde < constrainingEdge->num_constrained_edges(); ++i_cde)
      68              :                         {
      69              :                         //      get constrained edge
      70            0 :                                 ConstrainedEdge* constrainedEdge = dynamic_cast<ConstrainedEdge*>(
      71              :                                                                                                         constrainingEdge->constrained_edge(i_cde));
      72              : 
      73              :                         //      check
      74            0 :                                 if(constrainedEdge == NULL)
      75            0 :                                         UG_THROW("Child element should be "
      76              :                                                                 "constrained edge, but is not.");
      77              : 
      78              :                         //      get non-hanging vertex
      79            0 :                                 Vertex* vrt = GetConnectedVertex(constrainedEdge, hgVrt);
      80              : 
      81              :                         //      push back in list of interpolation vertices
      82            0 :                                 vConstrainingVrt.push_back(vrt);
      83              :                         }
      84              :                 }
      85              :                 else
      86              :                 {
      87              :                 //      we have to find the constraining vertices of hgVrt without having
      88              :                 //      access to the parent element.
      89              :                         Grid::edge_traits::secure_container edges;
      90              :                 //todo: associated elements should support const!
      91              :                         const_cast<Grid&>(grid).associated_elements(edges, hgVrt);
      92            0 :                         for(size_t i_edge = 0; i_edge < edges.size(); ++i_edge){
      93              :                                 Edge* e = edges[i_edge];
      94            0 :                                 if(e->is_constrained()){
      95            0 :                                         Vertex* conVrt = GetConnectedVertex(e, hgVrt);
      96            0 :                                         if(!conVrt->is_constrained()){
      97            0 :                                                 vConstrainingVrt.push_back(conVrt);
      98              :                                         }
      99              :                                 }
     100              :                         }
     101              :                 }
     102              :         }
     103              :                 break;
     104              :         case FACE:
     105              :         {
     106              :         //      in a parallel environment, the parent may be missing...
     107              :                 GridObject* constrainingObject = hgVrt->get_constraining_object();
     108            0 :                 if(constrainingObject){
     109              :                 //      cast to constraining quadrilateral
     110              :                         ConstrainingQuadrilateral* bigQuad =
     111            0 :                                         dynamic_cast<ConstrainingQuadrilateral*>(constrainingObject);
     112              : 
     113              :                 //      check that quad is correct
     114            0 :                         if(bigQuad == NULL)
     115            0 :                                 UG_THROW("Parent element should be "
     116              :                                                                 "constraining quad, but is not.");
     117              : 
     118              :                 //      get constraining vertices
     119              :                 //      \todo: This is only valid for a surface grid!!!
     120            0 :                         for(size_t i_cf=0; i_cf < bigQuad->num_constrained_faces(); ++i_cf)
     121              :                         {
     122              :                                 Face* face = bigQuad->constrained_face(i_cf);
     123              : 
     124            0 :                                 Vertex* vrt = NULL;
     125              :                                 size_t i_vrt = 0;
     126            0 :                                 for(i_vrt = 0; i_vrt < face->num_vertices(); ++i_vrt)
     127              :                                 {
     128            0 :                                         vrt = face->vertex(i_vrt);
     129            0 :                                         if(hgVrt != vrt && (!vrt->is_constrained()))
     130              :                                                 break;
     131              :                                 }
     132            0 :                                 if(i_vrt == face->num_vertices())
     133            0 :                                         UG_THROW("ERROR: Vertex not detected.\n");
     134              : 
     135            0 :                                 vConstrainingVrt.push_back(vrt);
     136              :                         }
     137              :                 }
     138              :                 else
     139              :                 {
     140              :                 //      we have to find the constraining vertices of hgVrt without having
     141              :                 //      access to the parent element.
     142              :                         Grid::face_traits::secure_container faces;
     143              :                 //todo: associated elements should support const!
     144              :                         const_cast<Grid&>(grid).associated_elements(faces, hgVrt);
     145            0 :                         for(size_t i_face = 0; i_face < faces.size(); ++i_face){
     146              :                                 Face* f = faces[i_face];
     147            0 :                                 if(f->is_constrained()){
     148            0 :                                         Vertex* vrt = NULL;
     149              :                                         size_t i_vrt = 0;
     150            0 :                                         for(i_vrt = 0; i_vrt < f->num_vertices(); ++i_vrt){
     151            0 :                                                 vrt = f->vertex(i_vrt);
     152            0 :                                                 if(hgVrt != vrt && (!vrt->is_constrained()))
     153              :                                                         break;
     154              :                                         }
     155              : 
     156            0 :                                         if(i_vrt == f->num_vertices())
     157            0 :                                                 UG_THROW("ERROR: Vertex not detected.\n");
     158              : 
     159            0 :                                         vConstrainingVrt.push_back(vrt);
     160              :                                 }
     161              :                         }
     162              :                 }
     163              :         }
     164              :                 break;
     165            0 :         default:
     166            0 :                 UG_THROW("Parent element of hanging vertex wrong: "
     167              :                                 << hgVrt->get_parent_base_object_id()
     168              :                                 << ". Element info: "
     169              :                                 << ElementDebugInfo(grid, hgVrt));
     170              :                 break;
     171              :         }
     172            0 : }
     173              : 
     174              : } // end namespace ug
        

Generated by: LCOV version 2.0-1