FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
hecmw_dist_alloc.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 <ctype.h>
10#include "hecmw_struct.h"
11#include "hecmw_util.h"
12#include "hecmw_dist_alloc.h"
13
14/*============================================================================*/
15/* initialize structures for local mesh */
16/*============================================================================*/
17/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
18/* global information */
19/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
20static int init_struct_global(struct hecmwST_local_mesh *mesh) {
21 HECMW_assert(mesh);
22
23 memset(mesh->gridfile, 0, sizeof(mesh->gridfile));
24 mesh->hecmw_n_file = 0;
25 mesh->files = NULL;
26 memset(mesh->header, 0, sizeof(mesh->header));
27
34
35 mesh->zero_temp = 0.0;
36
37 return 0;
38}
39
40/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
41/* node information */
42/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
43static int init_struct_node(struct hecmwST_local_mesh *mesh) {
44 HECMW_assert(mesh);
45
46 mesh->n_node = 0;
47 mesh->n_node_gross = 0;
48 mesh->nn_middle = 0;
49 mesh->nn_internal = 0;
51
52 mesh->node = NULL;
53 mesh->node_ID = NULL;
55
56 mesh->n_dof = 0;
57 mesh->n_dof_grp = 0;
58 mesh->n_dof_tot = 0;
61
64
67
68 return 0;
69}
70
71/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
72/* element information */
73/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
74static int init_struct_elem(struct hecmwST_local_mesh *mesh) {
75 HECMW_assert(mesh);
76
77 mesh->n_elem = 0;
78 mesh->n_elem_gross = 0;
79 mesh->ne_internal = 0;
81
82 mesh->elem_ID = NULL;
84
85 mesh->n_elem_type = 0;
89
92
94
98
101
104
105 return 0;
106}
107
108/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
109/* domain & communication information */
110/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
111static int init_struct_comm(struct hecmwST_local_mesh *mesh) {
112 HECMW_assert(mesh);
113
114 mesh->zero = 0;
115 mesh->PETOT = 0;
116 mesh->PEsmpTOT = 0;
117 mesh->my_rank = 0;
118 mesh->errnof = 0;
119 mesh->n_subdomain = 0;
120
121 mesh->n_neighbor_pe = 0;
123
130
131 return 0;
132}
133
134/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
135/* adaptation information */
136/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
137static int init_struct_adapt(struct hecmwST_local_mesh *mesh) {
138 HECMW_assert(mesh);
139
141 mesh->n_adapt = 0;
150
151 return 0;
152}
153
154/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
155/* refinement information */
156/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
157static int init_struct_refine(struct hecmwST_local_mesh *mesh) {
158 HECMW_assert(mesh);
159
160 mesh->n_refine = 0;
166
167 return 0;
168}
169
170/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
171/* section information */
172/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
173static int init_struct_sect(struct hecmwST_local_mesh *mesh) {
174 HECMW_assert(mesh && mesh->section);
175
176 mesh->section->n_sect = 0;
185
186 return 0;
187}
188
189/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
190/* material information */
191/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
192static int init_struct_mat(struct hecmwST_local_mesh *mesh) {
193 HECMW_assert(mesh && mesh->material);
194
195 mesh->material->n_mat = 0;
205
206 return 0;
207}
208
209/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
210/* MPC information */
211/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
212static int init_struct_mpc(struct hecmwST_local_mesh *mesh) {
213 HECMW_assert(mesh && mesh->mpc);
214
215 mesh->mpc->n_mpc = 0;
217 mesh->mpc->mpc_item = NULL;
218 mesh->mpc->mpc_dof = NULL;
219 mesh->mpc->mpc_val = NULL;
221
222 return 0;
223}
224
225/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
226/* amplitude information */
227/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
228static int init_struct_amp(struct hecmwST_local_mesh *mesh) {
229 HECMW_assert(mesh && mesh->amp);
230
231 mesh->amp->n_amp = 0;
232 mesh->amp->amp_name = NULL;
237 mesh->amp->amp_val = NULL;
239
240 return 0;
241}
242
243/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
244/* node group information */
245/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
246static int init_struct_node_grp(struct hecmwST_local_mesh *mesh) {
247 HECMW_assert(mesh && mesh->node_group);
248
249 mesh->node_group->n_grp = 0;
253
254 mesh->node_group->n_bc = 0;
260
261 return 0;
262}
263
264/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
265/* element group information */
266/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
267static int init_struct_elem_grp(struct hecmwST_local_mesh *mesh) {
268 HECMW_assert(mesh && mesh->elem_group);
269
270 mesh->elem_group->n_grp = 0;
274
275 mesh->elem_group->n_bc = 0;
280
281 return 0;
282}
283
284/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
285/* surface group information */
286/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
287static int init_struct_surf_grp(struct hecmwST_local_mesh *mesh) {
288 HECMW_assert(mesh && mesh->surf_group);
289
290 mesh->surf_group->n_grp = 0;
294
295 mesh->surf_group->n_bc = 0;
300
301 return 0;
302}
303
304/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
305/* contact information */
306/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
307static int init_struct_contact_pair(struct hecmwST_local_mesh *mesh) {
309
316
317 return 0;
318}
319
320/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
321/* initialize structures for local mesh */
322/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
325
326 /* global information */
327 if (init_struct_global(mesh)) {
328 return -1;
329 }
330
331 /* node information */
332 if (init_struct_node(mesh)) {
333 return -1;
334 }
335
336 /* element information */
337 if (init_struct_elem(mesh)) {
338 return -1;
339 }
340
341 /* domain & communication information */
342 if (init_struct_comm(mesh)) {
343 return -1;
344 }
345
346 /* adaptation information */
347 if (init_struct_adapt(mesh)) {
348 return -1;
349 }
350
351 /* refinement information */
352 if (init_struct_refine(mesh)) {
353 return -1;
354 }
355
356 /* section information */
357 if (init_struct_sect(mesh)) {
358 return -1;
359 }
360
361 /* material information */
362 if (init_struct_mat(mesh)) {
363 return -1;
364 }
365
366 /* MPC information */
367 if (init_struct_mpc(mesh)) {
368 return -1;
369 }
370
371 /* amplitude information */
372 if (init_struct_amp(mesh)) {
373 return -1;
374 }
375
376 /* node group information */
377 if (init_struct_node_grp(mesh)) {
378 return -1;
379 }
380
381 /* element group information */
382 if (init_struct_elem_grp(mesh)) {
383 return -1;
384 }
385
386 /* surface group information */
387 if (init_struct_surf_grp(mesh)) {
388 return -1;
389 }
390
391 /* contact information */
392 if (init_struct_contact_pair(mesh)) {
393 return -1;
394 }
395
396 return 0;
397}
398
399/*============================================================================*/
400/* allocate structures for local mesh */
401/*============================================================================*/
403 struct hecmwST_local_mesh *mesh;
404
405 /* local mesh < hecmwST_local_mesh > */
406 if ((mesh = (struct hecmwST_local_mesh *)HECMW_calloc(
407 1, sizeof(struct hecmwST_local_mesh))) == NULL) {
408 HECMW_set_error(errno, "");
409 return NULL;
410 }
411
412 /* section information < hecmwST_section > */
413 if ((mesh->section = (struct hecmwST_section *)HECMW_calloc(
414 1, sizeof(struct hecmwST_section))) == NULL) {
415 HECMW_set_error(errno, "");
416 return NULL;
417 }
418
419 /* material information < hecmwST_material > */
420 if ((mesh->material = (struct hecmwST_material *)HECMW_calloc(
421 1, sizeof(struct hecmwST_material))) == NULL) {
422 HECMW_set_error(errno, "");
423 return NULL;
424 }
425
426 /* MPC information < hecmwST_mpc > */
427 if ((mesh->mpc = (struct hecmwST_mpc *)HECMW_calloc(
428 1, sizeof(struct hecmwST_mpc))) == NULL) {
429 HECMW_set_error(errno, "");
430 return NULL;
431 }
432
433 /* amplitude information < hecmwST_amplitude > */
434 if ((mesh->amp = (struct hecmwST_amplitude *)HECMW_calloc(
435 1, sizeof(struct hecmwST_amplitude))) == NULL) {
436 HECMW_set_error(errno, "");
437 return NULL;
438 }
439
440 /* node group information < hecmwST_node_grp > */
442 1, sizeof(struct hecmwST_node_grp))) == NULL) {
443 HECMW_set_error(errno, "");
444 return NULL;
445 }
446
447 /* element group information < hecmwST_elem_grp > */
449 1, sizeof(struct hecmwST_elem_grp))) == NULL) {
450 HECMW_set_error(errno, "");
451 return NULL;
452 }
453
454 /* surface group information < hecmwST_surf_grp > */
456 1, sizeof(struct hecmwST_surf_grp))) == NULL) {
457 HECMW_set_error(errno, "");
458 return NULL;
459 }
460
461 /* contact information < hecmwST_contact_pair > */
463 1, sizeof(struct hecmwST_contact_pair))) == NULL) {
464 HECMW_set_error(errno, "");
465 return NULL;
466 }
467
468 /* origin of refined nodes < hecmwST_refine_origin > */
469 /* allocated only when refinement is performed */
471
472 /* initialization */
473 if (HECMW_dist_init(mesh)) {
474 return NULL;
475 }
476
477 return mesh;
478}
struct hecmwST_local_mesh * HECMW_dist_alloc()
int HECMW_dist_init(struct hecmwST_local_mesh *mesh)
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
int HECMW_set_error(int errorno, const char *fmt,...)
Definition: hecmw_error.c:37
#define NULL
#define HECMW_calloc(nmemb, size)
Definition: hecmw_malloc.h:21
#define HECMW_assert(cond)
Definition: hecmw_util.h:40
int * amp_type_definition
Definition: hecmw_struct.h:61
double * amp_table
Definition: hecmw_struct.h:72
double * bc_grp_val
Definition: hecmw_struct.h:103
struct hecmwST_section * section
Definition: hecmw_struct.h:244
double * elem_val_item
Definition: hecmw_struct.h:204
double * elem_mat_int_val
Definition: hecmw_struct.h:202
struct hecmwST_amplitude * amp
Definition: hecmw_struct.h:247
struct hecmwST_material * material
Definition: hecmw_struct.h:245
struct hecmwST_refine_origin * refine_origin
Definition: hecmw_struct.h:252
double * node_val_item
Definition: hecmw_struct.h:177
struct hecmwST_mpc * mpc
Definition: hecmw_struct.h:246
struct hecmwST_node_grp * node_group
Definition: hecmw_struct.h:248
double * node_init_val_item
Definition: hecmw_struct.h:180
struct hecmwST_contact_pair * contact_pair
Definition: hecmw_struct.h:251
struct hecmwST_surf_grp * surf_group
Definition: hecmw_struct.h:250
char gridfile[HECMW_FILENAME_LEN+1]
Definition: hecmw_struct.h:153
char header[HECMW_HEADER_LEN+1]
Definition: hecmw_struct.h:156
struct hecmwST_elem_grp * elem_group
Definition: hecmw_struct.h:249
int * when_i_was_refined_node
Definition: hecmw_struct.h:226
int * when_i_was_refined_elem
Definition: hecmw_struct.h:227
int * mat_subitem_index
Definition: hecmw_struct.h:42
double * mat_val
Definition: hecmw_struct.h:44
double * mat_temp
Definition: hecmw_struct.h:45
int * mpc_dof
Definition: hecmw_struct.h:52
double * mpc_val
Definition: hecmw_struct.h:53
double * mpc_const
Definition: hecmw_struct.h:54
int * mpc_index
Definition: hecmw_struct.h:50
int * mpc_item
Definition: hecmw_struct.h:51
double * bc_grp_val
Definition: hecmw_struct.h:89
double * sect_R_item
Definition: hecmw_struct.h:32
int * sect_mat_ID_index
Definition: hecmw_struct.h:27
int * sect_mat_ID_item
Definition: hecmw_struct.h:28
double * bc_grp_val
Definition: hecmw_struct.h:118