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

Go to the source code of this file.

Functions

static void restriction_tag (Point point, scalar t)
 
static long lookup_tag (Array *a, double tag)
 We also need a few helper functions.
 
trace int tag (scalar t)
 The function just takes the scalar field t which holds the initial and final tag values.
 
static int sort_long (const void *a, const void *b)
 
void remove_droplets (scalar f, int minsize=3, double threshold=1e-4, bool bubbles=false)
 

Function Documentation

◆ lookup_tag()

static long lookup_tag ( Array a,
double  tag 
)
static

We also need a few helper functions.

The function below implements a binary search of a sorted array. It returns the index in the array so that \(a[s] \leq tag < a[s+1]\).

Definition at line 30 of file tag.h.

References a, m(), p, s, tag, and x.

Referenced by tag().

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

◆ remove_droplets()

void remove_droplets ( scalar  f,
int  minsize = 3,
double  threshold = 1e-4,
bool  bubbles = false 
)

Removing (small) droplets/bubbles

Using tag(), the function below can identify and remove droplets (or bubbles) defined by VOF tracer f (resp. \(1 - f\)), smaller than a given diameter (minsize) expressed in number of cells. Alternatively, if minsize is negative, the function will keep only the -minsize largest droplets/bubbles.

Definition at line 285 of file tag.h.

References _i, d, dimension, f, i, int, n, pow(), size, sort_long(), tag, and x.

Referenced by event_init().

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

◆ restriction_tag()

static void restriction_tag ( Point  point,
scalar  t 
)
static

Tagging connected neighborhoods

The goal is to associate a unique (strictly positive) index ("tag") t* to cells which belong to the same "neighborhood". All cells in a neighborhood have an initial tag value (given by the user) which is non-zero and are separated from cells in other neighborhoods by cells which have an initial (and final) tag value of zero.

We first define the restriction function for tag values. The parent tag is just the minimum of its children's tags.

Definition at line 15 of file tag.h.

References HUGE, min, t, and x.

Referenced by tag().

Here is the caller graph for this function:

◆ sort_long()

static int sort_long ( const void a,
const void b 
)
static

Definition at line 271 of file tag.h.

References a, and b.

Referenced by remove_droplets().

Here is the caller graph for this function:

◆ tag()

trace int tag ( scalar  t)

The function just takes the scalar field t which holds the initial and final tag values.

It returns the maximum neighborhood tag value (which is also the number of neighborhoods).

We first set the restriction and prolongation functions (on trees).

As an initial guess, we set all the (leaf) cells which have a non-zero initial tag value to the Z- (or Morton-) index. We thus have a different "neighborhood" for each cell which has a non-zero initial tag, and a single neighborhood (tagged zero) for all the cells which have a zero initial tag.

To gather cells which belong to the same neighborhood, we repeat multigrid iterations until none of the tag values changes.

We first do a restriction from the finest to the coarsest level of the multigrid hierarchy, using the restriction_tag() function above.

We then go from the coarsest to the finest level and update the tag values.

If the parent tag is non-zero, we set the child tag to the value of its parent (i.e. to the minimum tag value of its siblings).

For cells which verify the threshold condition (i.e. for which t[] != 0), we refine this initial guess by taking the minimum (non-zero) tag value of its closest neighbors. We also track whether this update changes any of the tag values.

On trees, we need to take into account the minimum tag value of neighboring fine cells.

Reducing the range of indices

Each neighborhood is now tagged with a unique index. The range of indices is large however (between one and the total number of leaves). The goal of this step is to reduce this range to between one and the number of neighborhoods. To do this, we create an ordered array of unique indices.

We first check whether the index is larger than the maximum or smaller than the minimum value in the array. s is the position of the (possibly new) index in the array. A negative value means that the index is already in the array.

We find the range of existing indices [s-1:s] which contains the index. We check whether the index is already in the array.

If the index is new, we add it to the array in the correct position (s).

Parallel reduction

Each process now has its own local correspondence map between the neighborhood index and its rank in the array a (i.e. its reduced index). In parallel, we now need to build a global correspondence map.

We first get the maximum size over all processes of the local map and increase the size of the local map to this value.

Once we have the (global) map, we can replace the neighborhood indices with their index in the global map (+1).

We return the maximum index value.

Definition at line 64 of file tag.h.

References _i, a, array_append(), array_free(), array_new(), boundary_level, coarse(), dimension, fine(), grid, i, index, is_refined, j, k, l, lookup_tag(), Grid::maxdepth, min, n, neighbor(), npe, p, q, realloc(), refine_injection(), restriction, restriction_tag(), s, set_prolongation(), t, tag, x, and z_indexing().

Here is the call graph for this function: