40 for(std::vector<double>::iterator it =
cellN_.begin(); it !=
cellN_.end(); ++it)
60 for(std::vector<double>::iterator it =
cellN_.begin(); it !=
cellN_.end(); ++it)
68 std::cout <<
"rMin=" <<
rMin_ <<
" rMax=" <<
rMax_ <<
" NParticles=" << numParticles << std::endl;
69 for(
unsigned int i = 0; i <
cellN_.size(); i++)
71 std::cout <<
"From" << std::setw(8) <<
cell2Min(i) <<
" to" << std::setw(8) <<
cell2Max(i) <<
" number=" << std::setw(5) <<
cellN_[i] << std::endl;
73 std::cout <<
"Domain size [" << problem.
getXMin() <<
"," << problem.
getXMax() <<
"]x[" << problem.
getYMin() <<
"," << problem.
getYMax() <<
"]x[" << problem.
getZMin() <<
"," << problem.
getZMax() <<
"]" << std::endl;
75 for(
unsigned int i = 0; i <
intCellN.size() - 1; i++)
77 std::cout <<
"From" << std::setw(8) <<
intCell2Min(i) <<
" to" << std::setw(8) <<
intCell2Max(i) <<
" linear from " << std::setw(8) <<
intCellN[i] <<
" to " << std::setw(8) <<
intCellN[i + 1] << std::endl;
107 for(std::vector<double>::iterator it =
cellN_.begin(); it !=
cellN_.end(); ++it)
112 rMin_ = nextafter(1, 0.0);
113 rMax_ = nextafter(omega, std::numeric_limits<double>::max());
114 for(
unsigned int i = 0; i <
cellN_.size(); i++)
118 for(
unsigned int j = 0; j < coeff.size(); j++)
120 cellN_[i] += coeff[j] / (1.0 + j) * (std::pow(end, j + 1) - std::pow(start, j + 1));
125 for(std::vector<double>::iterator it =
cellN_.begin(); it !=
cellN_.end(); ++it)
136 std::cout <<
"rMin=" <<
rMin_ <<
" rMax=" <<
rMax_ << std::endl;
137 for(
unsigned int i = 0; i <
cellN_.size(); i++)
139 std::cout <<
"From" << std::setw(8) <<
cell2Min(i) <<
" to" << std::setw(8) <<
cell2Max(i) <<
" number=" << std::setw(5) <<
cellN_[i] << std::endl;
142 for(
unsigned int i = 0; i <
intCellN.size() - 1; i++)
144 std::cout <<
"From" << std::setw(8) <<
intCell2Min(i) <<
" to" << std::setw(8) <<
intCell2Max(i) <<
" linear from " << std::setw(8) <<
intCellN[i] <<
" to " << std::setw(8) <<
intCellN[i + 1] << std::endl;
158 if(r < rMin_ || r >=
rMax_)
166 if(r < rMin_ || r >=
rMax_)
208 return(a / (p + 2) * (std::pow(end, p + 2) - std::pow(start, p + 2)) + b / (p + 1) * (std::pow(end, p + 1) - std::pow(start, p + 1)));
220 double numerator = 0;
221 if(startCell == endCell)
223 numerator =
pdfIntCell(start, end, startCell, p);
225 else if(endCell < startCell)
233 for(
unsigned int i = startCell + 1; i < endCell; i++)
241 double denominator = 0;
242 for(
unsigned int i = 0; i <=
numCells_; i++)
247 return numerator / denominator;
254 double denominator = 0;
255 for(
unsigned int i = 0; i <=
numCells_; i++)
261 return(a * std::pow(x, p + 1) + b * std::pow(x, p)) / denominator;
270 double min = std::pow(2.0 * (r + h) / h, p) * (a * p * r - a * h + a * r + b * p + 2 * b) * (r + h) / ((p + 1) * (p + 2));
272 double plus = std::pow(2.0 * (r + h) / h, p) * (a * p * r - a * h + a * r + b * p + 2 * b) * (r + h) / ((p + 1) * (p + 2));
283 double min = (-2.0 * r / h / h * p * std::pow(2.0 * r / h + 2.0, p - 1) * (a * p * r - a * h + a * r + b * p + 2 * b) * (r + h) +
284 -std::pow(2.0 * r / h + 2.0, p) * a * (r + h) +
285 std::pow(2.0 * r / h + 2.0, p) * (a * p * r - a * h + a * r + b * p + 2 * b)) / ((p + 1) * (p + 2));
288 double plus = (-2.0 * r / h / h * p * std::pow(2.0 * r / h + 2.0, p - 1) * (a * p * r - a * h + a * r + b * p + 2 * b) * (r + h) +
289 -std::pow(2.0 * r / h + 2.0, p) * a * (r + h) +
290 std::pow(2.0 * r / h + 2.0, p) * (a * p * r - a * h + a * r + b * p + 2 * b)) / ((p + 1) * (p + 2));
298 return(a / 2.0 * (pow(end, 2) - pow(start, 2)) + b * (pow(end, 1) - pow(start, 1)));
310 double numerator = 0;
311 double denominator = 0;
312 if(startCell == endCell)
321 for(
unsigned int i = startCell + 1; i < endCell; i++)
331 return numerator / denominator;
340 double numerator = 0;
341 double denominator = 0;
346 double diffTeller = -(2.0 / h * p * std::pow(2.0 * (start + h) / h, p - 1) * (a * p * start - a * h + a * start + b * p + 2 * b) * (start + h) / ((p + 1) * (p + 2)) +
347 std::pow(2.0 * (start + h) / h, p) * (a * p + a) * (start + h) / ((p + 1) * (p + 2)) +
348 std::pow(2.0 * (start + h) / h, p) * (a * p * start - a * h + a * start + b * p + 2 * b) / ((p + 1) * (p + 2)));
349 double diffNoemer = -(a * start + b);
350 if(startCell == endCell)
359 for(
unsigned int i = startCell + 1; i < endCell; i++)
369 return(diffTeller * denominator - numerator * diffNoemer) / (denominator * denominator);
377 double numerator = 0;
378 double denominator = 0;
383 double diffTeller = (2.0 / h * p * std::pow(2.0 * (end + h) / h, p - 1) * (a * p * end - a * h + a * end + b * p + 2 * b) * (end + h) / ((p + 1) * (p + 2)) +
384 std::pow(2.0 * (end + h) / h, p) * (a * p + a) * (end + h) / ((p + 1) * (p + 2)) +
385 std::pow(2.0 * (end + h) / h, p) * (a * p * end - a * h + a * end + b * p + 2 * b) / ((p + 1) * (p + 2)));
386 double diffNoemer = (a * end + b);
387 if(startCell == endCell)
396 for(
unsigned int i = startCell + 1; i < endCell; i++)
406 return(diffTeller * denominator - numerator * diffNoemer) / (denominator * denominator);
414 double denominator = 0;
415 double diffTeller = 0;
417 if(startCell == endCell)
426 for(
unsigned int i = startCell + 1; i < endCell; i++)
434 return diffTeller / denominator;
439 unsigned int NLevels = hGridCellSizes.size() - 1;
440 unsigned int NParams = hGridCellSizes.size();
444 std::cout <<
"Length scale=" <<
length_ << std::endl;
448 std::cout <<
"Level sizes:";
449 for(
unsigned int i = 0; i < NParams; i++)
451 std::cout <<
" " << hGridCellSizes[i];
453 std::cout << std::endl;
456 std::vector<double> particlesPerLevel;
457 for(
unsigned int i = 0; i < NLevels; i++)
459 particlesPerLevel.push_back(
pdfInt(0.5 * hGridCellSizes[i], 0.5 * hGridCellSizes[i + 1], 0));
460 if(particlesPerLevel.back() < 0)
462 particlesPerLevel.back() = 0;
467 std::cout <<
"Particles per level: ";
468 for(
unsigned int i = 0; i < NLevels; i++)
470 std::cout <<
" " << particlesPerLevel[i];
472 std::cout << std::endl;
476 std::vector<std::vector<double> > diffParticlesPerLevel;
477 diffParticlesPerLevel.resize(NLevels);
478 for(
unsigned int i = 0; i < NLevels; i++)
480 for(
unsigned int j = 0; j < NParams; j++)
482 diffParticlesPerLevel[i].push_back(0.0);
485 diffParticlesPerLevel[i][j] += -0.5 *
diffPdfInt(0.5 * hGridCellSizes[i], 0);
489 diffParticlesPerLevel[i][j] += 0.5 *
diffPdfInt(0.5 * hGridCellSizes[i + 1], 0);
495 std::cout <<
"Diff Particles per level: " << std::endl;
496 for(
unsigned int i = 0; i < NLevels; i++)
498 for(
unsigned int j = 0; j < NParams; j++)
500 std::cout <<
" " << std::setw(12) << diffParticlesPerLevel[i][j];
502 std::cout << std::endl;
506 std::vector<double> cellsPerLevel;
507 for(
unsigned int i = 0; i < NLevels; i++)
513 std::cout <<
"Cells per level: ";
514 for(
unsigned int i = 0; i < NLevels; i++)
516 std::cout <<
" " << cellsPerLevel[i];
518 std::cout << std::endl;
522 std::vector<std::vector<double> > diffCellsPerLevel;
523 diffCellsPerLevel.resize(hGridCellSizes.size());
524 for(
unsigned int i = 0; i < NLevels; i++)
526 for(
unsigned int j = 0; j < NParams; j++)
534 diffCellsPerLevel[i].push_back(0.0);
540 std::cout <<
"Diff Cells per level: " << std::endl;
541 for(
unsigned int i = 0; i < NLevels; i++)
543 for(
unsigned int j = 0; j < NParams; j++)
545 std::cout <<
" " << std::setw(12) << diffCellsPerLevel[i][j];
547 std::cout << std::endl;
551 std::vector<double> particlesPerCell;
552 for(
unsigned int i = 0; i < NLevels; i++)
554 particlesPerCell.push_back(particlesPerLevel[i] / cellsPerLevel[i]);
558 std::cout <<
"Particles per cell: ";
559 for(
unsigned int i = 0; i < particlesPerCell.size(); i++)
561 std::cout <<
" " << particlesPerCell[i];
563 std::cout << std::endl;
567 std::vector<std::vector<double> > diffParticlesPerCell;
568 diffParticlesPerCell.resize(NLevels);
569 for(
unsigned int i = 0; i < NLevels; i++)
571 for(
unsigned int j = 0; j < NParams; j++)
573 diffParticlesPerCell[i].push_back((diffParticlesPerLevel[i][j] * cellsPerLevel[i] - particlesPerLevel[i] * diffCellsPerLevel[i][j]) / (cellsPerLevel[i] * cellsPerLevel[i]));
578 std::cout <<
"Diff Particles per Cell: " << std::endl;
579 for(
unsigned int i = 0; i < NLevels; i++)
581 for(
unsigned int j = 0; j < NParams; j++)
583 std::cout <<
" " << std::setw(12) << diffParticlesPerCell[i][j];
585 std::cout << std::endl;
589 double contactWork = 0, overheadWork = 0;
590 std::vector<double> diffContactWork;
591 std::vector<double> diffOverheadWork;
592 diffContactWork.resize(NParams);
593 diffOverheadWork.resize(NParams);
594 for(
unsigned int j = 0; j < NParams; j++)
596 diffContactWork[j] = 0;
597 diffOverheadWork[j] = 0;
600 for(
unsigned int i = 0; i < NLevels; i++)
602 contactWork += 0.5 * pow(3,
dimension_) * particlesPerCell[i] * particlesPerLevel[i];
603 overheadWork += 0.5 * (pow(3,
dimension_) + 1) * particlesPerLevel[i];
604 for(
unsigned int j = 0; j < NParams; j++)
606 diffContactWork[j] += 0.5 * pow(3,
dimension_) * (diffParticlesPerCell[i][j] * particlesPerLevel[i] + particlesPerCell[i] * diffParticlesPerLevel[i][j]);
607 diffOverheadWork[j] += 0.5 * (pow(3,
dimension_) + 1) * diffParticlesPerLevel[i][j];
610 unsigned int startJ, endJ;
626 for(
unsigned int j = startJ; j < endJ; j++)
628 double numberOfCellToCheck;
631 std::vector<double> diffNumberOfCellToCheck;
632 for(
unsigned int k = 0; k < NParams; k++)
634 diffNumberOfCellToCheck.push_back(0.0);
648 contactWork += particlesPerLevel[i] * numberOfCellToCheck * particlesPerCell[j];
649 overheadWork += particlesPerLevel[i] * numberOfCellToCheck;
651 for(
unsigned int k = 0; k < NParams; k++)
653 diffContactWork[k] += (diffParticlesPerLevel[i][k] * numberOfCellToCheck * particlesPerCell[j] + particlesPerLevel[i] * diffNumberOfCellToCheck[k] * particlesPerCell[j] + particlesPerLevel[i] * numberOfCellToCheck * diffParticlesPerCell[j][k]);
654 diffOverheadWork[k] += (diffParticlesPerLevel[i][k] * numberOfCellToCheck + particlesPerLevel[i] * diffNumberOfCellToCheck[k]);
660 std::cout <<
"Contact work: " << contactWork << std::endl;
663 std::cout <<
"diff Contactwork: ";
664 for(
unsigned int j = 0; j < NParams; j++)
666 std::cout <<
" " << diffContactWork[j];
668 std::cout << std::endl;
669 std::cout <<
"diff Overheadwork: ";
670 for(
unsigned int j = 0; j < NParams; j++)
674 std::cout << std::endl;
675 std::cout <<
"diff sum: ";
676 for(
unsigned int j = 0; j < NParams; j++)
680 std::cout << std::endl;
683 for(
unsigned int j = 0; j < NParams; j++)
691 unsigned int NLevels = hGridCellSizes.size() - 1;
692 unsigned int NParams = hGridCellSizes.size();
696 std::cout <<
"Length scale=" <<
length_ << std::endl;
700 std::cout <<
"Level sizes:" << std::endl;
701 for(
unsigned int i = 0; i < NParams; i++)
703 std::cout << std::setw(10) << hGridCellSizes[i] <<
" ";
705 std::cout << std::endl;
708 std::vector<double> particlesPerLevel;
709 for(
unsigned int i = 0; i < NLevels; i++)
711 particlesPerLevel.push_back(
pdfInt(0.5 * hGridCellSizes[i], 0.5 * hGridCellSizes[i + 1], 0));
712 if(particlesPerLevel.back() < 0)
714 particlesPerLevel.back() = 0;
719 std::cout <<
"Particles per level:" << std::endl;
720 for(
unsigned int i = 0; i < NLevels; i++)
722 std::cout << std::setw(10) << particlesPerLevel[i] <<
" ";
724 std::cout << std::endl;
727 std::vector<double> cellsPerLevel;
728 for(
unsigned int i = 0; i < NLevels; i++)
734 std::cout <<
"Cells per level:" << std::endl;
735 for(
unsigned int i = 0; i < NLevels; i++)
737 std::cout << std::setw(10) << cellsPerLevel[i] <<
" ";
739 std::cout << std::endl;
742 std::vector<double> particlesPerCell;
743 for(
unsigned int i = 0; i < NLevels; i++)
745 particlesPerCell.push_back(particlesPerLevel[i] / cellsPerLevel[i]);
749 std::cout <<
"Particles per cell:" << std::endl;
750 for(
unsigned int i = 0; i < particlesPerCell.size(); i++)
752 std::cout << std::setw(10) << particlesPerCell[i] <<
" ";
754 std::cout << std::endl;
757 std::vector<std::vector<double> > contactWork;
758 std::vector<std::vector<double> > overheadWork;
759 contactWork.resize(NLevels);
760 overheadWork.resize(NLevels);
761 for(
unsigned int i = 0; i < NLevels; i++)
763 contactWork[i].resize(NLevels);
764 overheadWork[i].resize(NLevels);
765 for(
unsigned int j = 0; j < NLevels; j++)
767 contactWork[i][j] = 0;
768 overheadWork[i][j] = 0;
772 for(
unsigned int i = 0; i < NLevels; i++)
774 contactWork[i][i] += 0.5 * pow(3,
dimension_) * particlesPerCell[i] * particlesPerLevel[i];
775 overheadWork[i][i] += 0.5 * (pow(3,
dimension_) + 1) * particlesPerLevel[i];
777 unsigned int startJ, endJ;
793 for(
unsigned int j = startJ; j < endJ; j++)
795 double numberOfCellToCheck;
797 contactWork[i][j] += particlesPerLevel[i] * numberOfCellToCheck * particlesPerCell[j];
798 overheadWork[i][j] += particlesPerLevel[i] * numberOfCellToCheck;
803 double totalContactWork = 0, totalOverheadWork = 0;
804 for(
unsigned int i = 0; i < NLevels; i++)
806 for(
unsigned int j = 0; j < NLevels; j++)
808 totalContactWork += contactWork[i][j];
809 totalOverheadWork += overheadWork[i][j];
815 std::cout <<
"Contact work: " << totalContactWork << std::endl;
816 for(
unsigned int i = 0; i < NLevels; i++)
818 for(
unsigned int j = 0; j < NLevels; j++)
820 std::cout << std::setw(10) << contactWork[i][j] <<
" ";
822 std::cout << std::endl;
824 std::cout <<
"Overhead work: " << totalOverheadWork << std::endl;
825 for(
unsigned int i = 0; i < NLevels; i++)
827 for(
unsigned int j = 0; j < NLevels; j++)
829 std::cout << std::setw(10) << overheadWork[i][j] <<
" ";
831 std::cout << std::endl;
833 std::cout <<
"Total work: " << totalContactWork + totalOverheadWork << std::endl;
842 std::cout <<
"calcDfDx" << std::endl;
844 double W =
calculateWork(hGridCellSizes, method, verbosity - 1);
848 for(
unsigned int i = 0; i < hGridCellSizes.size(); i++)
850 hGridCellSizes[i] += dx;
852 dfdx.push_back((nW - W) / dx);
853 hGridCellSizes[i] -= dx;
856 std::cout <<
"i=" << i <<
" Value=" << hGridCellSizes[i] <<
" Change=" << nW - W <<
" dfdx=" << dfdx.back() << std::endl;
865 std::cout <<
"checkLimits part 1 remove levels" << std::endl;
870 for(
unsigned int i = 1; i < hGridCellSizes.size(); i++)
872 if(std::abs(hGridCellSizes[i - 1] - hGridCellSizes[i]) < 1e-6)
874 if(dfdx[i - 1] < dfdx[i])
878 std::cout <<
"Remove level" << i << std::endl;
880 if(i > 0.5 * hGridCellSizes.size())
882 hGridCellSizes.erase(hGridCellSizes.begin() + i - 1);
883 dfdx.erase(dfdx.begin() + i - 1);
887 hGridCellSizes.erase(hGridCellSizes.begin() + i);
888 dfdx.erase(dfdx.begin() + i);
897 std::cout <<
"checkLimits part 2 calculate limit" << std::endl;
898 for(
unsigned int i = 0; i < hGridCellSizes.size(); i++)
900 std::cout <<
"i=" << i <<
" Value=" << hGridCellSizes[i] <<
" dfdx=" << dfdx[i] << std::endl;
903 double maxStepSize = -std::numeric_limits<double>::max();
905 for(
unsigned int i = 1; i < hGridCellSizes.size(); i++)
907 nmax = (hGridCellSizes[i - 1] - hGridCellSizes[i]) / (dfdx[i] - dfdx[i - 1]);
910 std::cout <<
"Max f=" << nmax <<
" because otherwise " << hGridCellSizes[i - 1] <<
"+x*" << dfdx[i - 1] <<
">" << hGridCellSizes[i] <<
"+x*" << dfdx[i] << std::endl;
914 maxStepSize = std::max(nmax, maxStepSize);
919 std::cout <<
"maxStepSize=" << maxStepSize << std::endl;
928 std::cout <<
"Apply step:" << std::endl;
930 for(
unsigned int i = 0; i < hGridCellSizes.size() - 1; i++)
932 hGridCellSizes[i] += stepsize * dfdx[i];
935 std::cout <<
"hGridCellSizes[i]" <<
"+" << stepsize <<
"*" << dfdx[i] <<
"=" << hGridCellSizes[i] << std::endl;
942 std::vector<double> curHGridCellSizes = startHGridCellSizes;
943 std::vector<double> xHGridCellSizes = startHGridCellSizes;
945 applyStep(curHGridCellSizes, searchDirection, cur, verbosity - 1);
946 double curWork =
calculateWork(curHGridCellSizes, method, verbosity - 1);
949 double resphi = 2.0 - 0.5 * (1 + std::sqrt(5));
952 if(max - cur > cur - min)
955 x = cur + resphi * (max - cur);
960 x = cur - resphi * (cur - min);
963 if(std::abs(max - min) < 1e-7 * (std::abs(cur) + std::abs(x)))
965 return 0.5 * (min + max);
968 applyStep(xHGridCellSizes, searchDirection, x, 0);
972 std::cout <<
"min=" << min <<
" max=" << max <<
" cur=" << cur <<
" curWork=" << curWork <<
" x=" << x <<
" xWork=" << xWork << std::endl;
976 if(max - cur > cur - min)
978 return goldenSectionSearch(startHGridCellSizes, searchDirection, cur, x, max, method, verbosity);
982 return goldenSectionSearch(startHGridCellSizes, searchDirection, min, x, cur, method, verbosity);
987 if(max - cur > cur - min)
989 return goldenSectionSearch(startHGridCellSizes, searchDirection, min, cur, x, method, verbosity);
993 return goldenSectionSearch(startHGridCellSizes, searchDirection, x, cur, max, method, verbosity);
1000 hGridCellSizes.clear();
1001 for(
unsigned int i = 0; i <= numberOfLevels; i++)
1003 hGridCellSizes.push_back(2.0 * (
rMin_ + (
rMax_ -
rMin_) * i / numberOfLevels));
1006 std::vector<double> dfdx;
1007 double step, max, W, oW;
1014 max =
checkLimit(hGridCellSizes, dfdx, verbosity - 3);
1015 step =
goldenSectionSearch(hGridCellSizes, dfdx, max, 0.5 * max, 0, method, verbosity - 2);
1016 applyStep(hGridCellSizes, dfdx, step, verbosity - 3);
1022 std::cout << stepNumber <<
" Bad step, trying closer search range" << std::endl;
1024 applyStep(hGridCellSizes, dfdx, -step, verbosity - 3);
1026 step =
goldenSectionSearch(hGridCellSizes, dfdx, max, 0.5 * max, 0, method, verbosity - 2);
1027 applyStep(hGridCellSizes, dfdx, step, verbosity - 3);
1033 std::cout << stepNumber <<
" Correct step: old work=" << oW <<
" new work=" << W <<
" difference=" << oW - W <<
" step=" << step / max << std::endl;
1036 while(oW - W > 1e-13 && stepNumber);
1040 std::cout <<
"Work=" << W << std::endl;
1041 std::cout <<
"Optimal cell sizes:";
1042 for(
unsigned int i = 0; i < hGridCellSizes.size(); i++)
1044 std::cout <<
" " << hGridCellSizes[i];
1046 std::cout << std::endl;
1052 unsigned int NLevels = hGridCellSizes.size() - 1;
1054 std::vector<double> particlesPerLevel;
1055 for(
unsigned int i = 0; i < NLevels; i++)
1057 particlesPerLevel.push_back(
pdfInt(0.5 * hGridCellSizes[i], 0.5 * hGridCellSizes[i + 1], 0));
1058 if(particlesPerLevel.back() < 0)
1060 particlesPerLevel.back() = 0;
1064 std::vector<double> cellsPerLevel;
1065 for(
unsigned int i = 0; i < NLevels; i++)
1070 for(
unsigned int i = 0; i < NLevels; i++)
1072 double l = particlesPerLevel[i] / cellsPerLevel[i];
1073 std::cout <<
"Histogram for level " << i <<
":";
1074 for(
unsigned int k = 0; k <= 10; k++)
1078 std::cout << std::endl;
double goldenSectionSearch(std::vector< double > &startHGridCellSizes, std::vector< double > &searchDirection, double min, double cur, double max, HGridMethod method, int verbosity)
BaseParticle * getLargestParticle() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
void getOptimalDistribution(std::vector< double > &hGridCellSizes, unsigned int numberOfLevels, HGridMethod method, int verbosity)
double diffPdfInt(double x, int power)
diff(int(f(r)*r^power*dr,r=s..e)/int(f(r)*dr,r=0..omega),e)=f(e)*e^power/int(f(r)*dr,r=0..omega)
double cell2Min(unsigned int i)
Computes the left bound of the cell with given ordinal number.
unsigned int getSystemDimensions() const
Returns the dimension of the simulation. Note there is also a particle dimension. ...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void initialisePolyFunc(double omega, std::vector< double > &coeff, unsigned int numberOfCells, int verbosity)
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
double calculateWork(std::vector< double > &hGridCellSizes, HGridMethod method, int verbosity)
The amount of work that has to be done to run a simulation using the HGrid, in steps.
double length_
The weighted length of the domain.
double diffStartExpectedCellsIntegral(double start, double end, int p, double h)
Mdouble exp(Mdouble Exponent)
double intCell2Min(unsigned int i)
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
double cell2Max(unsigned int i)
Computes the right bound of the cell with given ordinal number.
double intCell2Max(unsigned int i)
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
void initialise(const MercuryBase &problem, unsigned int numberOfCells, int verbosity)
HGridMethod
Enum class that indicates how particles in different levels (cross level checking) of the HGrid are c...
double expectedCellsIntegral(double start, double end, int p, double h)
This function calculates: int((2*r/h+2)^d f(r) dr,r=s..e)/int(f(r) dr,r=s..e)+ Used to calculated the...
void calculateDiffWork(std::vector< double > &hGridCellSizes, std::vector< double > &dfdx, HGridMethod method, int verbosity)
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
void histNumberParticlesPerCell(std::vector< double > &hGridCellSizes)
double diffHExpectedCellsIntegralCellNumerator(double start, double end, unsigned int i, int p, double h)
constexpr T factorial(const T t)
factorial function
void calcDfDx(std::vector< double > &hGridCellSizes, std::vector< double > &dfdx, HGridMethod method, int verbosity)
BaseParticle * getSmallestParticle() const
Gets a pointer to the smallest BaseParticle (by interactionRadius) in this ParticleHandler.
double rMax_
Radius of the largest particle, "rounded" to the smallest double that is larger than the radius of ea...
double expectedCellsIntegralCellDenominator(double start, double end, unsigned int i)
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
double checkLimit(std::vector< double > &hGridCellSizes, std::vector< double > &dfdx, int verbosity)
std::vector< double > cellN_
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
void applyStep(std::vector< double > &hGridCellSizes, std::vector< double > &dfdx, double stepsize, int verbosity)
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
double rMin_
Radius of the smallest particle, "rounded" to the largest double that is smaller than the radius of e...
std::vector< double > intCellN
unsigned int dimension_
The dimension of the system, usually 3, sometimes 2 or 1.
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
double cellCheckOverContactCheckRatio_
The ratio of the time required for a single geometric contact detection over the time required to ret...
double diffHExpectedCellsIntegral(double start, double end, int p, double h)
unsigned int radius2Cell(double r)
Assigns a BaseParticle of given radius to a certain cell.
double pdfIntCell(double start, double end, unsigned int i, int p)
double pdfInt(double start, double end, int power)
This function calculates: int(f(r)*r^power*dr,r=start..end)/int(f(r)*dr,r=0..omega) with r=a*r+b...
Mdouble getInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
double expectedCellsIntegralCellNumerator(double start, double end, unsigned int i, int p, double h)
unsigned int numCells_
Number of cells, usually called levels in the HGrid.
double diffEndExpectedCellsIntegral(double start, double end, int p, double h)
unsigned int radius2IntCell(double r)