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