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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Dmitry Logashenko
       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              : /*
      34              :  * A manager for the degenerated layer subsets. It helps to distinguish between the sides
      35              :  * of the degenerated elements and to find out the correspondence of the nodes
      36              :  * in them.
      37              :  */
      38              : #ifndef __H__UG__PLUGINS__D3F__DEGENERATED_LAYER_MANAGER__
      39              : #define __H__UG__PLUGINS__D3F__DEGENERATED_LAYER_MANAGER__
      40              : 
      41              : #include <map>
      42              : #include <vector>
      43              : 
      44              : // ug4 headers
      45              : #include "common/common.h"
      46              : #include "common/util/smart_pointer.h"
      47              : #include "lib_grid/grid/grid.h"
      48              : #include "lib_grid/tools/subset_group.h"
      49              : #include "lib_grid/tools/subset_handler_multi_grid.h"
      50              : #include "lib_grid/algorithms/subset_dim_util.h"
      51              : #include "lib_grid/grid_objects/grid_dim_traits.h"
      52              : #include "lib_grid/refinement/global_fractured_media_refiner.h"
      53              : #ifdef UG_PARALLEL
      54              : #include "lib_grid/parallelization/distributed_grid.h"
      55              : #include "lib_grid/parallelization/util/attachment_operations.hpp"
      56              : #endif
      57              : 
      58              : namespace ug {
      59              : 
      60              : /// Gegenerated layer subset manager
      61              : /**
      62              :  * Class for the manager of the degenerated layer (e.g. fracture) subsets. Note
      63              :  * that the object of the class should get ALL the subsets that belong to ALL
      64              :  * the degenerated layers in the domain. This object gets updated every time
      65              :  * the grid is refined.
      66              :  *
      67              :  * Usage instructions:
      68              :  * <ul>
      69              :  *  <li> Create the object of the DegeneratedLayerManager class </li>
      70              :  *  <li> Use the method DegeneratedLayerManager::add to register a degenerated
      71              :  *       layer subsets in the object </li>
      72              :  *  <li> Call the DegeneratedLayerManager::close method to mark the vertices
      73              :  *       as 'inner' or 'outer'. </li>
      74              :  * </ul>
      75              :  *
      76              :  * Remarks:
      77              :  * <ul>
      78              :  *  <li> The grid must be created (loaded) before the object is created. </li>
      79              :  *  <li> All the degenerated layer subsets must be registered in the same degenerated
      80              :  *       layer manager. There should exist only one such the manager at all. Alternatively,
      81              :  *       the different managers must hold groups of the layers that are not intersect or
      82              :  *       connected to each other. But every degenerated subset must be registered
      83              :  *       in one of the degenerated layer managers. </li>
      84              :  * </ul>
      85              :  *
      86              :  * References:
      87              :  * <ul>
      88              :  *  <li> S. Reiter, D. Logashenko, A. Grillo, G. Wittum, Preparation of grids
      89              :  *       for simulations of groundwater flow in fractured porous media,
      90              :  *       Computing and Visualization in Science, Vol. 15, No. 4 (2012),
      91              :  *       pp. 209-225, DOI: 10.1007/s00791-013-0210-7
      92              :  *  </li>
      93              :  * </ul>
      94              :  *
      95              :  * \tparam dim  (topological) dimensionality of the grid
      96              :  */
      97              : template <int dim>
      98              : class DegeneratedLayerManager
      99              : {
     100              : public:
     101              :         /// type of the attachment for the marks
     102              :                 typedef Attachment<signed char> mark_attachment_type;
     103              :                 
     104              :         ///     base grid element object type
     105              :                 typedef typename grid_dim_traits<dim>::grid_base_object element_type;
     106              :                 
     107              :         ///     grid element's side base object type
     108              :                 typedef typename grid_dim_traits<dim>::side_type side_type;
     109              :                 
     110              :         ///     max. number of corners of the elements
     111              :                 static const size_t maxElemCorners = grid_dim_traits<dim>::MaxNumVerticesOfElem;
     112              :                 
     113              :         ///     max. number of corners of non-degenerated sides
     114              :                 static const size_t maxLayerSideCorners = maxElemCorners / 2;
     115              :         
     116              :         /// Marks for the grid vertices
     117              :                 enum t_grid_object_mark
     118              :                 {
     119              :                         D_LAYER_UNKNOWN = -1,
     120              :                         D_LAYER_OUTER = 0,
     121              :                         D_LAYER_INNER = 1
     122              :                 };
     123              : 
     124              : public:
     125              :         /// Constructor
     126              :                 DegeneratedLayerManager
     127              :                 (
     128              :                         SmartPtr<MultiGridSubsetHandler> spSH ///< [in] subset handler of the grid
     129              :                 );
     130              :                 
     131              :         /// Destructor
     132              :                 virtual ~DegeneratedLayerManager ();
     133              :                 
     134              :         ///     Adds a fracture subdomain
     135              :                 void add
     136              :                 (
     137              :                         const char * ss_names ///< [in] subset names of the fractures
     138              :                 );
     139              :                 
     140              :         ///     Removes a fracture subdomain (e.g. for dimension-adaptive method)
     141              :                 void remove
     142              :                 (
     143              :                         const char * ss_names ///< [in] subset names of the fractures
     144              :                 );
     145              : 
     146              :         ///     Closes the manager, i.e. computes all the data, ...
     147              :                 void close ();
     148              :                 
     149              :         ///     Initializes a refiner with the fracture subsets
     150              :                 void init_refiner
     151              :                 (
     152              :                         SmartPtr<GlobalFracturedMediaRefiner> refiner, ///< the refiner
     153              :                         bool as_low_dim ///< whether it should consider the fractures as low-dimentional
     154              :                 );
     155              :                 
     156              :         ///     Returns true if the manager is closed (and can be used) or false otherwise
     157            0 :                 bool is_closed () {return m_bClosed;};
     158              :                 
     159              :         ///     Whether a subset is registered in the manager
     160            0 :                 bool contains
     161              :                 (
     162              :                         int si ///< [in] subset index
     163              :                 )
     164            0 :                 {return m_layerSsGrp.contains (si);};
     165              :                 
     166              :         ///     Returns the subset group of the fracture network
     167              :                 const SubsetGroup & subset_grp () {return m_layerSsGrp;};
     168              :                 
     169              :         ///     Number of subsets in the manager
     170            0 :                 size_t num_subsets () {return m_layerSsGrp.size ();};
     171              :                 
     172              :         /// Subset no. i in the manager (only if the manager is closed)
     173            0 :                 int subset (size_t i)
     174              :                 {
     175            0 :                         if (! is_closed ()) UG_THROW ("DegeneratedLayerManager: The manager is not closed.");
     176            0 :                         return m_layerSsGrp[i];
     177              :                 }
     178              :                 
     179              :         ///     Returs the mark of a vertex
     180            0 :                 int vert_mark (Vertex * vrt) {return m_aaVertMarks [vrt];};
     181              :                 
     182              :         ///     Gets the inner and the outer fracture sides of an element
     183              :                 void get_layer_sides
     184              :                 (
     185              :                         element_type * elem, ///< [in] the element
     186              :                         size_t & num_fract_co, ///< [out] number of corners of the inner/outer sides
     187              :                         side_type * & inner_side, ///< [out] its fracture inner side
     188              :                         size_t & inner_side_idx, ///< [out] index of the inner side in the reference element
     189              :                         size_t inner_side_corners [], ///< [out] inner side corner idx -> elem. corner idx (maxLayerSideCorners elements)
     190              :                         side_type * & outer_side, ///< [out] its fracture outer side
     191              :                         size_t & outer_side_idx, ///< [out] index of the outer side in the reference element
     192              :                         size_t outer_side_corners [], ///< [out] outer side corner idx -> elem. corner idx (maxLayerSideCorners elements)
     193              :                         size_t ass_co [] = NULL ///< [out] correspondence of the corners of the sides (2 * maxLayerSideCorners elements or NULL)
     194              :                 );
     195              :                 
     196              :         ///     Assigns a different subset index to the inner sides of a layer
     197              :                 int assign_middle_subset
     198              :                 (
     199              :                         int layer_si, ///< subset index of the layer
     200              :                         int middle_si = -1 ///< the subset index to assign (or -1 to create a new subset)
     201              :                 );
     202              :                 
     203              :         ///     Assigns a different subset to the inner sides of a layer
     204              :                 int assign_middle_subset
     205              :                 (
     206              :                         int layer_si, ///< subset index of the layer
     207              :                         const char* middle_ss_name ///< name of the subset to assign
     208              :                 );
     209              :                 
     210              :         ///     Assigns a different subset to the inner sides of a layer
     211              :                 int assign_middle_subset
     212              :                 (
     213              :                         const char* layer_ss_name, ///< subset name of the layer
     214              :                         const char* middle_ss_name ///< name of the subset to assign
     215              :                 );
     216              :                 
     217              : protected:
     218              :         /// Marks the inner fracture vertices
     219              :                 void mark_vertices ();
     220              :         
     221              :         ///     Called when a grid adaption has been performed
     222              :                 void grid_adaption_callback (const GridMessage_Adaption& msg);
     223              : 
     224              :         ///     Called when a grid has been distributed between different processes
     225              :                 void grid_distribution_callback (const GridMessage_Distribution& msg);
     226              :         
     227              : private:
     228              :         /// Subset handler to use
     229              :                 SmartPtr<MultiGridSubsetHandler> m_spSH;
     230              :         
     231              :         ///     Subset group of the fractures
     232              :                 SubsetGroup m_layerSsGrp;
     233              :         
     234              :         /// Attachment keeping the grid object marks for the vertices
     235              :                 mark_attachment_type m_aVertexMarks;
     236              :         ///     Attachment accessor
     237              :                 MultiGrid::AttachmentAccessor<Vertex, mark_attachment_type> m_aaVertMarks;
     238              :                 
     239              :         ///     'closed'-flag
     240              :                 bool m_bClosed;
     241              :                 
     242              :         //      Message hub callback id's for the notifications of the changes of the grid:
     243              :                 MessageHub::SPCallbackId m_spGridAdaptionCallbackID;
     244              :                 MessageHub::SPCallbackId m_spGridDistributionCallbackID;
     245              : };
     246              : 
     247              : } // end namespace ug
     248              : 
     249              : #include "deg_layer_mngr_impl.h"
     250              : 
     251              : #endif // __H__UG__PLUGINS__D3F__DEGENERATED_LAYER_MANAGER__
     252              : 
     253              : /* End of File */
        

Generated by: LCOV version 2.0-1