Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
myc.h
Go to the documentation of this file.
1/** @file myc.h
2 */
3/*-----------------------------------------------------*
4 *MYC - Mixed Youngs and Central Scheme *
5 *-----------------------------------------------------*/
6/*
7
8Known problems: the index [0,0,0], i.e. the central cell
9in the block, never occurs: neither in the central scheme
10nor in Youngs' method. Therefore an isolated droplet will have
11a normal with all components to zero. I took care of the
12division-by-zero issue, but not of this one.
13
14Ruben
15
16*/
17
19{
20 double m1,m2,m[4][3],t0,t1,t2;
21 int cn;
22
23 /* write the plane as: sgn(mx) X = my Y + mz Z + alpha
24 m00 X = m01 Y + m02 Z + alpha */
25 m1 = c[-1,0,-1] + c[-1,0,1] + c[-1,-1,0] + c[-1,1,0] +
26 c[-1,0,0];
27 m2 = c[1,0,-1] + c[1,0,1] + c[1,-1,0] + c[1,1,0] +
28 c[1,0,0];
29 m[0][0] = m1 > m2 ? 1. : -1.;
30
31 m1 = c[-1,-1,0]+ c[1,-1,0]+ c[0,-1,0];
32 m2 = c[-1,1,0]+ c[1,1,0]+ c[0,1,0];
33 m[0][1] = 0.5*(m1-m2);
34
35 m1 = c[-1,0,-1]+ c[1,0,-1]+ c[0,0,-1];
36 m2 = c[-1,0,1]+ c[1,0,1]+ c[0,0,1];
37 m[0][2] = 0.5*(m1-m2);
38
39 /* write the plane as: sgn(my) Y = mx X + mz Z + alpha
40 m11 Y = m10 X + m12 Z + alpha */
41 m1 = c[-1,-1,0] + c[-1,1,0] + c[-1,0,0];
42 m2 = c[1,-1,0] + c[1,1,0] + c[1,0,0];
43 m[1][0] = 0.5*(m1-m2);
44
45 m1 = c[0,-1,-1] + c[0,-1,1] + c[1,-1,0] + c[-1,-1,0] +
46 c[0,-1,0];
47 m2 = c[0,1,-1] + c[0,1,1] + c[1,1,0] + c[-1,1,0] +
48 c[0,1,0];
49 m[1][1] = m1 > m2 ? 1. : -1.;
50
51 m1 = c[0,-1,-1]+ c[0,0,-1]+ c[0,1,-1];
52 m2 = c[0,-1,1]+ c[0,0,1]+ c[0,1,1];
53 m[1][2] = 0.5*(m1-m2);
54
55 /* write the plane as: sgn(mz) Z = mx X + my Y + alpha
56 m22 Z = m20 X + m21 Y + alpha */
57
58 m1 = c[-1,0,-1]+ c[-1,0,1]+ c[-1,0,0];
59 m2 = c[1,0,-1]+ c[1,0,1]+ c[1,0,0];
60 m[2][0] = 0.5*(m1-m2);
61
62 m1 = c[0,-1,-1]+ c[0,-1,1]+ c[0,-1,0];
63 m2 = c[0,1,-1]+ c[0,1,1]+ c[0,1,0];
64 m[2][1] = 0.5*(m1-m2);
65
66 m1 = c[-1,0,-1] + c[1,0,-1] + c[0,-1,-1] + c[0,1,-1] +
67 c[0,0,-1];
68 m2 = c[-1,0,1] + c[1,0,1] + c[0,-1,1] + c[0,1,1] +
69 c[0,0,1];
70 m[2][2] = m1 > m2 ? 1. : -1.;
71
72 /* normalize each set (mx,my,mz): |mx|+|my|+|mz| = 1 */
73 t0 = fabs(m[0][0]) + fabs(m[0][1]) + fabs(m[0][2]);
74 m[0][0] /= t0;
75 m[0][1] /= t0;
76 m[0][2] /= t0;
77
78 t0 = fabs(m[1][0]) + fabs(m[1][1]) + fabs(m[1][2]);
79 m[1][0] /= t0;
80 m[1][1] /= t0;
81 m[1][2] /= t0;
82
83 t0 = fabs(m[2][0]) + fabs(m[2][1]) + fabs(m[2][2]);
84 m[2][0] /= t0;
85 m[2][1] /= t0;
86 m[2][2] /= t0;
87
88 /* choose among the three central scheme */
89 t0 = fabs(m[0][0]);
90 t1 = fabs(m[1][1]);
91 t2 = fabs(m[2][2]);
92
93 cn = 0;
94 if (t1 > t0) {
95 t0 = t1;
96 cn = 1;
97 }
98 if (t2 > t0)
99 cn = 2;
100
101 /* Youngs-CIAM scheme */
102 m1 = c[-1,-1,-1] + c[-1,1,-1] + c[-1,-1,1] + c[-1,1,1] +
103 2.*(c[-1,-1,0] + c[-1,1,0] + c[-1,0,-1] + c[-1,0,1]) +
104 4.*c[-1,0,0];
105 m2 = c[1,-1,-1] + c[1,1,-1] + c[1,-1,1] + c[1,1,1] +
106 2.*(c[1,-1,0] + c[1,1,0] + c[1,0,-1] + c[1,0,1]) +
107 4.*c[1,0,0];
108 m[3][0] = m1 - m2;
109
110 m1 = c[-1,-1,-1] + c[-1,-1,1] + c[1,-1,-1] + c[1,-1,1] +
111 2.*( c[-1,-1,0] + c[1,-1,0] + c[0,-1,-1] + c[0,-1,1]) +
112 4.*c[0,-1,0];
113 m2 = c[-1,1,-1] + c[-1,1,1] + c[1,1,-1] + c[1,1,1] +
114 2.*(c[-1,1,0] + c[1,1,0] + c[0,1,-1] + c[0,1,1]) +
115 4.*c[0,1,0];
116 m[3][1] = m1 - m2;
117
118 m1 = c[-1,-1,-1] + c[-1,1,-1] + c[1,-1,-1] + c[1,1,-1] +
119 2.*(c[-1,0,-1] + c[1,0,-1] + c[0,-1,-1] + c[0,1,-1]) +
120 4.*c[0,0,-1];
121 m2 = c[-1,-1,1] + c[-1,1,1] + c[1,-1,1] + c[1,1,1] +
122 2.*(c[-1,0,1] + c[1,0,1] + c[0,-1,1] + c[0,1,1]) +
123 4.*c[0,0,1];
124 m[3][2] = m1 - m2;
125
126 /* normalize the set (mx,my,mz): |mx|+|my|+|mz| = 1 */
127 t0 = fabs(m[3][0]) + fabs(m[3][1]) + fabs(m[3][2]);
128 if (t0 < 1e-30) {
129 coord mxyz = {1., 0., 0.};
130 return mxyz;
131 }
132
133 m[3][0] /= t0;
134 m[3][1] /= t0;
135 m[3][2] /= t0;
136
137 /* choose between the previous choice and Youngs-CIAM */
138 t0 = fabs (m[3][0]);
139 t1 = fabs (m[3][1]);
140 t2 = fabs (m[3][2]);
141 if (t1 > t0)
142 t0 = t1;
143 if (t2 > t0)
144 t0 = t2;
145
146 if (fabs(m[cn][cn]) > t0)
147 cn = 3;
148
149 /* components of the normal vector */
150 coord mxyz = {m[cn][0], m[cn][1], m[cn][2]};
151 return mxyz;
152}
define m((k)==0 &&(l)==0 &&(m)==0) macro2 foreach_point(double _x=0.
int x
Definition common.h:76
Point point
Definition conserving.h:86
coord mycs(Point point, scalar c)
Definition myc.h:18
Definition linear.h:21
Definition common.h:78
scalar c
Definition vof.h:57