FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
hecmw_couple_init_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 <string.h>
9#include <errno.h>
10
11#include "hecmw_struct.h"
12#include "hecmw_dist_copy_f2c.h"
13#include "hecmw_couple_define.h"
14#include "hecmw_couple_init.h"
15
16static struct hecmwST_local_mesh *mesh_unit1 = NULL, *mesh_unit2 = NULL;
17
18/*================================================================================================*/
19
20static struct hecmwST_local_mesh *alloc_struct_local_mesh(void) {
22
24 sizeof(struct hecmwST_local_mesh));
25 if (mesh == NULL) {
26 HECMW_set_error(errno, "");
27 return NULL;
28 }
29 mesh->section = NULL;
31 mesh->mpc = NULL;
32 mesh->amp = NULL;
36
37 mesh->section =
38 (struct hecmwST_section *)HECMW_malloc(sizeof(struct hecmwST_section));
39 if (mesh->section == NULL) {
40 HECMW_set_error(errno, "");
41 goto error;
42 }
43
44 mesh->material =
45 (struct hecmwST_material *)HECMW_malloc(sizeof(struct hecmwST_material));
46 if (mesh->material == NULL) {
47 HECMW_set_error(errno, "");
48 goto error;
49 }
50
51 mesh->mpc = (struct hecmwST_mpc *)HECMW_malloc(sizeof(struct hecmwST_mpc));
52 if (mesh->mpc == NULL) {
53 HECMW_set_error(errno, "");
54 goto error;
55 }
56
58 sizeof(struct hecmwST_amplitude));
59 if (mesh->amp == NULL) {
60 HECMW_set_error(errno, "");
61 goto error;
62 }
63
65 (struct hecmwST_node_grp *)HECMW_malloc(sizeof(struct hecmwST_node_grp));
66 if (mesh->node_group == NULL) {
67 HECMW_set_error(errno, "");
68 goto error;
69 }
70
72 (struct hecmwST_elem_grp *)HECMW_malloc(sizeof(struct hecmwST_elem_grp));
73 if (mesh->elem_group == NULL) {
74 HECMW_set_error(errno, "");
75 goto error;
76 }
77
79 (struct hecmwST_surf_grp *)HECMW_malloc(sizeof(struct hecmwST_surf_grp));
80 if (mesh->surf_group == NULL) {
81 HECMW_set_error(errno, "");
82 goto error;
83 }
84
85 return mesh;
86
87error:
88 HECMW_dist_free(mesh);
89 return NULL;
90}
91
92/*================================================================================================*/
93
94extern void hecmw_couple_init_if(char *boundary_id, int *err, int len) {
95 char c_id[HECMW_NAME_LEN + 1];
96
97 *err = 1;
98
99 if (HECMW_strcpy_f2c_r(boundary_id, len, c_id, sizeof(c_id)) == NULL) return;
100 if (HECMW_couple_init(c_id, mesh_unit1, mesh_unit2) != HECMW_SUCCESS) return;
101
102 *err = 0;
103}
104
105extern void hecmw_couple_init_if_(char *boundary_id, int *err, int len) {
106 hecmw_couple_init_if(boundary_id, err, len);
107}
108
109extern void hecmw_couple_init_if__(char *boundary_id, int *err, int len) {
110 hecmw_couple_init_if(boundary_id, err, len);
111}
112
113extern void HECMW_COUPLE_INIT_IF(char *boundary_id, int *err, int len) {
114 hecmw_couple_init_if(boundary_id, err, len);
115}
116
117/*------------------------------------------------------------------------------------------------*/
118
119extern void hecmw_couple_init_init_if(int *unit_specifier, int *err) {
120 *err = 1;
121
122 if (*unit_specifier == HECMW_COUPLE_UNIT1) {
123 if ((mesh_unit1 = alloc_struct_local_mesh()) == NULL) return;
124 if (HECMW_dist_copy_f2c_init(mesh_unit1)) return;
125 } else if (*unit_specifier == HECMW_COUPLE_UNIT2) {
126 if ((mesh_unit2 = alloc_struct_local_mesh()) == NULL) return;
127 if (HECMW_dist_copy_f2c_init(mesh_unit2)) return;
128 } else {
129 return;
130 }
131
132 *err = 0;
133}
134
135extern void hecmw_couple_init_init_if_(int *unit_specifier, int *err) {
136 hecmw_couple_init_init_if(unit_specifier, err);
137}
138
139extern void hecmw_couple_init_init_if__(int *unit_specifier, int *err) {
140 hecmw_couple_init_init_if(unit_specifier, err);
141}
142
143extern void HECMW_COUPLE_INIT_INIT_IF(int *unit_specifier, int *err) {
144 hecmw_couple_init_init_if(unit_specifier, err);
145}
146
147/*------------------------------------------------------------------------------------------------*/
148
149extern void hecmw_couple_init_final_if(int *err) {
150 *err = 1;
151
152 if (HECMW_dist_copy_f2c_finalize()) return;
153 HECMW_dist_free(mesh_unit1);
154 HECMW_dist_free(mesh_unit2);
155
156 mesh_unit1 = NULL;
157 mesh_unit2 = NULL;
158
159 *err = 0;
160}
161
162extern void hecmw_couple_init_final_if_(int *err) {
164}
165
166extern void hecmw_couple_init_final_if__(int *err) {
168}
169
170extern void HECMW_COUPLE_INIT_FINAL_IF(int *err) {
172}
#define HECMW_SUCCESS
Definition: hecmw_config.h:64
#define HECMW_NAME_LEN
Definition: hecmw_config.h:70
#define HECMW_COUPLE_UNIT1
#define HECMW_COUPLE_UNIT2
int HECMW_couple_init(const char *boundary_id, struct hecmwST_local_mesh *mesh_unit1, struct hecmwST_local_mesh *mesh_unit2)
void hecmw_couple_init_init_if(int *unit_specifier, int *err)
void hecmw_couple_init_init_if_(int *unit_specifier, int *err)
void HECMW_COUPLE_INIT_FINAL_IF(int *err)
void hecmw_couple_init_if_(char *boundary_id, int *err, int len)
void hecmw_couple_init_if__(char *boundary_id, int *err, int len)
void hecmw_couple_init_init_if__(int *unit_specifier, int *err)
void HECMW_COUPLE_INIT_INIT_IF(int *unit_specifier, int *err)
void hecmw_couple_init_final_if_(int *err)
void hecmw_couple_init_final_if(int *err)
void hecmw_couple_init_final_if__(int *err)
void HECMW_COUPLE_INIT_IF(char *boundary_id, int *err, int len)
void hecmw_couple_init_if(char *boundary_id, int *err, int len)
int HECMW_dist_copy_f2c_init(struct hecmwST_local_mesh *local_mesh)
int HECMW_dist_copy_f2c_finalize(void)
void HECMW_dist_free(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
char * HECMW_strcpy_f2c_r(const char *fstr, int flen, char *buf, int bufsize)
Definition: hecmw_lib_fc.c:45
#define HECMW_malloc(size)
Definition: hecmw_malloc.h:20
struct hecmwST_section * section
Definition: hecmw_struct.h:244
struct hecmwST_amplitude * amp
Definition: hecmw_struct.h:247
struct hecmwST_material * material
Definition: hecmw_struct.h:245
struct hecmwST_mpc * mpc
Definition: hecmw_struct.h:246
struct hecmwST_node_grp * node_group
Definition: hecmw_struct.h:248
struct hecmwST_surf_grp * surf_group
Definition: hecmw_struct.h:250
struct hecmwST_elem_grp * elem_group
Definition: hecmw_struct.h:249