Compare commits
2 Commits
master
...
ml/bump-an
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d77956996c | ||
|
|
5141d0901a |
@ -14,6 +14,11 @@ add_subdirectory(tug EXCLUDE_FROM_ALL)
|
|||||||
|
|
||||||
add_subdirectory(eval)
|
add_subdirectory(eval)
|
||||||
|
|
||||||
add_executable(bench ${GEN_SRC})
|
add_executable(bench_FTCS ${GEN_SRC})
|
||||||
target_link_libraries(bench PRIVATE Eigen3::Eigen tug)
|
target_link_libraries(bench_FTCS PRIVATE Eigen3::Eigen tug)
|
||||||
target_include_directories(bench PRIVATE ${CMAKE_BINARY_DIR}/eval)
|
target_include_directories(bench_FTCS PRIVATE ${CMAKE_BINARY_DIR}/eval)
|
||||||
|
target_compile_definitions(bench_FTCS PRIVATE BENCH_FTCS)
|
||||||
|
|
||||||
|
add_executable(bench_BTCS ${GEN_SRC})
|
||||||
|
target_link_libraries(bench_BTCS PRIVATE Eigen3::Eigen tug)
|
||||||
|
target_include_directories(bench_BTCS PRIVATE ${CMAKE_BINARY_DIR}/eval)
|
||||||
|
|||||||
10
Readme.md
10
Readme.md
@ -6,11 +6,11 @@ This repository contains input data from POET simulations used in the
|
|||||||
NAAICE project and is simulated with the latest version of tug with
|
NAAICE project and is simulated with the latest version of tug with
|
||||||
heterogeneous alphas.
|
heterogeneous alphas.
|
||||||
|
|
||||||
Benchmarks (grids, timestep, file paths, etc) are defined in the
|
Benchmarks (grids, timestep, file paths, etc) are defined in the header file
|
||||||
header file `eval/bench_defs.hpp.in`. The data used by the three
|
`eval/bench_defs.hpp.in`. The data used by the three benchmarks `barite_200`,
|
||||||
benchmarks `barite_200`, `barite_large` and `surfex` are in the
|
`barite_large` and `surfex` are in the corresponding subdirectories of `eval`,
|
||||||
corresponding subdirectories of `eval`, as `tar.gz`. Remember to
|
as `tar.gz`. Remember to unpack them before running the executable into the
|
||||||
unpack them before running the executable!
|
same directory of the executable. Or just let CMake do it for you.
|
||||||
|
|
||||||
To write the results to file, set the `BENCH_OUTPUT` environmental
|
To write the results to file, set the `BENCH_OUTPUT` environmental
|
||||||
variable, e.g. `BENCH_OUTPUT=1 ./bench`. The resulting fields are
|
variable, e.g. `BENCH_OUTPUT=1 ./bench`. The resulting fields are
|
||||||
|
|||||||
@ -1,5 +1,31 @@
|
|||||||
set(BARITE_200_BENCH "${CMAKE_CURRENT_SOURCE_DIR}/barite_200")
|
set(benchmarks
|
||||||
set(BARITE_LARGE_BENCH "${CMAKE_CURRENT_SOURCE_DIR}/barite_large")
|
"${CMAKE_CURRENT_SOURCE_DIR}/barite_200"
|
||||||
set(SURFEX_BENCH "${CMAKE_CURRENT_SOURCE_DIR}/surfex")
|
"${CMAKE_CURRENT_SOURCE_DIR}/barite_large"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/surfex"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(benchmark ${benchmarks})
|
||||||
|
# find tar.gz files
|
||||||
|
file(GLOB_RECURSE tar_files "${benchmark}/*.tar.gz")
|
||||||
|
foreach(tar_file ${tar_files})
|
||||||
|
# get the name of the tar file
|
||||||
|
get_filename_component(tar_name ${tar_file} NAME_WE)
|
||||||
|
# get the name of the directory
|
||||||
|
get_filename_component(dir_name ${tar_file} DIRECTORY)
|
||||||
|
get_filename_component(dir_name ${dir_name} NAME)
|
||||||
|
# create the directory
|
||||||
|
message("Extracting ${tar_name} to ${dir_name}")
|
||||||
|
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${dir_name}")
|
||||||
|
# extract the tar file
|
||||||
|
execute_process(
|
||||||
|
COMMAND tar -xzf ${tar_file}
|
||||||
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${dir_name}"
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(BARITE_200_BENCH "${CMAKE_BINARY_DIR}/barite_200")
|
||||||
|
set(BARITE_LARGE_BENCH "${CMAKE_BINARY_DIR}/barite_large")
|
||||||
|
set(SURFEX_BENCH "${CMAKE_BINARY_DIR}/surfex")
|
||||||
|
|
||||||
configure_file(bench_defs.hpp.in bench_defs.hpp)
|
configure_file(bench_defs.hpp.in bench_defs.hpp)
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#ifndef _BENCH_DEFS_HPP
|
#ifndef _BENCH_DEFS_HPP
|
||||||
#define _BENCH_DEFS_HPP
|
#define _BENCH_DEFS_HPP
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
struct init_boundary {
|
struct init_boundary {
|
||||||
const std::vector<int> north_const;
|
const std::vector<int> north_const;
|
||||||
@ -31,7 +31,6 @@ struct bench_input {
|
|||||||
const int iterations;
|
const int iterations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const std::vector<int> gen_vec(int elems) {
|
static const std::vector<int> gen_vec(int elems) {
|
||||||
std::vector<int> vec(elems);
|
std::vector<int> vec(elems);
|
||||||
for (int i = 0; i < elems; i++) {
|
for (int i = 0; i < elems; i++) {
|
||||||
@ -42,7 +41,7 @@ static const std::vector<int> gen_vec(int elems) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const std::vector<int> gen_vec_rev(int from, int to) {
|
static const std::vector<int> gen_vec_rev(int from, int to) {
|
||||||
int size = to - from+1;
|
int size = to - from + 1;
|
||||||
std::vector<int> vec(size);
|
std::vector<int> vec(size);
|
||||||
for (int i = from; i < to; i++) {
|
for (int i = from; i < to; i++) {
|
||||||
vec[i] = i;
|
vec[i] = i;
|
||||||
@ -66,9 +65,8 @@ static bench_input barite_200_input = {
|
|||||||
.west_const = {0, 1, 2, 3, 4},
|
.west_const = {0, 1, 2, 3, 4},
|
||||||
.values = {111.0124, 55.50622, -3.336970273297e-08, 0.1, 0.2,
|
.values = {111.0124, 55.50622, -3.336970273297e-08, 0.1, 0.2,
|
||||||
.0, .0}},
|
.0, .0}},
|
||||||
.timestep = 1000,
|
.timestep = 500,
|
||||||
.iterations = 50
|
.iterations = 100};
|
||||||
};
|
|
||||||
|
|
||||||
static bench_input barite_large_input = {
|
static bench_input barite_large_input = {
|
||||||
.csv_file_init = "@BARITE_LARGE_BENCH@/barite_large_init.csv",
|
.csv_file_init = "@BARITE_LARGE_BENCH@/barite_large_init.csv",
|
||||||
@ -83,9 +81,8 @@ static bench_input barite_large_input = {
|
|||||||
.east_const = {},
|
.east_const = {},
|
||||||
.west_const = {},
|
.west_const = {},
|
||||||
.values = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},
|
.values = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},
|
||||||
.timestep = 100,
|
.timestep = 50,
|
||||||
.iterations = 5
|
.iterations = 10};
|
||||||
};
|
|
||||||
|
|
||||||
static bench_input surfex_input = {
|
static bench_input surfex_input = {
|
||||||
.csv_file_init = "@SURFEX_BENCH@/surfex_init.csv",
|
.csv_file_init = "@SURFEX_BENCH@/surfex_init.csv",
|
||||||
@ -96,58 +93,31 @@ static bench_input surfex_input = {
|
|||||||
.s_x = 0.02,
|
.s_x = 0.02,
|
||||||
.s_y = 0.01,
|
.s_y = 0.01,
|
||||||
.boundary = {.north_const = gen_vec(200),
|
.boundary = {.north_const = gen_vec(200),
|
||||||
.south_const = gen_vec(200),
|
.south_const = gen_vec(200),
|
||||||
.east_const = gen_vec(100),
|
.east_const = gen_vec(100),
|
||||||
.west_const = gen_vec(100),
|
.west_const = gen_vec(100),
|
||||||
.values = {120.0, // H
|
.values = {120.0, // H
|
||||||
55.1, // O
|
55.1, // O
|
||||||
8.0e-17, // Charge
|
8.0e-17, // Charge
|
||||||
2.0e-15, // CH4
|
2.0e-15, // CH4
|
||||||
0.2, // C
|
0.2, // C
|
||||||
0.03, // Ca
|
0.03, // Ca
|
||||||
0.5, // Cl
|
0.5, // Cl
|
||||||
0.0002, // Fe2
|
0.0002, // Fe2
|
||||||
2.0e-08, // Fe3
|
2.0e-08, // Fe3
|
||||||
2.0e-11, // H0
|
2.0e-11, // H0
|
||||||
1.0e-05, // K
|
1.0e-05, // K
|
||||||
0.2, // Mg
|
0.2, // Mg
|
||||||
0.3, // Na
|
0.3, // Na
|
||||||
0, // HS2
|
0, // HS2
|
||||||
8.3e-12, // S2
|
8.3e-12, // S2
|
||||||
5.1e-14, // S4
|
5.1e-14, // S4
|
||||||
0.026, // S6
|
0.026, // S6
|
||||||
0.045, // Sr
|
0.045, // Sr
|
||||||
2.5e-08, // U4
|
2.5e-08, // U4
|
||||||
1.6e-10, // U5
|
1.6e-10, // U5
|
||||||
1.0e-05}}, // U6
|
1.0e-05}}, // U6
|
||||||
.timestep = 3600,
|
.timestep = 1800,
|
||||||
.iterations = 20
|
.iterations = 40};
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _BENCH_DEFS_HPP
|
#endif // _BENCH_DEFS_HPP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tug/Simulation.hpp>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using TugType = double;
|
using TugType = double;
|
||||||
|
|
||||||
|
|||||||
37
src/run.cpp
37
src/run.cpp
@ -1,8 +1,8 @@
|
|||||||
#include "run.hpp"
|
#include "run.hpp"
|
||||||
|
|
||||||
#include "io.hpp"
|
#include "io.hpp"
|
||||||
#include "tug/Boundary.hpp"
|
#include "tug/Core/Numeric/FTCS.hpp"
|
||||||
#include "tug/Grid.hpp"
|
#include "tug/Diffusion.hpp"
|
||||||
|
|
||||||
#include <Eigen/src/Core/Map.h>
|
#include <Eigen/src/Core/Map.h>
|
||||||
#include <Eigen/src/Core/Matrix.h>
|
#include <Eigen/src/Core/Matrix.h>
|
||||||
@ -11,7 +11,7 @@
|
|||||||
#include <ratio>
|
#include <ratio>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <tug/Simulation.hpp>
|
#include <tug/Core/Matrix.hpp>
|
||||||
|
|
||||||
#include <Eigen/Eigen>
|
#include <Eigen/Eigen>
|
||||||
|
|
||||||
@ -30,14 +30,19 @@ double run_bench(const bench_input &input, const std::string &output_file) {
|
|||||||
// create tug grids and boundary conditions
|
// create tug grids and boundary conditions
|
||||||
for (int i = 0; i < raw_data.size(); i++) {
|
for (int i = 0; i < raw_data.size(); i++) {
|
||||||
|
|
||||||
Eigen::Map<RowMajorMat> mat(raw_data[i].data(), input.nrows, input.ncols);
|
#ifdef BENCH_FTCS
|
||||||
tug::Grid<TugType> grid(input.nrows, input.ncols);
|
tug::Diffusion<TugType, tug::FTCS_APPROACH> diffu(raw_data[i].data(),
|
||||||
|
input.nrows, input.ncols);
|
||||||
|
#else
|
||||||
|
tug::Diffusion<TugType, tug::BTCS_APPROACH> diffu(raw_data[i].data(),
|
||||||
|
input.nrows, input.ncols);
|
||||||
|
#endif
|
||||||
|
|
||||||
grid.setConcentrations(mat);
|
diffu.setDomain(input.s_x, input.s_y);
|
||||||
grid.setDomain(input.s_x, input.s_y);
|
diffu.setAlphaX(alpha_x);
|
||||||
grid.setAlpha(alpha_x, alpha_y);
|
diffu.setAlphaY(alpha_y);
|
||||||
|
|
||||||
tug::Boundary<TugType> boundary(grid);
|
tug::Boundary<TugType> &boundary = diffu.getBoundaryConditions();
|
||||||
|
|
||||||
// set north boundary
|
// set north boundary
|
||||||
for (const auto &index : input.boundary.north_const) {
|
for (const auto &index : input.boundary.north_const) {
|
||||||
@ -63,21 +68,15 @@ double run_bench(const bench_input &input, const std::string &output_file) {
|
|||||||
input.boundary.values[i]);
|
input.boundary.values[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
tug::Simulation<TugType> sim(grid, boundary);
|
|
||||||
|
|
||||||
if (const char *out = std::getenv("OMP_NUM_THREADS")) {
|
if (const char *out = std::getenv("OMP_NUM_THREADS")) {
|
||||||
int ompNumThreads = std::stoi(out, NULL);
|
int ompNumThreads = std::stoi(out, NULL);
|
||||||
sim.setNumberThreads(ompNumThreads);
|
diffu.setNumberThreads(ompNumThreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
sim.setTimestep(input.timestep);
|
diffu.setTimestep(input.timestep);
|
||||||
sim.setIterations(input.iterations);
|
diffu.setIterations(input.iterations);
|
||||||
|
|
||||||
sim.run();
|
diffu.run();
|
||||||
|
|
||||||
const auto &result = grid.getConcentrations();
|
|
||||||
|
|
||||||
raw_data[i] = eigenMatrix_to_vector(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto end_t = std::chrono::high_resolution_clock::now();
|
const auto end_t = std::chrono::high_resolution_clock::now();
|
||||||
|
|||||||
2
tug
2
tug
@ -1 +1 @@
|
|||||||
Subproject commit 4867261f9d902ea2be161889a968d3bff519f15c
|
Subproject commit 9ca0735654d0ca808fa4704b2b2e13cf417ab865
|
||||||
Loading…
x
Reference in New Issue
Block a user