forked from STEllAR-GROUP/hpx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsheneos_client.cpp
100 lines (78 loc) · 3.18 KB
/
sheneos_client.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright (c) 2007-2017 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <hpx/hpx_init.hpp>
#include <cstddef>
#include <iostream>
#include <string>
#include <vector>
#include "sheneos/interpolator.hpp"
#include <hpx/program_options.hpp>
///////////////////////////////////////////////////////////////////////////////
inline bool
eval(char const* expr, sheneos::interpolator& shen, double ye,
double temp, double rho, std::vector<double> const& expected)
{
std::vector<double> results = shen.interpolate(ye, temp, rho);
std::cout << expr << std::endl;
std::cout << std::string(strnlen(expr, 256), '-') << std::endl;
if (results.size() != expected.size()) {
std::cout << "Result size mismatch, got: " << results.size()
<< ", expected: " << expected.size() << std::endl;
return false;
}
for (std::size_t i = 0; i < results.size(); ++i) {
std::cout << results[i]
<< ", expected: " << expected[i]
<< std::endl;
}
return true;
}
int hpx_main(hpx::program_options::variables_map& vm)
{
std::string const datafilename = vm["file"].as<std::string>();
int num_partitions = 27;
{
char const* shen_symbolic_name = "/sheneos_client/test";
std::vector<double> const expected = {
9.809012e+34, // pressure
1.602810e+20, // energy
2.843643e+00, // entropy
4.151515e+01, // munu
3.960476e+20, // cs2
2.052315e+08, // dedt
2.864134e+20, // dpdrhoe
3.556341e+14, // dpderho
};
// create the distributed interpolation object on num_localities
sheneos::interpolator shen(datafilename, shen_symbolic_name, num_partitions);
eval("shen(0.2660725, 63.0, std::pow(10., 14.74994))", shen,
0.2660725, 63.0, std::pow(10., 14.74994), expected);
std::cout << std::endl << std::endl;
// create a second client instance connected to the already existing
// interpolation object
sheneos::interpolator shen_connected;
shen_connected.connect(shen_symbolic_name);
eval("shen(0.2660725, 63.0, std::pow(10., 14.74994))", shen_connected,
0.2660725, 63.0, std::pow(10., 14.74994), expected);
std::cout << std::endl << std::endl;
}
hpx::finalize();
return 0;
}
///////////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
// Configure application-specific options
hpx::program_options::options_description desc_commandline(
"Usage: " HPX_APPLICATION_STRING " [options]");
desc_commandline.add_options()
("file", hpx::program_options::value<std::string>()->default_value(
"sheneos_220r_180t_50y_extT_analmu_20100322_SVNr28.h5"),
"name of HDF5 data file containing the Shen EOS tables")
;
// Initialize and run HPX
return hpx::init(desc_commandline, argc, argv);
}