OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
RadialPeak.h
Go to the documentation of this file.
1#ifndef __RADIALPEAK_H__
2#define __RADIALPEAK_H__
3
4#include <string>
5
6#include "boost/type_traits/remove_cv.hpp"
7#include "boost/variant/get.hpp"
8#include "boost/variant/variant.hpp"
9#include "boost/smart_ptr.hpp"
10
11#include "Util/Types.h"
12#include "Util/PeakReader.h"
14
19struct RadialPeak {
20
21 static const std::string name;
22
24 if (args.size() != 2) {
25 throw OptPilotException("RadialPeak::operator()",
26 "radialPeak expects 2 arguments, " + std::to_string(args.size()) + " given");
27 }
28
29 peak_filename_ = boost::get<std::string>(args[0]);
30 turn_number_ = boost::get<double>(args[1]);
31
32 bool is_valid = true;
33
34 boost::scoped_ptr<PeakReader> sim_peaks(new PeakReader(peak_filename_));
35 try {
36 sim_peaks->parseFile();
37 } catch (OptPilotException &ex) {
38 std::cout << "Caught exception: " << ex.what() << std::endl;
39 is_valid = false;
40 }
41
42 double sim_radius = 0.0;
43 try {
44 sim_peaks->getPeak(turn_number_, sim_radius);
45 } catch(OptPilotException &e) {
46 std::cout << "Exception while getting value "
47 << "from peak file: " << e.what()
48 << std::endl;
49 is_valid = false;
50 }
51
52 return boost::make_tuple(sim_radius, is_valid);
53 }
54
55private:
56
57 std::string peak_filename_;
59
60 // define a mapping to arguments in argument vector
61 boost::tuple<std::string, int> argument_types;
62 // :FIXME: remove unused enum
63#if 0
64 enum {
65 peak_filename
66 , turn_number
67 } argument_type_id;
68#endif
69};
70
71#endif
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
boost::tuple< double, bool > Result_t
Definition: Expression.h:66
constexpr double e
The value of.
Definition: Physics.h:39
std::vector< argument_t > arguments_t
Definition: function.hpp:19
std::string peak_filename_
Definition: RadialPeak.h:57
Expressions::Result_t operator()(client::function::arguments_t args)
Definition: RadialPeak.h:23
static const std::string name
Definition: RadialPeak.h:21
boost::tuple< std::string, int > argument_types
Definition: RadialPeak.h:61
int turn_number_
Definition: RadialPeak.h:58
virtual const char * what() const