Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
implicit.h File Reference
#include "poisson.h"
Include dependency graph for implicit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IMPLICIT_H   1
 

Functions

void event_defaults0 (void)
 The scheme is unconditionally stable for gravity waves, so the gravity wave CFL is set to \(\infty\), if it has not already been set (typically by the user).
 
void event_defaults (void)
 The rigid lid condition \(\partial_t\eta = 0\) implies.
 
static trace void relax_hydro (scalar *ql, scalar *rhsl, int lev, void *data)
 The relaxation and residual functions of the multigrid solver are derived from the Poisson–Helmholtz equation for \(\eta^{n+1}\) derived from the equations above.
 
static trace double residual_hydro (scalar *ql, scalar *rhsl, scalar *resl, void *data)
 
void event_half_advection (void)
 The semi-implicit update of the layer heights is done in two steps.
 
void event_acceleration (void)
 The r.h.s.
 
void event_pressure (void)
 In the second (implicit) step, the Poisson–Helmholtz equation for \(\eta^{n+1}\) is solved and the corresponding values for the fluxes ^{n+1}$ are obtained by applying the corresponding pressure gradient term.
 

Variables

mgstats mgH = { .minlevel = 1 }
 
double theta_H = 0.5
 
bool rigid = false
 The free-surface can be replaced with a "rigid lid" by setting rigid to true.
 
scalar res_eta = {-1}
 This can be used to optionally store the residual (for debugging).
 
scalar rhs_eta
 
vector alpha_eta
 

Macro Definition Documentation

◆ IMPLICIT_H

#define IMPLICIT_H   1

Definition at line 29 of file implicit.h.

Function Documentation

◆ event_acceleration()

void event_acceleration ( void  )

The r.h.s.

and \(\alpha\) coefficients of the Poisson–Helmholtz equation are computed using the flux values at the "half-timestep".

Event: acceleration (i++)

The r.h.s. is

\[ \text{rhs}_\eta = \beta\eta^n - \Delta t\sum_k\nabla\cdot(hu)^\star_k \]

The fields used by the relaxation function above need to be restricted to all levels.

The restriction function for \(\eta\), which has been modified by the multilayer solver, needs to be replaced by the (default) averaging function for the multigrid solver to work properly.

Definition at line 162 of file implicit.h.

References _i, a_baro, alpha_eta, cm, dimension, dry, dt, eta, eta_r, fm, foreach_layer, h, ha, hf, hu, restriction, restriction_average(), rhs_eta, rigid, sq(), theta_H, u, uf, vector::x, and x.

Here is the call graph for this function:

◆ event_defaults()

void event_defaults ( void  )

The rigid lid condition \(\partial_t\eta = 0\) implies.

Event: defaults (i = 0)

\[ \begin{aligned} 0 & = - \sum_k \nabla \cdot [\theta_H (hu)_k^{n + 1} + (1 - \theta_H) (hu)^n_k] \\ \frac{(hu)^{n + 1}_k - (hu)_k^n}{\Delta t} & = - \Delta tgh^{n + 1 / 2}_k (\theta_H \nabla \eta_r^{n + 1} + (1 - \theta_H) \nabla \eta_r^n) \end{aligned} \]

where \(\eta_r\) is the equivalent free-surface height (i.e. pressure) applied on the rigid lid.

Event: defaults (i = 0)

The default density field is set to unity (times the metric).

We reset the multigrid parameters to their default values.

If the viscosity is non-zero, we need to allocate the face-centered viscosity field.

We also initialize the list of tracers to be advected with the VOF function \(f\) (or its complementary function).

We set limiting.

On trees, we ensure that limiting is also applied to prolongation and refinement.

We add the interface and the density to the default display.

We switch to a pure minmod limiter by default for increased robustness.

With the MUSCL scheme we use the CFL depends on the dimension of the problem.

On trees we need to replace the default bilinear refinement/prolongation with linear so that reconstructed values also use slope limiting.

The restriction/refine attributes of the charge density are those of a tracer otherwise the conservation is not guaranteed.

By default the permittivity is unity and other quantities are zero.

The (velocity) CFL is limited by the unsplit advection scheme, so is dependent on the dimension. The (gravity wave) CFL is set to 1/2 (if not already set by the user).

The gradient and prolongation/restriction functions are set for all tracer fields.

We setup the default display.

Definition at line 64 of file implicit.h.

References eta_r, and rigid.

◆ event_defaults0()

void event_defaults0 ( void  )

The scheme is unconditionally stable for gravity waves, so the gravity wave CFL is set to \(\infty\), if it has not already been set (typically by the user).

Event: defaults0 (i = 0)

Definition at line 37 of file implicit.h.

References CFL_H, HUGE, mgH, mgstats::nrelax, and x.

◆ event_half_advection()

void event_half_advection ( void  )

The semi-implicit update of the layer heights is done in two steps.

