FrontISTR  5.9.0
Large-scale structural analysis program with finit element method
hecmw_io_get_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 "hecmw_struct.h"
9 #include "hecmw_util.h"
10 #include "hecmw_dist_free.h"
11 #include "hecmw_io_get_mesh.h"
12 #include "hecmw_dist_copy_c2f.h"
13 #include "hecmw_io_hec.h"
14 
15 static struct hecmwST_local_mesh *mesh;
16 
17 void hecmw_get_mesh_init_if(char *name_ID, int *err, int len) {
18  char cname[HECMW_FILENAME_LEN + 1];
19 
20  if (HECMW_strcpy_f2c_r(name_ID, len, cname, sizeof(cname)) == NULL) {
21  *err = 1;
22  return;
23  }
24 
25  mesh = HECMW_get_mesh(cname);
26  if (mesh == NULL) {
27  *err = 1;
28  return;
29  }
30 
31  if (HECMW_dist_copy_c2f_init(mesh)) {
32  *err = 1;
33  return;
34  }
35 
36  *err = 0;
37 }
38 
39 void hecmw_get_mesh_init_if_(char *name_ID, int *err, int len) {
40  hecmw_get_mesh_init_if(name_ID, err, len);
41 }
42 
43 void hecmw_get_mesh_init_if__(char *name_ID, int *err, int len) {
44  hecmw_get_mesh_init_if(name_ID, err, len);
45 }
46 
47 void HECMW_GET_MESH_INIT_IF(char *name_ID, int *err, int len) {
48  hecmw_get_mesh_init_if(name_ID, err, len);
49 }
50 
51 /*----------------------------------------------------------------------------*/
52 
53 void hecmw_get_entire_mesh_init_if(char *filename, int *err, int len) {
54  char cname[HECMW_FILENAME_LEN + 1];
55 
56  if (HECMW_strcpy_f2c_r(filename, len, cname, sizeof(cname)) == NULL) {
57  *err = 1;
58  return;
59  }
60 
61  mesh = HECMW_get_entire_mesh(cname);
62  if (mesh == NULL) {
63  *err = 1;
64  return;
65  }
66 
67  if (HECMW_dist_copy_c2f_init(mesh)) {
68  *err = 1;
69  return;
70  }
71 
72  *err = 0;
73 }
74 
75 /*----------------------------------------------------------------------------*/
76 
77 void hecmw_get_mesh_finalize_if(int *ierr) {
79  *ierr = 1;
80  return;
81  }
82  HECMW_dist_free(mesh);
83  mesh = NULL;
84  *ierr = 0;
85 }
86 
87 void hecmw_get_mesh_finalize_if_(int *ierr) {
89 }
90 
93 }
94 
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:87
int HECMW_dist_copy_c2f_init(struct hecmwST_local_mesh *local_mesh)
int HECMW_dist_copy_c2f_finalize(void)
void HECMW_dist_free(struct hecmwST_local_mesh *mesh)
struct hecmwST_local_mesh * HECMW_get_mesh(char *name_ID)
void hecmw_get_mesh_finalize_if(int *ierr)
void HECMW_GET_MESH_INIT_IF(char *name_ID, int *err, int len)
void HECMW_GET_MESH_FINALIZE_IF(int *ierr)
void hecmw_get_entire_mesh_init_if(char *filename, int *err, int len)
void hecmw_get_mesh_finalize_if_(int *ierr)
void hecmw_get_mesh_init_if__(char *name_ID, int *err, int len)
void hecmw_get_mesh_init_if_(char *name_ID, int *err, int len)
void hecmw_get_mesh_finalize_if__(int *ierr)
void hecmw_get_mesh_init_if(char *name_ID, int *err, int len)
struct hecmwST_local_mesh * HECMW_get_entire_mesh(const char *filename)
#define NULL
char * HECMW_strcpy_f2c_r(const char *fstr, int flen, char *buf, int bufsize)
Definition: hecmw_lib_fc.c:44