FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_put_mesh_if.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_struct.h"
10 #include "hecmw_util.h"
11 #include "hecmw_dist_copy_f2c.h"
12 #include "hecmw_io_put_mesh.h"
13 #include "hecmw_dist_free.h"
14 
15 static struct hecmwST_local_mesh *mesh;
16 
17 static int alloc_struct(void) {
18  mesh = HECMW_malloc(sizeof(*mesh));
19  if (mesh == NULL) {
20  HECMW_set_error(errno, "");
21  return -1;
22  }
23 
24  mesh->section = HECMW_malloc(sizeof(*mesh->section));
25  if (mesh->section == NULL) {
26  HECMW_set_error(errno, "");
27  return -1;
28  }
29 
30  mesh->material = HECMW_malloc(sizeof(*mesh->material));
31  if (mesh->material == NULL) {
32  HECMW_set_error(errno, "");
33  return -1;
34  }
35 
36  mesh->mpc = HECMW_malloc(sizeof(*mesh->mpc));
37  if (mesh->mpc == NULL) {
38  HECMW_set_error(errno, "");
39  return -1;
40  }
41 
42  mesh->amp = HECMW_malloc(sizeof(*mesh->amp));
43  if (mesh->amp == NULL) {
44  HECMW_set_error(errno, "");
45  return -1;
46  }
47 
48  mesh->node_group = HECMW_malloc(sizeof(*mesh->node_group));
49  if (mesh->node_group == NULL) {
50  HECMW_set_error(errno, "");
51  return -1;
52  }
53 
54  mesh->elem_group = HECMW_malloc(sizeof(*mesh->elem_group));
55  if (mesh->elem_group == NULL) {
56  HECMW_set_error(errno, "");
57  return -1;
58  }
59 
60  mesh->surf_group = HECMW_malloc(sizeof(*mesh->surf_group));
61  if (mesh->surf_group == NULL) {
62  HECMW_set_error(errno, "");
63  return -1;
64  }
65 
66  mesh->contact_pair = HECMW_malloc(sizeof(*mesh->contact_pair));
67  if (mesh->contact_pair == NULL) {
68  HECMW_set_error(errno, "");
69  return -1;
70  }
71 
72  return 0;
73 }
74 
75 /*----------------------------------------------------------------------------*/
76 
77 void hecmw_put_mesh_if(char *name_ID, int *err, int len) {
78  char cname[HECMW_NAME_LEN + 1];
79 
80  *err = 1;
81 
82  if (HECMW_strcpy_f2c_r(name_ID, len, cname, sizeof(cname)) == NULL) {
83  return;
84  }
85 
86  if (HECMW_put_mesh(mesh, cname)) {
87  return;
88  }
89 
90  *err = 0;
91 }
92 
93 void hecmw_put_mesh_if_(char *name_ID, int *err, int len) {
94  hecmw_put_mesh_if(name_ID, err, len);
95 }
96 
97 void hecmw_put_mesh_if__(char *name_ID, int *err, int len) {
98  hecmw_put_mesh_if(name_ID, err, len);
99 }
100 
101 void HECMW_PUT_MESH_IF(char *name_ID, int *err, int len) {
102  hecmw_put_mesh_if(name_ID, err, len);
103 }
104 
105 /*----------------------------------------------------------------------------*/
106 
107 void hecmw_put_mesh_init_if(int *err) {
108  *err = 1;
109 
110  if (alloc_struct()) {
111  return;
112  }
113 
114  if (HECMW_dist_copy_f2c_init(mesh)) {
115  return;
116  }
117 
118  *err = 0;
119 }
120 
122 
124 
126 
127 /*----------------------------------------------------------------------------*/
128 
130  *err = 1;
131 
133  return;
134  }
135  HECMW_dist_free(mesh);
136  mesh = NULL;
137 
138  *err = 0;
139 }
140 
142 
144 
hecmwST_local_mesh::mpc
struct hecmwST_mpc * mpc
Definition: hecmw_struct.h:247
hecmw_put_mesh_if_
void hecmw_put_mesh_if_(char *name_ID, int *err, int len)
Definition: hecmw_put_mesh_if.c:93
hecmw_put_mesh_if__
void hecmw_put_mesh_if__(char *name_ID, int *err, int len)
Definition: hecmw_put_mesh_if.c:97
hecmw_put_mesh_init_if__
void hecmw_put_mesh_init_if__(int *err)
Definition: hecmw_put_mesh_if.c:123
HECMW_dist_free
void HECMW_dist_free(struct hecmwST_local_mesh *mesh)
Definition: hecmw_dist_free.c:218
HECMW_malloc
#define HECMW_malloc(size)
Definition: hecmw_malloc.h:20
hecmwST_local_mesh::elem_group
struct hecmwST_elem_grp * elem_group
Definition: hecmw_struct.h:250
hecmwST_local_mesh
Definition: hecmw_struct.h:139
hecmw_put_mesh_init_if_
void hecmw_put_mesh_init_if_(int *err)
Definition: hecmw_put_mesh_if.c:121
HECMW_PUT_MESH_FINALIZE_IF
void HECMW_PUT_MESH_FINALIZE_IF(int *err)
Definition: hecmw_put_mesh_if.c:145
hecmw_dist_free.h
hecmw_put_mesh_if
void hecmw_put_mesh_if(char *name_ID, int *err, int len)
Definition: hecmw_put_mesh_if.c:77
hecmw_put_mesh_finalize_if_
void hecmw_put_mesh_finalize_if_(int *err)
Definition: hecmw_put_mesh_if.c:141
HECMW_dist_copy_f2c_finalize
int HECMW_dist_copy_f2c_finalize(void)
Definition: hecmw_dist_copy_f2c.c:2033
hecmw_struct.h
hecmw_io_put_mesh.h
HECMW_PUT_MESH_INIT_IF
void HECMW_PUT_MESH_INIT_IF(int *err)
Definition: hecmw_put_mesh_if.c:125
HECMW_PUT_MESH_IF
void HECMW_PUT_MESH_IF(char *name_ID, int *err, int len)
Definition: hecmw_put_mesh_if.c:101
HECMW_NAME_LEN
#define HECMW_NAME_LEN
Definition: hecmw_config.h:70
hecmwST_local_mesh::material
struct hecmwST_material * material
Definition: hecmw_struct.h:246
hecmwST_local_mesh::amp
struct hecmwST_amplitude * amp
Definition: hecmw_struct.h:248
hecmw_put_mesh_finalize_if
void hecmw_put_mesh_finalize_if(int *err)
Definition: hecmw_put_mesh_if.c:129
hecmw_put_mesh_init_if
void hecmw_put_mesh_init_if(int *err)
Definition: hecmw_put_mesh_if.c:107
hecmw_dist_copy_f2c.h
hecmw_put_mesh_finalize_if__
void hecmw_put_mesh_finalize_if__(int *err)
Definition: hecmw_put_mesh_if.c:143
HECMW_strcpy_f2c_r
char * HECMW_strcpy_f2c_r(const char *fstr, int flen, char *buf, int bufsize)
Definition: hecmw_lib_fc.c:45
HECMW_set_error
int HECMW_set_error(int errorno, const char *fmt,...)
Definition: hecmw_error.c:37
HECMW_dist_copy_f2c_init
int HECMW_dist_copy_f2c_init(struct hecmwST_local_mesh *local_mesh)
Definition: hecmw_dist_copy_f2c.c:2007
hecmwST_local_mesh::section
struct hecmwST_section * section
Definition: hecmw_struct.h:245
NULL
#define NULL
Definition: hecmw_io_nastran.c:30
hecmwST_local_mesh::surf_group
struct hecmwST_surf_grp * surf_group
Definition: hecmw_struct.h:251
hecmwST_local_mesh::node_group
struct hecmwST_node_grp * node_group
Definition: hecmw_struct.h:249
hecmw_util.h
hecmwST_local_mesh::contact_pair
struct hecmwST_contact_pair * contact_pair
Definition: hecmw_struct.h:252
HECMW_put_mesh
int HECMW_put_mesh(struct hecmwST_local_mesh *mesh, char *name_ID)
Definition: hecmw_io_put_mesh.c:13