Scine::Readuct  6.0.0
This is the SCINE module ReaDuct.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
TaskFactory.h
Go to the documentation of this file.
1 
7 #ifndef READUCT_TASKFACTORY_H_
8 #define READUCT_TASKFACTORY_H_
9 
12 #include "Tasks/BondOrderTask.h"
14 #include "Tasks/HessianTask.h"
15 #include "Tasks/IntegralTask.h"
16 #include "Tasks/IrcTask.h"
19 #include "Tasks/SinglePointTask.h"
20 #include "Tasks/Task.h"
22 #include <algorithm>
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
27 namespace Scine {
28 namespace Readuct {
29 
33 class TaskFactory {
34  public:
36  TaskFactory() = delete;
46  static std::unique_ptr<Task> produce(std::string name, const std::vector<std::string>& input,
47  const std::vector<std::string>& output, std::shared_ptr<Core::Log> logger = nullptr) {
48  std::unique_ptr<Task> task;
49  std::transform(name.begin(), name.end(), name.begin(), ::toupper);
50  if (name == "OPT" || name == "GEOOPT" || name == "GEOMETRYOPTIMIZATION" || name == "GEOMETRY_OPTIMIZATION") {
51  task = std::make_unique<GeometryOptimizationTask>(input, output, logger);
52  }
53  else if (name == "AFIR" || name == "AFIROPT" || name == "AFIROPTIMIZATION" || name == "AFIR_OPTIMIZATION") {
54  task = std::make_unique<AfirOptimizationTask>(input, output, logger);
55  }
56  else if (name == "TS" || name == "TSOPT" || name == "TRANSITIONSTATE_OPTIMIZATION" ||
57  name == "TRANSITION_STATE_OPTIMIZATION") {
58  task = std::make_unique<TsOptimizationTask>(input, output, logger);
59  }
60  else if (name == "SP" || name == "SINGLEPOINT" || name == "ENERGY" || name == "SINGLE_POINT") {
61  task = std::make_unique<SinglePointTask>(input, output, logger);
62  }
63  else if (name == "IRC" || name == "IRCOPT") {
64  task = std::make_unique<IrcTask>(input, output, logger);
65  }
66  else if (name == "NT" || name == "NEWTONTRAJECTORY" || name == "NTOPTIMIZATION" ||
67  name == "NEWTONTRAJECTORYOPTIMIZATION" || name == "NTOPT" || name == "NT1") {
68  task = std::make_unique<NtOptimizationTask>(input, output);
69  }
70  else if (name == "NT2" || name == "NEWTONTRAJECTORY2" || name == "NTOPTIMIZATION2" ||
71  name == "NEWTONTRAJECTORYOPTIMIZATION2" || name == "NTOPT2") {
72  task = std::make_unique<NtOptimization2Task>(input, output);
73  }
74  else if (name == "HESSIAN" || name == "FREQUENCY_ANALYSIS" || name == "FREQUENCYANALYSIS" || name == "FREQ" ||
75  name == "FREQUENCY" || name == "FREQUENCIES") {
76  task = std::make_unique<HessianTask>(input, output, logger);
77  }
78  else if (name == "BONDS" || name == "BOND_ORDERS" || name == "BONDORDERS" || name == "BOS" || name == "BO") {
79  task = std::make_unique<BondOrderTask>(input, output, logger);
80  }
81  else if (name == "BSPLINE_INTERPOLATION" || name == "BSPLINEINTERPOLATION" || name == "BSPLINE") {
82  task = std::make_unique<BSplineInterpolationTask>(input, output, logger);
83  }
84  else if (name == "INTEGRALS" || name == "INTS") {
85  task = std::make_unique<IntegralTask>(input, output, logger);
86  }
87  else {
88  throw std::runtime_error("The requested task '" + name + "' is not available.\n");
89  }
90  return task;
91  }
92 }; // namespace Readuct
93 
94 } // namespace Readuct
95 } // namespace Scine
96 
97 #endif // READUCT_TASKFACTORY_H_
static std::unique_ptr< Task > produce(std::string name, const std::vector< std::string > &input, const std::vector< std::string > &output, std::shared_ptr< Core::Log > logger=nullptr)
Contstructs a Task with a given set of input and output systems.
Definition: TaskFactory.h:46
A factory generating Tasks by name (mainly).
Definition: TaskFactory.h:33
TaskFactory()=delete
Has only static functions.