NANDRAD Data Model Library  Version 2.0
NANDRAD
NANDRAD_Interval.h
1 /* The NANDRAD data model library.
2 
3  Copyright (c) 2012-today, Institut für Bauklimatik, TU Dresden, Germany
4 
5  Primary authors:
6  Andreas Nicolai <andreas.nicolai -[at]- tu-dresden.de>
7  Anne Paepcke <anne.paepcke -[at]- tu-dresden.de>
8 
9  This library is part of SIM-VICUS (https://github.com/ghorwin/SIM-VICUS)
10 
11  This library is free software: you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 */
21 
22 #ifndef NANDRAD_IntervalH
23 #define NANDRAD_IntervalH
24 
25 #include <string>
26 
27 #include "NANDRAD_CodeGenMacros.h"
28 
29 #include <IBK_Parameter.h>
30 
31 namespace NANDRAD {
32 
33 /*! The class Interval defines intervals of simulation time.
34  It is used to define output grids and schedules.
35 */
36 class Interval {
37  NANDRAD_READWRITE_PRIVATE
38 public:
39  /*! Parameters. */
40  enum para_t {
41  /*! Start time point. */
42  P_Start, // Keyword: Start [d] 'Start time point.'
43  /*! End time point. */
44  P_End, // Keyword: End [d] 'End time point.'
45  /*! StepSize. */
46  P_StepSize, // Keyword: StepSize [h] 'StepSize.'
47  NUM_P
48  };
49 
50  NANDRAD_READWRITE_IFNOTEMPTY(Interval)
51  NANDRAD_COMP(Interval)
52 
53  /*! Convenience function to specify a parameter through start time point and end time point.
54  This sets parameters IP_START and IP_END to given values using the unit u for both parameters.
55  \param start The start time point, expected to be already in the unit u.
56  \param endtime The end time point, expected to be already in the unit u. If endtime should not
57  be specified, given std::numeric_limits<double>::max() as value.
58  \param u Time unit of start and endtime.
59  */
60  void setStartEnd( double start, double endtime, IBK::Unit u );
61 
62  /*! Checks input parameters.
63  Definition of Start and End intervals are optional. If provided, the values must be >= 0
64  and End time point must be always beyond start time point.
65  Throws an IBK::Exception if conditions are not met.
66  */
67  void checkParameters() const;
68 
69  /*! Returns true, if t lies inside the internal.
70  This check requires a valid START parameter to be set.
71  \param t Simulation time, in [s], simtime definition.
72  \warning This function expects checkParameters() to be called beforehand.
73  */
74  bool isInInterval(double t) const;
75 
76  /*! Returns the end time point.
77  It returns the END parameter if given. Otherwise infinitiy.
78  \warning This function expects checkParameters() to be called beforehand.
79  */
80  double endTime() const;
81 
82  /*! The parameters defining the interval. */
83  IBK::Parameter m_para[NUM_P]; // XML:E
84 };
85 
86 } // namespace NANDRAD
87 
88 #endif // NANDRAD_IntervalH
void setStartEnd(double start, double endtime, IBK::Unit u)
Convenience function to specify a parameter through start time point and end time point...
void checkParameters() const
Checks input parameters.
bool isInInterval(double t) const
Returns true, if t lies inside the internal.
IBK::Parameter m_para[NUM_P]
The parameters defining the interval.
The class Interval defines intervals of simulation time.
double endTime() const
Returns the end time point.
The namespace NANDRAD contains the data model classes that make up the NANDRAD solver input data...