Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
range.h File Reference

Go to the source code of this file.

Data Structures

struct  Memalloc
 
struct  Memrange
 
struct  _Memindex
 

Macros

#define Memindex   struct _Memindex *
 
#define mem_allocated(m, i, j)
 The mem_data() macros return the data stored at a specific (multidimensional) index.
 
#define mem_data(m, i, j)   ((m)->b[i][j])
 

Functions

void memrange_alloc (Memrange *r, Memalloc *mem, int i)
 
bool memrange_free (Memrange *r, Memalloc *mem, int i)
 
struct _Memindexmem_new (int len)
 The mem_new() function returns a new (empty) Memindex.
 
void mem_destroy (struct _Memindex *m, int len)
 The mem_destroy() function frees all the memory allocated by a given Memindex.
 
void mem_assign (struct _Memindex *m, int i, int j, int len, void *b)
 The mem_assign() function assigns a (pointer) value to a given index.
 
void mem_free (struct _Memindex *m, int i, int j, int len, void *b)
 The mem_free() function frees a given index.
 
macro foreach_mem (struct _Memindex *index, int len, int _i)
 The foreach_mem() macro traverses every _i allocated elements of array _m taking into account a periodicity of _len (and ghost cells).
 

Macro Definition Documentation

◆ mem_allocated

#define mem_allocated (   m,
  i,
  j 
)
Value:
((i) >= (m)->r1.start && (i) < (m->r1.end) && \
(m)->b[i] && \
(j) >= (m)->r2[i].start && (j) < (m)->r2[i].end && \
(m)->b[i][j])
define m((k)==0 &&(l)==0 &&(m)==0) macro2 foreach_point(double _x=0.
*cs[i, 0, 0] a *[i -1, 0, 0] j
Definition embed.h:88
scalar int i
Definition embed.h:74
size *double * b

The mem_data() macros return the data stored at a specific (multidimensional) index.

It assumes that the index is allocated. This can be checked with mem_allocated().

Definition at line 153 of file range.h.

◆ mem_data

#define mem_data (   m,
  i,
  j 
)    ((m)->b[i][j])

Definition at line 158 of file range.h.

◆ Memindex

#define Memindex   struct _Memindex *

Definition at line 140 of file range.h.

Function Documentation

◆ foreach_mem()

macro foreach_mem ( struct _Memindex index,
int  len,
int  _i 
)

The foreach_mem() macro traverses every _i allocated elements of array _m taking into account a periodicity of _len (and ghost cells).

Definition at line 309 of file range.h.

References _i, GHOSTS, Point::i, index, _Memindex::len, max, min, Period, point, and x.

◆ mem_assign()

void mem_assign ( struct _Memindex m,
int  i,
int  j,
int  len,
void b 
)

The mem_assign() function assigns a (pointer) value to a given index.

Definition at line 220 of file range.h.

References b, i, j, m(), mem_data, memrange_alloc(), and x.

Here is the call graph for this function:

◆ mem_destroy()

void mem_destroy ( struct _Memindex m,
int  len 
)

The mem_destroy() function frees all the memory allocated by a given Memindex.

Definition at line 183 of file range.h.

References free(), i, j, and m().

Referenced by destroy_layer().

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

◆ mem_free()

void mem_free ( struct _Memindex m,
int  i,
int  j,
int  len,
void b 
)

The mem_free() function frees a given index.

Definition at line 261 of file range.h.

References i, j, m(), memrange_free(), and x.

Here is the call graph for this function:

◆ mem_new()

struct _Memindex * mem_new ( int  len)

The mem_new() function returns a new (empty) Memindex.

Definition at line 173 of file range.h.

References calloc(), m(), and Memindex.

Referenced by new_layer().

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

◆ memrange_alloc()

void memrange_alloc ( Memrange r,
Memalloc mem,
int  i 
)

Memory allocation for one-dimensional arrays

The memrange_alloc() function allocates the memory of the arrays defined by mem and updates the corresponding index range r for a (new) element of index i.

The mem argument is an array of Memalloc structures ending with a NULL pointer for element p.

Definition at line 36 of file range.h.

References calloc(), Memrange::end, i, m(), Memalloc::p, realloc(), Memrange::start, and x.

Referenced by mem_assign().

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

◆ memrange_free()

bool memrange_free ( Memrange r,
Memalloc mem,
int  i 
)

Memory deallocation for one-dimensional arrays

The memrange_free() function takes the same arguments as memrange_alloc() but performs the inverse operation. It returns true if the arrays are empty after deallocation (i.e. the range of indices is empty).

Definition at line 75 of file range.h.

References assert, Memrange::end, free(), i, m(), Memalloc::p, realloc(), Memalloc::size, Memrange::start, and x.

Referenced by mem_free().

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