Diffusion¶
Wall-normal relation¶
\[\dmomdif{1}{1}\]
34const int isize = domain->glsizes[0];
35const double * hxxc = domain->hxxc;
36const double * jdxf = domain->jdxf;
37const double * jdxc = domain->jdxc;
38laplacians.lapx = memory_calloc(isize - 1, sizeof(laplacian_t));
39for (int i = 2; i <= isize; i++) {
40 const double l = 1. / JDXF(i ) * JDXC(i-1) / HXXC(i-1) / HXXC(i-1);
41 const double u = 1. / JDXF(i ) * JDXC(i ) / HXXC(i ) / HXXC(i );
42 const double c = - l - u;
43 laplacians.LAPX(i).l = l;
44 laplacians.LAPX(i).c = c;
45 laplacians.LAPX(i).u = u;
46}
251static int diffusion_x (
252 const domain_t * domain,
253 const double diffusivity,
254 const double * restrict ux,
255 double * restrict src
256) {
257 const int isize = domain->mysizes[0];
258 const int jsize = domain->mysizes[1];
259#if NDIMS == 3
260 const int ksize = domain->mysizes[2];
261#endif
262 const laplacian_t * lapx = laplacians.lapx;
263 BEGIN
264 src[cnt] += diffusivity * (
265#if NDIMS == 2
266 + LAPX(i).l * UX(i-1, j )
267 + LAPX(i).c * UX(i , j )
268 + LAPX(i).u * UX(i+1, j )
269#else
270 + LAPX(i).l * UX(i-1, j , k )
271 + LAPX(i).c * UX(i , j , k )
272 + LAPX(i).u * UX(i+1, j , k )
273#endif
274 );
275 END
276 return 0;
277}
\[\dmomdif{2}{1}\]
50const double hy = domain->hy;
51const double l = 1. / hy / hy;
52const double u = 1. / hy / hy;
53const double c = - l - u;
54laplacians.lapy.l = l;
55laplacians.lapy.c = c;
56laplacians.lapy.u = u;
280static int diffusion_y (
281 const domain_t * domain,
282 const double diffusivity,
283 const double * restrict ux,
284 double * restrict src
285) {
286 const int isize = domain->mysizes[0];
287 const int jsize = domain->mysizes[1];
288#if NDIMS == 3
289 const int ksize = domain->mysizes[2];
290#endif
291 const laplacian_t * lapy = &laplacians.lapy;
292 BEGIN
293 src[cnt] += diffusivity * (
294#if NDIMS == 2
295 + (*lapy).l * UX(i , j-1)
296 + (*lapy).c * UX(i , j )
297 + (*lapy).u * UX(i , j+1)
298#else
299 + (*lapy).l * UX(i , j-1, k )
300 + (*lapy).c * UX(i , j , k )
301 + (*lapy).u * UX(i , j+1, k )
302#endif
303 );
304 END
305 return 0;
306}
\[\dmomdif{3}{1}\]
61const double hz = domain->hz;
62const double l = 1. / hz / hz;
63const double u = 1. / hz / hz;
64const double c = - l - u;
65laplacians.lapz.l = l;
66laplacians.lapz.c = c;
67laplacians.lapz.u = u;
310static int diffusion_z (
311 const domain_t * domain,
312 const double diffusivity,
313 const double * restrict ux,
314 double * restrict src
315) {
316 const int isize = domain->mysizes[0];
317 const int jsize = domain->mysizes[1];
318 const int ksize = domain->mysizes[2];
319 const laplacian_t * lapz = &laplacians.lapz;
320 BEGIN
321 src[cnt] += diffusivity * (
322 + (*lapz).l * UX(i , j , k-1)
323 + (*lapz).c * UX(i , j , k )
324 + (*lapz).u * UX(i , j , k+1)
325 );
326 END
327 return 0;
328}
Stream-wise relation¶
\[\dmomdif{1}{2}\]
33const int isize = domain->glsizes[0];
34const double * hxxf = domain->hxxf;
35const double * jdxf = domain->jdxf;
36const double * jdxc = domain->jdxc;
37laplacians.lapx = memory_calloc(isize, sizeof(laplacian_t));
38for (int i = 1; i <= isize; i++) {
39 const double l = 1. / JDXC(i ) * JDXF(i ) / HXXF(i ) / HXXF(i );
40 const double u = 1. / JDXC(i ) * JDXF(i+1) / HXXF(i+1) / HXXF(i+1);
41 const double c = - l - u;
42 laplacians.LAPX(i).l = l;
43 laplacians.LAPX(i).c = c;
44 laplacians.LAPX(i).u = u;
45}
244static int diffusion_x (
245 const domain_t * domain,
246 const double diffusivity,
247 const double * restrict uy,
248 double * restrict src
249) {
250 const int isize = domain->mysizes[0];
251 const int jsize = domain->mysizes[1];
252#if NDIMS == 3
253 const int ksize = domain->mysizes[2];
254#endif
255 const laplacian_t * lapx = laplacians.lapx;
256 BEGIN
257 src[cnt] += diffusivity * (
258#if NDIMS == 2
259 + LAPX(i).l * UY(i-1, j )
260 + LAPX(i).c * UY(i , j )
261 + LAPX(i).u * UY(i+1, j )
262#else
263 + LAPX(i).l * UY(i-1, j , k )
264 + LAPX(i).c * UY(i , j , k )
265 + LAPX(i).u * UY(i+1, j , k )
266#endif
267 );
268 END
269 return 0;
270}
\[\dmomdif{2}{2}\]
49const double hy = domain->hy;
50const double l = 1. / hy / hy;
51const double u = 1. / hy / hy;
52const double c = - l - u;
53laplacians.lapy.l = l;
54laplacians.lapy.c = c;
55laplacians.lapy.u = u;
273static int diffusion_y (
274 const domain_t * domain,
275 const double diffusivity,
276 const double * restrict uy,
277 double * restrict src
278) {
279 const int isize = domain->mysizes[0];
280 const int jsize = domain->mysizes[1];
281#if NDIMS == 3
282 const int ksize = domain->mysizes[2];
283#endif
284 const laplacian_t * lapy = &laplacians.lapy;
285 BEGIN
286 src[cnt] += diffusivity * (
287#if NDIMS == 2
288 + (*lapy).l * UY(i , j-1)
289 + (*lapy).c * UY(i , j )
290 + (*lapy).u * UY(i , j+1)
291#else
292 + (*lapy).l * UY(i , j-1, k )
293 + (*lapy).c * UY(i , j , k )
294 + (*lapy).u * UY(i , j+1, k )
295#endif
296 );
297 END
298 return 0;
299}
\[\dmomdif{3}{2}\]
60const double hz = domain->hz;
61const double l = 1. / hz / hz;
62const double u = 1. / hz / hz;
63const double c = - l - u;
64laplacians.lapz.l = l;
65laplacians.lapz.c = c;
66laplacians.lapz.u = u;
303static int diffusion_z (
304 const domain_t * domain,
305 const double diffusivity,
306 const double * restrict uy,
307 double * restrict src
308) {
309 const int isize = domain->mysizes[0];
310 const int jsize = domain->mysizes[1];
311 const int ksize = domain->mysizes[2];
312 const laplacian_t * lapz = &laplacians.lapz;
313 BEGIN
314 src[cnt] += diffusivity * (
315 + (*lapz).l * UY(i , j , k-1)
316 + (*lapz).c * UY(i , j , k )
317 + (*lapz).u * UY(i , j , k+1)
318 );
319 END
320 return 0;
321}
Span-wise relation¶
\[\dmomdif{1}{3}\]
192static int diffusion_x (
193 const domain_t * domain,
194 const double diffusivity,
195 const double * restrict uz,
196 double * restrict src
197) {
198 const int isize = domain->mysizes[0];
199 const int jsize = domain->mysizes[1];
200 const int ksize = domain->mysizes[2];
201 const laplacian_t * lapx = laplacians.lapx;
202 BEGIN
203 src[cnt] += diffusivity * (
204 + LAPX(i).l * UZ(i-1, j , k )
205 + LAPX(i).c * UZ(i , j , k )
206 + LAPX(i).u * UZ(i+1, j , k )
207 );
208 END
209 return 0;
210}
31const int isize = domain->glsizes[0];
32const double * hxxf = domain->hxxf;
33const double * jdxf = domain->jdxf;
34const double * jdxc = domain->jdxc;
35laplacians.lapx = memory_calloc(isize, sizeof(laplacian_t));
36for (int i = 1; i <= isize; i++) {
37 const double l = 1. / JDXC(i ) * JDXF(i ) / HXXF(i ) / HXXF(i );
38 const double u = 1. / JDXC(i ) * JDXF(i+1) / HXXF(i+1) / HXXF(i+1);
39 const double c = - l - u;
40 laplacians.LAPX(i).l = l;
41 laplacians.LAPX(i).c = c;
42 laplacians.LAPX(i).u = u;
43}
\[\dmomdif{2}{3}\]
213static int diffusion_y (
214 const domain_t * domain,
215 const double diffusivity,
216 const double * restrict uz,
217 double * restrict src
218) {
219 const int isize = domain->mysizes[0];
220 const int jsize = domain->mysizes[1];
221 const int ksize = domain->mysizes[2];
222 const laplacian_t * lapy = &laplacians.lapy;
223 BEGIN
224 src[cnt] += diffusivity * (
225 + (*lapy).l * UZ(i , j-1, k )
226 + (*lapy).c * UZ(i , j , k )
227 + (*lapy).u * UZ(i , j+1, k )
228 );
229 END
230 return 0;
231}
47const double hy = domain->hy;
48const double l = 1. / hy / hy;
49const double u = 1. / hy / hy;
50const double c = - l - u;
51laplacians.lapy.l = l;
52laplacians.lapy.c = c;
53laplacians.lapy.u = u;
\[\dmomdif{3}{3}\]
57const double hz = domain->hz;
58const double l = 1. / hz / hz;
59const double u = 1. / hz / hz;
60const double c = - l - u;
61laplacians.lapz.l = l;
62laplacians.lapz.c = c;
63laplacians.lapz.u = u;
234static int diffusion_z (
235 const domain_t * domain,
236 const double diffusivity,
237 const double * restrict uz,
238 double * restrict src
239) {
240 const int isize = domain->mysizes[0];
241 const int jsize = domain->mysizes[1];
242 const int ksize = domain->mysizes[2];
243 const laplacian_t * lapz = &laplacians.lapz;
244 BEGIN
245 src[cnt] += diffusivity * (
246 + (*lapz).l * UZ(i , j , k-1)
247 + (*lapz).c * UZ(i , j , k )
248 + (*lapz).u * UZ(i , j , k+1)
249 );
250 END
251 return 0;
252}