diff --git a/extensions/BoundaryFunctions.h b/extensions/BoundaryFunctions.h index b7d643759ed2eb347a8c266e4d63ca9243d3473c..4af72a7acb79083f7e922936d8272fc7b0d8f8a9 100644 --- a/extensions/BoundaryFunctions.h +++ b/extensions/BoundaryFunctions.h @@ -86,7 +86,7 @@ public: BoundaryFct2() : AbstractFunction<double, WorldVector<double> >(1), y(0.205), c(6.0) {}; BoundaryFct2(double y_, double c_) : AbstractFunction<double, WorldVector<double> >(1), y(y_),c(c_) {}; double operator()(const WorldVector<double>& x) const { - return 1.0/sqr(2.0*y) * sin(M_PI*(*timePtr)/8.0)*c*(y+x[1])*(y-x[1]); + return 1.0/sqr(2.0*y) * sin(m_pi*(*timePtr)/8.0)*c*(y+x[1])*(y-x[1]); }; protected: double y,c; @@ -98,7 +98,7 @@ public: BoundaryFct2_robin() : AbstractFunction<double, WorldVector<double> >(1), y(0.205), c(6.0) {}; BoundaryFct2_robin(double y_, double c_) : AbstractFunction<double, WorldVector<double> >(1), y(y_),c(c_) {}; double operator()(const WorldVector<double>& x) const { - double result = 1.0/sqr(2.0*y) * sin(M_PI*(*timePtr)/8.0)*c*(y+x[1])*(y-x[1]); + double result = 1.0/sqr(2.0*y) * sin(m_pi*(*timePtr)/8.0)*c*(y+x[1])*(y-x[1]); double n = (x[0]<0.0?-1.0:1.0); return -1.0*result*n; }; @@ -116,8 +116,8 @@ class StokesFlow : public AbstractFunction<WorldVector<double>, WorldVector<doub Initfile::get("user parameter->colloidal radius",R, 1); Initfile::get("pfc-parameter->density",density, 1); Initfile::get("pfc-parameter->r",r, 1); - radius = R/(1.0-R) * 2.0*M_PI/sqrt(3.0); - D = radius + 2.0*M_PI/sqrt(3.0); + radius = R/(1.0-R) * 2.0*m_pi/sqrt(3.0); + D = radius + 2.0*m_pi/sqrt(3.0); center.set(0.0); Initfile::get("user parameter->colloids position[0]",center, 1); @@ -152,8 +152,8 @@ class StokesFlow_component : public AbstractFunction<double, WorldVector<double> Initfile::get("user parameter->colloidal radius",R, 1); Initfile::get("pfc-parameter->density",density, 1); Initfile::get("pfc-parameter->r",r, 1); - radius = R/(1.0-R) * 2.0*M_PI/sqrt(3.0); - D = radius + 2.0*M_PI/sqrt(3.0); + radius = R/(1.0-R) * 2.0*m_pi/sqrt(3.0); + D = radius + 2.0*m_pi/sqrt(3.0); center.set(0.0); Initfile::get("user parameter->colloids position[0]",center, 1); @@ -189,8 +189,8 @@ class StokesFlow_robin : public AbstractFunction<double, WorldVector<double> > Initfile::get("user parameter->colloidal radius",R, 1); Initfile::get("pfc-parameter->density",density, 1); Initfile::get("pfc-parameter->r",r, 1); - radius = R/(1.0-R) * 2.0*M_PI/sqrt(3.0); - D = radius + 2.0*M_PI/sqrt(3.0); + radius = R/(1.0-R) * 2.0*m_pi/sqrt(3.0); + D = radius + 2.0*m_pi/sqrt(3.0); center.set(0.0); Initfile::get("user parameter->colloids position[0]",center, 1); diff --git a/extensions/Helpers.h b/extensions/Helpers.h index b725091aa1bd7f8457abb4b562b7d855545820ac..f98eb2982328ae3f4aa383ac03304062d16c9491 100644 --- a/extensions/Helpers.h +++ b/extensions/Helpers.h @@ -9,15 +9,22 @@ #include "parallel/StdMpi.h" #endif +#ifdef _WIN32 +#include <io.h> +#else #include <unistd.h> +#endif #include <ios> #include <iostream> #include <fstream> #include <string> + #include <boost/numeric/mtl/mtl.hpp> #include <boost/numeric/itl/itl.hpp> #include "boost/lexical_cast.hpp" #include "boost/date_time/posix_time/posix_time.hpp" +#include <boost/math/special_functions/fpclassify.hpp> + #include <time.h> #include <stdarg.h> @@ -53,11 +60,21 @@ namespace Helpers { inline int signum(int val) { return val > 0 ? 1 : (val < 0 ? -1 : 0); } inline int signum(bool val) { return val ? 1 : -1; } inline int toInt(bool val) { return val ? 1 : 0; } - inline bool isNumber(double val) { return !isnan(val) && !isinf(val); } + inline bool isNumber(double val) { return !boost::math::isnan(val) && !boost::math::isinf(val); } inline bool toBool(double val, double tol = DBL_TOL) { return val > tol || val < -tol ? true : false; } inline bool isPositiv(double val, double tol = DBL_TOL) { return val > -tol; } inline bool isStrictPositiv(double val, double tol = DBL_TOL) { return val > tol; } + template<typename T> + T atanh(T x) + { +#ifndef _WIN32 + return atanh(x); +#else + return 0.5*log((1.0+x)/(1.0-x)); +#endif + } + // routines for conversion to string // ================================= @@ -302,13 +319,6 @@ namespace Helpers { // ============= void plot(std::vector<double> &values, int numRows = 7, int numCols = 20, std::string symbol = "*"); - - // process_mem_usage(double &, double &) - takes two doubles by reference, - // attempts to read the system-dependent data for a process' virtual memory - // size and resident set size, and return the results in KB. - // - // On failure, returns 0.0, 0.0 - void process_mem_usage(double& vm_usage, double& resident_set); inline long getMicroTimestamp() { using namespace boost::posix_time; diff --git a/extensions/MetaTools.h b/extensions/MetaTools.h index 4e52c46508659226bf2a849c56d176a3e0420808..89a15980dbdf50d77d1de2f7d1a70647c9b67c5d 100644 --- a/extensions/MetaTools.h +++ b/extensions/MetaTools.h @@ -208,6 +208,7 @@ namespace tools { /// \brief /// template to compute the Nth root of a via iteration /// +#ifndef _WIN32 template <int a, int N, int I=1> struct Root { // instantiate next step or result type as branch @@ -230,7 +231,7 @@ namespace tools { BOOST_STATIC_CONSTANT(int, value = 0 ); }; /**@}*/ - +#endif // ______________________________________________________________________________________________________ // monomials and polynomials @@ -340,7 +341,7 @@ namespace tools { // ______________________________________________________________________________________________________ // Bezier-Polynomial - +#ifndef _WIN32 namespace details { // sum_{I=0}^N B_I^N(x)*c_I @@ -426,7 +427,7 @@ namespace tools { private: Coefficients& coefficients; // p in points is element of result_type }; - +#endif // ______________________________________________________________________________________________________ // for loops: for<i, n [,{incr,decr}]>, for<mpl::range_c>, for<mpl::vector_c> diff --git a/extensions/PhaseFieldConvert.h b/extensions/PhaseFieldConvert.h index b8d5143f5f70ef1a79f41e957cd7975f85fa669a..cc3e5205e174d195bf3d696a1e9a93da78dd3686 100644 --- a/extensions/PhaseFieldConvert.h +++ b/extensions/PhaseFieldConvert.h @@ -3,6 +3,8 @@ #ifndef PHASE_FIELD_CONVERT_H #define PHASE_FIELD_CONVERT_H +#include "Helpers.h" + using namespace AMDiS; /// \brief @@ -180,7 +182,7 @@ struct PhaseFieldToSignedDist : AbstractFunction<double, double> double operator()(const double &phi) const { double z = std::max(-1.0 + 1.e-12, std::min(1.0 - 1.e-12, -phi)); - return (epsilon/scalingFactor) * atanh(z); + return (epsilon/scalingFactor) * Helpers::atanh(z); } private: diff --git a/extensions/SignedDistFunctors.h b/extensions/SignedDistFunctors.h index 8bdb629e80df07df0f80406ad38f5fba12f1e008..74c508ce0392a2c44677fdffa8a36a42381f06f7 100644 --- a/extensions/SignedDistFunctors.h +++ b/extensions/SignedDistFunctors.h @@ -50,7 +50,7 @@ static double signedDist2D(const WorldVector<double> x, const WorldVector<double if (x_trans[0] >= 0.0) { alpha = acos(x_trans[0] / norm_xy); } else { - alpha = 2.0*M_PI - acos(x_trans[0] / norm_xy); + alpha = 2.0*m_pi - acos(x_trans[0] / norm_xy); } return (norm_xy - (*radius)(alpha)); @@ -79,9 +79,9 @@ static double signedDist3D(const WorldVector<double> x, const WorldVector<double if(x_trans[1]>=0) { alpha = acos(x_trans[0]/norm_xy); } else { - alpha = 2.0*M_PI - acos(x_trans[0]/norm_xy); + alpha = 2.0*m_pi - acos(x_trans[0]/norm_xy); } - beta = 0.5*M_PI - atan(x_trans[2]/norm_xy); + beta = 0.5*m_pi - atan(x_trans[2]/norm_xy); return (norm_xyz - (*radius)(alpha, beta)); }; diff --git a/extensions/VectorOperations.h b/extensions/VectorOperations.h index de102970327c92dfb66facc4301d661e305f26a9..87548ef26d86e695fe732da5a0388be3ef857649 100644 --- a/extensions/VectorOperations.h +++ b/extensions/VectorOperations.h @@ -10,7 +10,6 @@ #include "parallel/StdMpi.h" #endif -#include <unistd.h> #include <ios> #include <iostream> #include <fstream> @@ -192,7 +191,8 @@ namespace vector_operations { { typedef void matrix_void_type; void operator()(WorldMatrix<Value>& v, size_t r, size_t c) { - TEST_EXIT(Global::getGeo(WORLD) == r && Global::getGeo(WORLD) == c) + size_t dow = static_cast<size_t>(Global::getGeo(WORLD)); + TEST_EXIT(dow == r && dow == c) ("WorldMatrices can not be resized!\n"); } }; @@ -589,14 +589,14 @@ namespace vector_operations { std::vector<pair<T1,T2> > order(vec1.size()); // create vector of pairs - for (int i=0; i<vec1.size(); ++i) + for (size_t i=0; i<vec1.size(); ++i) order[i] = make_pair(vec1[i], vec2[i]); // sort vector of pairs sort(order.begin(), order.end(), comp); // copy sorted pairs back to vectors - for (int i=0; i<vec1.size(); ++i) { + for (size_t i=0; i<vec1.size(); ++i) { vec1[i] = order[i].first; vec2[i] = order[i].second; }