-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCell.cpp
More file actions
78 lines (69 loc) · 1.66 KB
/
Copy pathCell.cpp
File metadata and controls
78 lines (69 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
Author: Blake
Date: 11/8/17
*/
#include "Cell.h"
double Cell::distToCollision(Part_ptr pi)
{
double total_xs = mat->getMacroXS(pi);
double dist = -log(Urand())/total_xs;
return dist;
}
bool Cell::amIHere( const point& pos )
{
bool isWithin = true;
//cycle through each surface and if there is one that has a incorrect eval, you are not in this cell
for(auto surfacePair: surfacePairs)
{
bool posInSurface = (surfacePair.first->eval(pos) < 0); //is the position inside(true) or out of the surface
bool cellInSurface = surfacePair.second;
bool match = posInSurface == cellInSurface;
isWithin = isWithin == match;
}
return isWithin;
}
pair<Surf_ptr, double> Cell::closestSurface(Part_ptr p)
{
Surf_ptr min_surf = nullptr;
double min_val = std::numeric_limits<double>::max();
point pos = p->getPos();
point dir = p->getDir();
for(auto bound: surfacePairs)
{
Surf_ptr cur_surf = bound.first;
double dist = cur_surf->distance(pos,dir);
if(dist < min_val && dist > 0)
{
min_surf = cur_surf;
min_val = dist;
}
}
if(min_surf == nullptr)
{
p->printState();
std::cerr << "ERROR: NO SURFACE FOUND" << std::endl;
std::exit(1);
}
return make_pair(min_surf, min_val);
}
double Cell::distToSurface(Part_ptr pi)
{
Surf_ptr close_surface;
double dist;
tie(close_surface,dist) = closestSurface(pi);
return dist;
}
// Estimator interface
void Cell::scoreTally(Part_ptr p , double xs)
{
// for each EstimatorCollection
// for each attribute
// get the index of the Estimator to score
// score the estimator
}
void Cell::endTallyHist()
{
for(auto est : estimators) {
est->endHist();
}
}