Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
heights.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HSHIFT   20.
 
#define BGHOSTS   2
 We make sure that two layers of ghost cells are defined on the boundaries (the default is one layer).
 

Functions

static double height (double H)
 
static int orientation (double H)
 
static void half_column (Point point, scalar c, vector h, vector cs, int j)
 
static void column_propagation (vector h)
 
 for (int _d=0;_d< 2;_d++) static void refine_h_x(Point point
 
 if (complete) return
 
 for (int i=-1;i<=1;i++) if(h[0
 
trace void heights (scalar c, vector h)
 The heights() function implementation is similar to the multigrid case, but the construction of the shifted volume fraction field cs is more complex.
 

Variables

scalar h
 
int ori = orientation(h[])
 If some children have not been initialised, we first check that the (three in 2D, nine in 3D) coarse heights are defined and have compatible orientations.
 
 i
 
double h0
 
double dh = (height(h[0,1]) - height(h[0,-1]))/4.
 
 attribute
 An attribute is added so that the height function field can be associated to a (VOF) tracer.
 

Macro Definition Documentation

◆ BGHOSTS

#define BGHOSTS   2

We make sure that two layers of ghost cells are defined on the boundaries (the default is one layer).

Definition at line 43 of file heights.h.

◆ HSHIFT

#define HSHIFT   20.

Height-Functions

The "height-function" is a vector field which gives the distance, along each coordinate axis, from the center of the cell to the closest interface defined by a volume fraction field. This distance is estimated using the "column integral" of the volume fraction in the corresponding direction. This integral is not always defined (for example because the interface is too far i.e. farther than 5.5 cells in our implementation) in which case the value of the field is set to nodata*. See e.g. Popinet, 2009 for more details on height functions.

We also store the "orientation" of the height function together with its value by adding HSHIFT if the volume fraction is unity on the "top" end. The function below applied to the value will return the corresponding height and orientation.

The distance is normalised with the cell size so that the coordinates of the interface are given by

(x, y + Delta*height(h.y[])) or (x + Delta*height(h.x[]), y)
scalar h[]
Definition atmosphere.h:6
int y
Definition common.h:76
int x
Definition common.h:76
static double height(double H)
Definition heights.h:31

Definition at line 29 of file heights.h.

Function Documentation

◆ column_propagation()

static void column_propagation ( vector  h)
static

Column propagation

Once columns are computed on a local 9-cells-high stencil, we will need to "propagate" these values upward or downward so that they are accessible at distances of up to 5.5 cells from the interface. This is important in 3D in particular where marginal (~45 degrees) cases may require such high stencils to compute consistent HF curvatures. We do this by selecting the smallest height in a 5-cells neighborhood along each direction.

Definition at line 224 of file heights.h.

References _i, dimension, h, height(), i, and x.

Referenced by heights().

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

◆ for() [1/2]

for ( )

Multigrid implementation

The heights() function takes a volume fraction field c and returns the height function vector field h.

Definition at line 303 of file heights.h.

References allocated(), h, height(), i, is_boundary, is_prolongation, neighbor(), nodata, and x.

Here is the call graph for this function:

◆ for() [2/2]

for ( int  i = -1; i <= 1; i++)

◆ half_column()

static void half_column ( Point  point,
scalar  c,
vector  h,
vector  cs,
int  j 
)
static

Half-column integration

This helper function performs the integration on half a column, either "downward" (j = -1) or "upward" (j = 1).

The 'state' of the height function can be: complete if both ends were found, zero or one if one end was found and between zero and one if only the interface was found.

S* is the state and H the (partial) value of the height function. If we are on the (first) downward integration (j = -1) we initialise S and H with the volume fraction in the current cell.

On the upward integration (j = 1), we recover the state of the downward integration. Both the state and the (possibly partial) height value are encoded in a single number using a base 100 shift for the state.

Check whether this is an inconsistent height.

Otherwise, this is either a complete or a partial height.

If this is a complete height, we start a fresh upward integration.

We consider the four neighboring cells of the half column, the corresponding volume fraction ci is recovered either from the standard volume fraction field c (first two cells) or from the shifted field cs (last two cells). The construction of cs is explained in the next section.

We then check whether the partial height is complete or not.

We just left an interfacial cell (S) and found a full or empty cell (ci): this is a partial height and we can stop the integration. If the cell is full (ci = 1) we shift the origin of the height.

If S is empty or full and ci is full or empty, we went right through he interface i.e. the height is complete and we can stop the integration. The origin is shifted appropriately and the orientation is encoded using the "HSHIFT trick".

If ci is identical to S (which is empty or full), we check that H is an integer (i.e. its fractional value is zero), otherwise we are in the case where we found an interface but didn't go through it: this is an inconsistent height and we stop the integration.

We update the global state using the state S of the half-integration.

For the downward integration, we check that the partial heights (S != complete) are consistent: if the first cell is full or empty or if the last cell is interfacial, the partial height is marked as inconsistent.

This is a partial height: we encode the state using a base 100 shift.

For the upward integration, we update the current state using the state of the half-integration S only if the first downward integration returned a partial height, or if the upward integration returned a complete height with a smaller value than the (complete) height of the downward integration.

Finally, we set the vector field h using the state and height.

Definition at line 51 of file heights.h.

References c, cs, dimension, h, height(), HSHIFT, i, j, nodata, s, S, state, and x.

Referenced by heights().

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

◆ height()

static double height ( double  H)
inlinestatic

Definition at line 31 of file heights.h.

References HSHIFT, and x.

Referenced by column_propagation(), for(), half_column(), height_curvature(), height_curvature_fit(), and if().

Here is the caller graph for this function:

◆ heights()

trace void heights ( scalar  c,
vector  h 
)

The heights() function implementation is similar to the multigrid case, but the construction of the shifted volume fraction field cs is more complex.

To compute the shifted field, we first need to restrict the volume fraction on all levels.

We traverse the tree level by level, from coarse to fine. On the root cell the height function is undefined.

We construct the ( \(\pm 2\)) shifted field at this level.

We then need to apply boundary conditions on the shifted field. This is more complex than for a constant resolution grid.

We first construct the ( \(\pm 1\)) shifted field for the immediately coarser level. This is done by copying the volume fraction field for pairs of adjacent cells.

We can now use this shifted coarse field (which matches the shifted fine field) to apply boundary conditions on coarse/fine prolongation halos.

We can now sum the half-column at this level, downward or upward according to j.

We fill the prolongation cells with "nodata". The restriction function does nothing as we have already defined h on all levels.

Finally, we "propagate" values along columns.

Final prolongation cells will be filled with values obtained either from neighboring columns or by interpolation from coarser levels (see refine_h_x() above).

Definition at line 366 of file heights.h.

References boundary_iterate, c, column_propagation(), depth, dimension, foreach_halo, h, half_column(), i, j, l, level, nboundary, no_data(), no_restriction(), nodata, point, restriction, s, set_prolongation(), set_restriction(), and x.

Referenced by curvature(), event_init(), and event_vof().

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

◆ if()

if ( complete  )

◆ orientation()

static int orientation ( double  H)
inlinestatic

Definition at line 35 of file heights.h.

References HSHIFT, and x.

Referenced by height_curvature(), height_curvature_fit(), and if().

Here is the caller graph for this function:

Variable Documentation

◆ attribute

attribute
Initial value:

An attribute is added so that the height function field can be associated to a (VOF) tracer.

Definition at line 460 of file heights.h.

◆ dh

◆ h

scalar h
Initial value:
{
bool complete = true

Definition at line 296 of file heights.h.

Referenced by column_propagation(), for(), half_column(), and heights().

◆ h0

double h0
Initial value:
= (30.*height(h[]) + height(h[0,1]) + height(h[0,-1]))/16.
+ 20. *ori
scalar h
Definition heights.h:297
int ori
If some children have not been initialised, we first check that the (three in 2D, nine in 3D) coarse ...
Definition heights.h:323

Definition at line 329 of file heights.h.

Referenced by kpp_bottom_layer(), kpp_do_kpp(), kpp_init_kpp(), and kpp_surface_layer().

◆ i

i
Initial value:
== nodata || orientation(h[0,i]) != ori)
#define nodata
Definition common.h:7
i
Definition heights.h:326
static int orientation(double H)
Definition heights.h:35
return
Definition vof.h:77

Definition at line 326 of file heights.h.

Referenced by column_propagation(), for(), half_column(), and heights().

◆ ori

int ori = orientation(h[])

If some children have not been initialised, we first check that the (three in 2D, nine in 3D) coarse heights are defined and have compatible orientations.

If not, the children heights are undefined. Otherwise, a (bi)quadratic fit of the coarse heights is used to compute the children heights.

Definition at line 323 of file heights.h.