-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33 prolongation and restriction tests (#34)
Add tests for prolongation and restriction operators. Co-authored-by: Martin J. Kühn <62713180+mknaranja@users.noreply.github.com> Co-authored-by: Martin Joachim Kühn <Martin.Kuehn@DLR.de>
- Loading branch information
1 parent
4688f6f
commit 7ec31ae
Showing
5 changed files
with
675 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "mockgrid.h" | ||
void create_grid(gmgpolar& test_p) | ||
{ | ||
time_t seed = 5000; | ||
std::default_random_engine gen(seed); //deterministic seed to reproduce | ||
std::uniform_real_distribution<double> dis(gyro::dcntl[Param::R0], gyro::dcntl[Param::R]); | ||
std::uniform_real_distribution<double> theta_distribution(0, 2 * PI); | ||
|
||
std::cout << "creating randomized grid with std::default_random_engine seed " + std::to_string(seed) << std::endl; | ||
level* new_level = new level(0); | ||
new_level->nr = pow(2, gyro::icntl[Param::nr_exp]); | ||
new_level->r = std::vector<double>(new_level->nr + 1); | ||
|
||
std::vector<double> rands(new_level->nr - 1); | ||
for (int j = 0; j < new_level->nr - 1; ++j) { | ||
rands[j] = dis(gen); | ||
} | ||
std::sort(rands.begin(), rands.end()); | ||
new_level->r[0] = gyro::dcntl[Param::R0]; | ||
for (int i = 1; i < new_level->nr; i++) { | ||
new_level->r[i] = rands[i - 1]; //random grid on coarser level | ||
} | ||
new_level->r[new_level->nr] = gyro::dcntl[Param::R]; | ||
new_level->nr++; | ||
int ntmp = pow(2, ceil(log2(new_level->nr))); | ||
new_level->ntheta = gyro::icntl[Param::periodic] ? ntmp : ntmp + 1; | ||
|
||
new_level->theta = std::vector<double>(new_level->ntheta); | ||
|
||
std::vector<double> randst(ntmp - 1); | ||
for (int k = 0; k < ntmp - 1; ++k) { | ||
randst[k] = theta_distribution(gen); | ||
} | ||
std::sort(randst.begin(), randst.end()); | ||
new_level->theta[0] = 0; | ||
for (int i = 1; i < ntmp; i++) { | ||
new_level->theta[i] = randst[i - 1]; | ||
} | ||
if (!gyro::icntl[Param::periodic]) { | ||
new_level->theta[ntmp] = 2 * PI; | ||
} | ||
|
||
new_level->ntheta_int = gyro::icntl[Param::periodic] ? new_level->ntheta : new_level->ntheta - 1; | ||
new_level->nr_int = new_level->nr - 1; | ||
|
||
new_level->thetaplus = std::vector<double>(new_level->ntheta_int); | ||
for (int k = 0; k < new_level->ntheta_int - 1; k++) { | ||
new_level->thetaplus[k] = new_level->theta[k + 1] - new_level->theta[k]; | ||
} | ||
new_level->thetaplus[new_level->ntheta_int - 1] = 2 * PI - new_level->theta[new_level->ntheta_int - 1]; | ||
|
||
new_level->hplus = std::vector<double>(new_level->nr_int); | ||
for (int k = 0; k < new_level->nr_int; k++) { | ||
new_level->hplus[k] = new_level->r[k + 1] - new_level->r[k]; | ||
} | ||
|
||
level* coarser_level = new level(1); | ||
coarser_level->nr = pow(2, gyro::icntl[Param::nr_exp] - 1) + 1; | ||
ntmp = pow(2, ceil(log2(coarser_level->nr))); | ||
coarser_level->ntheta = gyro::icntl[Param::periodic] ? ntmp : ntmp + 1; | ||
|
||
coarser_level->ntheta_int = gyro::icntl[Param::periodic] ? coarser_level->ntheta : coarser_level->ntheta - 1; | ||
coarser_level->nr_int = coarser_level->nr - 1; | ||
test_p.v_level.push_back(new_level); | ||
test_p.v_level.push_back(coarser_level); | ||
test_p.levels_orig = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "gmgpolar.h" | ||
#include <random> | ||
#include <stdlib.h> | ||
#include <algorithm> | ||
|
||
#ifndef MOCKGRID_H | ||
#define MOCKGRID_H | ||
|
||
void create_grid(gmgpolar& test_p); | ||
|
||
#endif |
Oops, something went wrong.