Repository navigation
Expand file tree
/
Copy pathsegment_network.h
More file actions
119 lines (97 loc) · 3.26 KB
/
Copy pathsegment_network.h
File metadata and controls
119 lines (97 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* SPDX-FileCopyrightText: 2025 Gesellschaft fuer Anlagen- und Reaktorsicherheit gGmbH
* SPDX-License-Identifier: EUPL-1.2
* SPDX-FileContributor: Sebastian Reiter
* SPDX-FileContributor: Goethe Universität Frankfurt
* SPDX-FileType: SOURCE
*
* This file is part of d3f++.
* d3f++ is an extension for UG4. Licensing information and citation requirements of UG4 are provided in LICENSES/UG4-LGPL_2.1
*/
#ifndef __H__UG_segment_network
#define __H__UG_segment_network
#include "lib_grid/grid/grid.h"
#include "lib_grid/common_attachments.h"
#include "lib_grid/tools/subset_handler_grid.h"
#include "lib_disc/spatial_disc/user_data/user_data.h"
namespace ug{
namespace d3f{
/// Represents a network of segments, like, e.g. a low dimensional river network.
/**
* The class gives access to the two-dimensional coordinate of each vertex of the river
* and to the gauge at that vertex.
*
* Note that this implementation should be used with 3d objects only!
*/
class SegmentNetwork
{
public:
static const int dim = 3;
typedef vector2 vector_t;
typedef Attachment<vector_t> position_attachment_t;
typedef Grid::VertexAttachmentAccessor<position_attachment_t> position_accessor_t;
typedef number gauge_t;
typedef Attachment<gauge_t> gauge_attachment_t;
typedef Grid::VertexAttachmentAccessor<gauge_attachment_t> gauge_accessor_t;
public:
/// Constructor:
SegmentNetwork ()
{
m_grid.attach_to_vertices(m_aPos);
m_aaPos.access(m_grid, m_aPos);
m_grid.attach_to_vertices(m_aGauge);
m_aaGauge.access(m_grid, m_aGauge);
m_SH.assign_grid(&m_grid);
}
/// Destructor:
~SegmentNetwork () {}
/// loads a segment network from a grid file
void load_from_file
(
const char* name, ///< file name to read from
number maxEdgeLen ///< max. length of the edges to refine to
);
/// sets the gauge values from a UserData object
void set_gauge_values
(
SmartPtr<UserData<number, dim> > h ///< the data to write to the gauge at the vertices
);
/// saves the segment network into a file (mainly for plotting) using the given gauge values
void save_to_file_with_
(
gauge_accessor_t& z_acc, ///< to save in the z-coordinate
const char* name ///< file name to write to
);
/// saves the segment network into a file (mainly for plotting)
void save_to_file
(
const char* name ///< file name to write to
)
{
save_to_file_with_ (m_aaGauge, name);
}
/// finds the vertices in the specified sphere to vrtsOut
/** @return returns the number of vertices found.*/
size_t find_vertices
(
std::vector<Vertex*>& vrtsOut,
const vector_t& center,
number radius
) const;
inline Grid& grid() {return m_grid;}
inline position_attachment_t position_attachment () {return m_aPos;}
inline position_accessor_t position_accessor () {return m_aaPos;}
inline gauge_attachment_t gauge_attachment() {return m_aGauge;}
inline gauge_accessor_t gauge_accessor() {return m_aaGauge;}
inline GridSubsetHandler& subset_handler() {return m_SH;}
private:
Grid m_grid;
position_attachment_t m_aPos;
position_accessor_t m_aaPos;
gauge_attachment_t m_aGauge;
gauge_accessor_t m_aaGauge;
GridSubsetHandler m_SH;
};
}// end of namespace
}// end of namespace
#endif //__H__UG_segment_network