32void propagate(Vec dr[], Vec values[],
Real z_translation, uint blocks_per_dim ) {
36 const int target_scell_index = (z_translation > 0) ? 1: -1;
39 Vec targetValues[(blocks_per_dim + 2) *
WID];
41 for (uint k_block = 0; k_block < blocks_per_dim; k_block++){
43 for (uint k_cell=0; k_cell <
WID; ++k_cell) {
45 uint gid = k_block *
WID + k_cell +
WID;
47 targetValues[gid] = 0.0;
51 for (uint k_block = 0; k_block < blocks_per_dim; k_block++){
53 for (uint k_cell=0; k_cell <
WID; ++k_cell){
55 uint gid = k_block *
WID + k_cell +
WID;
64 if ( z_translation < 0 ) {
66 z_2 = -z_translation / dr[gid][0];
68 z_1 = 1.0 - z_translation / dr[gid][0];
72 if(
abs(z_1) > 1.0 ||
abs(z_2) > 1.0 ) {
73 std::cout <<
"Error, CFL condition violated\n";
74 std::cout <<
"Exiting\n";
84 const Vec ngbr_target_density =
85 z_2 * ( a[0] + z_2 * ( a[1] + z_2 * a[2] ) ) -
86 z_1 * ( a[0] + z_1 * ( a[1] + z_1 * a[2] ) );
90 targetValues[gid + target_scell_index] += ngbr_target_density * dr[gid] / dr[gid + target_scell_index];
92 targetValues[gid] += values[gid] - ngbr_target_density;
97 for (uint k_block = 0; k_block<blocks_per_dim;k_block++){
99 for (uint k_cell=0; k_cell<
WID; ++k_cell){
101 uint gid = k_block *
WID + k_cell +
WID;
103 values[gid] = targetValues[gid];
113 sprintf(name,
"reconstructions_%05d.dat",step);
114 FILE* fp=fopen(name,
"w");
117 const int subcells = 50;
119 for (
unsigned int k_block = 0; k_block<blocks_per_dim;k_block++){
120 for (uint k_cell=0; k_cell<
WID; ++k_cell){
121#ifdef ACC_SEMILAG_PPM
127 int iend = k_block *
WID + k_cell;
129 r0 += dr[iend-1+
WID];
132 for (uint k_subcell=0; k_subcell< subcells; ++k_subcell){
133 Vec r_norm = (
Real)(k_subcell + 0.5)/subcells;
134 Vec r = r0 + r_norm * dr[k_block *
WID + k_cell +
WID];
136#ifdef ACC_SEMILAG_PPM
139 2.0 * r_norm * a[1] +
140 3.0 * r_norm * r_norm * a[2];
143 fprintf(fp,
"%20.12g %20.12e %20.12e\n", r[0], values[k_block *
WID + k_cell +
WID][0], target[0]);
164 const Real dr0 = 20000;
165 const int blocks_per_dim = 100;
166 const int i_block = 0;
167 const int j_block = 0;
168 const int j_cell = 0;
170 Vec dr[(blocks_per_dim+2)*
WID];
171 Vec values[(blocks_per_dim+2)*
WID];
174 boost::uniform_real<Real> u(0.0, 2.0 * dr0);
175 boost::variate_generator<boost::mt19937&, boost::uniform_real<Real> > gen(rng, u);
176 gen.distribution().reset();
177 gen.engine().seed(12345);
181 for (uint
k=0;
k<
WID* (blocks_per_dim + 2); ++
k){
187 int ir = (blocks_per_dim + 2) *
WID / 2;
188 int ir2 = (blocks_per_dim + 2) *
WID / 3;
189 int max_refinement = 5;
190 int cells_per_level = 2;
192 refine(dr,ir,max_refinement,cells_per_level);
196 for (uint
k=
WID;
k < (blocks_per_dim + 2) *
WID / 2; ++
k) {
203 Real r1 = -10.0 * dr0;
205 for(uint
i=0;
i < blocks_per_dim *
WID;
i++){
208 r = r + 0.5 * dr[
i +
WID][0];
219 r = r + 0.5 * dr[
i +
WID][0];
227 for (uint istep=0; istep < nstep; ++istep) {
228 propagate(dr, values, step, blocks_per_dim);
229 if ((istep+1) % 10 == 0)