Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
intermediate.hxx
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __SOLVER_VARIABLE_STORAGE_INTERMEDIATE_HXX__
22#define __SOLVER_VARIABLE_STORAGE_INTERMEDIATE_HXX__
23
24#include <antares/solver/variable/print.h>
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
36
38{
39 Antares::Memory::Zero(HOURS_PER_YEAR, hour);
40 memset(month, 0, sizeof(month));
41 memset(week, 0, sizeof(week));
42 memset(day, 0, sizeof(day));
43}
44
45inline IntermediateValues::Type& IntermediateValues::operator[](const unsigned int index)
46{
47 return hour[index];
48}
49
51 const unsigned int index) const
52{
53 return hour[index];
54}
55
56template<class VCardT>
57inline void IntermediateValues::buildAnnualSurveyReport(SurveyResults& report,
58 int fileLevel,
59 int precision) const
60{
61 if (!(fileLevel & Category::FileLevel::id))
62 {
63 switch (precision)
64 {
65 case Category::hourly:
66 internalExportAnnualValues<HOURS_PER_YEAR, VCardT>(report, hour, false);
67 break;
68 case Category::daily:
69 internalExportAnnualValues<DAYS_PER_YEAR, VCardT>(report, day, false);
70 break;
71 case Category::weekly:
72 internalExportAnnualValues<WEEKS_PER_YEAR, VCardT>(report, week, false);
73 break;
74 case Category::monthly:
75 internalExportAnnualValues<MONTHS_PER_YEAR, VCardT>(report, month, false);
76 break;
77 case Category::annual:
78 internalExportAnnualValues<1, VCardT>(report, &year, true);
79 break;
80 }
81 }
82}
83
84template<unsigned int Size, class VCardT, class A>
85void IntermediateValues::internalExportAnnualValues(SurveyResults& report,
86 const A& array,
87 bool annual) const
88{
89 using namespace Yuni;
90 assert(report.data.columnIndex < report.maxVariables && "Column index out of bounds");
91
92 // Caption
93 report.captions[0][report.data.columnIndex] = report.variableCaption;
94 report.captions[1][report.data.columnIndex] = report.variableUnit;
95 report.captions[2][report.data.columnIndex] = nullptr;
96 // Precision
97 report.precision[report.data.columnIndex] = PrecisionToPrintfFormat<VCardT::decimal>::Value();
98 // Non applicability
99 report.nonApplicableStatus[report.data.columnIndex] = *report.isCurrentVarNA;
100
101 // Values
102 if (not annual)
103 {
104 (void)::memcpy(report.values[report.data.columnIndex], array, sizeof(double) * Size);
105 }
106 else
107 {
108 double& target = *(report.values[report.data.columnIndex]);
109 target = year;
110 }
111
112 // Next column index
113 ++report.data.columnIndex;
114}
115
116} // namespace Variable
117} // namespace Solver
118} // namespace Antares
119
120#endif // __SOLVER_VARIABLE_STORAGE_INTERMEDIATE_HXX__
static void Release(T *&pointer)
Release a raw pointer.
Definition memory.hxx:32
Type week[WEEKS_PER_YEAR]
Values for each week.
Definition intermediate.h:132
double Type
Basic type.
Definition intermediate.h:49
Type year
Year.
Definition intermediate.h:138
void reset()
Reset all values.
Definition intermediate.hxx:37
Antares::Memory::Stored< Type >::Type hour
Values for each hour in the year.
Definition intermediate.h:136
Type & operator[](const uint index)
Vector alias for an hour in the year.
Type month[MONTHS_PER_YEAR]
Values for each month.
Definition intermediate.h:130
Type day[DAYS_PER_YEAR]
Values for each day in the year.
Definition intermediate.h:134
~IntermediateValues()
Destructor.
Definition intermediate.hxx:32
Definition variable.h:25