mesh.h 2.91 KB
Newer Older
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
1
/*
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
2
 * MigFlow - Copyright (C) <2010-2018>
3
4
 * <Universite catholique de Louvain (UCL), Belgium
 *  Universite de Montpellier, France>
Michel Henry's avatar
Michel Henry committed
5
 *
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
6
 * List of the contributors to the development of MigFlow: see AUTHORS file.
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
7
 * Description and complete License: see LICENSE file.
Michel Henry's avatar
Michel Henry committed
8
9
10
 *
 * This program (MigFlow) is free software:
 * you can redistribute it and/or modify it under the terms of the GNU Lesser General
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
11
12
 * Public License as published by the Free Software Foundation, either version
 * 3 of the License, or (at your option) any later version.
Michel Henry's avatar
Michel Henry committed
13
 *
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
14
15
16
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Lesser General Public License for more details.
Michel Henry's avatar
Michel Henry committed
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
Michel Henry's avatar
Michel Henry committed
20
 * along with this program (see COPYING and COPYING.LESSER files).  If not,
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
21
22
23
 * see <http://www.gnu.org/licenses/>.
 */

24
25
26
#ifndef MESH_H
#define MESH_H

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
27
#include <stdio.h>
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
28
#include <stdint.h>
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
29

30
31
32
typedef struct {
  int n_nodes;
  double *x;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
33
  int n_elements;
34
  int *elements;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
35
36
  int n_boundaries;
  char **boundary_names;
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
37
  int n_interfaces;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
38
  int *interfaces; // eid0, closure0, {(eid1, closure1),(-1,phys_id)}
39
40
41
42
} Mesh;

Mesh *mesh_load_msh(const char *filename);
void mesh_free(Mesh *m);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
43
44
int mesh_write_msh(Mesh *mesh, FILE *f);
int mesh_write_msh_scalar(const Mesh *mesh, FILE *f, const char *field_name, double t, int iter, const double *solution, int n_fields, int field_id);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
45
int mesh_write_msh_vector(const Mesh *mesh, FILE *f, const char *field_name, double t, int iter, const double *solution, int n_fields, int field_id[DIMENSION]);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
46
void mesh_gen_edges(Mesh *m, int n_bnd_elements, int *bnd_elements, int *bnd_tags);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
47
48

int mesh_write_pos_scalar(const Mesh *mesh, const char *dir_name, const char *field_name, double t, int iter, const double *solution, int n_fields, int field_id);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
49
int mesh_write_pos_vector(const Mesh *mesh, const char *dir_name, const char *field_name, double t, int iter, const double *solution, int n_fields, int field_id[DIMENSION]);
50
void mesh_set_elements(Mesh *m, int n_nodes, double *x, int n_elements, int *elements, int n_boundaries, int *boundaries, int *boundary_tags,int n_physicals, char **physicals);
51

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
52
// not really necessary but useful to implement bnd conditions,
Michel Henry's avatar
Michel Henry committed
53
// can be rebuilt from the interface list
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
54
55
56
57
58
59
60
61
62
typedef struct {
  int n_interfaces;
  int *interfaces;
  int n_nodes;
  int *nodes;
} MeshBoundary;

MeshBoundary *mesh_boundaries_create(const Mesh *m);
void mesh_boundaries_free(MeshBoundary *mbnd, int n);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

#if DIMENSION == 2
static  int elbnd[6][2] = {
  {0,1},{1,2},{2,0},
  {1,0},{2,1},{0,2}};
#else
static int elbnd[24][3] = {
  {0,1,2},{0,2,3},{0,3,1},{1,3,2},
  {2,0,1},{3,0,2},{1,0,3},{2,1,3},
  {1,2,0},{2,3,0},{3,1,0},{3,2,1},

  {0,2,1},{0,3,2},{0,1,3},{1,2,3},
  {2,1,0},{3,2,0},{1,3,0},{2,3,1},
  {1,0,2},{2,0,3},{3,0,1},{3,1,2}
};
#endif
79
#endif