LCOV - code coverage report
Current view: top level - ugbase/lib_grid/refinement/projectors - refinement_projector.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 35 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 13 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_refinement_projector
      34              : #define __H__UG_refinement_projector
      35              : 
      36              : #include "common/boost_serialization.h"
      37              : #include "common/error.h"
      38              : #include "lib_grid/grid/geometry.h"
      39              : #include "lib_grid/grid/sub_grid.h"
      40              : #include "lib_grid/callbacks/element_callback_interface.h"
      41              : 
      42              : namespace ug{
      43              : 
      44              : ///     Adjusts vertex coordinates during refinement
      45              : /** The refinement projector serves as a base class for other refinement projectors
      46              :  * and serves as a simple linear projector at the same time. I.E. new vertices are
      47              :  * always placed at the center of their parent element.
      48              :  *
      49              :  * Internally, refinement projectors are implemented for 3d coordinates. Geometries
      50              :  * of lower dimension can still be treated since they are wrapped in a
      51              :  * IGeometry3d class. While this adds a small overhead it simplifies implementation
      52              :  * and usability considerably, since no additional template dependencies have to
      53              :  * be considered.
      54              :  */
      55              : class RefinementProjector {
      56              : public:
      57            0 :         RefinementProjector ()                  {}
      58              : 
      59            0 :         RefinementProjector (SPIGeometry3d geometry) :
      60              :                 m_geometry (geometry),
      61            0 :                 m_concernedElementsCallback (make_sp(new ConsiderAll()))
      62            0 :         {}
      63              :         
      64              :         RefinementProjector (SPElementCallback cb) :
      65              :                 m_concernedElementsCallback (cb)
      66              :         {}
      67              : 
      68              :         RefinementProjector (SPIGeometry3d geometry,
      69            0 :                                                  SPElementCallback concernedElems) :
      70              :                 m_geometry (geometry),
      71            0 :                 m_concernedElementsCallback (concernedElems)
      72              :         {}
      73              : 
      74            0 :         virtual ~RefinementProjector () {}
      75              : 
      76            0 :         virtual void set_geometry (SPIGeometry3d geometry)
      77              :         {
      78            0 :                 m_geometry = geometry;
      79            0 :         }
      80              : 
      81            0 :         virtual SPIGeometry3d geometry () const                         {return m_geometry;}
      82              : 
      83              : 
      84            0 :         virtual void set_concerned_elements (SPElementCallback cb)
      85            0 :         {m_concernedElementsCallback = cb;}
      86              : 
      87              : /**     returns 'true' if a specialized projector requires the subgrid during its
      88              :  * 'refinement_begins' method.
      89              :  *
      90              :  * \note        Implementers of derived classes should overload this method and
      91              :  *                      return 'true' if their 'refinement_begins' method requires a subgrid.
      92              :  *                      Please have a look at the documentation of 
      93              :  *                      'RefinementProjector::refinement_begins' for more information.
      94              :  */
      95            0 :         virtual bool refinement_begins_requires_subgrid () const        {return false;}
      96              : 
      97              : ///     called before refinement begins
      98              : /**     if not NULL, the specified sub-grid will contains all elements that will be
      99              :  * refined and are affected by the given projector.
     100              :  *
     101              :  * If the specialized implementation of refinement_begins requires this subgrid,
     102              :  * the method 'refinement_begins_requires_subgrid' should be specialized and should
     103              :  * return 'true'. In this case the subgrid should always be provided by the caller.
     104              :  * If you call 'RefinementProjector::refinement_begins(sg);' at the beginning of
     105              :  * your specialization, an error will be thrown if this is not the case.
     106              :  */
     107            0 :         virtual void refinement_begins(const ISubGrid* sg)
     108              :         {
     109            0 :                 UG_COND_THROW(m_geometry.invalid(),
     110              :                                           "Please set a valid geometry to RefinementProjectors "
     111              :                                           "before using them during refinement.");
     112            0 :                 UG_COND_THROW(refinement_begins_requires_subgrid() && !sg,
     113              :                                           "subgrid required in 'RefinementProjector::refinement_begins' "
     114              :                                           "but not provided.");
     115            0 :         }
     116              : 
     117              : ///     called when refinement is done
     118            0 :         virtual void refinement_ends()  {}
     119              : 
     120              : ///     called when a new vertex was created from an old vertex.
     121            0 :         virtual number new_vertex(Vertex* vrt, Vertex* parent)
     122              :         {
     123            0 :                 set_pos(vrt, pos(parent));
     124            0 :                 return 1;
     125              :         }
     126              : 
     127              : ///     called when a new vertex was created from an old edge.
     128            0 :         virtual number new_vertex(Vertex* vrt, Edge* parent)
     129              :         {
     130            0 :                 set_pos(vrt, geom().element_center(parent));
     131            0 :                 return 1;
     132              :         }
     133              : 
     134              : ///     called when a new vertex was created from an old face.
     135            0 :         virtual number new_vertex(Vertex* vrt, Face* parent)
     136              :         {
     137            0 :                 set_pos(vrt, geom().element_center(parent));
     138            0 :                 return 1;
     139              :         }
     140              : 
     141              : ///     called when a new vertex was created from an old volume.
     142            0 :         virtual number new_vertex(Vertex* vrt, Volume* parent)
     143              :         {
     144            0 :                 set_pos(vrt, geom().element_center(parent));
     145            0 :                 return 1;
     146              :         }
     147              : 
     148              : protected:
     149              :         vector3 pos (Vertex* v) const
     150              :         {
     151              :                 // UG_COND_THROW(m_geometry.invalid(),
     152              :                 //                        "Invalid Geometry in IRefinementProjector. Please make "
     153              :                 //                        "sure to set a valid adaptor through 'set_geometry_adaptor'.");
     154            0 :                 return m_geometry->pos(v);
     155              :         }
     156              : 
     157              :         void set_pos(Vertex* v, const vector3& p)
     158              :         {
     159              :                 // UG_COND_THROW(m_geometry.invalid(),
     160              :                 //                        "Invalid Geometry in IRefinementProjector. Please make "
     161              :                 //                        "sure to set a valid adaptor through 'set_geometry_adaptor'.");
     162            0 :                 m_geometry->set_pos(v, p);
     163            0 :         }
     164              : 
     165              :         IGeometry3d& geom ()                                {return *m_geometry;}
     166              :         const IGeometry3d& geom () const    {return *m_geometry;}
     167              : 
     168              :         template <class TElem>
     169              :         bool is_concerned (TElem* e) {
     170            0 :                 return (*m_concernedElementsCallback)(e);
     171              :         }
     172              : 
     173              : private:
     174              :         friend class boost::serialization::access;
     175              : 
     176              :         template <class Archive>
     177              :         void serialize( Archive& ar, const unsigned int version)
     178              :         {
     179              :         }
     180              : 
     181              :         SPIGeometry3d           m_geometry;
     182              :         SPElementCallback       m_concernedElementsCallback;
     183              : };
     184              : 
     185              : typedef SmartPtr<RefinementProjector>     SPRefinementProjector;
     186              : 
     187              : }//     end of namespace
     188              : 
     189              : #endif  //__H__UG_refinement_projector
        

Generated by: LCOV version 2.0-1