FrontISTR  5.7.1
Large-scale structural analysis program with finit element method
hecmw_visual_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_result.h"
11 #include "hecmw_util.h"
12 #include "hecmw_dist_copy_f2c.h"
13 #include "hecmw_result_copy_f2c.h"
14 #include "hecmw_dist_free.h"
15 #include "hecmw_visualizer.h"
16 
17 static struct hecmwST_local_mesh *mesh;
18 static struct hecmwST_result_data *result;
19 
20 /*----------------------------------------------------------------------------*/
21 static int alloc_local_mesh(void) {
22  mesh = HECMW_malloc(sizeof(*mesh));
23  if (mesh == NULL) {
24  HECMW_set_error(errno, "");
25  return -1;
26  }
27 
28  mesh->section = HECMW_malloc(sizeof(*mesh->section));
29  if (mesh->section == NULL) {
30  HECMW_set_error(errno, "");
31  return -1;
32  }
33 
34  mesh->material = HECMW_malloc(sizeof(*mesh->material));
35  if (mesh->material == NULL) {
36  HECMW_set_error(errno, "");
37  return -1;
38  }
39 
40  mesh->mpc = HECMW_malloc(sizeof(*mesh->mpc));
41  if (mesh->mpc == NULL) {
42  HECMW_set_error(errno, "");
43  return -1;
44  }
45 
46  mesh->amp = HECMW_malloc(sizeof(*mesh->amp));
47  if (mesh->amp == NULL) {
48  HECMW_set_error(errno, "");
49  return -1;
50  }
51 
52  mesh->node_group = HECMW_malloc(sizeof(*mesh->node_group));
53  if (mesh->node_group == NULL) {
54  HECMW_set_error(errno, "");
55  return -1;
56  }
57 
58  mesh->elem_group = HECMW_malloc(sizeof(*mesh->elem_group));
59  if (mesh->elem_group == NULL) {
60  HECMW_set_error(errno, "");
61  return -1;
62  }
63 
64  mesh->surf_group = HECMW_malloc(sizeof(*mesh->surf_group));
65  if (mesh->surf_group == NULL) {
66  HECMW_set_error(errno, "");
67  return -1;
68  }
69 
70  mesh->contact_pair = HECMW_malloc(sizeof(*mesh->contact_pair));
71  if (mesh->contact_pair == NULL) {
72  HECMW_set_error(errno, "");
73  return -1;
74  }
75 
76  return 0;
77 }
78 
79 /*----------------------------------------------------------------------------*/
80 static int alloc_result(void) {
81  result = HECMW_malloc(sizeof(*result));
82  if (result == NULL) {
83  HECMW_set_error(errno, "");
84  return -1;
85  }
86  return 0;
87 }
88 
89 /*----------------------------------------------------------------------------*/
90 void hecmw_visualize_if(int *step, int *err) {
91  *err = 1;
92  if (HECMW_visualize(mesh, result, *step)) return;
93  *err = 0;
94 }
95 
96 void hecmw_visualize_if_(int *step, int *err) {
97  hecmw_visualize_if(step, err);
98 }
99 
100 void hecmw_visualize_if__(int *step, int *err) {
101  hecmw_visualize_if(step, err);
102 }
103 
104 void HECMW_VISUALIZE_IF(int *step, int *err) {
105  hecmw_visualize_if(step, err);
106 }
107 
108 /*----------------------------------------------------------------------------*/
109 void hecmw_visualize_init_if(int *nnode, int *nelem, int *err) {
110  *err = 1;
111 
112  if (alloc_local_mesh()) return;
113 
114  if (alloc_result()) return;
115 
116  if (HECMW_dist_copy_f2c_init(mesh)) return;
117 
118  if (HECMW_result_copy_f2c_init(result, *nnode, *nelem)) return;
119 
120  *err = 0;
121 }
122 
123 void hecmw_visualize_init_if_(int *nnode, int *nelem, int *err) {
124  hecmw_visualize_init_if(nnode, nelem, err);
125 }
126 
127 void hecmw_visualize_init_if__(int *nnode, int *nelem, int *err) {
128  hecmw_visualize_init_if(nnode, nelem, err);
129 }
130 
131 void HECMW_VISUALIZE_INIT_IF(int *nnode, int *nelem, int *err) {
132  hecmw_visualize_init_if(nnode, nelem, err);
133 }
134 
135 /*----------------------------------------------------------------------------*/
137  *err = 0;
138 
139  if (HECMW_dist_copy_f2c_finalize()) return;
140 
141  if (HECMW_result_copy_f2c_finalize()) return;
142 
143  HECMW_dist_free(mesh);
144  mesh = NULL;
145 
146  HECMW_result_free(result);
147  result = NULL;
148 
149  *err = 0;
150 }
151 
154 }
155 
158 }
159 
161 
162 /*----------------------------------------------------------------------------*/
163 void hecmw_init_for_visual_if(int *err) {
164  *err = 1;
165  if (HECMW_visualize_init()) return;
166  *err = 0;
167 }
168 
170 
172 
174 
175 /*----------------------------------------------------------------------------*/
177  *err = 1;
178  if (HECMW_visualize_finalize()) return;
179  *err = 0;
180 }
181 
184 }
185 
188 }
189 
192 }
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)
int HECMW_set_error(int errorno, const char *fmt,...)
Definition: hecmw_error.c:37
#define NULL
#define HECMW_malloc(size)
Definition: hecmw_malloc.h:20
void HECMW_result_free(struct hecmwST_result_data *result)
Definition: hecmw_result.c:21
int HECMW_result_copy_f2c_init(struct hecmwST_result_data *result_data, int n_node, int n_elem)
int HECMW_result_copy_f2c_finalize(void)
void hecmw_finalize_for_visual_if__(int *err)
void hecmw_visualize_finalize_if__(int *err)
void hecmw_init_for_visual_if_(int *err)
void hecmw_finalize_for_visual_if(int *err)
void hecmw_init_for_visual_if(int *err)
void hecmw_visualize_init_if(int *nnode, int *nelem, int *err)
void hecmw_visualize_if_(int *step, int *err)
void hecmw_visualize_init_if_(int *nnode, int *nelem, int *err)
void hecmw_visualize_if__(int *step, int *err)
void hecmw_finalize_for_visual_if_(int *err)
void hecmw_init_for_visual_if__(int *err)
void HECMW_VISUALIZE_FINALIZE_IF(int *err)
void hecmw_visualize_finalize_if(int *err)
void hecmw_visualize_finalize_if_(int *err)
void HECMW_VISUALIZE_INIT_IF(int *nnode, int *nelem, int *err)
void HECMW_VISUALIZE_IF(int *step, int *err)
void HECMW_INIT_FOR_VISUAL_IF(int *err)
void HECMW_FINALIZE_FOR_VISUAL_IF(int *err)
void hecmw_visualize_init_if__(int *nnode, int *nelem, int *err)
void hecmw_visualize_if(int *step, int *err)
int HECMW_visualize(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, int timestep)
int HECMW_visualize_init(void)
int HECMW_visualize_finalize(void)
struct hecmwST_section * section
Definition: hecmw_struct.h:245
struct hecmwST_amplitude * amp
Definition: hecmw_struct.h:248
struct hecmwST_material * material
Definition: hecmw_struct.h:246
struct hecmwST_mpc * mpc
Definition: hecmw_struct.h:247
struct hecmwST_node_grp * node_group
Definition: hecmw_struct.h:249
struct hecmwST_contact_pair * contact_pair
Definition: hecmw_struct.h:252
struct hecmwST_surf_grp * surf_group
Definition: hecmw_struct.h:251
struct hecmwST_elem_grp * elem_group
Definition: hecmw_struct.h:250