LCOV - code coverage report
Current view: top level - ugbase/bridge/grid_bridges - subset_handler_bridge.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 68.1 % 47 32
Test Date: 2025-09-21 23:31:46 Functions: 16.7 % 6 1

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2015:  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 "grid_bridges.h"
      34              : #include "lib_grid/algorithms/subset_util.h"
      35              : #include "lib_grid/subset_handler.h"
      36              : #include "lib_grid/tools/surface_view.h"
      37              : using namespace std;
      38              : 
      39              : 
      40              : namespace ug{
      41              : 
      42              : template <class TElem>
      43            0 : static void AssignSubsetsByLevel(SubsetHandler& sh, MultiGrid& mg)
      44              : {
      45            0 :         for(size_t lvl = 0; lvl < mg.num_levels(); ++lvl){
      46            0 :                 std::stringstream ss;
      47              :                 ss << "Level " << lvl;
      48            0 :                 sh.subset_info(lvl).name = ss.str().c_str();
      49              : 
      50              :                 typedef typename Grid::traits<TElem>::iterator TIter;
      51            0 :                 for(TIter iter = mg.begin<TElem>(lvl); iter != mg.end<TElem>(lvl); ++iter){
      52            0 :                         sh.assign_subset(*iter, lvl);
      53              :                 }
      54              :         }
      55            0 : }
      56              : 
      57            0 : void AssignSubsetsByLevel(SubsetHandler& sh, MultiGrid& mg)
      58              : {
      59            0 :         AssignSubsetsByLevel<Vertex>(sh, mg);
      60            0 :         AssignSubsetsByLevel<Edge>(sh, mg);
      61            0 :         AssignSubsetsByLevel<Face>(sh, mg);
      62            0 :         AssignSubsetsByLevel<Volume>(sh, mg);
      63              : 
      64            0 :         AssignSubsetColors(sh);
      65            0 :         EraseEmptySubsets(sh);
      66            0 : }
      67              : 
      68              : namespace bridge{
      69              : 
      70            1 : void RegisterGridBridge_SubsetHandler(Registry& reg, string parentGroup)
      71              : {
      72              :         string grp = parentGroup;
      73              :         
      74              : //  ISubsetHandler
      75            3 :         reg.add_class_<ISubsetHandler>("ISubsetHandler", grp)
      76            3 :                 .add_method("assign_subset", static_cast<void (ISubsetHandler::*)(Vertex*, int)>(&ISubsetHandler::assign_subset))
      77            4 :                 .add_method("assign_subset", static_cast<void (ISubsetHandler::*)(Edge*, int)>(&ISubsetHandler::assign_subset))
      78            4 :                 .add_method("assign_subset", static_cast<void (ISubsetHandler::*)(Face*, int)>(&ISubsetHandler::assign_subset))
      79            4 :                 .add_method("assign_subset", static_cast<void (ISubsetHandler::*)(Volume*, int)>(&ISubsetHandler::assign_subset))
      80            4 :                 .add_method("get_subset_index", static_cast<int (ISubsetHandler::*)(Vertex*) const>(&ISubsetHandler::get_subset_index))
      81            4 :                 .add_method("get_subset_index", static_cast<int (ISubsetHandler::*)(Edge*) const>(&ISubsetHandler::get_subset_index))
      82            4 :                 .add_method("get_subset_index", static_cast<int (ISubsetHandler::*)(Face*) const>(&ISubsetHandler::get_subset_index))
      83            4 :                 .add_method("get_subset_index", static_cast<int (ISubsetHandler::*)(Volume*) const>(&ISubsetHandler::get_subset_index))
      84              : 
      85            3 :                 .add_method("num_subsets", &ISubsetHandler::num_subsets)
      86            2 :                 .add_method("get_subset_name", &ISubsetHandler::get_subset_name, "subset name", "subsetIndex")
      87            2 :                 .add_method("set_subset_name", &ISubsetHandler::set_subset_name, "", "name#subsetIndex")
      88            3 :                 .add_method("get_subset_index", static_cast<int (ISubsetHandler::*)(const char*) const>(
      89              :                                                                                 &ISubsetHandler::get_subset_index), "subsetIndex", "subsetName")
      90            3 :                 .add_method("set_default_subset_index", &ISubsetHandler::set_default_subset_index, "", "subsetIndex")
      91            2 :                 .add_method("get_default_subset_index", &ISubsetHandler::set_default_subset_index, "subsetIndex", "");
      92              :         
      93              : //      SubsetHandler
      94            3 :         reg.add_class_<SubsetHandler, ISubsetHandler>("SubsetHandler", grp)
      95            1 :                 .add_constructor()
      96            2 :                 .add_method("assign_grid", static_cast<void (SubsetHandler::*)(Grid&)>(&SubsetHandler::assign_grid), "", "g")
      97            1 :                 .set_construct_as_smart_pointer(true);
      98              : 
      99              : 
     100              : //      MGSubsetHandler
     101            3 :         reg.add_class_<MGSubsetHandler, ISubsetHandler>("MGSubsetHandler", grp)
     102            1 :                 .add_constructor()
     103            2 :                 .add_method("assign_grid", &MGSubsetHandler::assign_grid, "", "mg")
     104            1 :                 .set_construct_as_smart_pointer(true);
     105              : 
     106              : //      SurfaceView
     107            3 :         reg.add_class_<SurfaceView>("SurfaceView", grp)
     108            2 :                 .add_method("subset_handler", static_cast<ConstSmartPtr<MGSubsetHandler> (SurfaceView::*)() const>(
     109              :                                                                                 &SurfaceView::subset_handler));
     110              : 
     111              : //      subset util
     112            3 :         reg.add_function("AdjustSubsetsForSimulation",
     113              :                                         static_cast<void (*)(SubsetHandler&, bool)>(
     114              :                                         &AdjustSubsetsForSimulation<SubsetHandler>), grp)
     115            3 :                 .add_function("AdjustSubsetsForSimulation",
     116              :                                         static_cast<void (*)(MGSubsetHandler&, bool)>(
     117              :                                         &AdjustSubsetsForSimulation<MGSubsetHandler>), grp)
     118            2 :                 .add_function("AssignSubsetsByElementType",
     119              :                                         static_cast<void (*)(ISubsetHandler&)>(&AssignSubsetsByElementType))
     120            2 :                 .add_function("AssignSubsetColors", &AssignSubsetColors)
     121            2 :                 .add_function("AssignSubsetsByLevel", static_cast<void (*)(SubsetHandler&, MultiGrid&)>(&AssignSubsetsByLevel));
     122            1 : }
     123              : 
     124              : }//     end of namespace
     125              : }//     end of namespace
        

Generated by: LCOV version 2.0-1