mirror of
https://codeberg.org/vcbferreira/NuFI_deal.ii
synced 2026-08-12 14:33:18 +02:00
slight change to eval_f s
Also added dependencies and instruction to README
This commit is contained in:
@@ -7,6 +7,30 @@ This simulation of the Vlasov-Poisson system dimensions uses
|
|||||||
|
|
||||||
______________________________________________________________________
|
______________________________________________________________________
|
||||||
|
|
||||||
|
# How to use
|
||||||
|
|
||||||
|
## Dependencies:
|
||||||
|
|
||||||
|
- [deal.ii](https://dealii.org/) >= 9.6.0
|
||||||
|
- OpenMP
|
||||||
|
- [perf](https://perfwiki.github.io/main/) + [flameGraph](https://github.com/brendangregg/FlameGraph) (optional)
|
||||||
|
|
||||||
|
After cloning the repo to your machine `cd` into it and run:
|
||||||
|
|
||||||
|
```
|
||||||
|
mkdir -p build; cd build/
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
cd ..
|
||||||
|
```
|
||||||
|
|
||||||
|
Then check/change `parameters.lua` and run with `./build/nufi_poisson`.
|
||||||
|
If you want to run with a [FlameGraph](https://www.brendangregg.com/flamegraphs.html) visualization at the end use `./run`.
|
||||||
|
|
||||||
|
______________________________________________________________________
|
||||||
|
|
||||||
|
# Further description
|
||||||
|
|
||||||
dimensions: 1x1v
|
dimensions: 1x1v
|
||||||
|
|
||||||
status: builds, runs
|
status: builds, runs
|
||||||
|
|||||||
+10
-9
@@ -32,6 +32,7 @@ std::vector<double> NuFISolver::eval_ftilda(
|
|||||||
const std::vector<SolutionSnapshot<1>> &phi_history) const {
|
const std::vector<SolutionSnapshot<1>> &phi_history) const {
|
||||||
|
|
||||||
size_t x_size = X.size();
|
size_t x_size = X.size();
|
||||||
|
const double dt = Parameters::DT;
|
||||||
|
|
||||||
std::vector<double> U(x_size, u);
|
std::vector<double> U(x_size, u);
|
||||||
std::vector<double> results(x_size);
|
std::vector<double> results(x_size);
|
||||||
@@ -47,7 +48,7 @@ std::vector<double> NuFISolver::eval_ftilda(
|
|||||||
// We omit the initial half-step.
|
// We omit the initial half-step.
|
||||||
while (--n) {
|
while (--n) {
|
||||||
for (size_t i = 0; i < x_size; ++i)
|
for (size_t i = 0; i < x_size; ++i)
|
||||||
X[i] = X[i] - Parameters::DT * U[i];
|
X[i] = X[i] - dt * U[i];
|
||||||
|
|
||||||
AssertThrow(
|
AssertThrow(
|
||||||
phi_history[n].solution.size() ==
|
phi_history[n].solution.size() ==
|
||||||
@@ -68,13 +69,13 @@ std::vector<double> NuFISolver::eval_ftilda(
|
|||||||
|
|
||||||
for (size_t i = 0; i < x_size; ++i) {
|
for (size_t i = 0; i < x_size; ++i) {
|
||||||
Ex[i] = -tmp[i];
|
Ex[i] = -tmp[i];
|
||||||
U[i] = U[i] + Parameters::DT * Ex[i];
|
U[i] = U[i] + dt * Ex[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The final half-step.
|
// The final half-step.
|
||||||
for (size_t i = 0; i < x_size; ++i)
|
for (size_t i = 0; i < x_size; ++i)
|
||||||
X[i] = X[i] - Parameters::DT * U[i];
|
X[i] = X[i] - dt * U[i];
|
||||||
|
|
||||||
tmp = eval(X, grid_struct[phi_history[n].grid_version],
|
tmp = eval(X, grid_struct[phi_history[n].grid_version],
|
||||||
phi_history[n].solution); // call eval only once
|
phi_history[n].solution); // call eval only once
|
||||||
@@ -92,7 +93,7 @@ std::vector<double>
|
|||||||
NuFISolver::eval_f(unsigned int n, std::vector<double> X, double u,
|
NuFISolver::eval_f(unsigned int n, std::vector<double> X, double u,
|
||||||
const std::vector<GridStructure<1>> &grid_struct,
|
const std::vector<GridStructure<1>> &grid_struct,
|
||||||
const std::vector<SolutionSnapshot<1>> &phi_history) const {
|
const std::vector<SolutionSnapshot<1>> &phi_history) const {
|
||||||
|
const double dt = Parameters::DT;
|
||||||
size_t x_size = X.size();
|
size_t x_size = X.size();
|
||||||
|
|
||||||
std::vector<double> U(x_size, u);
|
std::vector<double> U(x_size, u);
|
||||||
@@ -111,30 +112,30 @@ NuFISolver::eval_f(unsigned int n, std::vector<double> X, double u,
|
|||||||
phi_history[n].solution); // call eval only once
|
phi_history[n].solution); // call eval only once
|
||||||
for (size_t i = 0; i < x_size; ++i) {
|
for (size_t i = 0; i < x_size; ++i) {
|
||||||
Ex[i] = -tmp[i];
|
Ex[i] = -tmp[i];
|
||||||
U[i] = U[i] + 0.5 * Parameters::DT * Ex[i];
|
U[i] = U[i] + 0.5 * dt * Ex[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
while (--n) {
|
while (--n) {
|
||||||
for (size_t i = 0; i < x_size; ++i)
|
for (size_t i = 0; i < x_size; ++i)
|
||||||
X[i] = X[i] - Parameters::DT * U[i];
|
X[i] = X[i] - dt * U[i];
|
||||||
|
|
||||||
tmp = eval(X, grid_struct[phi_history[n].grid_version],
|
tmp = eval(X, grid_struct[phi_history[n].grid_version],
|
||||||
phi_history[n].solution); // call eval only once
|
phi_history[n].solution); // call eval only once
|
||||||
for (size_t i = 0; i < x_size; ++i) {
|
for (size_t i = 0; i < x_size; ++i) {
|
||||||
Ex[i] = -tmp[i];
|
Ex[i] = -tmp[i];
|
||||||
U[i] = U[i] + Parameters::DT * Ex[i];
|
U[i] = U[i] + dt * Ex[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The final half-step.
|
// The final half-step.
|
||||||
for (size_t i = 0; i < x_size; ++i)
|
for (size_t i = 0; i < x_size; ++i)
|
||||||
X[i] = X[i] - Parameters::DT * U[i];
|
X[i] = X[i] - dt * U[i];
|
||||||
|
|
||||||
tmp = eval(X, grid_struct[phi_history[n].grid_version],
|
tmp = eval(X, grid_struct[phi_history[n].grid_version],
|
||||||
phi_history[n].solution); // call eval only once
|
phi_history[n].solution); // call eval only once
|
||||||
for (size_t i = 0; i < x_size; ++i) {
|
for (size_t i = 0; i < x_size; ++i) {
|
||||||
Ex[i] = -tmp[i];
|
Ex[i] = -tmp[i];
|
||||||
U[i] = U[i] + 0.5 * Parameters::DT * Ex[i];
|
U[i] = U[i] + 0.5 * dt * Ex[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < x_size; ++i)
|
for (size_t i = 0; i < x_size; ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user