fluid_problem.h 3.82 KB
Newer Older
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
1
2
/*
 * Marblesbag - Copyright (C) <2010-2018>
3
4
 * <Universite catholique de Louvain (UCL), Belgium
 *  Universite de Montpellier, France>
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
5
 * 	
6
 * List of the contributors to the development of Marblesbag: see AUTHORS file.
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
7
8
9
 * Description and complete License: see LICENSE file.
 * 	
 * This program (Marblesbag) 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 StrongBoundaryCallback(int n, const double *x, double *bnd);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
38
39
typedef struct {
  char *tag;
Jonathan Lambrechts's avatar
weak bc    
Jonathan Lambrechts committed
40
  int row;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
41
  int field;
42
  StrongBoundaryCallback *apply;
43
} StrongBoundary;
44

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
45
typedef struct FluidProblem FluidProblem;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
46
typedef void f_cb(FluidProblem *problem,const double *n, double *f,const double *s,const double *ds,const double c,const double *dc,const double dt, int eid);
47
typedef struct {
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
48
49
50
51
52
53
  char *tag;
  f_cb *cb;
} WeakBoundary;


struct FluidProblem {
54
55
  double *rho;
  double *mu;
56
  double g;
57
  Mesh *mesh;
58
  MeshTree *mesh_tree;
Matthieu Constant's avatar
Matthieu Constant committed
59
60
  double *porosity;
  double *oldporosity;
61
  double *solution;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
62
  double *solution_explicit;
Matthieu Constant's avatar
Matthieu Constant committed
63
  double *node_volume;
64
65
  int n_strong_boundaries;
  StrongBoundary *strong_boundaries;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
66
67
  int n_weak_boundaries;
  WeakBoundary *weak_boundaries;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
68
  HXTLinearSystem *linear_system;
69
70
71
72
73
74
  int n_particles;
  double *particle_uvw;
  double *particle_position;
  double *particle_volume;
  double *particle_velocity;
  double *particle_mass;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
75
  double *particle_force;
76
  int n_fluids;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
77
  //stabilisation coefficients
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
78
79
  double *taup;
  double *tauc;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
80
  double *taua;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
81
  double *extraa;
82
  int *particle_element_id;
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
83
};
84

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
85
int fluid_problem_export(const FluidProblem *problem, const char *output_dir, double t, int iter);
86
int fluid_problem_export_vtk(const FluidProblem *problem, const char *output_dir, double t, int iter);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
87
int fluid_problem_import_vtk(FluidProblem *problem, const char *filename);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
88
89
// complete force on the particle (including gravity)
void fluid_problem_compute_node_particle_force(FluidProblem *problem, double dt, double *particle_force);
90
int fluid_problem_implicit_euler(FluidProblem *problem, double dt);
Matthieu Constant's avatar
Matthieu Constant committed
91
void fluid_problem_set_particles(FluidProblem *problem, int n, double *mass, double *volume, double *position, double *velocity, long int *elid, int reload);
92
void fluid_problem_free(FluidProblem *problem);
93
FluidProblem *fluid_problem_new(double g, int n_fluids, double *mu, double *rho);
94
void fluid_problem_load_msh(FluidProblem *problem, const char *mesh_file_name);
Matthieu Constant's avatar
Matthieu Constant committed
95
void fluid_problem_adapt_mesh(FluidProblem *problem, double lcmax, double lcmin, double n_el);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
96
97
int *fluid_problem_particle_element_id(FluidProblem *problem);
int fluid_problem_n_particles(FluidProblem *problem);
Matthieu Constant's avatar
Matthieu Constant committed
98
void fluid_problem_after_import(FluidProblem *problem);
Jonathan Lambrechts's avatar
broken    
Jonathan Lambrechts committed
99
int fluid_problem_n_fields(const FluidProblem *p);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
100
101
102
double *fluid_problem_solution(const FluidProblem *p);
double *fluid_problem_coordinates(const FluidProblem *p);
int fluid_problem_n_nodes(const FluidProblem *p);
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
103
void fluid_problem_set_weak_boundary(FluidProblem *p, const char *tag, const char *bndtype);
104
void fluid_problem_set_strong_boundary(FluidProblem *p, const char *tag, int field, int row, StrongBoundaryCallback *apply);
105
#endif