The first step is the explicit advection to time \(t + (1 - \theta_H)\Delta t\) of all tracers (including layer heights) i.e.

\[ \begin{aligned} h_k^{n + \theta} & = h_k^n - (1 - \theta_H) \Delta t \nabla \cdot (hu)^n_k \end{aligned} \]

Event: half_advection (i++)

Definition at line 152 of file implicit.h.

References advect(), dt, hf, hu, theta_H, and tracers.

Here is the call graph for this function:

◆ event_pressure()

void event_pressure ( void  )

In the second (implicit) step, the Poisson–Helmholtz equation for \(\eta^{n+1}\) is solved and the corresponding values for the fluxes ^{n+1}$ are obtained by applying the corresponding pressure gradient term.

Event: pressure (i++)

The restriction function for \(\eta\) is restored.

Note that what is stored in hu corresponds to \(\theta_H(hu)^{n+1}\) since this is the flux which will be used in the pressure event to perform the "implicit" update of the tracers (including layer heights) i.e.

\[ \begin{aligned} h_k^{n + 1} & = h_k^{n + \theta} - \Delta t \nabla \cdot \theta_H (hu)^{n+1}_k \end{aligned} \]

Definition at line 221 of file implicit.h.

References _i, a_baro, alpha_eta, dry, dt, eta, eta_r, foreach_layer, h, ha, hf, hu, scalar::i, mg_solve(), mgH, mgstats::minlevel, relax_hydro(), res_eta, residual_hydro(), restriction_eta(), rhs_eta, theta_H, TOLERANCE, u, uf, vector::x, and x.

Here is the call graph for this function:

◆ relax_hydro()

static trace void relax_hydro ( scalar ql,
scalar rhsl,
int  lev,
void data 
)
static

The relaxation and residual functions of the multigrid solver are derived from the Poisson–Helmholtz equation for \(\eta^{n+1}\) derived from the equations above.

\[ \begin{aligned} \beta\eta^{n + 1} + \nabla \cdot (\alpha \nabla \eta^{n + 1}) & = \beta\eta^n - \Delta t \sum_k \nabla \cdot (hu)_k^{\star}\\ \alpha & \equiv - g (\theta \Delta t)^2 \sum_k h^{n + 1 / 2}_k\\ (hu)_k^{\star} & \equiv (hu)_k^n - \Delta tgh^{n + 1 / 2}_k \theta (1 - \theta) \nabla \eta^n \end{aligned} \]

where \(\beta = 1\) for a free surface and \(\beta = 0\) for a rigid lid.

Definition at line 86 of file implicit.h.

References _i, a_baro, alpha, cm, d, data, diagonalize(), dimension, eta, Point::i, level, n, point, rhs_eta, rigid, vector::x, and x.

Referenced by event_pressure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ residual_hydro()

static trace double residual_hydro ( scalar ql,
scalar rhsl,
scalar resl,
void data 
)
static

Definition at line 111 of file implicit.h.

References _i, a_baro, alpha, cm, data, dimension, eta, g, max, res_eta, rhs_eta, rigid, vector::x, and x.

Referenced by event_pressure().

Here is the caller graph for this function:

Variable Documentation

◆ alpha_eta

vector alpha_eta

Definition at line 138 of file implicit.h.

Referenced by event_acceleration(), and event_pressure().

◆ mgH

mgstats mgH = { .minlevel = 1 }

Time-implicit barotropic integration

This implements a semi-implicit scheme for the evolution of the free-surface elevation \(\eta\) of the [multilayer solver](README). The scheme can be summarised as

\[ \begin{aligned} \frac{\eta^{n + 1} - \eta^n}{\Delta t} & = - \sum_k \nabla \cdot [\theta_H (hu)_k^{n + 1} + (1 - \theta_H) (hu)^n_k] \\ \frac{(hu)^{n + 1}_k - (hu)_k^n}{\Delta t} & = - \Delta tgh^{n + 1 / 2}_k (\theta_H \nabla \eta^{n + 1} + (1 - \theta_H) \nabla \eta^n) \end{aligned} \]

where \(\theta_H\) is the "implicitness parameter" typically set to \(1/2\).

The resulting Poisson–Helmholtz equation for \(\eta^{n+1}\) is solved using the multigrid Poisson solver. The convergence statistics are stored in mgH.

Definition at line 26 of file implicit.h.

Referenced by event_defaults0(), event_perfs(), and event_pressure().

◆ res_eta

scalar res_eta = {-1}

This can be used to optionally store the residual (for debugging).

Definition at line 135 of file implicit.h.

Referenced by event_pressure(), residual_hydro(), and residual_nh().

◆ rhs_eta

◆ rigid

bool rigid = false

The free-surface can be replaced with a "rigid lid" by setting rigid to true.

Definition at line 48 of file implicit.h.

Referenced by event_acceleration(), event_defaults(), relax_hydro(), relax_nh(), residual_hydro(), and residual_nh().

◆ theta_H

double theta_H = 0.5