Commit 64f8817f authored by snuverink_j's avatar snuverink_j
Browse files

fix compiler warnings for missing declarations: put functions in anonymous...

fix compiler warnings for missing declarations: put functions in anonymous namespaces; add header includes
parent 070d1bc7
......@@ -21,6 +21,8 @@ class Measurement {
public:
double spos;
double measurement;
friend std::istream & operator>>(std::istream & stream, Measurement & measurement);
};
/**
......
......@@ -62,10 +62,12 @@ enum MPITag_t {
enum State_t {IDLE = 0, RUNNING = 1};
/// serializes params using Boost archive
void serialize(Param_t params, std::ostringstream &os);
void serialize(Param_t params, std::ostringstream &os);
void serialize(reqVarContainer_t params, std::ostringstream &os);
/// deserializes params using Boost archive
void deserialize(char *buffer, Param_t &params);
void deserialize(char *buffer, Param_t &params);
void deserialize(char *buffer, reqVarContainer_t &params);
/// broadcast params to all entities in comm
void MPI_Bcast_params(Param_t &params, size_t root, MPI_Comm comm);
......
......@@ -30,6 +30,26 @@ using namespace std;
namespace {
//return the inverse of the "alpha,beta,gamma" transformation matrix
FMatrix<double, 3, 3> invers(double c, double c_prim, double s, double s_prim) {
FMatrix<double, 3, 3> M;
double det = -pow(c_prim, 3) * pow(s, 3) + 3 * c * s_prim * pow(c_prim, 2)
* pow(s, 2) - 3 * pow(c, 2) * c_prim * s * pow(s_prim, 2) + pow(c, 3) * pow(s_prim, 3);
M(0, 0) = (-c_prim * s * pow(s_prim, 2) + c * pow(s_prim, 3)) / det;
M(0, 1) = (-2 * c_prim * pow(s, 2) * s_prim + 2 * c * s * pow(s_prim, 2)) / det;
M(0, 2) = (-c_prim * pow(s, 3) + c * pow(s, 2) * s_prim) / det;
M(1, 0) = (-pow(c_prim, 2) * s * s_prim + c * c_prim * pow(s_prim, 2)) / det;
M(1, 1) = (-pow(c_prim, 2) * pow(s, 2) + pow(c, 2) * pow(s_prim, 2)) / det;
M(1, 2) = (-c * c_prim * pow(s, 2) + pow(c, 2) * s * s_prim) / det;
M(2, 0) = (-pow(c_prim, 3) * s + c * pow(c_prim, 2) * s_prim) / det;
M(2, 1) = (-2 * c * pow(c_prim, 2) * s + 2 * pow(c, 2) * c_prim * s_prim) / det;
M(2, 2) = (-pow(c, 2) * c_prim * s + pow(c, 3) * s_prim) / det;
return M;
}
struct ColDesc {
// Column name.
......@@ -219,25 +239,6 @@ inline std::string Aperture::A_row::getType_elm() {
inline double Aperture::A_row::getOrb() {
return Orb;
}
//return the inverse of the "alpha,beta,gamma" transformation matrix
FMatrix<double, 3, 3> invers(double c, double c_prim, double s, double s_prim) {
FMatrix<double, 3, 3> M;
double det = -pow(c_prim, 3) * pow(s, 3) + 3 * c * s_prim * pow(c_prim, 2)
* pow(s, 2) - 3 * pow(c, 2) * c_prim * s * pow(s_prim, 2) + pow(c, 3) * pow(s_prim, 3);
M(0, 0) = (-c_prim * s * pow(s_prim, 2) + c * pow(s_prim, 3)) / det;
M(0, 1) = (-2 * c_prim * pow(s, 2) * s_prim + 2 * c * s * pow(s_prim, 2)) / det;
M(0, 2) = (-c_prim * pow(s, 3) + c * pow(s, 2) * s_prim) / det;
M(1, 0) = (-pow(c_prim, 2) * s * s_prim + c * c_prim * pow(s_prim, 2)) / det;
M(1, 1) = (-pow(c_prim, 2) * pow(s, 2) + pow(c, 2) * pow(s_prim, 2)) / det;
M(1, 2) = (-c * c_prim * pow(s, 2) + pow(c, 2) * s * s_prim) / det;
M(2, 0) = (-pow(c_prim, 3) * s + c * pow(c_prim, 2) * s_prim) / det;
M(2, 1) = (-2 * c * pow(c_prim, 2) * s + 2 * pow(c, 2) * c_prim * s_prim) / det;
M(2, 2) = (-pow(c, 2) * c_prim * s + pow(c, 3) * s_prim) / det;
return M;
}
//iterator used for the displacement in the list of optic elments
......
......@@ -27,6 +27,26 @@ using namespace std;
namespace {
//return the inverse of the "alpha,beta,gamma" transformation matrix
FMatrix<double, 3, 3> sp_invers(double c, double c_prim, double s, double s_prim) {
FMatrix<double, 3, 3> M;
double det = -pow(c_prim, 3) * pow(s, 3) + 3 * c * s_prim * pow(c_prim, 2)
* pow(s, 2) - 3 * pow(c, 2) * c_prim * s * pow(s_prim, 2) + pow(c, 3) * pow(s_prim, 3);
M(0, 0) = (-c_prim * s * pow(s_prim, 2) + c * pow(s_prim, 3)) / det;
M(0, 1) = (-2 * c_prim * pow(s, 2) * s_prim + 2 * c * s * pow(s_prim, 2)) / det;
M(0, 2) = (-c_prim * pow(s, 3) + c * pow(s, 2) * s_prim) / det;
M(1, 0) = (-pow(c_prim, 2) * s * s_prim + c * c_prim * pow(s_prim, 2)) / det;
M(1, 1) = (-pow(c_prim, 2) * pow(s, 2) + pow(c, 2) * pow(s_prim, 2)) / det;
M(1, 2) = (-c * c_prim * pow(s, 2) + pow(c, 2) * s * s_prim) / det;
M(2, 0) = (-pow(c_prim, 3) * s + c * pow(c_prim, 2) * s_prim) / det;
M(2, 1) = (-2 * c * pow(c_prim, 2) * s + 2 * pow(c, 2) * c_prim * s_prim) / det;
M(2, 2) = (-pow(c, 2) * c_prim * s + pow(c, 3) * s_prim) / det;
return M;
}
struct ColDesc {
// Column name.
......@@ -203,28 +223,6 @@ inline double MSplit::A_row::getDisp_y_prim(int ind) {
return Interpol[ind].Disp_y_prim;
}
//return the inverse of the "alpha,beta,gamma" transformation matrix
FMatrix<double, 3, 3> sp_invers(double c, double c_prim, double s, double s_prim) {
FMatrix<double, 3, 3> M;
double det = -pow(c_prim, 3) * pow(s, 3) + 3 * c * s_prim * pow(c_prim, 2)
* pow(s, 2) - 3 * pow(c, 2) * c_prim * s * pow(s_prim, 2) + pow(c, 3) * pow(s_prim, 3);
M(0, 0) = (-c_prim * s * pow(s_prim, 2) + c * pow(s_prim, 3)) / det;
M(0, 1) = (-2 * c_prim * pow(s, 2) * s_prim + 2 * c * s * pow(s_prim, 2)) / det;
M(0, 2) = (-c_prim * pow(s, 3) + c * pow(s, 2) * s_prim) / det;
M(1, 0) = (-pow(c_prim, 2) * s * s_prim + c * c_prim * pow(s_prim, 2)) / det;
M(1, 1) = (-pow(c_prim, 2) * pow(s, 2) + pow(c, 2) * pow(s_prim, 2)) / det;
M(1, 2) = (-c * c_prim * pow(s, 2) + pow(c, 2) * s * s_prim) / det;
M(2, 0) = (-pow(c_prim, 3) * s + c * pow(c_prim, 2) * s_prim) / det;
M(2, 1) = (-2 * c * pow(c_prim, 2) * s + 2 * pow(c, 2) * c_prim * s_prim) / det;
M(2, 2) = (-pow(c, 2) * c_prim * s + pow(c, 3) * s_prim) / det;
return M;
}
//iterator used for the displacement in the list of optic elments
MSplit::A_Tline::iterator MSplit::begin() {
return itsTable.begin();
......
......@@ -15,6 +15,8 @@
//
// ------------------------------------------------------------------------
#include "Attributes/Attributes.h"
#include "AbstractObjects/Attribute.h"
#include "Attributes/Bool.h"
#include "Attributes/BoolArray.h"
......
......@@ -144,10 +144,10 @@ const Euclid3DGeometry &Offset::getGeometry() const {
return *geometry_m;
}
std::ostream& operator<<(std::ostream& out, const Vector_t& vec) {
out << "(" << vec(0) << ", " << vec(1) << ", " << vec(2) << ")";
return out;
}
// std::ostream& operator<<(std::ostream& out, const Vector_t& vec) {
// out << "(" << vec(0) << ", " << vec(1) << ", " << vec(2) << ")";
// return out;
// }
double Offset::getTheta(Vector_t vec1, Vector_t vec2) {
if (fabs(vec1(2)) > 1e-9 || fabs(vec2(2)) > 1e-9)
......
......@@ -25,6 +25,15 @@
typedef FTps<double, 6> Series;
// namespace {
// void printSciForm(std::ostream &os, double num, int prec = 14, int fw = 22) {
// std::streamsize old_prec = os.precision(prec); // Save old,
// os.setf(std::ios::scientific, std::ios::floatfield); // and set new formats.
// os << std::setw(fw) << num; // Print number.
// os.precision(old_prec); // Restore old formats.
// os.setf(std::ios::fixed, std::ios::floatfield);
// }
// }
// Class AbstractMapper
// ------------------------------------------------------------------------
......@@ -67,15 +76,6 @@ buildMultipoleVectorPotential(const BMultipoleField &field) {
}
}
void printSciForm(std::ostream &os, double num, int prec = 14, int fw = 22) {
std::streamsize old_prec = os.precision(prec); // Save old,
os.setf(std::ios::scientific, std::ios::floatfield); // and set new formats.
os << std::setw(fw) << num; // Print number.
os.precision(old_prec); // Restore old formats.
os.setf(std::ios::fixed, std::ios::floatfield);
}
Series AbstractMapper::
buildSBendVectorPotential(const BMultipoleField &field, double h) {
//std::cerr << "==> In AbstractMapper::buildSBendVectorPotential(const BMultipoleField &field, double h)"
......
......@@ -4,7 +4,20 @@
#include "Utility/RandomNumberGen.h"
#include "Utilities/GeneralClassicException.h"
extern Inform *gmsg;
namespace {
Vector_t normalize(const Vector_t & vec)
{
double length = sqrt(dot(vec, vec));
#ifndef NOPAssert
if (length < 1e-12)
throw GeneralClassicException("normalize()",
"length of vector less than 1e-12");
#endif
return vec / length;
}
}
Quaternion::Quaternion(const Tenzor<double, 3> &M):
Vektor<double, 4>(0.0)
......@@ -18,19 +31,6 @@ Quaternion::Quaternion(const Tenzor<double, 3> &M):
(*this)(3) = std::abs(M(1, 0) - M(0, 1)) > 0? copysign((*this)(3), M(1, 0) - M(0, 1)): 0.0;
}
Vector_t normalize(const Vector_t & vec)
{
double length = sqrt(dot(vec, vec));
#ifndef NOPAssert
if (length < 1e-12)
throw GeneralClassicException("normalize()",
"length of vector less than 1e-12");
#endif
return vec / length;
}
Quaternion getQuaternion(Vector_t u, Vector_t ref)
{
const double tol = 1e-12;
......
......@@ -47,6 +47,19 @@ namespace interpolation {
typedef PolynomialCoefficient Coeff;
namespace {
std::vector<double> getDeltaPos(Mesh* mesh) {
Mesh::Iterator it = mesh->begin();
std::vector<double> pos1 = it.getPosition();
for (size_t i = 0; i < it.getState().size(); ++i)
it[i]++;
std::vector<double> pos2 = it.getPosition();
for (size_t i = 0; i < pos2.size(); ++i)
pos2[i] -= pos1[i];
return pos2;
}
}
PPSolveFactory::PPSolveFactory(Mesh* points,
std::vector<std::vector<double> > values,
int polyPatchOrder,
......@@ -100,17 +113,6 @@ PPSolveFactory::PPSolveFactory(Mesh* points,
(posDim, polyPatchOrder_m-1, polyPatchOrder_m);
}
std::vector<double> getDeltaPos(Mesh* mesh) {
Mesh::Iterator it = mesh->begin();
std::vector<double> pos1 = it.getPosition();
for (size_t i = 0; i < it.getState().size(); ++i)
it[i]++;
std::vector<double> pos2 = it.getPosition();
for (size_t i = 0; i < pos2.size(); ++i)
pos2[i] -= pos1[i];
return pos2;
}
std::vector<double> PPSolveFactory::outOfBoundsPosition(
Mesh::Iterator outOfBoundsIt) {
const Mesh* mesh = outOfBoundsIt.getMesh();
......
......@@ -503,8 +503,4 @@ ThreeDGrid* SectorMagneticFieldMap::IO::generateGrid
ThreeDGrid* grid = new ThreeDGrid(r_grid, y_grid, phi_grid);
grid->setConstantSpacing(true);
return grid;
}
double dot_prod(Vector_t vec_1, Vector_t vec_2) {
return vec_1[0]*vec_2[0] + vec_1[1]*vec_2[1] + vec_1[2]*vec_2[2];
}
}
\ No newline at end of file
......@@ -975,9 +975,10 @@ bool CollimatorPhysics::stillAlive(PartBunchBase<double, 3> *bunch) {
}
bool myCompF(PART x, PART y) {
return x.label > y.label;
namespace {
bool myCompF(PART x, PART y) {
return x.label > y.label;
}
}
void CollimatorPhysics::deleteParticleFromLocalVector() {
......@@ -1007,8 +1008,10 @@ void CollimatorPhysics::deleteParticleFromLocalVector() {
#ifdef OPAL_DKS
bool myCompFDKS(PART_DKS x, PART_DKS y) {
return x.label > y.label;
namespace {
bool myCompFDKS(PART_DKS x, PART_DKS y) {
return x.label > y.label;
}
}
void CollimatorPhysics::addBackToBunchDKS(PartBunchBase<double, 3> *bunch, unsigned i) {
......
......@@ -9,11 +9,8 @@
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>
#include <fstream>
#include <regex>
using namespace std;
extern Inform *gmsg;
OpalBeamline::OpalBeamline():
elements_m(),
prepared_m(false),
......@@ -585,66 +582,68 @@ void OpalBeamline::save3DLattice() {
mesh.write(OpalData::getInstance()->getInputBasename());
}
std::string parseInput() {
std::ifstream in(OpalData::getInstance()->getInputFn());
std::string source("");
std::string str;
char testBit;
const std::string commentFormat("");
const boost::regex empty("^[ \t]*$");
const boost::regex lineEnd(";");
const std::string lineEndFormat(";\n");
const boost::regex cppCommentExpr("//.*");
const boost::regex cCommentExpr("/\\*.*?\\*/"); // "/\\*(?>[^*/]+|\\*[^/]|/[^*])*(?>(?R)(?>[^*/]+|\\*[^/]|/[^*])*)*\\*/"
bool priorEmpty = true;
in.get(testBit);
while (!in.eof()) {
in.putback(testBit);
std::getline(in, str);
str = boost::regex_replace(str, cppCommentExpr, commentFormat);
str = boost::regex_replace(str, empty, commentFormat);
if (str.size() > 0) {
source += str;// + '\n';
priorEmpty = false;
} else if (!priorEmpty) {
source += "##EMPTY_LINE##";
priorEmpty = true;
}
namespace {
std::string parseInput() {
std::ifstream in(OpalData::getInstance()->getInputFn());
std::string source("");
std::string str;
char testBit;
const std::string commentFormat("");
const boost::regex empty("^[ \t]*$");
const boost::regex lineEnd(";");
const std::string lineEndFormat(";\n");
const boost::regex cppCommentExpr("//.*");
const boost::regex cCommentExpr("/\\*.*?\\*/"); // "/\\*(?>[^*/]+|\\*[^/]|/[^*])*(?>(?R)(?>[^*/]+|\\*[^/]|/[^*])*)*\\*/"
bool priorEmpty = true;
in.get(testBit);
}
while (!in.eof()) {
in.putback(testBit);
std::getline(in, str);
str = boost::regex_replace(str, cppCommentExpr, commentFormat);
str = boost::regex_replace(str, empty, commentFormat);
if (str.size() > 0) {
source += str;// + '\n';
priorEmpty = false;
} else if (!priorEmpty) {
source += "##EMPTY_LINE##";
priorEmpty = true;
}
source = boost::regex_replace(source, cCommentExpr, commentFormat);
source = boost::regex_replace(source, lineEnd, lineEndFormat, boost::match_default | boost::format_all);
in.get(testBit);
}
return source;
}
source = boost::regex_replace(source, cCommentExpr, commentFormat);
source = boost::regex_replace(source, lineEnd, lineEndFormat, boost::match_default | boost::format_all);
unsigned int getMinimalSignificantDigits(double num, const unsigned int maxDigits) {
char buf[32];
snprintf(buf, 32, "%.*f", maxDigits + 1, num);
string numStr(buf);
unsigned int length = numStr.length();
unsigned int numDigits = maxDigits;
unsigned int i = 2;
while (i < maxDigits + 1 && numStr[length - i] == '0') {
--numDigits;
++ i;
return source;
}
return numDigits;
}
unsigned int getMinimalSignificantDigits(double num, const unsigned int maxDigits) {
char buf[32];
snprintf(buf, 32, "%.*f", maxDigits + 1, num);
string numStr(buf);
unsigned int length = numStr.length();
unsigned int numDigits = maxDigits;
unsigned int i = 2;
while (i < maxDigits + 1 && numStr[length - i] == '0') {
--numDigits;
++ i;
}
std::string round2string(double num, const unsigned int maxDigits) {
char buf[64];
return numDigits;
}
snprintf(buf, 64, "%.*f", getMinimalSignificantDigits(num, maxDigits), num);
std::string round2string(double num, const unsigned int maxDigits) {
char buf[64];
return std::string(buf);
snprintf(buf, 64, "%.*f", getMinimalSignificantDigits(num, maxDigits), num);
return std::string(buf);
}
}
void OpalBeamline::save3DInput() {
......
......@@ -80,25 +80,15 @@ Inform *gmsg;
#include <set>
#include <algorithm>
// DTA
#define NC 5
void printStringVector(const std::vector<std::string> &strings) {
unsigned int iend = strings.size(), nc = 0;
for(unsigned int i = 0; i < iend; ++i) {
std::cout << " " << strings[i];
if(++nc == NC) { nc = 0; std::cout << std::endl; }
namespace {
void errorHandlerGSL(const char *reason,
const char *file,
int line,
int gsl_errno) {
throw OpalException(file, reason);
}
if(nc != 0) std::cout << std::endl;
std::cout << std::endl;
}
void errorHandlerGSL(const char *reason,
const char *file,
int line,
int gsl_errno);
int main(int argc, char *argv[]) {
Ippl *ippl = new Ippl(argc, argv);
gmsg = new Inform("OPAL");
......@@ -195,8 +185,8 @@ int main(int argc, char *argv[]) {
FileStream::setEcho(Options::echo);
char *startup = getenv("HOME");
boost::filesystem::path p = strncat(startup, "/init.opal", 20);
if (startup != NULL && is_regular_file(p)) {
boost::filesystem::path p = strncat(startup, "/init.opal", 20);
if (startup != NULL && is_regular_file(p)) {
FileStream::setEcho(false);
FileStream *is;
......@@ -227,8 +217,6 @@ int main(int argc, char *argv[]) {
int arg = -1;
std::string fname;
std::string restartFileName;
// if(argc > 3) {
// if(argc > 5) {
// // will write dumping date into a new h5 file
for(int ii = 1; ii < argc; ++ ii) {
std::string argStr = std::string(argv[ii]);
......@@ -355,7 +343,7 @@ int main(int argc, char *argv[]) {
IpplTimings::print();
IpplTimings::print(std::string("timing.dat"),
IpplTimings::print(std::string("timing.dat"),
OpalData::getInstance()->getProblemCharacteristicValues());
if(Ippl::myNode() == 0) {
......@@ -389,7 +377,7 @@ int main(int argc, char *argv[]) {
}
Ippl::Comm->barrier();
Fieldmap::clearDictionary();
Fieldmap::clearDictionary();
OpalData::deleteInstance();
delete gmsg;
delete ippl;
......@@ -476,10 +464,3 @@ int main(int argc, char *argv[]) {
return 1;
}
void errorHandlerGSL(const char *reason,
const char *file,
int,
int) {
throw OpalException(file, reason);
}
......@@ -148,11 +148,10 @@
#include "changes.h"
// Namespace Configure
// Modify these methods to add new commands.
// ------------------------------------------------------------------------
namespace Configure {
namespace {
void makeActions() {
OpalData *opal = OpalData::getInstance();
......@@ -279,8 +278,9 @@ namespace Configure {
opal->create(new Sequence());
opal->create(new OpalRingDefinition());
}
};
namespace Configure {
void configure() {
makeDefinitions();
makeElements();
......
#include <map>
#include <string>
#include "changes.h"
namespace Versions {
std::map<unsigned int, std::string> changes;
......
......@@ -45,6 +45,7 @@
using namespace interpolation;
namespace {
void test_points(int dim, int lower, int upper, std::vector< std::vector<int> > pts) {
int upper_size = 1;
int lower_size = 1;
......@@ -78,6 +79,7 @@ void test_points(int dim, int lower, int upper, std::vector< std::vector<int> >
}
}
}
}
TEST(PPSolveFactoryTest, TestNearbyPointsSquares) {
OpalTestUtilities::SilenceTest silencer;
......@@ -220,7 +222,7 @@ TEST_F(PPSolveFactoryTestFixture, DISABLED_TestSolvePolynomialQuadraticSmoothed)
}
}
namespace {
std::vector<double> get_value(std::vector<double> x, int np) {
static const double twopi = asin(1.)*4;
std::vector<double> a_value(3);
......@@ -314,7 +316,7 @@ void plot(int n_points, std::vector<double> start, std::vector<double> end, Poly
void plot(int n_points, std::vector<double> start, std::vector<double> end, PolynomialPatch* patch, int n_grid_points, std::string title) {
}
#endif // PolynomialPatchTest_MakePlots