Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
layers.h
Go to the documentation of this file.
1/** @file layers.h
2 */
3/**
4# Multiple "layers"
5
6This adds support for multiple "layers" i.e. a constant number `nl` of
7contiguous scalar fields. */
8
9int nl = 1;
10
11/**
12We redefine two types of block traversals. An "outer" traversal,
13usable outside for (int _i = 0; _i < _N; _i++) /* foreach */ loops, which uses a global `_layer` index... */
14
15int _layer = 0;
16
17#undef foreach_block
18macro /* foreach_block */ {
19 for (_layer = 0; _layer < nl; _layer++)
20 {...}
21 _layer = 0;
22}
23
24/**
25... and an "inner" traversal, usable within for (int _i = 0; _i < _N; _i++) /* foreach */ loops, which
26uses the `point.l` index as local layer index. */
27
28#undef foreach_block_inner
30 for (p.l = 0; p.l < nl; p.l++)
31 {...}
32 p.l = 0;
33}
34
35/**
36We also redefine the "per field" (inner) traversal. */
37
38#undef foreach_blockf
39macro /* foreach_blockf */ {
40 for (p.l = 0; p.l < _attribute[_f.i].block; p.l++)
41 {...}
42 p.l = 0;
43}
44
45/**
46The two indices are combined to access field values. In practice only
47one of the indices is used. */
48
50@def _index(a,m)
51 (a.i + (_layer + point.l + m < _attribute[a.i].block ?
52 _layer + point.l + m : 0))
53@
54
56@define val(a,k,p,m) data(k,p,m)[_index(a,m)]
57
58/**
59foreach_layer() is just an alias for /* foreach_block */. */
60
61#define foreach_layer() /* foreach_block */
const vector a
Definition all-mach.h:59
if TRASH define &&NewPid *& val(newpid, 0, 0, 0)) -> pid > 0) @else @ define is_newpid()(((NewPid *)&val(newpid, 0, 0, 0)) ->pid > 0) @endif Array *linear_tree(size_t size, scalar newpid)
Definition balance.h:13
define k
define m((k)==0 &&(l)==0 &&(m)==0) macro2 foreach_point(double _x=0.
#define define
int x
Definition common.h:76
static _Attributes * _attribute
Definition common.h:165
#define p
Definition tree.h:320
define _index(a, m)(a.i) @define val(a
Point point
Definition conserving.h:86
int nl
Definition layers.h:9
which uses a global _layer index *int _layer
Definition layers.h:15
which uses the point l index as local layer index *macro foreach_block_inner(Point p=point)
Definition layers.h:29
loops
We redefine two types of block traversals.
Definition layers.h:13
macro
We also redefine the "per field" (inner) traversal.
Definition layers.h:18
#define data(k, l)
Definition linear.h:26
double * layer
Definition multilayer.h:44
static bool which(const char *command)
Definition output.h:389
Definition linear.h:21
int block
Definition common.h:161
Array * index