3D-ICE 3.0.0
material_element.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 "material_element.h"
42#include "ic_element.h"
43
44/******************************************************************************/
45
47{
48 material_init (&melement->Material) ;
49
50 melement->NMElements = (Quantity_t) 0u ;
51
52 ic_element_list_init (&melement->MElements) ;
53}
54
55/******************************************************************************/
56
58(
61)
62{
64
65 material_copy (&dst->Material, &src->Material) ;
66
67 dst->NMElements = src->NMElements ;
68
69 ic_element_list_copy (&dst->MElements, &src->MElements) ;
70}
71
72/******************************************************************************/
73
75{
76 material_destroy (&melement->Material) ;
77
78 ic_element_list_destroy (&melement->MElements) ;
79
80 material_element_init (melement) ;
81}
82
83/******************************************************************************/
84
86{
87 MaterialElement_t *melement =
88
89 (MaterialElement_t *) malloc (sizeof(MaterialElement_t));
90
91 if (melement != NULL)
92
93 material_element_init (melement) ;
94
95 return melement ;
96}
97
98/*****************************************************************************/
99
101{
102 if (melement == NULL)
103
104 return NULL ;
105
107
108 if (newm != NULL)
109
110 material_element_copy (newm, melement) ;
111
112 return newm ;
113}
114
115/*****************************************************************************/
116
118{
119 if (melement == NULL)
120
121 return ;
122
123 material_element_destroy (melement) ;
124
125 free (melement) ;
126}
127
128/******************************************************************************/
129
131(
132 MaterialElement_t *melement,
133 MaterialElement_t *other
134)
135{
136 return material_same_id (&melement->Material, &other->Material) ;
137}
138
139/******************************************************************************/
140
142(
143 MaterialElement_t *melement,
144 FILE *stream,
145 String_t prefix
146)
147{
148 fprintf (stream,
149 "%s%s:\n",
150 prefix, melement->Material.Id) ;
151
152 ic_element_list_print
153
154 (&melement->MElements, stream, prefix) ;
155
156 fprintf (stream, " ;\n%s\n", prefix) ;
157}
158
159/******************************************************************************/
160
162(
163 MaterialElement_t *melement,
164 CellIndex_t row_index,
165 CellIndex_t column_index,
166 Dimensions_t *dimensions
167)
168{
169 CellDimension_t cellx = get_cell_center_x (dimensions, column_index) ;
170 CellDimension_t celly = get_cell_center_y (dimensions, row_index) ;
171
172 ICElementListNode_t *icelementn ;
173
174 for (icelementn = ic_element_list_begin (&melement->MElements) ;
175 icelementn != NULL ;
176 icelementn = ic_element_list_next (icelementn))
177 {
178 ICElement_t *icelement = ic_element_list_data (icelementn) ;
179
180 if (ic_element_has_center (icelement, cellx, celly) == true)
181
182 return &melement->Material ;
183 }
184
185 return NULL ;
186}
ChipDimension_t get_cell_center_x(Dimensions_t *dimensions, CellIndex_t column_index)
Definition: dimensions.c:564
ChipDimension_t get_cell_center_y(Dimensions_t *dimensions, CellIndex_t row_index)
Definition: dimensions.c:590
bool ic_element_has_center(ICElement_t *icelement, CellDimension_t cellx, CellDimension_t celly)
Definition: ic_element.c:162
void material_copy(Material_t *dst, Material_t *src)
Definition: material.c:55
void material_destroy(Material_t *material)
Definition: material.c:67
bool material_same_id(Material_t *material, Material_t *other)
Definition: material.c:119
void material_init(Material_t *material)
Definition: material.c:45
void material_element_free(MaterialElement_t *melement)
MaterialElement_t * material_element_clone(MaterialElement_t *melement)
Material_t * get_material_at_location(MaterialElement_t *melement, CellIndex_t row_index, CellIndex_t column_index, Dimensions_t *dimensions)
void material_element_print(MaterialElement_t *melement, FILE *stream, String_t prefix)
bool material_element_same_material(MaterialElement_t *melement, MaterialElement_t *other)
void material_element_copy(MaterialElement_t *dst, MaterialElement_t *src)
MaterialElement_t * material_element_calloc(void)
void material_element_init(MaterialElement_t *melement)
void material_element_destroy(MaterialElement_t *melement)
char * String_t
Definition: string_t.h:55
Collections of all the structures that are needed for the thermal simulation.
Definition: dimensions.h:311
ICElementList_t MElements
Structure used to store data about the materials that compose the 2D/3D stack.
Definition: material.h:68
String_t Id
Definition: material.h:73
double CellDimension_t
Definition: types.h:177
uint32_t Quantity_t
Definition: types.h:59
uint32_t CellIndex_t
Definition: types.h:213