fluid_problem.h 6 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
#include "hxt_linear_system.h"
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
30

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

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


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

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


struct FluidProblem {
58
59
  double *rho;
  double *mu;
60
  double g;
61
  double coeffStab;
62
  double sigma;
Matthieu Constant's avatar
Matthieu Constant committed
63
  double kinetic_energy;
64
  Mesh *mesh;
65
  MeshTree *mesh_tree;
66
  Tree_cell *Tree;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
67
  Tree_cell **map;
68
  int *map2Tree;
69
70
  int size_initial_mesh; // number of initial elements in the mesh
  int size_initial_node; // number of initial nodes in the mesh
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
71
  MeshBoundary *boundaries;
Matthieu Constant's avatar
Matthieu Constant committed
72
73
  double *porosity;
  double *oldporosity;
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
74
  double *concentration;
75
  double *solution;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
76
  double *solution_explicit;
Matthieu Constant's avatar
Matthieu Constant committed
77
  double *node_volume;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
78
  double *element_size;
79
  double volume_drag;
80
81
  int n_strong_boundaries;
  StrongBoundary *strong_boundaries;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
82
83
  int n_weak_boundaries;
  WeakBoundary *weak_boundaries;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
84
  HXTLinearSystem *linear_system;
85
86
87
88
89
  int n_particles;
  double *particle_uvw;
  double *particle_position;
  double *particle_volume;
  double *particle_velocity;
90
  double *particle_contact;
91
  double *particle_mass;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
92
  double *particle_force;
93
  int n_fluids;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
94
  //stabilisation coefficients
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
95
96
  double *taup;
  double *tauc;
97
  int *particle_element_id;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
98
99
100
  //parameters
  int reduced_gravity;
  double stab_param;
101
  int drag_in_stab;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
102
};
103

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
104
105
// complete force on the particle (including gravity)
void fluid_problem_compute_node_particle_force(FluidProblem *problem, double dt, double *particle_force);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
106
int fluid_problem_implicit_euler(FluidProblem *problem, double dt, double newton_atol, double newton_rtol, int newton_max_it);
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
broken    
Jonathan Lambrechts committed
108
void fluid_problem_set_concentration_cg(FluidProblem *problem, double *concentration);
109
void fluid_problem_free(FluidProblem *problem);
110
FluidProblem *fluid_problem_new(double g, int n_fluids, double *mu, double *rho, double sigma, double coeffStab, double volume_drag, const char *petsc_solver_type, int drag_in_stab);
111
void fluid_problem_load_msh(FluidProblem *problem, const char *mesh_file_name);
112

113
114
void fluid_problem_adapt_mesh(FluidProblem *problem, double e_target, double lcmax, double lcmin, int n_el, double cmax, double cmin, double U_0, double P_0);
void fluid_problem_estimator_evaluation(FluidProblem *problem, double e_target, double lcmax, double lcmin, double n_el, double cmax, double cmin, int boolean_init, double U_0, double P_0);
115
void fluid_problem_local_adapt_mesh(FluidProblem *problem, double lcmax, double lcmin, int bool_init_tree);
116

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
117
118
int *fluid_problem_particle_element_id(FluidProblem *problem);
int fluid_problem_n_particles(FluidProblem *problem);
Matthieu Constant's avatar
Matthieu Constant committed
119
void fluid_problem_after_import(FluidProblem *problem);
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
120
int fluid_problem_n_fields(const FluidProblem *p);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
121
double *fluid_problem_solution(const FluidProblem *p);
122
void fluid_problem_set_weak_boundary(FluidProblem *p, const char *tag, BoundaryType type, BoundaryCallback *cb, int vid, int pid, int cid, int aid);
123
void fluid_problem_set_strong_boundary(FluidProblem *p, const char *tag, int field, int row, BoundaryCallback *apply);
124
125
double *fluid_problem_old_porosity(const FluidProblem *p);
double *fluid_problem_porosity(const FluidProblem *p);
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
126
double *fluid_problem_concentration_dg(const FluidProblem *p);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
127
double *fluid_problem_element_size(const FluidProblem *p);
128

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

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
131
132

// mesh data (for i/o)
133
void printing(Mesh *mesh);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
134
135
136
137
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);
138
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 transfer_solution);
139
//void fluid_problem_local_adapt_mesh(FluidProblem *problem, double lcmax, double lcmin);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
140
141
142
143
144
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
145
146
147
void fluid_problem_set_stab_param(FluidProblem *p, double  stab_param);
void fluid_problem_set_reduced_gravity(FluidProblem *p, int reduced_gravity);

148
int weak_boundary_n_values(const WeakBoundary *wbnd);
Matthieu Constant's avatar
Matthieu Constant committed
149
150
double fluid_problem_a_integ_volume(FluidProblem *problem);
double fluid_problem_a_integ_bnd(FluidProblem *problem, double dt);
151
void weak_boundary_values(const Mesh *mesh, const MeshBoundary *bnd, const WeakBoundary *wbnd, double *data);
152
#endif