Plugins
Loading...
Searching...
No Matches
value_by_id.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Gesellschaft fuer Anlagen- und Reaktorsicherheit gGmbH
3 * SPDX-License-Identifier: EUPL-1.2
4 * SPDX-FileContributor: Dmrity Logashenko
5 * SPDX-FileContributor: Goethe Universität Frankfurt
6 * SPDX-FileType: SOURCE
7 *
8 * This file is part of d3f++.
9 * d3f++ is an extension for UG4. Licensing information and citation requirements of UG4 are provided in LICENSES/UG4-LGPL_2.1
10 */
11
12
13
14/*
15 * Assigning values to region id's.
16 */
17#ifndef __H__UG__PLUGINS__D3F__VALUE_BY_ID__
18#define __H__UG__PLUGINS__D3F__VALUE_BY_ID__
19
20#include <vector>
21
22// ug4 headers
23#include "common/common.h"
24#include "common/math/ugmath.h"
26
27namespace ug {
28namespace d3f {
29
33template <typename TIdManager>
35: public TIdManager
36{
37public:
38
40 typedef TIdManager id_manager_type;
41
42public:
43
45 ValueById (number default_value)
46 : m_numCols (0),
47 m_interval (1),
48 m_default_value (default_value)
49 {};
50
52 void load_values_from (const char * file_name);
53
55 void set_interval (number delta) {m_interval = delta;}
56
58 number interpolate (number x, number y, number t) const;
59
61 size_t num_columns () const {return m_numCols;}
62
64 size_t max_identifier () const {return m_assigned.size () - 1;}
65
66private:
67
69 void append_value
70 (
71 long ident,
72 std::vector<number>& val
73 );
74
76 void load_values_from (std::istream & input);
77
78private:
79 size_t m_numCols;
81 std::vector<number> m_data;
82 std::vector<bool> m_assigned;
84};
85
86} // namespace d3f
87} // end namespace ug
88
89#include "value_by_id_impl.h"
90
91#endif // __H__UG__PLUGINS__D3F__VALUE_BY_ID__
92
93/* End of File */
Definition value_by_id.h:36
std::vector< bool > m_assigned
if the data for the id has been read (i.e. specified)
Definition value_by_id.h:82
std::vector< number > m_data
the data as a raw array for every id
Definition value_by_id.h:81
void append_value(long ident, std::vector< number > &val)
appends a value
Definition value_by_id_impl.h:47
size_t m_numCols
number of the "columns" in the data array (or 0 if not specified yet)
Definition value_by_id.h:79
void load_values_from(const char *file_name)
loads values from a file
Definition value_by_id_impl.h:148
number interpolate(number x, number y, number t) const
gets the value for a given point
Definition value_by_id_impl.h:24
void set_interval(number delta)
sets the 'time interval' to determine the column
Definition value_by_id.h:55
size_t max_identifier() const
returns the maximum index
Definition value_by_id.h:64
ValueById(number default_value)
constructor
Definition value_by_id.h:45
number m_interval
interval for the 'time' parameter to choose the correct column
Definition value_by_id.h:80
TIdManager id_manager_type
the id manager
Definition value_by_id.h:40
number m_default_value
the value to return if no id specified
Definition value_by_id.h:83
size_t num_columns() const
returns the number of the 'columns'
Definition value_by_id.h:61
double number