Commit d6e6e76f authored by snuverink_j's avatar snuverink_j
Browse files

code improvements

parent 1b34f8b8
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
#include <fstream> #include <fstream>
#include <cstring> #include <cstring>
// range of Inform message levels
constexpr int MIN_INFORM_LEVEL = 1;
constexpr int MAX_INFORM_LEVEL = 5;
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// manipulator functions // manipulator functions
......
...@@ -35,12 +35,6 @@ ...@@ -35,12 +35,6 @@
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
// range of Inform message levels
#define MIN_INFORM_LEVEL 1
#define MAX_INFORM_LEVEL 5
// how large is the buffer for this object?
#define MAX_INFORM_MSG_SIZE 32000
#define INFORM_ALL_NODES (-1) #define INFORM_ALL_NODES (-1)
......
...@@ -347,8 +347,7 @@ bool Cyclotron::apply(const size_t &id, const double &t, Vector_t &E, Vector_t & ...@@ -347,8 +347,7 @@ bool Cyclotron::apply(const size_t &id, const double &t, Vector_t &E, Vector_t &
bool flagNeedUpdate = false; bool flagNeedUpdate = false;
const double rpos = sqrt(RefPartBunch_m->R[id](0) * RefPartBunch_m->R[id](0) const double rpos = std::hypot(RefPartBunch_m->R[id](0), RefPartBunch_m->R[id](1));
+ RefPartBunch_m->R[id](1) * RefPartBunch_m->R[id](1));
const double zpos = RefPartBunch_m->R[id](2); const double zpos = RefPartBunch_m->R[id](2);
if (zpos > maxz_m || zpos < minz_m || rpos > maxr_m || rpos < minr_m){ if (zpos > maxz_m || zpos < minz_m || rpos > maxr_m || rpos < minr_m){
...@@ -377,7 +376,7 @@ bool Cyclotron::apply(const size_t &id, const double &t, Vector_t &E, Vector_t & ...@@ -377,7 +376,7 @@ bool Cyclotron::apply(const size_t &id, const double &t, Vector_t &E, Vector_t &
bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) { bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) {
const double rad = sqrt(R[0] * R[0] + R[1] * R[1]); const double rad = std::hypot(R[0],R[1]);
const double tempv = atan(R[1] / R[0]); const double tempv = atan(R[1] / R[0]);
double tet = tempv; double tet = tempv;
......
...@@ -436,8 +436,7 @@ void OptimizeCmd::execute() { ...@@ -436,8 +436,7 @@ void OptimizeCmd::execute() {
std::ifstream infile(tmplFile.c_str()); std::ifstream infile(tmplFile.c_str());
std::map<std::string, short> dvarCheck; std::map<std::string, short> dvarCheck;
auto itr = dvars.begin(); for (auto itr = dvars.begin(); itr != dvars.end(); ++ itr) {
for (; itr != dvars.end(); ++ itr) {
dvarCheck.insert(std::make_pair(boost::get<0>(itr->second), 0)); dvarCheck.insert(std::make_pair(boost::get<0>(itr->second), 0));
} }
...@@ -447,7 +446,7 @@ void OptimizeCmd::execute() { ...@@ -447,7 +446,7 @@ void OptimizeCmd::execute() {
//XXX doing the inverse would be better //XXX doing the inverse would be better
for(auto &check: dvarCheck) { for(auto &check: dvarCheck) {
size_t pos = line.find("_" + check.first + "_"); pos = line.find("_" + check.first + "_");
if (pos != std::string::npos && if (pos != std::string::npos &&
dvarCheck.find(check.first) != dvarCheck.end()) { dvarCheck.find(check.first) != dvarCheck.end()) {
dvarCheck.at(check.first) = 1; dvarCheck.at(check.first) = 1;
......
...@@ -33,7 +33,6 @@ Daniel Winklehner (MIT) ...@@ -33,7 +33,6 @@ Daniel Winklehner (MIT)
For further information contact: <a href="mailto:andreas.adelmann@psi.ch">andreas.adelmann@psi.ch</a> - For further information contact: <a href="mailto:andreas.adelmann@psi.ch">andreas.adelmann@psi.ch</a> -
Andreas Adelmann Andreas Adelmann
</P> </P>
Last modified today
</P> </P>
<P> <P>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment