|
Basilisk CFD
Adaptive Cartesian mesh PDE framework
|
Go to the source code of this file.
Functions | |
| void | event_defaults (void) |
| Event: defaults (i = 0) | |
| 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) |
| Tracers (including momentum \(\mathbf{q}\)) are advected by these events. | |
| event | tracer_advection (i++, last) |
| void | event_properties (void) |
| The equation of state (i.e. | |
| event | acceleration (i++, last) |
| This event can be overloaded to add acceleration terms. | |
| void | event_pressure (void) |
| The equation for the pressure is a Poisson–Helmoltz problem which we will solve with the multigrid solver. | |
| event | end_timestep (i++, last) |
| Some derived solvers need to hook themselves at the end of the timestep. | |
| void | event_adapt (void) |
| After mesh adaptation fluid properties need to be updated. | |
Variables | |
| vector | q [] |
| The primitive variables are the momentum \(\mathbf{q}\), pressure \(p\), density \(\rho\), (face) specific volume \(\alpha=1/\rho\), (face) dynamic viscosity \(\mu\) (which is zero by default) and (face) velocity field \(\mathbf{u}_f\). | |
| scalar | p [] |
| vector | uf [] |
| We allocate the (face) velocity field. | |
| const vector | alpha = unityf |
| const vector | mu = zerof |
| const scalar | rho = unity |
| scalar | ps [] |
| The equation of state is defined by the pressure field ps and \(\rho
c^2\). | |
| const scalar | rhoc2 = zeroc |
| const vector | a = zerof |
| vector | g [] |
| We store the combined pressure gradient and acceleration field in g*. | |
| mgstats | mgp = {0} |
| mgstats | mgu = {0} |
| double | dtmax |
| The timestep is computed using the CFL condition on the face velocity field. | |
Some derived solvers need to hook themselves at the end of the timestep.
After mesh adaptation fluid properties need to be updated.
Event: adapt (i++,last)
Definition at line 276 of file all-mach.h.
References event().
Event: defaults (i = 0)
Boundary conditions for VOF-advected tracers usually depend on boundary conditions for the VOF field.
Event: defaults (i = 0)
The default density field is set to unity (times the metric).
We reset the multigrid parameters to their default values.
Definition at line 69 of file all-mach.h.
References alpha, cm, fm, scalar::i, mgp, mgu, rho, unity, unityf, and vector::x.
Event: init (i = 0)
The face velocity field is obtained by simple linear interpolation from the momentum field. We make sure that the specific volume \(\alpha\) is defined by calling the "properties" event (see below).
Definition at line 88 of file all-mach.h.
References _i, alpha, event(), q, uf, and vector::x.
The equation for the pressure is a Poisson–Helmoltz problem which we will solve with the multigrid solver.
The statistics for the solver will be stored in mgp (resp. mgu for the viscosity solver).
Event: pressure (i++, last)
If the viscosity is not zero, we use the implicit viscosity solver to obtain the velocity field at time \(t + \Delta t\). The pressure term is taken into account using the pressure gradient at time \(t\). A provisionary momentum (without the pressure gradient) is then built from the velocity field.
We first define a temporary face velocity field \(\mathbf{u}_\star\) using simple averaging from \(\mathbf{q}_{\star}\), \(\alpha_{n+1}\) and the acceleration term.
The evolution equation for the pressure is
\[\partial_tp +\mathbf{u} \cdot \nabla p = - \rho c^2 \nabla \cdot \mathbf{u}\]
with \(\rho\) the density and \(c\) the speed of sound. Following the classical projection method for incompressible flows, we set
\[ \mathbf{u}_{n + 1} = \mathbf{u}_{\star} - \Delta t (\alpha\nabla p)_{n+1} \]
The evolution equation for the pressure can then be discretised as
\[ \frac{p_{n + 1} - p_n}{\Delta t} +\mathbf{u}_n \cdot \nabla p_n = - \rho c^2_{n + 1} \nabla \cdot \mathbf{u}_{n + 1} \]
which gives, after some manipulations, the Poisson–Helmholtz equation
\[ \lambda_{n + 1} p_{n + 1} + \nabla \cdot \left( \alpha \nabla p \right)_{n + 1} = \lambda_{n + 1} p_{\star} + \frac{1}{\Delta t} \nabla \cdot \mathbf{u}_{\star} \]
with
\[ p_{\star} = p_n - \Delta t\mathbf{u}_n \cdot \nabla p_n \]
and
\[ \lambda = \frac{- 1}{\Delta t^2 \rho c^2} \]
We compute \(\lambda\) and the corresponding term in the right-hand-side of the Poisson–Helmholtz equation.
We add the divergence of the velocity field to the right-hand-side.
The Poisson–Helmholtz solver is called with a definition of the tolerance identical to that used for incompressible flows.
The pressure gradient is applied to \(\mathbf{u}_\star\) to obtain the face velocity field at time \(n + 1\).
We also compute the combined face pressure gradient and acceleration field gf.
And finally we apply the pressure gradient/acceleration term to the flux/momentum. We also store the centered, combined pressure gradient and acceleration field g.
Definition at line 150 of file all-mach.h.
References _i, a, alpha, cm, dimension, dp, dt, fm, g, lambda, mgp, mgu, mu, mgstats::nrelax, p, poisson, ps, q, rho, rhoc2, sq(), TOLERANCE, uf, viscosity(), and vector::x.
The equation of state (i.e.
fields \(\alpha\), \(\rho\), \(\rho c^2\) and ps*) is defined by this event.
Event: properties (i++,last)
If the acceleration is not constant, we reset it to zero.
Definition at line 125 of file all-mach.h.
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).
Definition at line 110 of file all-mach.h.
References dt, dtmax, dtnext(), timestep(), and uf.
Definition at line 59 of file all-mach.h.
Referenced by advect(), area_integral(), area_z2(), array_append(), array_free(), array_new(), array_shrink(), barycenter(), box_matrix(), coeffs1(), coeffs2(), cpu_reduction(), curvature(), cvmix_1d_print(), cvmix_allocate_1d(), cvmix_allocate_2d(), cvmix_deallocate_1d(), cvmix_deallocate_2d(), distance(), dphidt(), eigenvalues(), embed_fraction_refine(), event_acceleration(), event_defaults(), event_end_timestep(), event_face_fields(), event_pressure(), event_properties(), event_viscous_term(), event_vof(), facets(), fine(), for(), foreach_segment(), fraction_refine(), free_solver(), geostrophic_velocity(), gpu_reduction(), h_relax(), h_residual(), heavier_than(), hllc(), horizontal_diffusion(), input_gfs(), input_pgm(), input_stl(), input_xy(), interpolate_array(), is_newpid(), kurganov(), line_area(), line_center(), locate(), lookup_tag(), matrix(), matrix1(), matrix_new(), max(), mg_cycle(), mg_solve(), min(), minmod3(), minmodremap(), msolve(), output_gauges(), parabola_fit_curvature(), pmaxsort(), ptotalsort(), quad_x(), quad_y(), quadratic(), query_sum(), rcv_pid_append_pids(), receive_tree(), rectangle_fraction(), relax(), relax_diffusion(), relax_GN(), relax_nh(), relax_nh1(), relax_psi(), relax_viscosity(), remap_c(), remap_robin(), repeat(), residual(), residual_diffusion(), residual_GN(), residual_nh(), residual_nh3(), residual_psi(), residual_viscosity(), riemann(), segBoxOverlap(), segment_flux(), send_tree(), solve(), solve_hessenberg(), sort_long(), split(), sum_add_point(), sum_add_sum(), tag(), update_distance(), util_matrix(), vertical_diffusion(), vertical_viscosity(), volumez(), wait_tree(), ws_send_array(), and zarea().
Definition at line 47 of file all-mach.h.
Referenced by centroids_curvature_fit(), constant_NNT(), embed_flux(), embed_geometry(), event_acceleration(), event_defaults(), event_end_timestep(), event_init(), event_pressure(), event_properties(), event_stability(), facets(), foreach_segment(), height_curvature_fit(), if(), if(), implicit_horizontal_diffusion(), line_alpha(), line_area(), line_center(), line_length_center(), poisson_thermal(), project(), rectangle_fraction(), refine_cm_axi(), relax(), relax_hydro(), relax_nh(), relax_thermal(), residual(), residual_hydro(), and residual_thermal().
| double dtmax |
The timestep is computed using the CFL condition on the face velocity field.
Definition at line 105 of file all-mach.h.
Referenced by bflux(), event_face_fields(), event_init(), event_stability(), hllc(), kinetic(), kurganov(), riemann(), timestep(), timestep(), update_conservation(), update_green_naghdi(), update_saint_venant(), and update_tracer().
| vector g[] |
We store the combined pressure gradient and acceleration field in g*.
Definition at line 65 of file all-mach.h.
Referenced by advect(), DistancePointEllipse(), eigenvalues(), eqstate_eos_alpha(), eqstate_eos_beta(), eqstate_eqstate1(), eta_prolongation(), event_end_timestep(), event_face_fields(), event_pressure(), GetRoot(), gradients(), h_residual(), meanflow_convectiveadjustment(), output_gauges(), refine_elevation(), refine_layered_elevation(), refine_linear_single(), residual(), residual_diffusion(), residual_hydro(), residual_nh(), residual_psi(), restriction_embed_linear(), tracer_fluxes(), update_conservation(), util_convert_fluxes(), vertex_buffer_glColor3f(), and vof_concentration_refine().
| mgstats mgp = {0} |
Definition at line 66 of file all-mach.h.
Referenced by event_defaults(), event_end_timestep(), event_perfs(), event_pressure(), and project().
| mgstats mgu = {0} |
Definition at line 66 of file all-mach.h.
Referenced by event_defaults(), event_perfs(), and event_pressure().
Definition at line 47 of file all-mach.h.
Referenced by event_pressure().
| scalar p[] |
Definition at line 45 of file all-mach.h.
Referenced by event_pressure().
| scalar ps[] |
The equation of state is defined by the pressure field ps and \(\rho c^2\).
In the incompressible limit \(\rho c^2\rightarrow\infty\). Rather than trying to compute this limit, we set both fields to zero and check for this particular case when computing the pressure (see below). This means that by default the fluid is incompressible.
Definition at line 57 of file all-mach.h.
Referenced by event_acceleration(), event_pressure(), event_properties(), and thermal_expansion().
| vector q[] |
The primitive variables are the momentum \(\mathbf{q}\), pressure \(p\), density \(\rho\), (face) specific volume \(\alpha=1/\rho\), (face) dynamic viscosity \(\mu\) (which is zero by default) and (face) velocity field \(\mathbf{u}_f\).
We wish to solve the generic momentum equation
\[ \partial_t\mathbf{q} + \nabla\cdot(\mathbf{q}\mathbf{u}) = - \nabla p + \nabla\cdot(\mu\nabla\mathbf{u}) + \rho\mathbf{a} \]
with \(\mathbf{q}=\rho\mathbf{u}\) the momentum, \(\mathbf{u}\) the velocity, \(\rho\) the density, \(\mu\) the dynamic viscosity, \(p\) the pressure and \(\mathbf{a}\) an acceleration. The pressure is defined through an equation of state and verifies the evolution equation
\[ \partial_t p + \mathbf{u}\cdot\nabla p = -\rho c^2\nabla\cdot\mathbf{u} \]
with \(c\) the speed of sound. By default the solver sets \(c=\infty\), \(\rho=1\) and the pressure equation reduces to
\[ \nabla\cdot\mathbf{u} = 0 \]
The advection of momentum is not performed by this solver (so that different schemes can be used) i.e. in the end, by default, we solve the incompressible (linearised) Euler equations with a projection method.
We build the solver using the generic time loop and the implicit viscous solver (which includes the multigrid Poisson–Helmholtz solver).
Definition at line 44 of file all-mach.h.
Referenced by average_pressure(), event_acceleration(), event_defaults(), event_end_timestep(), event_init(), event_pressure(), event_tracer_diffusion(), event_vof(), fE_refine(), init_grid(), mapped_position(), okada_rectangular_source(), planeBoxOverlap(), quadtree(), rectangular_source(), sound_speed(), tag(), update_cache_f(), update_distance(), and vertex_buffer_glBegin().
Definition at line 48 of file all-mach.h.
Referenced by event_defaults(), and event_pressure().
Definition at line 58 of file all-mach.h.
Referenced by event_defaults(), and event_pressure().
| 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 46 of file all-mach.h.
Referenced by event_init(), event_pressure(), and event_stability().