LCOV - code coverage report
Current view: top level - ugbase/lib_grid/refinement/projectors - cylinder_cut_projector.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 26 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 10 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_cylinder_cut_projector
      34              : #define __H__UG_cylinder_cut_projector
      35              : 
      36              : #include "refinement_projector.h"
      37              : 
      38              : namespace ug{
      39              : 
      40              : /// Refines linearily except for when a refined edge intersects the given cylinder
      41              : /**     Refines linearily except for when a refined edge intersects the given cylinder.
      42              :  * the new vertex will be placed at the intersection of the edge with the cylinder
      43              :  * in this case.
      44              :  *
      45              :  * \note        This projector is not commonly used during grid adaption. It serves
      46              :  *                      very special purposes for specialized algorithms. Used without
      47              :  *                      specialized meshing operations it may lead to bad elements.
      48              :  */
      49              : class CylinderCutProjector : public RefinementProjector {
      50              : public:
      51            0 :         CylinderCutProjector () :
      52              :                 m_center (0, 0, 0),
      53              :                 m_axis (0, 0, 1),
      54            0 :                 m_radius (1)
      55              :         {}
      56              :         
      57              :         CylinderCutProjector (const vector3& center,
      58              :                                                   const vector3& axis,
      59            0 :                                                   number radius) :
      60              :                 m_center (center),
      61              :                 m_axis (axis),
      62            0 :                 m_radius (radius)
      63              :         {}
      64              : 
      65              : /**     \sa ug::RefinementProjector::RefinementProjector*/
      66            0 :         CylinderCutProjector (SPIGeometry3d geometry,
      67              :                                                   const vector3& center,
      68              :                                                   const vector3& axis,
      69            0 :                                                   number radius) :
      70              :                 RefinementProjector (geometry),
      71              :                 m_center (center),
      72              :                 m_axis (axis),
      73            0 :                 m_radius (radius)
      74            0 :         {}
      75              : 
      76              : 
      77              : 
      78            0 :         virtual ~CylinderCutProjector ()                        {}
      79              : 
      80            0 :         void set_center (const vector3& center)             {m_center = center;}
      81            0 :         const vector3& center () const                              {return m_center;}
      82              : 
      83            0 :         void set_axis (const vector3& axis)                 {m_axis = axis;}
      84            0 :         const vector3& axis () const                                {return m_axis;}
      85              : 
      86            0 :         void set_radius (number radius)                         {m_radius = radius;}
      87            0 :         number radius () const                                          {return m_radius;}
      88              : 
      89              : ///     called when a new vertex was created from an old edge.
      90            0 :         virtual number new_vertex(Vertex* vrt, Edge* parent)
      91              :         {
      92              :                 number t0, t1;
      93            0 :                 vector3 from = pos(parent->vertex(0));
      94              :                 vector3 dir;
      95            0 :                 VecSubtract(dir, pos(parent->vertex(1)), from);
      96              : 
      97            0 :                 if(RayCylinderIntersection(t0, t1, from, dir, m_center, m_axis, m_radius))
      98              :                 {
      99              :                 //      if there are two intersections with parameters between 0 and 1,
     100              :                 //      we'll return their median.
     101            0 :                         bool t0IsFine = (t0 >= 0) && (t0 <= 1);
     102            0 :                         bool t1IsFine = (t1 >= 0) && (t1 <= 1);
     103            0 :                         if(t0IsFine){
     104            0 :                                 if(t1IsFine) {
     105              :                                         vector3 v0, v1, p;
     106              :                                         VecScaleAdd(v0, 1., from, t0, dir);
     107              :                                         VecScaleAdd(v1, 1., from, t1, dir);
     108              :                                         VecScaleAdd(p, 0.5, v0, 0.5, v1);
     109              :                                         set_pos(vrt, p);
     110              :                                 }
     111              :                                 else {
     112              :                                         vector3 p;
     113              :                                         VecScaleAdd(p, 1., from, t0, dir);
     114              :                                         set_pos(vrt, p);
     115              :                                 }
     116            0 :                                 return 1;
     117              :                         }
     118            0 :                         else if(t1IsFine) {
     119              :                                 vector3 p;
     120              :                                 VecScaleAdd(p, 1., from, t1, dir);
     121              :                                 set_pos(vrt, p);
     122              :                                 return 1;
     123              :                         }
     124              :                 }
     125              : 
     126              :                 RefinementProjector::new_vertex(vrt, parent);
     127            0 :                 return 1;
     128              :         }
     129              : 
     130              : private:
     131              :         friend class boost::serialization::access;
     132              : 
     133              :         template <class Archive>
     134              :         void serialize( Archive& ar, const unsigned int version)
     135              :         {
     136              :                 ar & make_nvp("center", m_center);
     137              :                 ar & make_nvp("axis", m_axis);
     138              :                 ar & make_nvp("radius", m_radius);
     139              :                 UG_EMPTY_BASE_CLASS_SERIALIZATION(CylinderCutProjector, RefinementProjector);
     140              :         }
     141              : 
     142              :         vector3 m_center;
     143              :         vector3 m_axis;
     144              :         number  m_radius;
     145              : };
     146              : 
     147              : }//     end of namespace
     148              : 
     149              : #endif  //__H__UG_cylinder_cut_projector
        

Generated by: LCOV version 2.0-1