Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
29//namespace support
30//{
31
32
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 >
40 {
41 public:
42
43 VertexFractureProperties( bool isBndFracVertex, T numberCrossingFracsInVertex )
44 : m_isBndFracVertex(isBndFracVertex), m_numberCountedFracsInVertex(numberCrossingFracsInVertex)
45 {
46 };
47
48
53
54 void setIsBndFracVertex( bool iBDV = true )
55 {
56 m_isBndFracVertex = iBDV;
57 }
58
59 void setNumberCrossingFracsInVertex( T const & nCFIV )
60 {
62 }
63
65 {
66 return m_isBndFracVertex;
67 }
68
69// T getCountedNumberFracsInVertex()
70// {
71// return m_numberCountedFracsInVertex;
72// }
73
74
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// {
96//
97// throw std::runtime_error("error");
98//
99// return 0;
100// }
101//
102// return m_numberCountedFracsInVertex / multipeInnerHits;
103// }
104
106 {
108 return *this;
109 }
110
111
112 private:
115 };
116
118
119// a class to store a matrix with two indices
120
121template< typename I, typename D,
122typename std::enable_if<std::is_integral<I>::value, int>::type = 0,
123typename 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 >
127{
128public:
129
130 // standard constructor
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
152private:
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
178
179
180template <class T>
181class T_min
182{
183
184public:
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 { if( minval > val ) minval = val; };
195
196
197protected:
198
200
201private:
202
203 T_min() {};
204};
205
207
208
209template <
210typename ECKENTYP,
211typename GESICHTSTYP,
212typename SENKRECHTENTYP
213>
215{
216
217public:
218
219 VertexFractureTriple( ECKENTYP const & edge, GESICHTSTYP const & face, SENKRECHTENTYP const & normal )
220 : m_edge(edge), m_face(face), m_normal(normal), m_newNormal(normal)
221 {
222 };
223
224 ECKENTYP const getEdge() const { return m_edge; }
225
226 GESICHTSTYP const getFace() const { return m_face; }
227
228 SENKRECHTENTYP const getNormal() const { return m_normal; }
229
230 void setNewNormal( SENKRECHTENTYP const & chNorml ) { m_newNormal = chNorml; }
231 SENKRECHTENTYP const getNewNormal() const { return m_newNormal; }
232
233private:
234
235 ECKENTYP m_edge;
236 GESICHTSTYP m_face;
237 SENKRECHTENTYP m_normal;
238 SENKRECHTENTYP m_newNormal;
239
242
243};
244
245
247
248template < typename VRT, typename IndTyp > //, typename EDG > //, typename SHIFTINFO > //, typename FAC >
250{
251
252public:
253
254 enum FracTyp { SingleFrac = 2, TEnd = 3, XCross = 4 };
255
256 CrossingVertexInfo( VRT const & crossVrt, IndTyp numbCrossFracs )
257 : 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>>())
262 {
263 if( numbCrossFracs == 2 )
264 {
266 }
267 if( numbCrossFracs == 3 )
268 {
269 m_fracTyp = TEnd;
270 }
271 else if( numbCrossFracs == 4 )
272 {
274 }
275 else
276 {
277 UG_LOG("frac typ wrong " << numbCrossFracs << std::endl);
278 }
279 }
280
281 VRT getCrossVertex() const { return m_crossVrt; }
282
283// IndTyp getNumbCrossFracs() const { return m_numbCrossFracs; }
284 FracTyp getFracTyp() const { return m_fracTyp; }
285
286 void addShiftVrtx( VRT const & vrt, bool isAtFreeSide = false )
287 {
288// if( m_fracTyp == XCross )
289 m_vecShiftedVrts.push_back(vrt);
290
291// if( isAtFreeSide )
292// UG_THROW("XCross ohne freie Seite " << std::endl);
293
294 if( m_fracTyp == TEnd )
295 {
296 std::pair<VRT, bool > addSVI( vrt, isAtFreeSide );
297 m_vecShiftedVrtsWithTypInf.push_back(addSVI);
298
299 if( isAtFreeSide )
301
302 if( m_numberAtFreeSide > 1 )
303 UG_THROW("was ist das fuer ein T Ende" << std::endl);
304 }
305
306 }
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 return m_vecShiftedVrts;
336 }
337
338 std::vector<std::pair<VRT,bool>> getVecShiftedVrtsWithTypInfo() const
339 {
340 if( m_fracTyp != TEnd )
341 UG_THROW("fuer Kreuz nicht erlaubt " << std::endl);
342
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
365private:
366
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;
377};
378
379
381
382//}
383
384}
385
386#endif
387
Definition support.h:250
IndTyp m_numbCrossFracs
Definition support.h:368
FracTyp getFracTyp() const
Definition support.h:284
CrossingVertexInfo(VRT const &crossVrt, IndTyp numbCrossFracs)
Definition support.h:256
VRT m_crossVrt
Definition support.h:367
std::vector< VRT > m_vecShiftedVrts
Definition support.h:369
IndTyp m_numberAtFreeSide
Definition support.h:376
VRT getCrossVertex() const
Definition support.h:281
void addShiftVrtx(VRT const &vrt, bool isAtFreeSide=false)
Definition support.h:286
std::vector< std::pair< VRT, bool > > getVecShiftedVrtsWithTypInfo() const
Definition support.h:338
FracTyp
Definition support.h:254
@ SingleFrac
Definition support.h:254
@ XCross
Definition support.h:254
@ TEnd
Definition support.h:254
std::vector< VRT > getVecShiftedVrts() const
Definition support.h:330
void setShiftVrtx(std::vector< VRT > const &vecVrt)
Definition support.h:314
std::vector< std::pair< VRT, bool > > m_vecShiftedVrtsWithTypInf
Definition support.h:370
FracTyp m_fracTyp
Definition support.h:375
Definition support.h:127
D & operator()(I i, I j)
Definition support.h:146
I x_degree
Definition support.h:155
MatrixTwoIndices()
Definition support.h:131
std::vector< D > values
Definition support.h:154
MatrixTwoIndices(I _x_degree_, I _y_degree_, D defVal=0)
Definition support.h:134
I y_degree
Definition support.h:155
D const operator()(I i, I j) const
Definition support.h:139
Definition support.h:182
T_min(T val)
Definition support.h:187
void operator()(T val)
Definition support.h:193
T_min()
Definition support.h:203
T minval
Definition support.h:199
T const operator()() const
Definition support.h:190
Definition support.h:40
void setIsBndFracVertex(bool iBDV=true)
Definition support.h:54
VertexFractureProperties & operator++(int a)
Definition support.h:105
bool getIsBndFracVertex()
Definition support.h:64
VertexFractureProperties(bool isBndFracVertex, T numberCrossingFracsInVertex)
Definition support.h:43
bool m_isBndFracVertex
Definition support.h:113
T m_numberCountedFracsInVertex
Definition support.h:114
T getNumberFracEdgesInVertex()
Definition support.h:75
void setNumberCrossingFracsInVertex(T const &nCFIV)
Definition support.h:59
VertexFractureProperties()
Definition support.h:49
Definition support.h:215
ECKENTYP const getEdge() const
Definition support.h:224
ECKENTYP m_edge
Definition support.h:235
VertexFractureTriple(ECKENTYP const &edge, GESICHTSTYP const &face, SENKRECHTENTYP const &normal)
Definition support.h:219
SENKRECHTENTYP const getNewNormal() const
Definition support.h:231
GESICHTSTYP m_face
Definition support.h:236
SENKRECHTENTYP m_normal
Definition support.h:237
SENKRECHTENTYP m_newNormal
Definition support.h:238
VertexFractureTriple()
Definition support.h:240
GESICHTSTYP const getFace() const
Definition support.h:226
void setNewNormal(SENKRECHTENTYP const &chNorml)
Definition support.h:230
SENKRECHTENTYP const getNormal() const
Definition support.h:228
#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