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

Generated by: LCOV version 2.0-1