FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_dist_free.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <errno.h>
9 #include "hecmw_dist_free.h"
10 #include "hecmw_dist_alloc.h"
11 #include "hecmw_util.h"
12 #include "hecmw_struct.h"
13 
14 static void free_section(struct hecmwST_section *section) {
15  if (section == NULL) return;
24 }
25 
26 static void free_material(struct hecmwST_material *material) {
27  int i;
28 
29  if (material == NULL) return;
30  for (i = 0; i < material->n_mat; i++) {
32  }
39 }
40 
41 static void free_mpc(struct hecmwST_mpc *mpc) {
42  if (mpc == NULL) return;
48 }
49 
50 static void free_amplitude(struct hecmwST_amplitude *amp) {
51  int i;
52 
53  if (amp == NULL) return;
54 
55  for (i = 0; i < amp->n_amp; i++) {
56  HECMW_free(amp->amp_name[i]);
57  }
65 }
66 
67 static void free_ngrp(struct hecmwST_node_grp *grp) {
68  int i;
69 
70  if (grp == NULL) return;
71 
72  for (i = 0; i < grp->n_grp; i++) {
73  HECMW_free(grp->grp_name[i]);
74  }
75  HECMW_free(grp->grp_name);
76  HECMW_free(grp->grp_index);
77  HECMW_free(grp->grp_item);
78  HECMW_free(grp->bc_grp_ID);
79  HECMW_free(grp->bc_grp_type);
81  HECMW_free(grp->bc_grp_dof);
82  HECMW_free(grp->bc_grp_val);
83 }
84 
85 static void free_egrp(struct hecmwST_elem_grp *grp) {
86  int i;
87 
88  if (grp == NULL) return;
89 
90  for (i = 0; i < grp->n_grp; i++) {
91  HECMW_free(grp->grp_name[i]);
92  }
93  HECMW_free(grp->grp_name);
94  HECMW_free(grp->grp_index);
95  HECMW_free(grp->grp_item);
96  HECMW_free(grp->bc_grp_ID);
97  HECMW_free(grp->bc_grp_type);
99  HECMW_free(grp->bc_grp_val);
100 }
101 
102 static void free_sgrp(struct hecmwST_surf_grp *grp) {
103  int i;
104 
105  if (grp == NULL) return;
106 
107  for (i = 0; i < grp->n_grp; i++) {
108  HECMW_free(grp->grp_name[i]);
109  }
110  HECMW_free(grp->grp_name);
111  HECMW_free(grp->grp_index);
112  HECMW_free(grp->grp_item);
113  HECMW_free(grp->bc_grp_ID);
114  HECMW_free(grp->bc_grp_type);
115  HECMW_free(grp->bc_grp_index);
116  HECMW_free(grp->bc_grp_val);
117 }
118 
119 static void free_contact_pair(struct hecmwST_contact_pair *cpair) {
120  int i;
121 
122  if (cpair == NULL) return;
123 
124  for (i = 0; i < cpair->n_pair; i++) {
125  HECMW_free(cpair->name[i]);
126  }
127 
128  HECMW_free(cpair->type);
129  HECMW_free(cpair->name);
130  HECMW_free(cpair->slave_grp_id);
132  HECMW_free(cpair->master_grp_id);
133 }
134 
135 static void free_refine_origin(struct hecmwST_refine_origin *reforg) {
136  int i;
137 
138  if (reforg == NULL) return;
139 
140  HECMW_free(reforg->index);
141  HECMW_free(reforg->item_index);
142  HECMW_free(reforg->item_item);
143 }
144 
146  int i;
147 
148  if (mesh == NULL) return;
149 
150  for (i = 0; i < mesh->hecmw_n_file; i++) {
151  HECMW_free(mesh->files[i]);
152  }
154 
158  HECMW_free(mesh->node);
165 
181 
189 
198 
204 
205  free_section(mesh->section);
206  free_material(mesh->material);
207  free_mpc(mesh->mpc);
208  free_amplitude(mesh->amp);
209  free_ngrp(mesh->node_group);
210  free_egrp(mesh->elem_group);
211  free_sgrp(mesh->surf_group);
212  free_contact_pair(mesh->contact_pair);
213  free_refine_origin(mesh->refine_origin);
214 
216 }
217 
219  if (mesh == NULL) return;
220 
222 
225  HECMW_free(mesh->mpc);
226  HECMW_free(mesh->amp);
232 
233  HECMW_free(mesh);
234 }
hecmwST_local_mesh::mpc
struct hecmwST_mpc * mpc
Definition: hecmw_struct.h:247
hecmwST_local_mesh::global_node_ID
int * global_node_ID
Definition: hecmw_struct.h:168
hecmwST_local_mesh::refine_origin
struct hecmwST_refine_origin * refine_origin
Definition: hecmw_struct.h:253
hecmwST_local_mesh::section_ID
int * section_ID
Definition: hecmw_struct.h:197
hecmwST_mpc
Definition: hecmw_struct.h:48
hecmwST_local_mesh::hecmw_n_file
int hecmw_n_file
Definition: hecmw_struct.h:155
hecmwST_local_mesh::shared_index
int * shared_index
Definition: hecmw_struct.h:221
hecmwST_node_grp::bc_grp_dof
int * bc_grp_dof
Definition: hecmw_struct.h:88
hecmwST_amplitude::amp_val
double * amp_val
Definition: hecmw_struct.h:71
hecmwST_node_grp::n_grp
int n_grp
Definition: hecmw_struct.h:76
hecmwST_section::sect_R_index
int * sect_R_index
Definition: hecmw_struct.h:34
hecmwST_amplitude::amp_index
int * amp_index
Definition: hecmw_struct.h:70
hecmwST_local_mesh::node_new2old
int * node_new2old
Definition: hecmw_struct.h:240
hecmwST_surf_grp::bc_grp_ID
int * bc_grp_ID
Definition: hecmw_struct.h:113
HECMW_dist_free
void HECMW_dist_free(struct hecmwST_local_mesh *mesh)
Definition: hecmw_dist_free.c:218
hecmwST_elem_grp::bc_grp_index
int * bc_grp_index
Definition: hecmw_struct.h:102
hecmwST_local_mesh::elem_node_item
int * elem_node_item
Definition: hecmw_struct.h:196
hecmwST_local_mesh::elem_old2new
int * elem_old2new
Definition: hecmw_struct.h:241
hecmwST_amplitude::amp_table
double * amp_table
Definition: hecmw_struct.h:72
hecmwST_refine_origin::item_index
int * item_index
Definition: hecmw_struct.h:135
hecmwST_local_mesh::shared_item
int * shared_item
Definition: hecmw_struct.h:222
hecmwST_local_mesh::elem_mat_int_val
double * elem_mat_int_val
Definition: hecmw_struct.h:203
hecmwST_local_mesh::elem_group
struct hecmwST_elem_grp * elem_group
Definition: hecmw_struct.h:250
hecmwST_local_mesh::elem_new2old
int * elem_new2old
Definition: hecmw_struct.h:242
mesh
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
hecmwST_local_mesh::adapt_parent
int * adapt_parent
Definition: hecmw_struct.h:233
hecmwST_local_mesh::elem_mat_int_index
int * elem_mat_int_index
Definition: hecmw_struct.h:202
hecmwST_local_mesh::adapt_parent_type
int * adapt_parent_type
Definition: hecmw_struct.h:229
hecmwST_refine_origin::index
int * index
Definition: hecmw_struct.h:134
hecmwST_section::sect_I_index
int * sect_I_index
Definition: hecmw_struct.h:32
hecmwST_node_grp::bc_grp_val
double * bc_grp_val
Definition: hecmw_struct.h:89
hecmwST_local_mesh::elem_type_item
int * elem_type_item
Definition: hecmw_struct.h:194
hecmwST_local_mesh::node_ID
int * node_ID
Definition: hecmw_struct.h:167
hecmwST_mpc::mpc_item
int * mpc_item
Definition: hecmw_struct.h:51
hecmwST_local_mesh
Definition: hecmw_struct.h:139
hecmwST_local_mesh::elem_ID
int * elem_ID
Definition: hecmw_struct.h:189
hecmwST_local_mesh::adapt_type
int * adapt_type
Definition: hecmw_struct.h:230
hecmwST_surf_grp::bc_grp_val
double * bc_grp_val
Definition: hecmw_struct.h:118
hecmwST_amplitude::amp_type_time
int * amp_type_time
Definition: hecmw_struct.h:64
hecmwST_amplitude::amp_type_value
int * amp_type_value
Definition: hecmw_struct.h:67
hecmwST_local_mesh::elem_type
int * elem_type
Definition: hecmw_struct.h:191
hecmwST_mpc::mpc_val
double * mpc_val
Definition: hecmw_struct.h:53
hecmwST_surf_grp::grp_index
int * grp_index
Definition: hecmw_struct.h:109
hecmwST_material::mat_subitem_index
int * mat_subitem_index
Definition: hecmw_struct.h:42
hecmwST_local_mesh::neighbor_pe
int * neighbor_pe
Definition: hecmw_struct.h:216
hecmwST_mpc::mpc_const
double * mpc_const
Definition: hecmw_struct.h:54
hecmwST_local_mesh::export_item
int * export_item
Definition: hecmw_struct.h:220
hecmw_dist_free.h
hecmwST_local_mesh::node_dof_item
int * node_dof_item
Definition: hecmw_struct.h:175
hecmwST_mpc::mpc_dof
int * mpc_dof
Definition: hecmw_struct.h:52
hecmwST_local_mesh::export_index
int * export_index
Definition: hecmw_struct.h:219
hecmwST_elem_grp::bc_grp_val
double * bc_grp_val
Definition: hecmw_struct.h:103
hecmwST_material::mat_table_index
int * mat_table_index
Definition: hecmw_struct.h:43
hecmwST_local_mesh::import_item
int * import_item
Definition: hecmw_struct.h:218
hecmwST_surf_grp::grp_item
int * grp_item
Definition: hecmw_struct.h:111
hecmwST_local_mesh::node_val_index
int * node_val_index
Definition: hecmw_struct.h:177
hecmwST_local_mesh::node_old2new
int * node_old2new
Definition: hecmw_struct.h:239
hecmw_struct.h
hecmwST_local_mesh::node
double * node
Definition: hecmw_struct.h:170
hecmwST_section::sect_opt
int * sect_opt
Definition: hecmw_struct.h:23
hecmwST_amplitude
Definition: hecmw_struct.h:57
hecmwST_elem_grp
Definition: hecmw_struct.h:92
hecmwST_refine_origin
Definition: hecmw_struct.h:133
hecmwST_contact_pair::slave_orisgrp_id
int * slave_orisgrp_id
Definition: hecmw_struct.h:129
hecmwST_local_mesh::n_node_refine_hist
int * n_node_refine_hist
Definition: hecmw_struct.h:243
hecmwST_local_mesh::when_i_was_refined_elem
int * when_i_was_refined_elem
Definition: hecmw_struct.h:228
hecmw_dist_alloc.h
hecmwST_local_mesh::node_dof_index
int * node_dof_index
Definition: hecmw_struct.h:174
hecmwST_contact_pair::n_pair
int n_pair
Definition: hecmw_struct.h:122
hecmwST_section::sect_mat_ID_index
int * sect_mat_ID_index
Definition: hecmw_struct.h:30
HECMW_dist_clean
void HECMW_dist_clean(struct hecmwST_local_mesh *mesh)
Definition: hecmw_dist_free.c:145
hecmwST_amplitude::n_amp
int n_amp
Definition: hecmw_struct.h:58
hecmwST_local_mesh::material
struct hecmwST_material * material
Definition: hecmw_struct.h:246
hecmwST_local_mesh::node_val_item
double * node_val_item
Definition: hecmw_struct.h:178
hecmwST_local_mesh::elem_mat_ID_index
int * elem_mat_ID_index
Definition: hecmw_struct.h:198
hecmwST_material::mat_temp
double * mat_temp
Definition: hecmw_struct.h:45
hecmwST_surf_grp::n_grp
int n_grp
Definition: hecmw_struct.h:107
hecmwST_local_mesh::amp
struct hecmwST_amplitude * amp
Definition: hecmw_struct.h:248
hecmwST_surf_grp::bc_grp_index
int * bc_grp_index
Definition: hecmw_struct.h:117
hecmwST_local_mesh::node_internal_list
int * node_internal_list
Definition: hecmw_struct.h:165
hecmwST_local_mesh::elem_val_index
int * elem_val_index
Definition: hecmw_struct.h:204
hecmwST_local_mesh::adapt_level
int * adapt_level
Definition: hecmw_struct.h:231
hecmwST_local_mesh::elem_node_index
int * elem_node_index
Definition: hecmw_struct.h:195
hecmwST_section::sect_type
int * sect_type
Definition: hecmw_struct.h:17
hecmwST_section
Definition: hecmw_struct.h:11
HECMW_dist_init
int HECMW_dist_init(struct hecmwST_local_mesh *mesh)
Definition: hecmw_dist_alloc.c:323
hecmwST_elem_grp::grp_item
int * grp_item
Definition: hecmw_struct.h:96
hecmwST_node_grp::grp_index
int * grp_index
Definition: hecmw_struct.h:78
hecmwST_elem_grp::grp_name
char ** grp_name
Definition: hecmw_struct.h:94
hecmwST_section::sect_I_item
int * sect_I_item
Definition: hecmw_struct.h:33
hecmwST_local_mesh::adapt_children_index
int * adapt_children_index
Definition: hecmw_struct.h:234
hecmwST_local_mesh::elem_type_index
int * elem_type_index
Definition: hecmw_struct.h:193
hecmwST_contact_pair::type
int * type
Definition: hecmw_struct.h:124
hecmwST_node_grp::grp_item
int * grp_item
Definition: hecmw_struct.h:79
hecmwST_local_mesh::elem_val_item
double * elem_val_item
Definition: hecmw_struct.h:205
hecmwST_amplitude::amp_name
char ** amp_name
Definition: hecmw_struct.h:59
hecmwST_section::sect_mat_ID_item
int * sect_mat_ID_item
Definition: hecmw_struct.h:31
hecmwST_material::n_mat
int n_mat
Definition: hecmw_struct.h:36
hecmwST_node_grp
Definition: hecmw_struct.h:75
hecmwST_local_mesh::elem_mat_ID_item
int * elem_mat_ID_item
Definition: hecmw_struct.h:199
hecmwST_node_grp::bc_grp_ID
int * bc_grp_ID
Definition: hecmw_struct.h:82
hecmwST_node_grp::bc_grp_type
int * bc_grp_type
Definition: hecmw_struct.h:84
hecmwST_local_mesh::when_i_was_refined_node
int * when_i_was_refined_node
Definition: hecmw_struct.h:227
hecmwST_material::mat_name
char ** mat_name
Definition: hecmw_struct.h:40
hecmwST_elem_grp::bc_grp_ID
int * bc_grp_ID
Definition: hecmw_struct.h:99
hecmwST_local_mesh::node_init_val_item
double * node_init_val_item
Definition: hecmw_struct.h:181
hecmwST_surf_grp
Definition: hecmw_struct.h:106
hecmwST_contact_pair
Definition: hecmw_struct.h:121
hecmwST_material::mat_item_index
int * mat_item_index
Definition: hecmw_struct.h:41
hecmwST_contact_pair::slave_grp_id
int * slave_grp_id
Definition: hecmw_struct.h:128
hecmwST_local_mesh::import_index
int * import_index
Definition: hecmw_struct.h:217
hecmwST_contact_pair::name
char ** name
Definition: hecmw_struct.h:123
hecmwST_local_mesh::files
char ** files
Definition: hecmw_struct.h:156
hecmwST_elem_grp::n_grp
int n_grp
Definition: hecmw_struct.h:93
hecmwST_material::mat_val
double * mat_val
Definition: hecmw_struct.h:44
hecmwST_local_mesh::section
struct hecmwST_section * section
Definition: hecmw_struct.h:245
hecmwST_elem_grp::grp_index
int * grp_index
Definition: hecmw_struct.h:95
hecmwST_node_grp::grp_name
char ** grp_name
Definition: hecmw_struct.h:77
hecmwST_node_grp::bc_grp_index
int * bc_grp_index
Definition: hecmw_struct.h:87
NULL
#define NULL
Definition: hecmw_io_nastran.c:30
HECMW_free
#define HECMW_free(ptr)
Definition: hecmw_malloc.h:24
hecmwST_elem_grp::bc_grp_type
int * bc_grp_type
Definition: hecmw_struct.h:101
hecmwST_local_mesh::adapt_children_item
int * adapt_children_item
Definition: hecmw_struct.h:235
hecmwST_material
Definition: hecmw_struct.h:35
hecmwST_section::sect_R_item
double * sect_R_item
Definition: hecmw_struct.h:35
hecmwST_mpc::mpc_index
int * mpc_index
Definition: hecmw_struct.h:50
hecmwST_surf_grp::grp_name
char ** grp_name
Definition: hecmw_struct.h:108
hecmwST_local_mesh::global_elem_ID
int * global_elem_ID
Definition: hecmw_struct.h:190
hecmwST_local_mesh::surf_group
struct hecmwST_surf_grp * surf_group
Definition: hecmw_struct.h:251
hecmwST_refine_origin::item_item
int * item_item
Definition: hecmw_struct.h:136
hecmwST_local_mesh::node_group
struct hecmwST_node_grp * node_group
Definition: hecmw_struct.h:249
hecmw_util.h
hecmwST_contact_pair::master_grp_id
int * master_grp_id
Definition: hecmw_struct.h:130
hecmwST_local_mesh::node_init_val_index
int * node_init_val_index
Definition: hecmw_struct.h:180
hecmwST_local_mesh::contact_pair
struct hecmwST_contact_pair * contact_pair
Definition: hecmw_struct.h:252
hecmwST_surf_grp::bc_grp_type
int * bc_grp_type
Definition: hecmw_struct.h:115
hecmwST_amplitude::amp_type_definition
int * amp_type_definition
Definition: hecmw_struct.h:61
hecmwST_local_mesh::elem_internal_list
int * elem_internal_list
Definition: hecmw_struct.h:187