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

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2012-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              : #ifndef __H__LIB_GRID__GLOBAL_FRACTURED_MEDIA_REFINER__
      34              : #define __H__LIB_GRID__GLOBAL_FRACTURED_MEDIA_REFINER__
      35              : 
      36              : #include <vector>
      37              : #include "lib_grid/lg_base.h"
      38              : #include "lib_grid/multi_grid.h"
      39              : #include "hanging_node_refiner_multi_grid.h"
      40              : #include "lib_grid/tools/bool_marker.h"
      41              : 
      42              : 
      43              : namespace ug
      44              : {
      45              : 
      46              : class ISubsetHandler;
      47              : 
      48              : ///     \addtogroup lib_grid_algorithms_refinement
      49              : ///     @{
      50              : ///     Performs global grid refinement, while performig anisotropic refinement in the given fractures.
      51              : /** If a subset shall be refined as a fracture, you may tell the refiner through
      52              :  * its method mark_as_fracture. Make sure that the subset specified in this
      53              :  * call, consists of two layers of elements. Pleas have a look at the literature
      54              :  * for a more detailed description of a fractures topology.
      55              :  * If you don't want to treat a subset as a fracture anymore (i.e. since the elements
      56              :  * have a good aspect ratio after a couple of refinements), you may tell the
      57              :  * refiner by setting the fracture mark to false using the method
      58              :  * mark_as_fracture once again.
      59              :  */
      60              : //template <class TAPosition>
      61              : class GlobalFracturedMediaRefiner : public IRefiner, public GridObserver
      62              : {
      63              :         public:
      64              :                 GlobalFracturedMediaRefiner(SPRefinementProjector projector = SPNULL);
      65              :                 GlobalFracturedMediaRefiner(MultiGrid& mg,
      66              :                                                                      SPRefinementProjector projector = SPNULL);
      67              :                                                            
      68              :                 virtual ~GlobalFracturedMediaRefiner();
      69              : 
      70              :                 virtual void grid_to_be_destroyed(Grid* grid);
      71              :                 
      72              :                 void assign_grid(MultiGrid& mg);
      73              :                 void assign_grid(MultiGrid* mg);
      74              : 
      75            0 :                 void set_subset_handler(ISubsetHandler* sh)     {m_pSH = sh;}
      76            0 :                 void set_subset_handler(ISubsetHandler& sh) {m_pSH = &sh;}
      77              : 
      78              :         ///     sets the position attachment
      79              :         /**     If you don't explicitly set the position attachment through this method,
      80              :          * the default position attachment is used, as returned by
      81              :          * ug::GetDefaultPositionAttachment.*/
      82              :                 //void set_position_attachment(TAPosition& aPos)    {m_aPos = aPos;}
      83              : 
      84              :         ///     if enabled, a subset will be regarded as a fracture.
      85              :         /**     If a subset is regarded as a fracture, it will be refined appropriately.
      86              :          * Please make sure, that the specified subset has a valid topology, as
      87              :          * described in ug::GlobalFracturedMediaRefiner.
      88              :          * @param subInd        The index of the subset whose property is set
      89              :          * @param isFracture    true or false, indicating whether the subset shall
      90              :          *                                              be regarded as a fracture or not.*/
      91              :                 void mark_as_fracture(int subInd, bool isFracture);
      92              : 
      93              :         ///     returns whether the specified subset is regarded as a fracture.
      94              :                 bool is_fracture(int subInd);
      95              : 
      96              : 
      97            0 :                 virtual Grid* get_associated_grid()             {return m_pMG;}
      98            0 :                 virtual Grid* grid()                                    {return m_pMG;}
      99            0 :                 virtual MultiGrid* multi_grid()                 {return m_pMG;}
     100              : 
     101            0 :                 virtual bool adaptivity_supported() const       {return false;}
     102            0 :                 virtual bool coarsening_supported() const       {return false;}
     103              : 
     104              :                 virtual bool save_marks_to_file(const char* filename);
     105              : 
     106              :         protected:
     107              :         ///     returns the number of (globally) marked edges on this level of the hierarchy
     108              :                 virtual void num_marked_edges_local(std::vector<int>& numMarkedEdgesOut);
     109              :         ///     returns the number of (globally) marked faces on this level of the hierarchy
     110              :                 virtual void num_marked_faces_local(std::vector<int>& numMarkedFacesOut);
     111              :         ///     returns the number of (globally) marked volumes on this level of the hierarchy
     112              :                 virtual void num_marked_volumes_local(std::vector<int>& numMarkedVolsOut);
     113              : 
     114              :                 template <class TElem>
     115              :                 void num_marked_elems(std::vector<int>& numMarkedElemsOut);
     116              :                 
     117              :         ////////////////////////////////
     118              :         ///     performs refinement on the marked elements.
     119              :                 virtual void perform_refinement();
     120              : 
     121              :         ///     called by perform_refinement to adjust the marks
     122              :         /**     Everything that shall be refined, should be marked in m_marker.
     123              :          * Note that the method calls communicate_marks twice, to allow derived
     124              :          * classes to e.g. communicate marks in a parallel environment. There thus
     125              :          * shouldn't be a need to reimplement adjust_marks in a derived class.*/
     126              :                 virtual void adjust_marks();
     127              : 
     128              :         ///     Called by adjust_marks. Default implementation does nothing.
     129              :         /**     If you communicate marks (using an or operation) in this method, then the
     130              :          * GlobalFracturedMediaRefiner should run fine in a parallel environment, too.
     131              :          * The default implementation does nothing (that's fine for a serial environment).*/
     132            0 :                 virtual void communicate_marks(BoolMarker& marker)          {}
     133              : 
     134              :         ///     performs the actual marking
     135              :         /**     This class is specialized for Face and Volume.*/
     136              :                 template <class TElem>
     137              :                 void assign_elem_and_side_marks();
     138              : 
     139              :         ///     recursively marks sides of all marked top level elements of the given type
     140              :                 template <class TElem>
     141              :                 void mark_sides_of_marked_top_level_elements();
     142              : 
     143              :         ///     returns the number of marked entries
     144              :                 template <class TElem>
     145              :                 size_t num_marked(const std::vector<TElem*>& elems) const;
     146              : 
     147              :         ///     a callback that allows to deny refinement of special vertices
     148            0 :                 virtual bool refinement_is_allowed(Vertex* elem)        {return true;}
     149              :         ///     a callback that allows to deny refinement of special edges
     150            0 :                 virtual bool refinement_is_allowed(Edge* elem)          {return true;}
     151              :         ///     a callback that allows to deny refinement of special faces
     152            0 :                 virtual bool refinement_is_allowed(Face* elem)                  {return true;}
     153              :         ///     a callback that allows to deny refinement of special volumes
     154            0 :                 virtual bool refinement_is_allowed(Volume* elem)                {return true;}
     155              :                 
     156              :         ///     this method helps derived classes to perform operations directly before actual element refinment is performed.
     157              :         /**     Called from the refine() method in each refinement-iteration after
     158              :          *      collect_objects_for_refine().
     159              :          *      Default implementation is empty.*/
     160            0 :                 virtual void refinement_step_begins()   {};
     161              : 
     162              :         ///     this method helps derived classes to perform operations directly after actual element refinment took place.
     163              :         /**     Called from the refine() method in each refinement-iteration after
     164              :          *      all scheduled elements had been refined.
     165              :          *      The refine process will either terminate after this method or will
     166              :          *      start a new iteration, if new elements had been marked during refine.
     167              :          *      Default implementation is empty.*/
     168            0 :                 virtual void refinement_step_ends()             {};
     169              :                 
     170              :         ///     returns true if the specified element is a fracture element.
     171              :         /**     Note that this method does not check whether the underlying subset-handler
     172              :          * is valid. Make sure to check that beforehand.*/
     173              :                 template <class TElem>
     174            0 :                 bool is_fracture_element(TElem* e)      {return is_fracture(m_pSH->get_subset_index(e));}
     175              : 
     176              :         protected:
     177              :                 BoolMarker                      m_marker;
     178              :                 std::vector<bool> m_subsetIsFracture;
     179              :                 //TAPosition                    m_aPos;
     180              :                 MultiGrid*                      m_pMG;
     181              :                 ISubsetHandler*         m_pSH;
     182              : };
     183              : 
     184              : /// @}
     185              : }//     end of namespace
     186              : 
     187              : #endif
        

Generated by: LCOV version 2.0-1