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
6This implements the radial coordinate mapping illustrated below.
7
8![Radial coordinate mapping](figures/radial.svg)
9
10It works in 1D, 2D and 3D. The 3D version corresponds to cylindrical
11coordinates since the \f$z\f$-coordinate is unchanged.
12
13The only parameter is \f$d\theta\f$, the total angle of the sector. */
14
15double dtheta = pi/3.;
16
17/**
18For convenience we add definitions for the radial and angular
19coordinates $(r, \theta)$. */
20
21macro VARIABLES (Point point = point, int _ig = ig, int _jg = jg, int _kg = kg)
22{
24 double r = x, theta = y*dtheta/L0;
26}
27
28/** @brief Event: metric (i = 0) */
29void 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, 1e-20);
87}
define l
static int _ig[]
Definition cartesian1D.h:64
def is_boundary() _jg[]
Definition cartesian.h:152
free(list1)
int y
Definition common.h:76
int x
Definition common.h:76
#define pi
Definition common.h:4
scalar * all
Definition common.h:342
const scalar cm[]
Definition common.h:397
scalar * list_concat(scalar *l1, scalar *l2)
Definition common.h:234
double L0
Definition common.h:36
scalar * list_copy(scalar *l)
Definition common.h:225
const vector fm[]
Definition common.h:396
Point point
Definition conserving.h:86
macro
We also redefine the "per field" (inner) traversal.
Definition layers.h:18
size_t max
Definition mtrace.h:8
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
double dtheta
Definition radial.h:15
void event_metric(void)
Event: metric (i = 0)
Definition radial.h:29
def _i
Definition stencils.h:405
Definition linear.h:21
scalar x
Definition common.h:47
double theta
This is the generalised minmod limiter.
Definition utils.h:223