3D-ICE 3.0.0
analysis.c
1/******************************************************************************
2 * This file is part of 3D-ICE, version 3.1.0 . *
3 * *
4 * 3D-ICE is free software: you can redistribute it and/or modify it under *
5 * the terms of the GNU General Public License as published by the Free *
6 * Software Foundation, either version 3 of the License, or any later *
7 * version. *
8 * *
9 * 3D-ICE is distributed in the hope that it will be useful, but WITHOUT *
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
12 * more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along *
15 * with 3D-ICE. If not, see <http://www.gnu.org/licenses/>. *
16 * *
17 * Copyright (C) 2021 *
18 * Embedded Systems Laboratory - Ecole Polytechnique Federale de Lausanne *
19 * All Rights Reserved. *
20 * *
21 * Authors: Arvind Sridhar Alessandro Vincenzi *
22 * Giseong Bak Martino Ruggiero *
23 * Thomas Brunschwiler Eder Zulian *
24 * Federico Terraneo Darong Huang *
25 * Luis Costero Marina Zapater *
26 * David Atienza *
27 * *
28 * For any comment, suggestion or request about 3D-ICE, please register and *
29 * write to the mailing list (see http://listes.epfl.ch/doc.cgi?liste=3d-ice) *
30 * Any usage of 3D-ICE for research, commercial or other purposes must be *
31 * properly acknowledged in the resulting products or publications. *
32 * *
33 * EPFL-STI-IEL-ESL Mail : 3d-ice@listes.epfl.ch *
34 * Batiment ELG, ELG 130 (SUBSCRIPTION IS NECESSARY) *
35 * Station 11 *
36 * 1015 Lausanne, Switzerland Url : http://esl.epfl.ch/3d-ice *
37 ******************************************************************************/
38
39#include <stdlib.h> // For the memory functions malloc/free
40
41#include "analysis.h"
42
43/******************************************************************************/
44
45void analysis_init (Analysis_t *analysis)
46{
48 analysis->StepTime = (Time_t) 0.0 ;
49 analysis->SlotTime = (Time_t) 0.0 ;
50 analysis->SlotLength = (Quantity_t) 0u ;
51 analysis->CurrentTime = (Quantity_t) 0u ;
52 analysis->InitialTemperature = (Temperature_t) 0.0 ;
53}
54
55/******************************************************************************/
56
58{
59 analysis_destroy (dst) ;
60
61 dst->AnalysisType = src->AnalysisType ;
62 dst->StepTime = src->StepTime ;
63 dst->SlotTime = src->SlotTime ;
64 dst->SlotLength = src->SlotLength ;
65 dst->CurrentTime = src->CurrentTime ;
66 dst->InitialTemperature = src->InitialTemperature ;
67}
68
69/******************************************************************************/
70
72{
73 // Nothing to do ...
74
75 analysis_init (analysis) ;
76}
77
78/******************************************************************************/
79
81{
82 Analysis_t *analysis = (Analysis_t *) malloc (sizeof (Analysis_t)) ;
83
84 if (analysis != NULL)
85
86 analysis_init (analysis) ;
87
88 return analysis ;
89}
90
91/******************************************************************************/
92
94{
95 if (analysis == NULL)
96
97 return NULL ;
98
99 Analysis_t *newa = analysis_calloc ( ) ;
100
101 if (newa != NULL)
102
103 analysis_copy (newa, analysis) ;
104
105 return newa ;
106}
107
108/******************************************************************************/
109
110void analysys_free (Analysis_t *analysis)
111{
112 if (analysis == NULL)
113
114 return ;
115
116 analysis_destroy (analysis) ;
117
118 free (analysis) ;
119}
120
121/******************************************************************************/
122
123void analysis_print (Analysis_t *analysis, FILE *stream, String_t prefix)
124{
125 fprintf (stream, "%ssolver : \n", prefix) ;
126
128
129 fprintf (stream, " steady ;\n") ;
130
131 else
132
133 fprintf (stream, " transient step %.2f, slot %.2f ;\n",
134 analysis->StepTime, analysis->SlotTime) ;
135
136 fprintf (stream, "%s initial temperature %.2f ;\n",
137 prefix, analysis->InitialTemperature) ;
138
139 fprintf (stream, "%s\n", prefix) ;
140}
141
142/******************************************************************************/
143
145)
146{
147 return analysis->CurrentTime * analysis->StepTime ;
148}
149
150/******************************************************************************/
151
153{
154 analysis->CurrentTime++ ;
155}
156
157/******************************************************************************/
158
160{
161 if (analysis->CurrentTime % analysis->SlotLength == 0u)
162
163 return true ;
164
165 return false ;
166}
167
168/******************************************************************************/
void analysis_init(Analysis_t *analysis)
Definition: analysis.c:45
void analysis_copy(Analysis_t *dst, Analysis_t *src)
Definition: analysis.c:57
void increase_by_step_time(Analysis_t *analysis)
Definition: analysis.c:152
void analysis_print(Analysis_t *analysis, FILE *stream, String_t prefix)
Definition: analysis.c:123
Time_t get_simulated_time(Analysis_t *analysis)
Definition: analysis.c:144
bool slot_completed(Analysis_t *analysis)
Definition: analysis.c:159
Analysis_t * analysis_clone(Analysis_t *analysis)
Definition: analysis.c:93
void analysis_destroy(Analysis_t *analysis)
Definition: analysis.c:71
Analysis_t * analysis_calloc(void)
Definition: analysis.c:80
char * String_t
Definition: string_t.h:55
Informations about the type of thermal simulation to be run, timing and its initial settings.
Definition: analysis.h:65
AnalysisType_t AnalysisType
Definition: analysis.h:68
Quantity_t CurrentTime
Definition: analysis.h:84
Time_t StepTime
Definition: analysis.h:72
Time_t SlotTime
Definition: analysis.h:76
Quantity_t SlotLength
Definition: analysis.h:80
Temperature_t InitialTemperature
Definition: analysis.h:88
double Time_t
Definition: types.h:65
double Temperature_t
Definition: types.h:71
AnalysisType_t
Definition: types.h:455
@ TDICE_ANALYSIS_TYPE_NONE
Undefined analysis type.
Definition: types.h:456
@ TDICE_ANALYSIS_TYPE_STEADY
Steady state analysis.
Definition: types.h:458
uint32_t Quantity_t
Definition: types.h:59