|
Basilisk CFD
Adaptive Cartesian mesh PDE framework
|
Go to the source code of this file.
Data Structures | |
| struct | Multigrid |
| struct | _Point |
Macros | |
| #define | GRIDNAME "Multigrid" |
| #define | GHOSTS 2 |
| #define | ND(i) ((size_t)(1 << point.level)*((int *)&Dimensions)[i]) |
| #define | _I (point.i - GHOSTS) |
| #define | _J (point.j - GHOSTS) |
| #define | _K (point.k - GHOSTS) |
| #define | _DELTA (1./((1 << point.level)*Dimensions_scale)) |
| #define | multigrid ((Multigrid *)grid) |
| #define | CELL(m, level, i) (*((Cell *) &m[level][(i)*datasize])) |
| #define | SET_DIMENSIONS() |
| #define | foreach_edge() for (int _i = 0; _i < _N; _i++) /* foreach_face */ |
| #define | for (int _i = 0; _i < _N; _i++) /* foreach_cell */ foreach_cell_restore() |
| Similarly, on trees we need prolongation functions which also follow this definition. | |
Typedefs | |
| typedef double | real |
Variables | |
| int | Dimensions_scale = 1 |
| static Point | last_point |
| define | l |
| define VT _attribute[s.i] v y scalar * | list |
| #define _DELTA (1./((1 << point.level)*Dimensions_scale)) |
Definition at line 32 of file multigrid.h.
Definition at line 27 of file multigrid.h.
Definition at line 28 of file multigrid.h.
Definition at line 29 of file multigrid.h.
Definition at line 70 of file multigrid.h.
| for (int _i = 0; _i < _N; _i++) /* foreach_cell */ foreach_cell_restore() |
Similarly, on trees we need prolongation functions which also follow this definition.
Once we have computed the fluxes on all faces, we can update the volume fraction field according to the one-dimensional advection equation.
This is similar to curvature but this time for the position of the interface, defined as
\[ pos = \mathbf{G}\cdot(\mathbf{x} - \mathbf{Z}) \]
with \(\mathbf{G}\) and \(\mathbf{Z}\) two vectors and \(\mathbf{x}\) the coordinates of the interface.
This is defined only in interfacial cells. In all the other cells it takes the value nodata.
We first need a function to compute the position \(\mathbf{x}\) of an interface. For accuracy, we first try to use height functions.
This function is modelled on refine_face_x() and is typically used to refine the values of the face-centered velocity field uf. It uses linear interpolation, taking into account the weighting by the embedded fractions fs.
The simplest way to implement a multi-dimensional VOF advection scheme is to use dimension-splitting i.e. advect the field along each dimension successively using a one-dimensional scheme.
We implement the one-dimensional scheme along the x-dimension and use the for (int _d = 0; _d < dimension; _d++) operator to automatically derive the corresponding functions along the other dimensions.
\[ \partial_tc = -\nabla_x\cdot(\mathbf{u}_f c) + c\nabla_x\cdot\mathbf{u}_f \]
The first term is computed using the fluxes. The second term – which is non-zero for the one-dimensional velocity field – is approximated using a centered volume fraction field cc which will be defined below.
For tracers, the corresponding one-dimensional update is
\[ \partial_tt_j = -\nabla_x\cdot(\mathbf{u}_f t_j) + t_j\nabla_x\cdot\mathbf{u}_f \]
The compressive second-term can be removed by defining the NO_1D_COMPRESSION macro.
To compute the volume fraction flux, we check the sign of the velocity component normal to the face and compute the index i of the corresponding upwind cell (either 0 or -1).
We also check that we are not violating the CFL condition.
If we assume that un is negative i.e. s is -1 and i is 0, the volume fraction flux through the face of the cell is given by the dark area in the figure below. The corresponding volume fraction can be computed using the rectangle_fraction() function.
When the upwind cell is entirely full or empty we can avoid this computation.
Once we have the upwind volume fraction cf, the volume fraction flux through the face is simply:
If we are transporting tracers, we compute their flux using the upwind volume fraction cf and a tracer value upwinded using the Bell–Collela–Glaz scheme and the gradient computed above.
Definition at line 246 of file multigrid.h.
| #define GHOSTS 2 |
Definition at line 12 of file multigrid.h.
| #define GRIDNAME "Multigrid" |
Definition at line 10 of file multigrid.h.
Definition at line 69 of file multigrid.h.
| #define ND | ( | i | ) | ((size_t)(1 << point.level)*((int *)&Dimensions)[i]) |
Definition at line 24 of file multigrid.h.
| #define SET_DIMENSIONS | ( | ) |
Definition at line 235 of file multigrid.h.
Definition at line 6 of file multigrid.h.
Definition at line 594 of file multigrid.h.
References BGHOSTS, d, default_scalar_bc, dimension, enable_fpe(), foreach_boundary_dir(), free(), scalar::i, is_vertex_scalar(), j, l, list, list_append(), neighborp(), periodic_bc(), point, s, v, and x.
Referenced by init_grid().
Referenced by adapt_wavelet(), balance(), check_flags(), coarsen_cell(), coarsen_cell_recursive(), debug_mpi(), flag_border_cells(), foreach_tree(), foreach_visible(), has_local_child(), if(), input_gfs(), is_newpid(), is_root(), locals_pids(), mpi_boundary_coarsen(), mpi_boundary_refine(), mpi_boundary_update_buffers(), mpi_partitioning(), neighborhood(), output_tree(), receive_tree(), refine_cell(), refine_face_solenoidal(), restore_mpi(), root_pids(), tree_boundary_level(), tree_check(), unrefine(), update_saint_venant(), and z_indexing().
Definition at line 938 of file multigrid.h.
References Dimensions, Dimensions_scale, max, x, ivec::x, and ivec::y.
| for | ( | ) | && |
Definition at line 712 of file multigrid.h.
References list_add(), periodic_bc(), periodic_bc(), right, s, and x.
Definition at line 267 of file multigrid.h.
References _k, depth, dimension, GHOSTS, Point::i, Point::level, OMP_PARALLEL(), point, reductions, SET_DIMENSIONS, and x.
| free | ( | list1 | ) |
Referenced by box_boundary_level(), free_grid(), and if().
Definition at line 788 of file multigrid.h.
References free(), free_boundaries(), grid, m(), multigrid, and x.
Referenced by init_grid().
| if | ( | ! | list1 | ) |
| if | ( | l | = = 0 | ) |
Definition at line 807 of file multigrid.h.
References add_boundary(), all, b, box_boundary_level(), datasize, Grid::depth, depth, dimension, Dimensions, free_grid(), GHOSTS, grid, l, Point::level, log_base2(), m(), Grid::maxdepth, mpi_boundary_new(), Grid::n, N, n, periodic_boundary_level_x(), point, qcalloc, qmalloc, reset, SET_DIMENSIONS, size, Grid::tn, x, and ivec::x.
Definition at line 869 of file multigrid.h.
References depth, Dimensions, GHOSTS, Point::i, L0, Point::level, point, SET_DIMENSIONS, x, ivec::x, X0, Y0, and Z0.
Definition at line 800 of file multigrid.h.
Referenced by init_grid().
| OMP_PARALLEL | ( | ) |
| undef val def val | ( | a | , |
| k | , | ||
| l | , | ||
| m | |||
| ) | -> d)[point.j + (l) + (point.i + (k))*(((size_t)(1 << point.level)*((int *)&Dimensions)[ 1 ]) + 2* 2 ) + ((Multigrid *)grid) ->shift[point.level] + _index(a,m)* ((Multigrid *)grid) ->shift[depth() + 1]]) @ @define allocated(...) true @def allocated_child(k,l,m) (level < depth() && point.i > 0 && point.i <= ((size_t)(1 << point.level)*((int *)&Dimensions)[ 0 ]) + 2 && point.j > 0 && point.j <= ((size_t)(1 << point.level)*((int *)&Dimensions)[ 1 ]) + 2) @ @define depth() (grid->depth) @def fine(a,k,l,m) (((real *) ((Multigrid *)grid) ->d)[2*point.j - 2 + (l) + (2*point.i - 2 + (k))*(((size_t)(1 << point.level)*((int *)&Dimensions)[ 1 ])*2 + 2* 2 ) + ((Multigrid *)grid) ->shift[point.level + 1] + _index(a,m)* ((Multigrid *)grid) ->shift[depth() + 1]]) @ @def coarse(a,k,l,m) (((real *) ((Multigrid *)grid) ->d)[(point.j + 2 )/2 + (l) + ((point.i + 2 )/2 + (k))*(((size_t)(1 << point.level)*((int *)&Dimensions)[ 1 ])/2 + 2* 2 ) + ((Multigrid *)grid) ->shift[point.level - 1] + _index(a,m)* ((Multigrid *)grid) ->shift[depth() + 1]]) @ macro POINT_VARIABLES (Point point = point) |
Definition at line 81 of file multigrid.h.
References GHOSTS, Point::i, Point::level, level, point, VARIABLES(), and x.
| int Dimensions_scale = 1 |
Definition at line 31 of file multigrid.h.
Referenced by dimensions().
Definition at line 592 of file multigrid.h.
Referenced by box_boundary_level(), init_grid(), and OMP_PARALLEL().
|
static |
Definition at line 63 of file multigrid.h.
Definition at line 709 of file multigrid.h.
Referenced by box_boundary_level().