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

            Line data    Source code
       1              : /*
       2              :  * support.h
       3              :  *
       4              :  *  Created on: 5.8.2024
       5              :  *      Author: Markus M. Knodel
       6              : * help classes to implement the Arte algorithm
       7              :   */
       8              : 
       9              : 
      10              : #ifndef __SUPPORT_H__
      11              : #define __SUPPORT_H__
      12              : 
      13              : #include <iostream>
      14              : #include <stdexcept>
      15              : #include <cmath>
      16              : #include <iostream>
      17              : #include <stdlib.h>
      18              : #include <vector>
      19              : #include <assert.h>
      20              : #include <string>
      21              : #include <sstream>
      22              : #include <utility>
      23              : #include <vector>
      24              : #include <type_traits>
      25              : 
      26              : namespace ug
      27              : {
      28              : 
      29              : //namespace support
      30              : //{
      31              : 
      32              : 
      33              :  //////////////////////////////////////////////////////////////////////////////
      34              : 
      35              : // class to help count and store a bool and a number of templete type
      36              : // comparable to std::pair<bool,int> but more dedicated to the specific aim
      37              :  
      38              :  template< typename T >
      39              :  class VertexFractureProperties
      40              :  {
      41              :  public:
      42              : 
      43            0 :         VertexFractureProperties( bool isBndFracVertex,  T numberCrossingFracsInVertex )
      44            0 :         : m_isBndFracVertex(isBndFracVertex), m_numberCountedFracsInVertex(numberCrossingFracsInVertex)
      45              :         {
      46              :         };
      47              : 
      48              : 
      49              :         VertexFractureProperties()
      50              :         : VertexFractureProperties( false, 0 )
      51              :         {
      52              :         };
      53              : 
      54              :         void setIsBndFracVertex( bool iBDV = true )
      55              :         {
      56            0 :                 m_isBndFracVertex = iBDV;
      57            0 :         }
      58              : 
      59              :         void setNumberCrossingFracsInVertex( T const & nCFIV )
      60              :         {
      61              :                 m_numberCountedFracsInVertex = nCFIV;
      62              :         }
      63              : 
      64              :         bool getIsBndFracVertex()
      65              :         {
      66            0 :                 return m_isBndFracVertex;
      67              :         }
      68              : 
      69              : //      T getCountedNumberFracsInVertex()
      70              : //      {
      71              : //              return m_numberCountedFracsInVertex;
      72              : //      }
      73              : 
      74              : 
      75              :         T getNumberFracEdgesInVertex()
      76              :         {
      77            0 :                 return m_numberCountedFracsInVertex;
      78              :         }
      79              : 
      80              : //      T getNumberCrossingFracsInVertex()
      81              : //  {
      82              : //              if( m_isBndFracVertex )
      83              : //                      return m_numberCountedFracsInVertex;
      84              : //
      85              : //              // for inner vertices, each edge passed when
      86              : //              // fractures are counted along their edges
      87              : //              // that the vertizes get hit twice for each fracture run
      88              : //              // only for boundary vertices, this happens only once per fracture
      89              : //              T multipeInnerHits = 2;
      90              : //
      91              : //              T rest = m_numberCountedFracsInVertex % multipeInnerHits;
      92              : //
      93              : //              if( rest != 0 )
      94              : //              {
      95              : ////                    UG_THROW("Expand layers: rest division frac counting not zero " << m_numberCountedFracsInVertex << std::endl);
      96              : //
      97              : //                      throw std::runtime_error("error");
      98              : //
      99              : //                      return 0;
     100              : //              }
     101              : //
     102              : //              return m_numberCountedFracsInVertex / multipeInnerHits;
     103              : //  }
     104              : 
     105              :         VertexFractureProperties & operator++( int a )
     106              :         {
     107            0 :                 m_numberCountedFracsInVertex++;
     108              :                 return *this;
     109              :         }
     110              : 
     111              : 
     112              :  private:
     113              :         bool m_isBndFracVertex;
     114              :         T m_numberCountedFracsInVertex;
     115              :  };
     116              :  
     117              :  //////////////////////////////////////////////////////////////////////////////
     118              :  
     119              : // a class to store a matrix with two indices
     120              :  
     121              : template< typename I, typename D,
     122              : typename std::enable_if<std::is_integral<I>::value, int>::type = 0,
     123              : typename std::enable_if<std::is_arithmetic<D>::value, int>::type = 0
     124              : //, typename std::conditional_t<std::is_same_v<D, bool>, char, D>
     125              :         >
     126              : class MatrixTwoIndices
     127              : {
     128              : public:
     129              : 
     130              :    // standard constructor
     131              :    MatrixTwoIndices() : x_degree(-1), y_degree(-1) {};
     132              : 
     133              :    // constructor, wants to know the degrees
     134              :    MatrixTwoIndices( I _x_degree_, I _y_degree_, D defVal = 0 )
     135              :           : x_degree(_x_degree_), y_degree(_y_degree_)
     136              :         { values = std::vector<D>(  (_x_degree_)*(_y_degree_),  defVal  ); }
     137              : 
     138              :    // asking for a special element, cout << object(i,j) ...
     139              :    D const operator()( I i, I j ) const
     140              :    {
     141              :           assert( x_degree > 0 &&  y_degree > 0 );
     142              :       return values[ j*(x_degree) + i ];
     143              :    }
     144              : 
     145              :    // giving a special element a special value , object(i,j) = xx -> values[...] = xx
     146              :    D & operator()( I i, I j )
     147              :    {
     148              :           assert( x_degree > 0 &&  y_degree > 0 );
     149              :       return values[ j*(x_degree) + i ];
     150              :    }
     151              : 
     152              : private:
     153              : 
     154              :    std::vector<D> values;
     155              :    I x_degree, y_degree; // the degree of the polynom in x and y
     156              : 
     157              :  };
     158              : 
     159              : //      std::vector<double> minDist2Center(fracInfos.size(), std::numeric_limits<double>);
     160              : // matrix, wo auch index drin ist der subdom
     161              : 
     162              : //      MatrixTwoIndices<IndexType,double> mat_fracInd_minFacePep( fracInfos.size(), 100 );
     163              : //      MatrixTwoIndices<IndexType,double> mat_fracInd_minFacePep( fracInfos.size(), std::numeric_limits<double>::max() );
     164              :         //MatrixTwoIndices mat_fracInd_minFacePep( fracInfos.size(), std::numeric_limits<double> );
     165              : 
     166              : //      MatrixTwoIndices<IndexType,double> mat_fracInd_minFacePep( 30, 20, std::numeric_limits<double>::max() );
     167              : //
     168              : //      class bla{
     169              : //
     170              : //      };
     171              : //
     172              : //      bla blubb;
     173              : //
     174              : //      MatrixTwoIndices<IndexType, bla> mat_by( 30, 20, blubb );
     175              : 
     176              : 
     177              : /////////////////////////////////////////////////////////////////////////////
     178              : 
     179              : 
     180              : template <class T>
     181              : class T_min
     182              : {
     183              :  
     184              : public:
     185              :   // constructor, initializes minval (cause the first told is in this
     186              :   // moment the maximum) 
     187              :   T_min( T val ) : minval( val ) {}; 
     188              : 
     189              :   // tells the minimal value
     190              :   T const operator()() const  { return minval; };
     191              :  
     192              :   // wants to know values, saves the minimum
     193              :   void operator()(T val) 
     194            0 :   { if( minval > val )  minval = val; };
     195              : 
     196              : 
     197              : protected:
     198              : 
     199              :   T minval;
     200              :   
     201              : private:
     202              :   
     203              :   T_min() {};
     204              : };
     205              : 
     206              : //////////////////////////////////////////////////////////////////////
     207              : 
     208              : 
     209              : template <
     210              : typename ECKENTYP,
     211              : typename GESICHTSTYP, 
     212              : typename SENKRECHTENTYP 
     213              : >
     214            0 : class VertexFractureTriple
     215              : {
     216              : 
     217              : public:
     218              :         
     219            0 :         VertexFractureTriple( ECKENTYP const & edge, GESICHTSTYP const & face, SENKRECHTENTYP const & normal   )
     220            0 :         : m_edge(edge), m_face(face), m_normal(normal), m_newNormal(normal)
     221              :         {       
     222              :         };
     223              : 
     224            0 :         ECKENTYP const getEdge() const { return m_edge; } 
     225              :         
     226            0 :         GESICHTSTYP const getFace() const { return m_face; } 
     227              :         
     228            0 :         SENKRECHTENTYP const getNormal() const { return m_normal; } 
     229              : 
     230            0 :         void setNewNormal( SENKRECHTENTYP const & chNorml ) { m_newNormal = chNorml; }
     231            0 :         SENKRECHTENTYP const getNewNormal() const { return m_newNormal; }
     232              : 
     233              : private:
     234              :         
     235              :         ECKENTYP m_edge;
     236              :         GESICHTSTYP m_face;
     237              :         SENKRECHTENTYP  m_normal;
     238              :         SENKRECHTENTYP  m_newNormal;
     239              :         
     240              :         VertexFractureTriple()
     241              :         {};
     242              :         
     243              : };
     244              : 
     245              : 
     246              : //////////////////////////////////////////////////////////////////
     247              : 
     248              : template < typename VRT, typename IndTyp > //, typename EDG > //, typename SHIFTINFO > //, typename FAC >
     249            0 : class CrossingVertexInfo
     250              : {
     251              : 
     252              : public:
     253              : 
     254              :         enum FracTyp { SingleFrac = 2, TEnd = 3, XCross = 4 };
     255              : 
     256            0 :         CrossingVertexInfo( VRT const & crossVrt, IndTyp numbCrossFracs )
     257            0 :         : m_crossVrt(crossVrt), m_numbCrossFracs( numbCrossFracs ),
     258              :           m_vecShiftedVrts(std::vector<VRT>()) //, m_vecOrigEdges(std::vector<EDG>()) //, m_vecAdjFracFac( std::vector<FAC>() )
     259              : //        m_shiftInfo(std::vector<SHIFTINFO>())
     260              :         ,  m_vecShiftedVrtsWithTypInf(std::vector<std::pair<VRT,bool>>())
     261            0 :         , m_numberAtFreeSide(0)
     262              :         {
     263            0 :                 if( numbCrossFracs == 2 )
     264              :                 {
     265            0 :                         m_fracTyp = SingleFrac;
     266              :                 }
     267            0 :                 if( numbCrossFracs == 3 )
     268              :                 {
     269            0 :                         m_fracTyp = TEnd;
     270              :                 }
     271            0 :                 else if( numbCrossFracs == 4 )
     272              :                 {
     273            0 :                         m_fracTyp = XCross;
     274              :                 }
     275              :                 else
     276              :                 {
     277              :                         UG_LOG("frac typ wrong " << numbCrossFracs << std::endl);
     278              :                 }
     279            0 :         }
     280              : 
     281            0 :         VRT getCrossVertex() const { return m_crossVrt; }
     282              : 
     283              : //      IndTyp getNumbCrossFracs() const { return m_numbCrossFracs; }
     284            0 :         FracTyp getFracTyp() const { return m_fracTyp; }
     285              : 
     286            0 :         void addShiftVrtx( VRT const & vrt, bool isAtFreeSide = false )
     287              :         {
     288              : //              if( m_fracTyp == XCross )
     289            0 :                 m_vecShiftedVrts.push_back(vrt);
     290              : 
     291              : //              if( isAtFreeSide )
     292              : //                      UG_THROW("XCross ohne freie Seite " << std::endl);
     293              : 
     294            0 :                 if( m_fracTyp == TEnd )
     295              :                 {
     296              :                         std::pair<VRT, bool > addSVI( vrt, isAtFreeSide );
     297            0 :                         m_vecShiftedVrtsWithTypInf.push_back(addSVI);
     298              : 
     299            0 :                         if( isAtFreeSide )
     300            0 :                                 m_numberAtFreeSide++;
     301              : 
     302            0 :                         if( m_numberAtFreeSide > 1 )
     303            0 :                                 UG_THROW("was ist das fuer ein T Ende" << std::endl);
     304              :                 }
     305              : 
     306            0 :         }
     307              : 
     308              : //      void addOriginalFracEdge( EDG const & edg ) { m_vecOrigEdges.push_back(edg); }
     309              : 
     310              : //      void addShiftInfo( SHIFTINFO const & shi ) { m_shiftInfo.push_back(shi); }
     311              : 
     312              : //      void addAdjntFracFaces( FAC const & fac ) { m_vecAdjFracFac.push_back(fac); }
     313              : 
     314              :         void setShiftVrtx( std::vector<VRT> const & vecVrt ) { m_vecShiftedVrts = vecVrt; }
     315              : 
     316              : //      void setOriginalFracEdge( std::vector<EDG>  const & vecEdg ) { m_vecOrigEdges = vecEdg; }
     317              : 
     318              : //      void setShiftInfo( SHIFTINFO const & vecShi ) { m_shiftInfo = vecShi; }
     319              : 
     320              : //      void setAdjntFracFaces( std::vector<FAC> const & vecFac ) { m_vecAdjFracFac = vecFac; }
     321              : 
     322              : //      void addShiftVectors( vector3 const & projectNrmFraOneToEdgTwoDirection, vector3 const & projectNrmFraTwoToEdgOneDirection, IndexType segmentNum )
     323              : //      {
     324              : //              m_projectNrmFraOneToEdgTwoDirection = projectNrmFraOneToEdgTwoDirection;
     325              : //              m_projectNrmFraTwoToEdgOneDirection = projectNrmFraTwoToEdgOneDirection;
     326              : //      }
     327              : 
     328              : 
     329              : 
     330              :         std::vector<VRT> getVecShiftedVrts() const
     331              :         {
     332              : //              if( m_fracTyp != XCross )
     333              : //                      UG_LOG("fuer Kreuz nicht erlaubt " << std::endl);
     334              : 
     335            0 :                 return m_vecShiftedVrts;
     336              :         }
     337              : 
     338            0 :         std::vector<std::pair<VRT,bool>> getVecShiftedVrtsWithTypInfo() const
     339              :         {
     340            0 :                 if( m_fracTyp != TEnd )
     341            0 :                         UG_THROW("fuer Kreuz nicht erlaubt " << std::endl);
     342              : 
     343            0 :                 return m_vecShiftedVrtsWithTypInf;
     344              :         }
     345              : 
     346              : 
     347              : //      std::vector<EDG> getVecOrigFracEdges() const { return m_vecOrigEdges; }
     348              : 
     349              : //      std::vector<SHIFTINFO> getShiftInfo() const { return m_shiftInfo; }
     350              : 
     351              : 
     352              : 
     353              : //      std::vector<FAC> getVecAdjntFracFaces() const { return m_vecAdjFracFac; }
     354              : 
     355              : //      std::pair<vector3,vector3> getShiftVectors( ) const
     356              : //      {
     357              : //              std::pair<vector3,vector3> shiVe;
     358              : //
     359              : //              shiVe.first  = m_projectNrmFraOneToEdgTwoDirection;
     360              : //              shiVe.second = m_projectNrmFraTwoToEdgOneDirection;
     361              : //
     362              : //              return shiVe;
     363              : //      }
     364              : 
     365              : private:
     366              : 
     367              :         VRT m_crossVrt;
     368              :         IndTyp m_numbCrossFracs;
     369              :         std::vector<VRT> m_vecShiftedVrts;
     370              :         std::vector<std::pair<VRT,bool>> m_vecShiftedVrtsWithTypInf;
     371              : //      std::vector<EDG> m_vecOrigEdges;
     372              : //      std::vector<FAC> m_vecAdjFracFac;
     373              : //      vector3 m_projectNrmFraOneToEdgTwoDirection, m_projectNrmFraTwoToEdgOneDirection;
     374              : //      std::vector<SHIFTINFO> m_shiftInfo;
     375              :         FracTyp m_fracTyp;
     376              :         IndTyp m_numberAtFreeSide;
     377              : };
     378              : 
     379              : 
     380              : //////////////////////////////////////////////////////////////////
     381              : 
     382              : //}
     383              : 
     384              : }
     385              : 
     386              : #endif
     387              : 
        

Generated by: LCOV version 2.0-1