ug4
Loading...
Searching...
No Matches
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
26namespace ug
27{
28
29namespace arte
30{
31
32//namespace support
33//{
34
35
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 >
43 {
44 public:
45
46 VertexFractureProperties( bool isBndFracVertex, T numberCrossingFracsInVertex )
47 : m_isBndFracVertex(isBndFracVertex), m_numberCountedFracsInVertex(numberCrossingFracsInVertex)
48 {
49 };
50
51
56
57 void setIsBndFracVertex( bool iBDV = true )
58 {
59 m_isBndFracVertex = iBDV;
60 }
61
62 void setNumberCrossingFracsInVertex( T const & nCFIV )
63 {
65 }
66
68 {
69 return m_isBndFracVertex;
70 }
71
72// T getCountedNumberFracsInVertex()
73// {
74// return m_numberCountedFracsInVertex;
75// }
76
77
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// {
99//
100// throw std::runtime_error("error");
101//
102// return 0;
103// }
104//
105// return m_numberCountedFracsInVertex / multipeInnerHits;
106// }
107
109 {
111 return *this;
112 }
113
114
115 private:
118 };
119
121
122// a class to store a matrix with two indices
123
124template< typename I, typename D,
125typename std::enable_if<std::is_integral<I>::value, int>::type = 0,
126typename 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 >
130{
131public:
132
133 // standard constructor
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
155private:
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
181
182
183template <class T>
184class T_min
185{
186
187public:
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 { if( minval > val ) minval = val; };
198
199
200protected:
201
203
204private:
205
206 T_min() {};
207};
208
210
211
212template <
213typename ECKENTYP,
214typename GESICHTSTYP,
215typename SENKRECHTENTYP
216>
218{
219
220public:
221
222 VertexFractureTriple( ECKENTYP const & edge, GESICHTSTYP const & face, SENKRECHTENTYP const & normal )
223 : m_edge(edge), m_face(face), m_normal(normal), m_newNormal(normal)
224 {
225 };
226
227 ECKENTYP const getEdge() const { return m_edge; }
228
229 GESICHTSTYP const getFace() const { return m_face; }
230
231 SENKRECHTENTYP const getNormal() const { return m_normal; }
232
233 void setNewNormal( SENKRECHTENTYP const & chNorml ) { m_newNormal = chNorml; }
234 SENKRECHTENTYP const getNewNormal() const { return m_newNormal; }
235
236private:
237
238 ECKENTYP m_edge;
239 GESICHTSTYP m_face;
240 SENKRECHTENTYP m_normal;
241 SENKRECHTENTYP m_newNormal;
242
245
246};
247
248
250
251template < typename VRT, typename IndTyp > //, typename EDG > //, typename SHIFTINFO > //, typename FAC >
253{
254
255public:
256
257 enum FracTyp { SingleFrac = 2, TEnd = 3, XCross = 4 };
258
259 CrossingVertexInfo( VRT const & crossVrt, IndTyp numbCrossFracs )
260 : 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>>())
265 {
266 if( numbCrossFracs == 2 )
267 {
269 }
270 if( numbCrossFracs == 3 )
271 {
272 m_fracTyp = TEnd;
273 }
274 else if( numbCrossFracs == 4 )
275 {
277 }
278 else
279 {
280 UG_LOG("frac typ wrong " << numbCrossFracs << std::endl);
281 }
282 }
283
284 VRT getCrossVertex() const { return m_crossVrt; }
285
286// IndTyp getNumbCrossFracs() const { return m_numbCrossFracs; }
287 FracTyp getFracTyp() const { return m_fracTyp; }
288
289 void addShiftVrtx( VRT const & vrt, bool isAtFreeSide = false )
290 {
291// if( m_fracTyp == XCross )
292 m_vecShiftedVrts.push_back(vrt);
293
294// if( isAtFreeSide )
295// UG_THROW("XCross ohne freie Seite " << std::endl);
296
297 if( m_fracTyp == TEnd )
298 {
299 std::pair<VRT, bool > addSVI( vrt, isAtFreeSide );
300 m_vecShiftedVrtsWithTypInf.push_back(addSVI);
301
302 if( isAtFreeSide )
304
305 if( m_numberAtFreeSide > 1 )
306 UG_THROW("was ist das fuer ein T Ende" << std::endl);
307 }
308
309 }
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 return m_vecShiftedVrts;
339 }
340
341 std::vector<std::pair<VRT,bool>> getVecShiftedVrtsWithTypInfo() const
342 {
343 if( m_fracTyp != TEnd )
344 UG_THROW("fuer Kreuz nicht erlaubt " << std::endl);
345
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
368private:
369
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;
380};
381
382
384
385//}
386}
387
388}
389
390#endif
391
Definition support.h:253
void addShiftVrtx(VRT const &vrt, bool isAtFreeSide=false)
Definition support.h:289
std::vector< std::pair< VRT, bool > > getVecShiftedVrtsWithTypInfo() const
Definition support.h:341
IndTyp m_numbCrossFracs
Definition support.h:371
std::vector< VRT > m_vecShiftedVrts
Definition support.h:372
IndTyp m_numberAtFreeSide
Definition support.h:379
CrossingVertexInfo(VRT const &crossVrt, IndTyp numbCrossFracs)
Definition support.h:259
FracTyp
Definition support.h:257
@ SingleFrac
Definition support.h:257
@ XCross
Definition support.h:257
@ TEnd
Definition support.h:257
std::vector< std::pair< VRT, bool > > m_vecShiftedVrtsWithTypInf
Definition support.h:373
FracTyp getFracTyp() const
Definition support.h:287
FracTyp m_fracTyp
Definition support.h:378
void setShiftVrtx(std::vector< VRT > const &vecVrt)
Definition support.h:317
std::vector< VRT > getVecShiftedVrts() const
Definition support.h:333
VRT getCrossVertex() const
Definition support.h:284
VRT m_crossVrt
Definition support.h:370
Definition support.h:130
I y_degree
Definition support.h:158
std::vector< D > values
Definition support.h:157
I x_degree
Definition support.h:158
MatrixTwoIndices(I _x_degree_, I _y_degree_, D defVal=0)
Definition support.h:137
D & operator()(I i, I j)
Definition support.h:149
D const operator()(I i, I j) const
Definition support.h:142
MatrixTwoIndices()
Definition support.h:134
Definition support.h:185
T minval
Definition support.h:202
T const operator()() const
Definition support.h:193
T_min(T val)
Definition support.h:190
void operator()(T val)
Definition support.h:196
T_min()
Definition support.h:206
Definition support.h:43
bool getIsBndFracVertex()
Definition support.h:67
VertexFractureProperties()
Definition support.h:52
void setIsBndFracVertex(bool iBDV=true)
Definition support.h:57
bool m_isBndFracVertex
Definition support.h:116
VertexFractureProperties(bool isBndFracVertex, T numberCrossingFracsInVertex)
Definition support.h:46
T m_numberCountedFracsInVertex
Definition support.h:117
void setNumberCrossingFracsInVertex(T const &nCFIV)
Definition support.h:62
VertexFractureProperties & operator++(int a)
Definition support.h:108
T getNumberFracEdgesInVertex()
Definition support.h:78
Definition support.h:218
GESICHTSTYP const getFace() const
Definition support.h:229
SENKRECHTENTYP const getNormal() const
Definition support.h:231
ECKENTYP const getEdge() const
Definition support.h:227
SENKRECHTENTYP m_normal
Definition support.h:240
VertexFractureTriple(ECKENTYP const &edge, GESICHTSTYP const &face, SENKRECHTENTYP const &normal)
Definition support.h:222
ECKENTYP m_edge
Definition support.h:238
GESICHTSTYP m_face
Definition support.h:239
SENKRECHTENTYP const getNewNormal() const
Definition support.h:234
VertexFractureTriple()
Definition support.h:243
void setNewNormal(SENKRECHTENTYP const &chNorml)
Definition support.h:233
SENKRECHTENTYP m_newNormal
Definition support.h:241
#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
the ug namespace