3D-ICE 3.0.0
material.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.h"
42
43/******************************************************************************/
44
45void material_init (Material_t *material)
46{
47 string_init (&material->Id) ;
48
49 material->VolumetricHeatCapacity = (SolidVHC_t) 0.0 ;
50 material->ThermalConductivity = (SolidTC_t) 0.0 ;
51}
52
53/******************************************************************************/
54
56{
57 material_destroy (dst) ;
58
59 string_copy (&dst->Id, &src->Id) ;
60
61 dst->VolumetricHeatCapacity = src->VolumetricHeatCapacity ;
62 dst->ThermalConductivity = src->ThermalConductivity ;
63}
64
65/******************************************************************************/
66
68{
69 string_destroy (&material->Id) ;
70
71 material_init (material) ;
72}
73
74/******************************************************************************/
75
77{
78 Material_t *material = (Material_t *) malloc (sizeof(Material_t)) ;
79
80 if (material != NULL)
81
82 material_init (material) ;
83
84 return material ;
85}
86
87/******************************************************************************/
88
90{
91 if (material == NULL)
92
93 return NULL ;
94
95 Material_t *newm = material_calloc ( ) ;
96
97 if (newm != NULL)
98
99 material_copy (newm, material) ;
100
101 return newm ;
102}
103
104/******************************************************************************/
105
106void material_free (Material_t *material)
107{
108 if (material == NULL)
109
110 return ;
111
112 material_destroy (material) ;
113
114 free (material) ;
115}
116
117/******************************************************************************/
118
119bool material_same_id (Material_t *material, Material_t *other)
120{
121 return string_equal (&material->Id, &other->Id) ;
122}
123
124/******************************************************************************/
125
126void material_print (Material_t *material, FILE *stream, String_t prefix)
127{
128 fprintf (stream,
129 "%smaterial %s :\n",
130 prefix, material->Id) ;
131
132 fprintf (stream,
133 "%s thermal conductivity %.4e ;\n",
134 prefix, material->ThermalConductivity) ;
135
136 fprintf (stream,
137 "%s volumetric heat capacity %.4e ;\n",
138 prefix, material->VolumetricHeatCapacity) ;
139}
140
141/******************************************************************************/
Material_t * material_calloc(void)
Definition: material.c:76
void material_copy(Material_t *dst, Material_t *src)
Definition: material.c:55
void material_destroy(Material_t *material)
Definition: material.c:67
Material_t * material_clone(Material_t *material)
Definition: material.c:89
bool material_same_id(Material_t *material, Material_t *other)
Definition: material.c:119
void material_print(Material_t *material, FILE *stream, String_t prefix)
Definition: material.c:126
void material_free(Material_t *material)
Definition: material.c:106
void material_init(Material_t *material)
Definition: material.c:45
char * String_t
Definition: string_t.h:55
void string_init(String_t *string)
Definition: string_t.c:46
bool string_equal(String_t *string, String_t *other)
Definition: string_t.c:71
void string_destroy(String_t *string)
Definition: string_t.c:78
void string_copy(String_t *dst, String_t *src)
Definition: string_t.c:53
Structure used to store data about the materials that compose the 2D/3D stack.
Definition: material.h:68
SolidVHC_t VolumetricHeatCapacity
Definition: material.h:80
SolidTC_t ThermalConductivity
Definition: material.h:87
String_t Id
Definition: material.h:73
double SolidVHC_t
Definition: types.h:99
double SolidTC_t
Definition: types.h:107