Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
radial.h
Go to the documentation of this file.
1
/** @file radial.h
2
*/
3
/**
4
# Radial/cylindrical coordinates
5
6
This implements the radial coordinate mapping illustrated below.
7
8

9
10
It works in 1D, 2D and 3D. The 3D version corresponds to cylindrical
11
coordinates since the \f$z\f$-coordinate is unchanged.
12
13
The only parameter is \f$d\theta\f$, the total angle of the sector. */
14
15
double
dtheta
=
pi
/3.;
16
17
/**
18
For convenience we add definitions for the radial and angular
19
coordinates $(r, \theta)$. */
20
21
macro
VARIABLES
(
Point
point
=
point
,
int
_ig
=
ig
,
int
_jg
=
jg
,
int
_kg
=
kg
)
22
{
23
VARIABLES
(
point
,
_ig
,
_jg
,
_kg
);
24
double
r =
x
,
theta
=
y
*
dtheta
/
L0
;
25
NOT_UNUSED
(r);
NOT_UNUSED
(
theta
);
26
}
27
28
/** @brief Event: metric (i = 0) */
29
void
event_metric
(
void
)
30
{
31
32
/**
33
We initialise the scale factors, taking care to first allocate the
34
fields if they are still constant. */
35
36
if
(
is_constant
(
cm
)) {
37
scalar
*
l
=
list_copy
(
all
);
38
cm
= {0}
/* new scalar */
;
39
free
(
all
);
40
all
=
list_concat
({
cm
},
l
);
41
free
(
l
);
42
}
43
if
(
is_constant
(
fm
.
x
)) {
44
scalar
*
l
=
list_copy
(
all
);
45
fm
= {0}
/* new vector */
;
46
free
(
all
);
47
all
=
list_concat
((
scalar
*){
fm
},
l
);
48
free
(
l
);
49
}
50
51
/**
52
The area (in 2D) of a mapped element is the area of an annulus
53
defined by the two radii \f$r-\Delta/2\f$ and \f$r+\Delta/2\f$, divided by
54
the total number of sectors \f$N=2\pi L0/(d\theta\Delta)\f$, this gives
55
\f[
56
\frac{\pi [(r + \Delta / 2)^2 - (r - \Delta / 2)^2]}{2 \pi L 0 / (d \theta
57
\Delta)} = \frac{2 \pi r \Delta}{2 \pi L 0 / (d \theta \Delta)} = \frac{rd
58
\theta}{L 0} \Delta^2
59
\f]
60
By definition, the (area) metric factor `cm` is the mapped area divided
61
by the unmapped area \f$\Delta^2\f$. */
62
63
scalar
cmv
=
cm
;
64
for
(
int
_i
= 0;
_i
<
_N
;
_i
++)
/* foreach */
65
cmv
[] = r*
dtheta
/
L0
;
66
67
/**
68
It is important to set proper boundary conditions, in particular
69
when refining the grid. */
70
71
/* BC: cm[left] = dirichlet(r*dtheta/L0) */
72
/* BC: cm[right] = dirichlet(r*dtheta/L0) */
73
74
/**
75
The (length) metric factor `fm` is the ratio of the mapped length of
76
a face to its unmapped length \f$\Delta\f$. In the present case, it is
77
unity for all dimensions except for the \f$x\f$ coordinates for which it
78
is the ratio of the arclength by the unmapped length \f$\Delta\f$. We
79
also set a small minimal value to avoid division by zero, in the
80
case of a vanishing inner radius. */
81
82
vector
fmv
=
fm
;
83
for
(
int
_i
= 0;
_i
<
_N
;
_i
++)
/* foreach_face */
84
fmv
.
x
[] = 1.;
85
for
(
int
_i
= 0;
_i
<
_N
;
_i
++)
/* foreach_face */
86
fmv
.x[] =
max
(r*
dtheta
/
L0
, 1
e
-20);
87
}
l
define l
Definition
cartesian-common.h:8
_ig
static int _ig[]
Definition
cartesian1D.h:64
_jg
def is_boundary() _jg[]
Definition
cartesian.h:152
free
free(list1)
y
int y
Definition
common.h:76
x
int x
Definition
common.h:76
pi
#define pi
Definition
common.h:4
all
scalar * all
Definition
common.h:342
cm
const scalar cm[]
Definition
common.h:397
list_concat
scalar * list_concat(scalar *l1, scalar *l2)
Definition
common.h:234
L0
double L0
Definition
common.h:36
list_copy
scalar * list_copy(scalar *l)
Definition
common.h:225
fm
const vector fm[]
Definition
common.h:396
point
Point point
Definition
conserving.h:86
macro
macro
We also redefine the "per field" (inner) traversal.
Definition
layers.h:18
max
size_t max
Definition
mtrace.h:8
VARIABLES
macro VARIABLES(Point point=point, int _ig=ig, int _jg=jg, int _kg=kg)
For convenience we add definitions for the radial and angular coordinates $(r, \theta)$.
Definition
radial.h:21
dtheta
double dtheta
Definition
radial.h:15
event_metric
void event_metric(void)
Event: metric (i = 0)
Definition
radial.h:29
_i
def _i
Definition
stencils.h:405
Point
Definition
linear.h:21
scalar
Definition
common.h:44
vector
Definition
common.h:46
vector::x
scalar x
Definition
common.h:47
theta
double theta
This is the generalised minmod limiter.
Definition
utils.h:223
radial.h
Generated by
1.9.8