10#ifndef __ENO_WENO_HPP__
11#define __ENO_WENO_HPP__
13#include "Grid/grid_dist_id.hpp"
15static double adjustWeights(
double v1,
double v2,
double v3,
double v4,
double v5)
17 double phix1, phix2, phix3;
24 phix1 = (v1 / 3.0) - (7.0 * v2 / 6.0) + (11.0 * v3 / 6.0);
25 phix2 = -(v2 / 6.0) + (5.0 * v3 / 6.0) + (v4 / 3.0);
26 phix3 = (v3 / 3.0) + (5.0 * v4 / 6.0) - (v5 / 6.0);
29 s1 = (13.0 / 12.0) * (v1 - 2*v2 + v3) * (v1 - 2*v2 + v3)
30 + 0.25 * (v1 - 4*v2 + 3*v3) * (v1 - 4*v2 + 3*v3);
31 s2 = (13.0 / 12.0) * (v2 - 2*v3 + v4) * (v2 - 2*v3 + v4)
32 + 0.25 * (v2 - v4) * (v2 - v4);
33 s3 = (13.0 / 12.0) * (v3 - 2*v4 + v5) * (v3 - 2*v4 + v5)
34 + 0.25 * (3*v3 - 4*v4 + v5) * (3*v3 - 4*v4 + v5);
37 a1 = 0.1 / ((s1 + eps)*(s1 + eps));
38 a2 = 0.6 / ((s2 + eps)*(s2 + eps));
39 a3 = 0.3 / ((s3 + eps)*(s3 + eps));
42 w1 = a1 / (a1 + a2 + a3);
43 w2 = a2 / (a1 + a2 + a3);
44 w3 = a3 / (a1 + a2 + a3);
47 return (w1 * phix1 + w2 * phix2 + w3 * phix3);
50template<
size_t Field,
typename gr
id_type,
typename key_type>
53 double c2, c3, c4, c5, c6;
54 double coeff = 1.0 /
grid.spacing(x);
57 c2 = (
grid.template get<Field>(key.move(x, -1)) -
grid.template get<Field>(key.move(x, -2))) * coeff;
58 c3 = (
grid.template get<Field>(key) -
grid.template get<Field>(key.move(x, -1))) * coeff;
59 c4 = (
grid.template get<Field>(key.move(x,1)) -
grid.template get<Field>(key)) * coeff;
60 c5 = (
grid.template get<Field>(key.move(x, 2)) -
grid.template get<Field>(key.move(x, 1))) * coeff;
61 c6 = (
grid.template get<Field>(key.move(x, 3)) -
grid.template get<Field>(key.move(x, 2))) * coeff;
62 df = adjustWeights(c6, c5, c4, c3, c2);
67template<
size_t Field,
typename gr
id_type,
typename key_type>
70 double c1, c2, c3, c4, c5;
71 double coeff = 1.0 /
grid.spacing(x);
74 c1 = (
grid.template get<Field>(key.move(x, -2)) -
grid.template get<Field>(key.move(x, -3))) * coeff;
75 c2 = (
grid.template get<Field>(key.move(x, -1)) -
grid.template get<Field>(key.move(x, -2))) * coeff;
76 c3 = (
grid.template get<Field>(key) -
grid.template get<Field>(key.move(x, -1))) * coeff;
77 c4 = (
grid.template get<Field>(key.move(x,1)) -
grid.template get<Field>(key)) * coeff;
78 c5 = (
grid.template get<Field>(key.move(x, 2)) -
grid.template get<Field>(key.move(x, 1))) * coeff;
80 df = adjustWeights(c1, c2, c3, c4, c5);
85template<
size_t Field,
typename gr
id_type,
typename key_type>
89 double gridsize =
grid.spacing(x);
90 double coeff = 1.0 / gridsize;
92 q1x = (
grid.template get<Field>(key.move(x,1)) -
grid.template get<Field>(key)) * coeff;
93 double d2ix = (
grid.template get<Field>(key.move(x,1)) - 2*
grid.template get<Field>(key) +
grid.template get<Field>(key.move(x,-1))) * 0.5 * coeff * coeff;
94 double d2ip1x = (
grid.template get<Field>(key.move(x,2)) - 2*
grid.template get<Field>(key.move(x,1)) +
grid.template get<Field>(key)) * 0.5 * coeff * coeff;
95 if(abs(d2ix) <= abs(d2ip1x))
97 q2x = -d2ix * gridsize;
98 double d3p1hx = (
grid.template get<Field>(key.move(x,1)) - 3*
grid.template get<Field>(key) + 3*
grid.template get<Field>(key.move(x,-1)) -
grid.template get<Field>(key.move(x,-2))) * coeff * coeff * coeff / 6.0;
99 double d3p3hx = (
grid.template get<Field>(key.move(x,2)) - 3*
grid.template get<Field>(key.move(x,1)) + 3*
grid.template get<Field>(key) -
grid.template get<Field>(key.move(x,-1))) * coeff * coeff * coeff / 6.0;
100 if(abs(d3p1hx) <= abs(d3p3hx))
101 q3x = -d3p1hx * gridsize * gridsize;
103 q3x = -d3p3hx * gridsize * gridsize;
107 q2x = -d2ip1x * gridsize;
108 double d3p1hx = (
grid.template get<Field>(key.move(x,2)) - 3*
grid.template get<Field>(key.move(x,1)) + 3*
grid.template get<Field>(key) -
grid.template get<Field>(key.move(x,-1))) * coeff * coeff * coeff / 6.0;
109 double d3p3hx = (
grid.template get<Field>(key.move(x,3)) - 3*
grid.template get<Field>(key.move(x,2)) + 3*
grid.template get<Field>(key.move(x,1)) -
grid.template get<Field>(key)) * coeff * coeff * coeff / 6.0;
110 if(abs(d3p1hx) <= abs(d3p3hx))
111 q3x = d3p1hx * 2 * gridsize * gridsize;
113 q3x = d3p3hx * 2 * gridsize * gridsize;
116 return (q1x + q2x + q3x);
119template<
size_t Field,
typename gr
id_type,
typename key_type>
122 double q1x, q2x, q3x;
123 double gridsize =
grid.spacing(x);
124 double coeff = 1.0 / gridsize;
126 q1x = (
grid.template get<Field>(key) -
grid.template get<Field>(key.move(x, -1))) * coeff;
127 double d2im1x = (
grid.template get<Field>(key) - 2*
grid.template get<Field>(key.move(x, -1)) +
grid.template get<Field>(key.move(x, -2))) * 0.5 * coeff * coeff;
128 double d2ix = (
grid.template get<Field>(key.move(x,1)) - 2*
grid.template get<Field>(key) +
grid.template get<Field>(key.move(x,-1))) * 0.5 * coeff * coeff;
130 if(abs(d2im1x) <= abs(d2ix))
132 q2x = d2im1x * gridsize;
133 double d3p1hx = (
grid.template get<Field>(key) - 3*
grid.template get<Field>(key.move(x,-1)) + 3*
grid.template get<Field>(key.move(x,-2)) -
grid.template get<Field>(key.move(x,-3))) * coeff * coeff * coeff / 6.0;
134 double d3p3hx = (
grid.template get<Field>(key.move(x,1)) - 3*
grid.template get<Field>(key) + 3*
grid.template get<Field>(key.move(x,-1)) -
grid.template get<Field>(key.move(x,-2))) * coeff * coeff * coeff / 6.0;
135 if(abs(d3p1hx) <= abs(d3p3hx))
136 q3x = d3p1hx * 2 * gridsize * gridsize;
138 q3x = d3p3hx * 2 * gridsize * gridsize;
142 q2x = d2ix * gridsize;
143 double d3p1hx = (
grid.template get<Field>(key.move(x,1)) - 3*
grid.template get<Field>(key) + 3*
grid.template get<Field>(key.move(x,-1)) -
grid.template get<Field>(key.move(x,-2))) * coeff * coeff * coeff / 6.0;
144 double d3p3hx = (
grid.template get<Field>(key.move(x,2)) - 3*
grid.template get<Field>(key.move(x,1)) + 3*
grid.template get<Field>(key) -
grid.template get<Field>(key.move(x,-1))) * coeff * coeff * coeff / 6.0;
145 if(abs(d3p1hx) <= abs(d3p3hx))
146 q3x = -d3p1hx * gridsize * gridsize;
148 q3x = -d3p3hx * gridsize * gridsize;
151 return (q1x + q2x + q3x);
This is a distributed grid.