Commit 0e6ef10a authored by Praetorius, Simon's avatar Praetorius, Simon

windows compatibility changes

parent 3d5c3720
......@@ -2,6 +2,8 @@
#include "VectorOperations.h" // getMin, sort, CompairPair
#include "Initfile.h"
#include <boost/math/special_functions/round.hpp>
namespace experimental {
std::map<const FiniteElemSpace*, std::pair<int, Box*> > Box::boxMap;
......@@ -66,7 +68,7 @@ namespace experimental {
bool Box::inBox(const PointType& x)
{
for (size_t i = 0; i < DOW; i++)
for (int i = 0; i < DOW; i++)
if (min_corner[i] > x[i] || max_corner[i] < x[i])
return false;
return true;
......@@ -85,7 +87,7 @@ namespace experimental {
int Box::getBox(const PointType& x)
{
std::vector<int> idx(DOW);
for (size_t i = 0; i < DOW; i++)
for (int i = 0; i < DOW; i++)
idx[i] = static_cast<int>((x[i]-min_corner[i])*N[i]/(max_corner[i]-min_corner[i]));
// idx[i] = static_cast<int>(floor((x[i]-min_corner[i])*N[i]/(max_corner[i]-min_corner[i])));
return idx2nr(idx);
......@@ -131,7 +133,7 @@ namespace experimental {
std::vector<double> distances;
std::set<int>::iterator nrIter;
int level = 0;
for (int level = 0; data.size() < nData && nrs.size() > 0; level++) {
for (int level = 0; static_cast<int>(data.size()) < nData && nrs.size() > 0; level++) {
int oldDataSize = data.size();
for (nrIter = nrs.begin(); nrIter != nrs.end(); nrIter++) {
data.insert(data.end(), boxData[*nrIter].begin(), boxData[*nrIter].end());
......@@ -140,8 +142,8 @@ namespace experimental {
if (addon > 0) {
// 1.) bestimme Abstand zu x
int n = distances.size();
TEST_EXIT(n + addon == data.size() && oldDataSize == n)("hier ist ein Index falsch: distances.size = %d, addon = %d, data.size = %d, oldDataSize = %d!\n",n,addon,data.size(),oldDataSize);
for (size_t i = 0; i < addon; i++) {
TEST_EXIT(n + addon ==static_cast<int>(data.size()) && oldDataSize == n)("hier ist ein Index falsch: distances.size = %d, addon = %d, data.size = %d, oldDataSize = %d!\n",n,addon,data.size(),oldDataSize);
for (int i = 0; i < addon; i++) {
distances.push_back(distance2(x, data[n+i].second, DOW));
}
// 2.) sortiere Paare aus dist und data
......@@ -150,7 +152,7 @@ namespace experimental {
}
// 3.) wenn noch nicht genügend Punkte, dann umgebende Boxen mit durchsuchen
if (data.size() < nData
if (static_cast<int>(data.size()) < nData
|| (level == 0 && distances[distances.size()-1] > boxBoundaryDist))
{
getSurroundingBoxes(center_box, level+1, nrs);
......@@ -189,7 +191,7 @@ namespace experimental {
std::vector<int> N_;
int N_sum = 0;
for (int i = 0; i < Global::getGeo(WORLD); i++) {
N_.push_back(static_cast<int>(round(pow(static_cast<double>(N_const),lengths[i]/sum_lengths))));
N_.push_back(boost::math::iround(pow(static_cast<double>(N_const),lengths[i]/sum_lengths)));
N_sum += N_[i];
}
......@@ -218,7 +220,7 @@ namespace experimental {
void Box::init()
{
int maxNr = 1;
for (size_t i = 0; i < DOW; i++)
for (int i = 0; i < DOW; i++)
maxNr *= N[i];
boxData.resize(maxNr);
......@@ -287,8 +289,8 @@ namespace experimental {
break;
case 2:
for (double phi = 0.0; phi < 2.0*m_pi; phi += incr) {
newIdx[0] = idx[0] + static_cast<int>(round(radius*cos(phi)));
newIdx[1] = idx[1] + static_cast<int>(round(radius*sin(phi)));
newIdx[0] = idx[0] + boost::math::iround(radius*cos(phi));
newIdx[1] = idx[1] + boost::math::iround(radius*sin(phi));
if (newIdx[0] >= 0 && newIdx[0] < N[0]
&& newIdx[1] >= 0 && newIdx[1] < N[1])
newNrs.insert(idx2nr(newIdx));
......@@ -297,9 +299,9 @@ namespace experimental {
case 3:
for (double phi = -m_pi; phi < m_pi; phi += incr) {
for (double theta = 0.0; theta < m_pi; theta += incr) {
newIdx[0] = idx[0] + static_cast<int>(round(radius*sin(theta)*cos(phi)));
newIdx[1] = idx[1] + static_cast<int>(round(radius*sin(theta)*sin(phi)));
newIdx[2] = idx[2] + static_cast<int>(round(radius*cos(theta)));
newIdx[0] = idx[0] + boost::math::iround(radius*sin(theta)*cos(phi));
newIdx[1] = idx[1] + boost::math::iround(radius*sin(theta)*sin(phi));
newIdx[2] = idx[2] + boost::math::iround(radius*cos(theta));
if (newIdx[0] >= 0 && newIdx[0] < N[0]
&& newIdx[1] >= 0 && newIdx[1] < N[1]
&& newIdx[2] >= 0 && newIdx[2] < N[2])
......@@ -323,7 +325,7 @@ namespace experimental {
std::vector<int> idx;
nr2idx(nr, idx); // --> idx
for (size_t i = 0; i < DOW; i++) {
for (int i = 0; i < DOW; i++) {
std::vector<int> idx_i = idx;
idx_i[i] = std::min(N[i]-1, idx_i[i]+1);
surrounding_nrs.insert(idx2nr(idx_i));
......@@ -351,7 +353,7 @@ namespace experimental {
std::vector<int> idx;
nr2idx(nr, idx);
PointType min_c, max_c;
for (size_t i = 0; i < DOW; i++) {
for (int i = 0; i < DOW; i++) {
min_c[i] = min_corner[i] + (max_corner[i]-min_corner[i])*idx[i]/N[i];
max_c[i] = min_corner[i] + (max_corner[i]-min_corner[i])*(idx[i]+1)/N[i];
}
......@@ -365,7 +367,7 @@ namespace experimental {
void Box::addData(PointType x, DataType data)
{
int nr = getBox(x);
if (nr < 0 || nr >= boxData.size())
if (nr < 0 || nr >= static_cast<int>(boxData.size()))
throw(std::runtime_error("box-nr out of range: nr = "+boost::lexical_cast<std::string>(nr)+", x = "+boost::lexical_cast<std::string>(x)+", boxSize = "+boost::lexical_cast<std::string>(boxData.size())));
boxData[nr].push_back(data);
}
......
......@@ -412,7 +412,7 @@ double distance_point_triangle_2d(double point[], double tri0[], double tri1[],
bool point_in_polygon(double point[], const std::vector<AMDiS::WorldVector<double> > &vertices) {
bool inside = false;
int i, j;
size_t i, j;
for (i = 0, j = vertices.size()-1; i < vertices.size(); j = i++) {
if ((((vertices[i][1] <= point[1]) && (point[1] < vertices[j][1])) ||
((vertices[j][1] <= point[1]) && (point[1] < vertices[i][1]))) &&
......
......@@ -258,7 +258,7 @@ void getNormals(FiniteElemSpace *feSpace, DOFVector<WorldVector<double> > *norma
Mesh *mesh = feSpace->getMesh();
const BasisFunction *basisFcts = feSpace->getBasisFcts();
int nBasisFcts = basisFcts->getNumber();
size_t nBasisFcts = basisFcts->getNumber();
std::vector<DegreeOfFreedom> localIndices(nBasisFcts);
DOFVector<std::set<DegreeOfFreedom> > neighbors(feSpace, "neighbors");
......@@ -295,11 +295,11 @@ void getNormals(FiniteElemSpace *feSpace, DOFVector<WorldVector<double> > *norma
DOFIterator<std::set<DegreeOfFreedom> > neighborsIter(&neighbors, USED_DOFS); neighborsIter.reset();
for (; !neighborsIter.end(); neighborsIter++, normalsIter++, coordsIter++/*, grdIter++*/)
{
int numPoints = 10; // 6 oder 10
size_t numPoints = 10; // 6 oder 10
std::set<DegreeOfFreedom> idx = *neighborsIter;
std::set<DegreeOfFreedom>::iterator it, it2;
for (int i = 1; i<3 && idx.size() < numPoints; i++) {
for (size_t i = 1; i<3 && idx.size() < numPoints; i++) {
for (it = idx.begin(); it != idx.end() && idx.size() < numPoints; it++) {
for (it2 = (neighbors[*it]).begin(); it2 != (neighbors[*it]).end() && idx.size() < numPoints; it2++) {
idx.insert(*it2);
......@@ -400,41 +400,6 @@ void getCurvature(DOFVector<WorldVector<double> >* normals,DOFVector<double>* cu
}
}
void process_mem_usage(double& vm_usage, double& resident_set)
{
using std::ios_base;
using std::ifstream;
using std::string;
vm_usage = 0.0;
resident_set = 0.0;
// 'file' stat seems to give the most reliable results
//
ifstream stat_stream("/proc/self/stat",ios_base::in);
// dummy vars for leading entries in stat that we don't care about
//
string pid, comm, state, ppid, pgrp, session, tty_nr;
string tpgid, flags, minflt, cminflt, majflt, cmajflt;
string utime, stime, cutime, cstime, priority, nice;
string O, itrealvalue, starttime;
// the two fields we want
//
unsigned long vsize;
long rss;
stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
>> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
>> utime >> stime >> cutime >> cstime >> priority >> nice
>> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest
long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages
vm_usage = vsize / 1024.0;
resident_set = rss * page_size_kb;
}
// plots a vector with ascii-code
void plot(std::vector<double> &values, int numRows, int numCols, std::string symbol)
{
......
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