fluid_problem.h 5.55 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>
Jonathan Lambrechts's avatar
Jonathan Lambrechts 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
8
 * Description and complete License: see LICENSE file.
 * 	
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
9
 * This program (MigFlow) is free software: 
10
 * 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
13
14
15
16
 * Public License as published by the Free Software Foundation, either version
 * 3 of the License, or (at your option) any later version.
 * 
 * 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.
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
18
 * 
19
20
 * You should have received a copy of the GNU Lesser General Public License
 * 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
27
#ifndef FLUID_PROBLEM_H
#define FLUID_PROBLEM_H

#include "mesh.h"
28
#include "mesh_find.h"
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
29

Matthieu Constant's avatar
Matthieu Constant committed
30
31
32
33
34
35
#if DIMENSION==2
#define N_N 3
#else
#define N_N 4
#endif

36
typedef void BoundaryCallback(int n, const double *x, double *bnd);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
37
38


Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
39
40
typedef struct {
  char *tag;
Jonathan Lambrechts's avatar
weak bc    
Jonathan Lambrechts committed
41
  int row;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
42
  int field;
43
  BoundaryCallback *apply;
44
} StrongBoundary;
45

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
46
typedef struct FluidProblem FluidProblem;
47
typedef enum {BND_WALL=0,BND_OPEN=1} BoundaryType;
48
typedef struct {
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
49
  char *tag;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
50
  BoundaryType type;
51
52
  BoundaryCallback *field_cb;
  int vid,pid,cid,aid;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
53
54
55
56
} WeakBoundary;


struct FluidProblem {
57
58
  double *rho;
  double *mu;
Nathan Coppin's avatar
Nathan Coppin committed
59
  double *g;
60
  double coeffStab;
61
  double drag_coeff_factor;
Matthieu Constant's avatar
Matthieu Constant committed
62
  double ip_factor;
63
  double sigma;
Matthieu Constant's avatar
Matthieu Constant committed
64
  double kinetic_energy;
65
  Mesh *mesh;
66
  MeshTree *mesh_tree;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
67
  MeshBoundary *boundaries;
Matthieu Constant's avatar
Matthieu Constant committed
68
69
  double *porosity;
  double *oldporosity;
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
70
  double *concentration;
71
  double *solution;
Matthieu Constant's avatar
Matthieu Constant committed
72
  double *node_volume;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
73
  double *element_size;
74
  double volume_drag;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
75
  double quadratic_drag;
76
77
  int n_strong_boundaries;
  StrongBoundary *strong_boundaries;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
78
79
  int n_weak_boundaries;
  WeakBoundary *weak_boundaries;
80
  double *boundary_force;
81
82
83
84
85
  int n_particles;
  double *particle_uvw;
  double *particle_position;
  double *particle_volume;
  double *particle_velocity;
86
  double *particle_contact;
87
  double *particle_mass;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
88
  double *particle_force;
Matthieu Constant's avatar
Matthieu Constant committed
89
  double *grad_a_cg;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
90
  double *bulk_force;
91
  double *all_kappa;
92
  int n_fluids;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
93
  //stabilisation coefficients
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
94
95
  double *taup;
  double *tauc;
96
  int *particle_element_id;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
97
98
99
  //parameters
  int reduced_gravity;
  double stab_param;
Nathan Coppin's avatar
Nathan Coppin committed
100
101
  int advection;
  int temporal;
102
  int drag_in_stab;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
103
};
104

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
105
106
// complete force on the particle (including gravity)
void fluid_problem_compute_node_particle_force(FluidProblem *problem, double dt, double *particle_force);
107
void fluid_problem_set_particles(FluidProblem *problem, int n, double *mass, double *volume, double *position, double *velocity, double *contact, long int *elid, int init, int reload);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
108
void fluid_problem_set_bulk_force(FluidProblem *problem, double *force);
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
109
void fluid_problem_set_concentration_cg(FluidProblem *problem, double *concentration);
110
void fluid_problem_free(FluidProblem *problem);
Matthieu Constant's avatar
Matthieu Constant committed
111
FluidProblem *fluid_problem_new(double *g, int n_fluids, double *mu, double *rho, double sigma, double coeffStab, double volume_drag, double quadratic_drag, int drag_in_stab, double drag_coeff_factor, double ip_factor,int temporal, int advection);
112
void fluid_problem_load_msh(FluidProblem *problem, const char *mesh_file_name);
Matthieu Constant's avatar
Matthieu Constant committed
113
void fluid_problem_adapt_mesh(FluidProblem *problem, double lcmax, double lcmin, double n_el, double cmax, double cmin, int old_n_particles, double *old_particle_position, double *old_particle_volume);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
114
115
int *fluid_problem_particle_element_id(FluidProblem *problem);
int fluid_problem_n_particles(FluidProblem *problem);
Matthieu Constant's avatar
Matthieu Constant committed
116
void fluid_problem_after_import(FluidProblem *problem);
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
117
int fluid_problem_n_fields(const FluidProblem *p);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
118
double *fluid_problem_solution(const FluidProblem *p);
119
void fluid_problem_set_weak_boundary(FluidProblem *p, const char *tag, BoundaryType type, BoundaryCallback *cb, int vid, int pid, int cid, int aid);
120
void fluid_problem_set_strong_boundary(FluidProblem *p, const char *tag, int field, int row, BoundaryCallback *apply);
121
122
double *fluid_problem_old_porosity(const FluidProblem *p);
double *fluid_problem_porosity(const FluidProblem *p);
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
123
double *fluid_problem_concentration_dg(const FluidProblem *p);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
124
double *fluid_problem_element_size(const FluidProblem *p);
125

Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
126
void fluid_problem_advance_concentration(FluidProblem *problem, double dt);
127

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
128
129
130
131
132
133
134
135
136
137
138
139

// mesh data (for i/o)
int fluid_problem_n_nodes(const FluidProblem *p);
double *fluid_problem_coordinates(const FluidProblem *p);
int fluid_problem_n_elements(const FluidProblem *p);
int *fluid_problem_elements(const FluidProblem *p);
void fluid_problem_set_elements(FluidProblem *p, int n_nodes, double *x, int n_elements, int *elements, int n_boundaries, int *boundaries, int *boundary_tags,int n_physicals, char **physicals);
int fluid_problem_n_mesh_boundaries(const FluidProblem *p);
void fluid_problem_mesh_boundary_info(const FluidProblem *p, int bid, char **bname, int *bsize);
void fluid_problem_mesh_boundary_interfaces(const FluidProblem *p, int bid, int *binterfaces);


Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
140
141
142
void fluid_problem_set_stab_param(FluidProblem *p, double  stab_param);
void fluid_problem_set_reduced_gravity(FluidProblem *p, int reduced_gravity);

143
int weak_boundary_n_values(const WeakBoundary *wbnd);
Matthieu Constant's avatar
Matthieu Constant committed
144
145
double fluid_problem_a_integ_volume(FluidProblem *problem);
double fluid_problem_a_integ_bnd(FluidProblem *problem, double dt);
146
void weak_boundary_values(const Mesh *mesh, const MeshBoundary *bnd, const WeakBoundary *wbnd, double *data);
147
#endif