LCOV - code coverage report
Current view: top level - ugbase/lib_grid/refinement/projectors - projection_handler.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 % 2 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2016:  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__UG_projection_handler_new
      34              : #define __H__UG_projection_handler_new
      35              : 
      36              : #include <vector>
      37              : #include <algorithm>
      38              : #include "common/assert.h"
      39              : #include "refinement_projector.h"
      40              : #include "lib_grid/tools/subset_handler_interface.h"
      41              : #include "lib_grid/callbacks/selection_callbacks.h"
      42              : #include "lib_grid/callbacks/subset_callbacks.h"
      43              : 
      44              : namespace ug{
      45              : 
      46              : ///     Associates different projectors with individual subsets
      47              : /**     In many cases it is useful to use different RefinementProjectors on different
      48              :  * parts of a grid. To do so one may use a SubsetHandler to partition the grid into
      49              :  * different parts. This SubsetHandler can then be passed to the ProjectionHandler
      50              :  * and different RefinementProjectors can be associated with each subset through
      51              :  * 'set_projector'.
      52              :  */
      53              : UG_API class ProjectionHandler : public RefinementProjector {
      54              : public:
      55              :         ProjectionHandler ();
      56              : 
      57              : /**     Please makre sure that the given subset-handler outlives the ProjectionHandler.
      58              :  * Please note that an alternative constructor taking a smart-pointer to a
      59              :  * SubsetHandler exists.
      60              :  * \sa ug::RefinementProjector::RefinementProjector*/
      61              :         ProjectionHandler (ISubsetHandler* psh);
      62              : 
      63              : /**     \sa ug::RefinementProjector::RefinementProjector*/
      64              :         ProjectionHandler (SmartPtr<ISubsetHandler> psh);
      65              : 
      66              : /**     Please makre sure that the given subset-handler outlives the ProjectionHandler.
      67              :  * Please note that an alternative constructor taking a smart-pointer to a
      68              :  * SubsetHandler exists.
      69              :  * \sa ug::RefinementProjector::RefinementProjector*/
      70              :         ProjectionHandler (SPIGeometry3d geometry,
      71              :                                            ISubsetHandler* psh);
      72              : 
      73              : /**     \sa ug::RefinementProjector::RefinementProjector*/
      74              :         template <class TGeomProvider>
      75            0 :         ProjectionHandler (const TGeomProvider& geometry,
      76              :                                            SmartPtr<ISubsetHandler> psh) :
      77              :                 RefinementProjector (geometry),
      78            0 :                 m_sh (psh.get()),
      79            0 :                 m_spSH (psh)
      80              :         {
      81            0 :                 m_defaultProjector = make_sp(new RefinementProjector);
      82            0 :         }
      83              : 
      84              :         virtual ~ProjectionHandler ();
      85              : 
      86              :         void clear();
      87              : 
      88              :         virtual void set_geometry (SPIGeometry3d geometry);
      89              : 
      90              : ///     Sets the geometry of the ProjectionHandler and of all associated projectors
      91              : /** \note       If you'd like to change the geometry of the ProjectionHandler only,
      92              :  *                      please use 'set_geometry' instead.*/
      93              :         virtual void set_geometry_all (SPIGeometry3d geometry);
      94              : 
      95              : /**     Please make sure that the given subset-handler outlives the ProjectionHandler.
      96              :  * Please note that an alternative 'set_subset_handler' exists, which takes a
      97              :  * smart-pointer to a SubsetHandler.*/
      98              :         void set_subset_handler (ISubsetHandler* psh);
      99              : 
     100              :         void set_subset_handler (SmartPtr<ISubsetHandler> psh);
     101              : 
     102              : 
     103              : ///     return the subset handler that the projection handler is based on
     104            0 :         inline const ISubsetHandler* subset_handler() const                     {return m_sh;}
     105              : 
     106              :         void set_default_projector (SPRefinementProjector projector);
     107              :         
     108              : ///     associate a projector with a given subsetIndex. Note that '-1' is a valid index, too.
     109              : /**     \note   if no geometry-object was set to the ProjectionHandler and if the given
     110              :  *                      projector has an associated geometry-object, the handler will copy
     111              :  *                      the geometry-object of the projector for its own use.*/
     112              :         void set_projector (int subsetIndex, SPRefinementProjector projector);
     113              : 
     114              : ///     associate a projector with a subset of the given name.
     115              : /** \note       a valid subset-handler has to be set to ProjectionHandler before a
     116              :  *                      subset can be specified by a name. Note that it is possible to
     117              :  *                      specify a subset by index before setting a SubsetHandler.
     118              :  *
     119              :  * \note        if no geometry-object was set to the ProjectionHandler and if the given
     120              :  *                      projector has an associated geometry-object, the handler will copy
     121              :  *                      the geometry-object of the projector for its own use.*/
     122              :         void set_projector (const char* subsetName, SPRefinementProjector projector);
     123              : 
     124            0 :         inline size_t num_projectors () const           {return m_projectors.size() > 0 ? m_projectors.size() - 1 : 0;}
     125              :         
     126              :         inline SPRefinementProjector
     127            0 :         projector (size_t i)                                            {projector_required((int)i); return m_projectors.at(i + 1);}
     128              : 
     129              :         inline ConstSmartPtr<RefinementProjector>
     130              :         projector (size_t i)    const                           {return m_projectors.at(i + 1);}
     131              : 
     132              :         inline SPRefinementProjector
     133              :         default_projector ()                                            {return m_defaultProjector;}
     134              : 
     135              :         inline ConstSmartPtr<RefinementProjector>
     136              :         default_projector ()    const                           {return m_defaultProjector;}
     137              : 
     138              : ////////////////////////////////////////
     139              : //      IMPLEMENTATION OF RefinementProjector
     140              :         virtual bool refinement_begins_requires_subgrid () const;
     141              : 
     142              : ///     prepares associated projectors for refinement
     143              : /**     If an associated projector hasn't got an associated geometry, the geometry
     144              :  * of the ProjectionHandler will automatically be assigned.*/
     145              :         virtual void refinement_begins (const ISubGrid* psg);
     146              : 
     147              :         virtual void refinement_ends();
     148              : 
     149              : ///     called when a new vertex was created from an old vertex.
     150              :         virtual number new_vertex (Vertex* vrt, Vertex* parent);
     151              : 
     152              : ///     called when a new vertex was created from an old edge.
     153              :         virtual number new_vertex (Vertex* vrt, Edge* parent);
     154              : 
     155              : ///     called when a new vertex was created from an old face.
     156              :         virtual number new_vertex (Vertex* vrt, Face* parent);
     157              : 
     158              : ///     called when a new vertex was created from an old volume.
     159              :         virtual number new_vertex (Vertex* vrt, Volume* parent);
     160              : 
     161              : 
     162              : private:
     163              :         friend class boost::serialization::access;
     164              : 
     165              :         void projector_required(int index);
     166              : 
     167              :         template <class TParent>
     168              :         number handle_new_vertex (Vertex* vrt, TParent* parent);
     169              : 
     170              :         ISubsetHandler*                                                         m_sh;
     171              :         SmartPtr<ISubsetHandler>                                  m_spSH;
     172              :         std::vector<SmartPtr<RefinementProjector> > m_projectors;
     173              :         SmartPtr<RefinementProjector>                             m_defaultProjector;
     174              : };
     175              : 
     176              : typedef SmartPtr<ProjectionHandler>       SPProjectionHandler;
     177              : 
     178              : }//     end of namespace
     179              : 
     180              : #endif  //__H__UG_projection_handler_new
        

Generated by: LCOV version 2.0-1