FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
hecmw_io_get_mesh.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_io_get_mesh.h"
11#include "hecmw_io_mesh.h"
12#include "hecmw_io_hec.h"
13#include "hecmw_io_geofem.h"
14#include "hecmw_io_abaqus.h"
15#include "hecmw_io_dist.h"
16#include "hecmw_dist_refine.h"
17#include "hecmw_dist_free.h"
18
19static struct hecmwST_local_mesh *get_entire_mesh(
21 int i;
23
24 if (HECMW_io_init()) return NULL;
25 HECMW_log(HECMW_LOG_DEBUG, "io_init done");
26
27 if (HECMW_io_pre_process()) return NULL;
28 HECMW_log(HECMW_LOG_DEBUG, "io_pre_process done");
29
30 for (i = 0; i < files->n_mesh; i++) {
31 struct hecmw_ctrl_meshfile *file = &files->meshfiles[i];
32
33 switch (file->type) {
35 if (HECMW_read_entire_mesh(file->filename)) return NULL;
36 break;
38 if (HECMW_read_geofem_mesh(file->filename)) return NULL;
39 break;
41 if (HECMW_read_abaqus_mesh(file->filename)) return NULL;
42 break;
43 default:
44 HECMW_assert(0);
45 }
46 }
47 HECMW_log(HECMW_LOG_DEBUG, "reading mesh done\n");
48
49 if (HECMW_io_post_process()) return NULL;
50 HECMW_log(HECMW_LOG_DEBUG, "post_process done\n");
51
53 if (mesh == NULL) return NULL;
54 HECMW_log(HECMW_LOG_DEBUG, "converting mesh done\n");
55
56 if (HECMW_io_finalize()) return NULL;
57 HECMW_log(HECMW_LOG_DEBUG, "io_finalize done\n");
58
59 return mesh;
60}
61
62struct hecmwST_local_mesh *HECMW_get_mesh(char *name_ID) {
63 struct hecmw_ctrl_meshfiles *files;
65 char filename[HECMW_FILENAME_LEN + 1];
66 char *cad_filename;
67 FILE *fp;
68
70 if (files == NULL) return NULL;
71
72 if (files->n_mesh == 1 &&
73 files->meshfiles[0].type == HECMW_CTRL_FTYPE_HECMW_DIST) {
74 strcpy(filename, files->meshfiles[0].filename);
75 mesh = HECMW_get_dist_mesh(filename);
76 } else {
77 mesh = get_entire_mesh(files);
78 }
79
80 strcpy(filename, files->meshfiles[0].filename);
81 strtok(filename, ".");
82 strcat(filename, ".rnf");
83 if ((fp = fopen(filename, "r")) == NULL) {
84 cad_filename = NULL;
85 } else {
86 fclose(fp);
87 cad_filename = filename;
88 }
89
90 if (HECMW_dist_refine(&mesh, files->meshfiles[0].refine, cad_filename,
91 NULL) != HECMW_SUCCESS) {
93 return NULL;
94 }
95
97
98 return mesh;
99}
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72
#define HECMW_SUCCESS
Definition: hecmw_config.h:64
void HECMW_ctrl_free_meshfiles(struct hecmw_ctrl_meshfiles *meshfiles)
struct hecmw_ctrl_meshfiles * HECMW_ctrl_get_meshfiles(char *name_ID)
#define HECMW_CTRL_FTYPE_HECMW_DIST
Definition: hecmw_control.h:14
#define HECMW_CTRL_FTYPE_HECMW_ENTIRE
Definition: hecmw_control.h:16
#define HECMW_CTRL_FTYPE_GEOFEM
Definition: hecmw_control.h:18
#define HECMW_CTRL_FTYPE_ABAQUS
Definition: hecmw_control.h:20
void HECMW_dist_free(struct hecmwST_local_mesh *mesh)
int HECMW_dist_refine(struct hecmwST_local_mesh **mesh, int refine, const char *cad_filename, const char *part_filename)
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
int HECMW_read_abaqus_mesh(const char *filename)
struct hecmwST_local_mesh * HECMW_get_dist_mesh(char *fname)
int HECMW_read_geofem_mesh(const char *filename)
struct hecmwST_local_mesh * HECMW_get_mesh(char *name_ID)
int HECMW_read_entire_mesh(const char *filename)
struct hecmwST_local_mesh * HECMW_io_make_local_mesh(void)
int HECMW_io_init(void)
int HECMW_io_pre_process(void)
int HECMW_io_post_process(void)
int HECMW_io_finalize(void)
#define NULL
int HECMW_log(int loglv, const char *fmt,...)
Definition: hecmw_log.c:260
#define HECMW_LOG_DEBUG
Definition: hecmw_log.h:21
#define HECMW_assert(cond)
Definition: hecmw_util.h:40
struct hecmw_ctrl_meshfile * meshfiles
Definition: hecmw_control.h:42