|
Basilisk CFD
Adaptive Cartesian mesh PDE framework
|
Go to the source code of this file.
Macros | |
| #define | neumann_pressure(i) (a.n[i]*fm.n[i]/alpha.n[i]) |
Functions | |
| void | event_defaults (void) |
| For embedded boundaries on trees, we need to define the pressure gradient for prolongation of pressure close to embedded boundaries. | |
| void | event_default_display (void) display("squares (color |
| We had some objects to display by default. | |
| void | event_init (void) |
| Event: init (i = 0) | |
| event | set_dtmax (i++, last) dtmax |
| void | event_stability (void) |
| Event: stability (i++,last) | |
| event | vof (i++, last) |
| If we are using VOF or diffuse tracers, we need to advance them (to time \(t+\Delta t/2\)) here. | |
| event | tracer_advection (i++, last) |
| event | tracer_diffusion (i++, last) |
| event | properties (i++, last) |
| The fluid properties such as specific volume (fields \(\alpha\) and \(\alpha_c\)) or dynamic viscosity (face field \(\mu_f\)) – at time \(t+\Delta t/2\) – can be defined by overloading this event. | |
| void | prediction () |
| void | event_advection_term (void) |
| Event: advection_term (i++,last) | |
| static void | correction (double dt) |
| void | event_viscous_term (void) |
| The viscous term is computed implicitly. | |
| void | event_acceleration (void) |
| Event: acceleration (i++,last) | |
| void | centered_gradient (scalar p, vector g) |
| void | event_projection (void) |
| To get the pressure field at time \(t + \Delta t\) we project the face velocity field (which will also be used for tracer advection at the next timestep). | |
| event | end_timestep (i++, last) |
| Some derived solvers need to hook themselves at the end of the timestep. | |
| void | event_adapt (void) |
| Event: adapt (i++,last) | |
Variables | |
| scalar | p [] = neumann ((a.n[ ghost ]*fm.n[ ghost ]/alpha.n[ ghost ])) |
| The primary variables are the centered pressure field \(p\) and the centered velocity field \(\mathbf{u}\). | |
| vector | uf [] |
| We allocate the (face) velocity field. | |
| vector | g [] |
| scalar | pf [] |
| const vector | mu = zerof |
| In the case of variable density, the user will need to define both the face and centered specific volume fields ( \(\alpha\) and \(\alpha_c\) respectively) i.e. | |
| const vector | a = zerof |
| const vector | alpha = unityf |
| const scalar | rho = unity |
| mgstats | mgp = {0} |
| mgstats | mgpf = {0} |
| mgstats | mgu = {0} |
| bool | stokes = false |
| void | spread = -1) |
| double | dtmax |
| After user initialisation, we initialise the face velocity and fluid properties. | |
For the default symmetric boundary conditions, we need to ensure that the normal component of the velocity is zero after projection. This means that, at the boundary, the acceleration \(\mathbf{a}\) must be balanced by the pressure gradient. Taking care of boundary orientation and staggering of \(\mathbf{a}\), this can be written
Definition at line 90 of file centered.h.
This function constructs the centered pressure gradient and acceleration field g using the face-centered acceleration field a and the cell-centered pressure field p.
We first compute a face field \(\mathbf{g}_f\) combining both acceleration and pressure gradient.
We average these face values to obtain the centered, combined acceleration and pressure gradient field.
Definition at line 411 of file centered.h.
References _i, a, alpha, dimension, fm, g, p, SEPS, vector::x, and x.
Referenced by event_end_timestep(), and event_projection().
We first define a function which adds the pressure gradient and acceleration terms.
Definition at line 345 of file centered.h.
References _i, dimension, dt, g, u, vector::x, and x.
Referenced by event_acceleration(), event_projection(), and event_viscous_term().
Some derived solvers need to hook themselves at the end of the timestep.
Event: acceleration (i++,last)
The acceleration term \(\mathbf{a}\) needs careful treatment as many equilibrium solutions depend on exact balance between the acceleration term and the pressure gradient: for example Laplace's balance for surface tension or hydrostatic pressure in the presence of gravity.
To ensure a consistent discretisation, the acceleration term is defined on faces as are pressure gradients and the centered combined acceleration and pressure gradient term \(\mathbf{g}\) is obtained by averaging.
The (provisionary) face velocity field at time \(t+\Delta t\) is obtained by interpolation from the centered velocity field. The acceleration term is added.
Definition at line 397 of file centered.h.
References _i, a, dt, face_value, fm, u, uf, vector::x, and x.
Event: adapt (i++,last)
After mesh adaptation fluid properties need to be updated. When using embedded boundaries the fluid fractions and face fluxes need to be checked for inconsistencies.
Definition at line 464 of file centered.h.
References _i, cs, event(), fractions_cleanup(), fs, uf, vector::x, and x.
Event: advection_term (i++,last)
We predict the face velocity field \(\mathbf{u}_f\) at time \(t+\Delta t/2\) then project it to make it divergence-free. We can then use it to compute the velocity advection term, using the standard Bell-Collela-Glaz advection scheme for each component of the velocity field.
Definition at line 330 of file centered.h.
References advection(), alpha, dt, g, mgpf, mgstats::nrelax, pf, prediction(), project(), stokes, u, and uf.
We had some objects to display by default.
Event: default_display (i = 0)
For embedded boundaries on trees, we need to define the pressure gradient for prolongation of pressure close to embedded boundaries.
Event: defaults (i = 0)
Event: defaults (i = 0)
We reset the multigrid parameters to their default values.
The pressures are never dumped.
The default density field is set to unity (times the metric and the solid factors).
On trees, refinement of the face-centered velocity field needs to preserve the divergence-free condition.
When using embedded boundaries, the restriction and prolongation operators need to take the boundary into account.
We set the dimensions of the velocity field.
Definition at line 129 of file centered.h.
References _i, alpha, alphav, CFL, cm, cs, dimension, fm, scalar::i, list_add(), mgp, mgpf, mgu, p, pf, refine_embed_linear(), refine_face(), refine_face_solenoidal(), restriction_embed_linear(), rho, s, uf, unityf, vector::x, and x.
To get the pressure field at time \(t + \Delta t\) we project the face velocity field (which will also be used for tracer advection at the next timestep).
Then compute the centered gradient field g.
Event: projection (i++,last)
We add the gradient field g to the centered velocity field.
Definition at line 438 of file centered.h.
References alpha, centered_gradient(), correction(), dt, g, mgp, mgstats::nrelax, p, project(), and uf.
Event: stability (i++,last)
We need to overload the stability event so that the CFL is taken into account (because we set stokes to true).
We first compute the minimum and maximum values of \(\alpha/f_m = 1/\rho\), as well as \(\Delta_{min}\).
The maximum timestep is set using the sum of surface tension coefficients.
Definition at line 237 of file centered.h.
References dt, dtmax, dtnext(), stokes, timestep(), and uf.
The viscous term is computed implicitly.
We first add the pressure gradient and acceleration terms, as computed at time \(t\), then call the implicit viscosity solver. We then remove the acceleration and pressure gradient terms as they will be replaced by their values at time \(t+\Delta t\).
Event: viscous_term (i++,last)
We reset the acceleration field (if it is not a constant).
Definition at line 360 of file centered.h.
References _i, a, correction(), dt, mgu, mu, mgstats::nrelax, rho, u, viscosity(), vector::x, and x.
| void prediction | ( | ) |
For second-order in time integration of the velocity advection term \(\nabla\cdot(\mathbf{u}\otimes\mathbf{u})\), we need to define the face velocity field \(\mathbf{u}_f\) at time \(t+\Delta t/2\). We use a version of the Bell-Collela-Glaz advection scheme and the pressure gradient and acceleration terms at time \(t\) (stored in vector \(\mathbf{g}\)).
Definition at line 268 of file centered.h.
References _i, dimension, dt, fm, fs, g, i, s, sign(), u, uf, un, vector::x, x, and vector::y.
Referenced by event_advection_term().
The fluid properties such as specific volume (fields \(\alpha\) and \(\alpha_c\)) or dynamic viscosity (face field \(\mu_f\)) – at time \(t+\Delta t/2\) – can be defined by overloading this event.
If we are using VOF or diffuse tracers, we need to advance them (to time \(t+\Delta t/2\)) here.
Note that this assumes that tracer fields are defined at time \(t-\Delta t/2\) i.e. are lagging the velocity/pressure fields by half a timestep.
Definition at line 72 of file centered.h.
Referenced by centered_gradient(), event_acceleration(), and event_viscous_term().
Definition at line 72 of file centered.h.
Referenced by centered_gradient(), event_advection_term(), event_defaults(), and event_projection().
| double dtmax |
After user initialisation, we initialise the face velocity and fluid properties.
Definition at line 205 of file centered.h.
Referenced by event_init(), and event_stability().
| vector g[] |
Definition at line 47 of file centered.h.
Referenced by centered_gradient(), correction(), event_advection_term(), event_projection(), and prediction().
| mgstats mgp = {0} |
Definition at line 74 of file centered.h.
Referenced by event_defaults(), and event_projection().
| mgstats mgpf = {0} |
Definition at line 74 of file centered.h.
Referenced by event_advection_term(), event_defaults(), and event_perfs().
| mgstats mgu = {0} |
Definition at line 74 of file centered.h.
Referenced by event_defaults(), and event_viscous_term().
In the case of variable density, the user will need to define both the face and centered specific volume fields ( \(\alpha\) and \(\alpha_c\) respectively) i.e.
\(1/\rho\). If not specified by the user, these fields are set to one i.e. the density is unity.
Viscosity is set by defining the face dynamic viscosity \(\mu\); default is zero.
The face field \(\mathbf{a}\) defines the acceleration term; default is zero.
The statistics for the (multigrid) solution of the pressure Poisson problems and implicit viscosity are stored in mgp, mgpf, mgu respectively.
If stokes is set to true, the velocity advection term \(\nabla\cdot(\mathbf{u}\otimes\mathbf{u})\) is omitted. This is a reference to Stokes flows for which inertia is negligible compared to viscosity.
Definition at line 72 of file centered.h.
Referenced by event_viscous_term().
The primary variables are the centered pressure field \(p\) and the centered velocity field \(\mathbf{u}\).
We wish to approximate numerically the incompressible, variable-density Navier–Stokes equations
\[ \partial_t\mathbf{u}+\nabla\cdot(\mathbf{u}\otimes\mathbf{u}) = \frac{1}{\rho}\left[-\nabla p + \nabla\cdot(2\mu\mathbf{D})\right] + \mathbf{a} \]
\[ \nabla\cdot\mathbf{u} = 0 \]
with the deformation tensor \(\mathbf{D}=[\nabla\mathbf{u} + (\nabla\mathbf{u})^T]/2\).
The scheme implemented here is close to that used in Gerris (Popinet, 2003, Popinet, 2009, Lagrée et al, 2011).
We will use the generic time loop, a CFL-limited timestep, the Bell-Collela-Glaz advection scheme and the implicit viscosity solver. If embedded boundaries are used, a different scheme is used for viscosity. The centered vector field \(\mathbf{g}\) will contain pressure gradients and acceleration terms.
We will also need an auxilliary face velocity field \(\mathbf{u}_f\) and the associated centered pressure field \(p_f\).
Definition at line 46 of file centered.h.
Referenced by centered_gradient(), event_defaults(), and event_projection().
| scalar pf[] |
Definition at line 48 of file centered.h.
Referenced by event_advection_term(), and event_defaults().
Definition at line 73 of file centered.h.
Referenced by event_defaults(), and event_viscous_term().
| void spread = -1) |
Definition at line 75 of file centered.h.
Referenced by event_advection_term(), event_defaults(), and event_stability().
| vector uf[] |
We allocate the (face) velocity field.
We wish to solve the advection equations
\[ \partial_tf_i+\mathbf{u}\cdot\nabla f_i=0 \]
where \(\mathbf{u}\) is the velocity field and \(f_i\) are a list of passive tracers. This can be done with a flux-based advection scheme such as the 2nd-order, unsplit, upwind scheme of Bell-Collela-Glaz, 1989.
The main time loop is defined in [run.h](). A stable timestep needs to respect the CFL condition. For compatibility with the other solvers, we allocate it as uf and define an alias. The gradient function is used to set the type of slope-limiting required. The default is to not use any limiting (i.e. a purely centered slope estimation).
Definition at line 47 of file centered.h.
Referenced by event_acceleration(), event_adapt(), event_advection_term(), event_defaults(), event_init(), event_projection(), event_stability(), event_tracer_advection(), for(), and prediction().