Skip to content

Commit ec7037a

Browse files
committed
Update to improve calcFirstIntersection performance.
1 parent ffe0ad1 commit ec7037a

File tree

9 files changed

+40
-43
lines changed

9 files changed

+40
-43
lines changed

System/geometry/interPoint.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sortVector(std::vector<interPoint>& IPts)
4747
[](const Geometry::interPoint& A,
4848
const Geometry::interPoint& B)
4949
{
50-
return (A.D > B.D);
50+
return (A.D < B.D);
5151
});
5252
return;
5353
}

System/modelSupport/SimInput.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ processExitChecks(Simulation& System,
190190
if (IParam.flag("validRandom"))
191191
{
192192
// set of used points within the bounding box of the
193-
// object.
193+
// object. NOT COMPLETE
194194
SValidCheck.calcTouch(System);
195195
return errFlag;
196196

197-
const size_t NPts=IParam.getValue<size_t>("validCheck");
197+
// const size_t NPts=IParam.getValue<size_t>("validCheck");
198198
const std::string FCObject=
199199
IParam.getValueError<std::string>("validRandom",0,0,"No FC-object");
200200
const attachSystem::FixedComp* FC=

System/monte/Acomp.cxx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1136,15 +1136,13 @@ Acomp::makePI(std::vector<BnId>& DNFobj) const
11361136
std::vector<BnId> Work; // Working copy
11371137
std::vector<BnId> PIComp; // Store for PI componends
11381138
std::vector<BnId> Tmod; // store modified components
1139-
int changeCount(0); // Number change
1139+
11401140
std::vector<BnId>::iterator uend; // itor to remove unique
11411141
// Need to make an initial copy.
11421142
Work=DNFobj;
11431143

1144-
int cnt(0);
11451144
do
11461145
{
1147-
cnt++;
11481146
// Deal with tri-state objects ??
11491147
sort(Work.begin(),Work.end());
11501148
uend=unique(Work.begin(),Work.end());
@@ -1177,7 +1175,6 @@ Acomp::makePI(std::vector<BnId>& DNFobj) const
11771175
Tmod.push_back(cVal.second);
11781176
oc->setPI(0);
11791177
vc->setPI(0);
1180-
changeCount++; // 1 changed
11811178
}
11821179
}
11831180
}

System/monte/AcompExtra.cxx

-7
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,6 @@ Acomp::expandBracket()
467467
Expand all the Intersection brackets
468468
*/
469469
{
470-
static int cnt(0);
471-
472-
cnt++;
473470
// all lower units
474471
for(Acomp& AC : Comp)
475472
AC.expandBracket();
@@ -864,9 +861,6 @@ Acomp::expandCNFBracket()
864861
{
865862
ELog::RegMethod RegA("Acomp","expandCNFBracket");
866863

867-
static int cnt(0);
868-
cnt++;
869-
870864
// all lower units
871865
for(Acomp& AC : Comp)
872866
AC.expandCNFBracket();
@@ -897,7 +891,6 @@ Acomp::expandCNFBracket()
897891
clearNulls();
898892
}
899893
while(removeUnionPair());
900-
cnt--;
901894
return;
902895
}
903896

System/monte/DBMaterial.cxx

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
* File: monte/DBMaterial.cxx
55
*
6-
* Copyright (c) 2004-2022 by Stuart Ansell
6+
* Copyright (c) 2004-2024 by Stuart Ansell
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by
@@ -46,7 +46,8 @@
4646
#include "MXcards.h"
4747
#include "Material.h"
4848
#include "DBMaterial.h"
49-
49+
#include "neutMaterial.h"
50+
5051
namespace ModelSupport
5152
{
5253

System/monte/HeadRule.cxx

+2
Original file line numberDiff line numberDiff line change
@@ -2965,6 +2965,7 @@ HeadRule::calcFirstIntersection(const Geometry::Vec3D& Org,
29652965
// note SNum is unsigned:
29662966
const int pAB=isValid(inter.Pt,inter.SNum);
29672967
const int mAB=isValid(inter.Pt,-inter.SNum);
2968+
29682969
if (pAB!=mAB) // exiting/entering surface
29692970
{
29702971
// previously used signValue but now gone to
@@ -2979,6 +2980,7 @@ HeadRule::calcFirstIntersection(const Geometry::Vec3D& Org,
29792980
outIP.SNum=signValue*inter.SNum;
29802981
outIP.SPtr=inter.SPtr;
29812982
outIP.outFlag=outGoingFlag;
2983+
return outIP;
29822984
}
29832985
}
29842986
return outIP;

test/testObject.cxx

+8-8
Original file line numberDiff line numberDiff line change
@@ -575,24 +575,24 @@ testObject::testTrackCell()
575575

576576
Tests.push_back(TTYPE("4 10 0.05524655 1 -2 3 -4 5 -6",-2,
577577
Geometry::Vec3D(0,0,0),Geometry::Vec3D(1,0,0),
578-
Geometry::Vec3D(1,0,0)));
578+
Geometry::Vec3D(1,0,0)));
579579

580580
Tests.push_back(TTYPE("4 10 0.05524655 1 -2 3 -4 5 -6",1,
581-
Geometry::Vec3D(0,0,0),Geometry::Vec3D(-1,0,0),
582-
Geometry::Vec3D(-1,0,0)));
581+
Geometry::Vec3D(0,0,0),Geometry::Vec3D(-1,0,0),
582+
Geometry::Vec3D(-1,0,0)));
583583

584584
Tests.push_back(TTYPE("4 10 0.05 11 -12 13 -14 15 -16 (-1:2:-3:4:-5:6)",-16,
585-
Geometry::Vec3D(-2,0,0),Geometry::Vec3D(0,0,1),
586-
Geometry::Vec3D(-2,0,3)));
585+
Geometry::Vec3D(-2,0,0),Geometry::Vec3D(0,0,1),
586+
Geometry::Vec3D(-2,0,3)));
587587

588588
Tests.push_back(TTYPE("4 10 0.05524655 1 -2 3 -4 5 -6",1,
589-
Geometry::Vec3D(-1.01,0,0),Geometry::Vec3D(1,0,0),
590-
Geometry::Vec3D(-1,0,0)));
589+
Geometry::Vec3D(-1.01,0,0),Geometry::Vec3D(1,0,0),
590+
Geometry::Vec3D(-1,0,0)));
591591

592592

593593
Tests.push_back(TTYPE("4 10 0.05524655 1 -2 3 -4 5 -6",-2,
594594
Geometry::Vec3D(3.01,0,0),Geometry::Vec3D(-1,0,0),
595-
Geometry::Vec3D(1,0,0)));
595+
Geometry::Vec3D(1,0,0)));
596596

597597
double aDist;
598598
const Geometry::Surface* SPtr; // Output surface

transport/BandDetector.cxx

+18-14
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,25 @@ namespace Transport
5151

5252

5353
BandDetector::BandDetector() :
54-
Detector(0),nH(0),nV(0),nE(0),Cent(Geometry::Vec3D(0,0,0)),
54+
Detector(0),nH(1),nV(1),nE(1),Cent(Geometry::Vec3D(0,0,0)),
5555
H(Geometry::Vec3D(1,0,0)),V(Geometry::Vec3D(0,0,1)),
5656
hSize(1.0),vSize(1.0),
57-
PlnNorm(Geometry::Vec3D(0,1,0)),PlnDist(0.0)
57+
PlnNorm(Geometry::Vec3D(0,1,0)),PlnDist(0.0),
58+
EData(1,1,1)
5859
/*!
5960
Default constructor
6061
Note that Detector index is unused
6162
*/
6263
{
6364
}
6465

65-
BandDetector::BandDetector(const int Hpts,const int Vpts,const int Epts,
66-
Geometry::Vec3D CV,
67-
const Geometry::Vec3D& Hvec,
68-
const Geometry::Vec3D& Vvec,
69-
const double ES,const double EE) :
66+
BandDetector::BandDetector(const size_t Hpts,
67+
const size_t Vpts,
68+
const size_t Epts,
69+
Geometry::Vec3D CV,
70+
const Geometry::Vec3D& Hvec,
71+
const Geometry::Vec3D& Vvec,
72+
const double ES,const double EE) :
7073
Detector(0),nH(Hpts),nV(Vpts),nE((Epts>0) ? Epts : 1),
7174
Cent(std::move(CV)),H(Hvec.unit()),V(Vvec.unit()),
7275
hSize(Hvec.abs()),vSize(Vvec.abs()),
@@ -181,21 +184,22 @@ BandDetector::setEnergy(const double ES,const double EE)
181184
if (engA>engB)
182185
std::swap(engA,engB);
183186

184-
if (fabs(engB-engA)<1e-7)
187+
if (std::abs(engB-engA)<1e-7)
185188
{
186189
ELog::EM<<"Setting energy gap--too small"<<ELog::endWarn;
187190
return;
188191
}
189-
const double step((engB-engA)/nE);
192+
const double step((engB-engA)/static_cast<double>(nE));
190193
EGrid.clear();
191-
for(int i=0;i<=nE;i++)
192-
EGrid.push_back(engA+i*step);
194+
for(size_t i=0;i<=nE;i++)
195+
EGrid.push_back(engA+static_cast<double>(i)*step);
193196
return;
194197
}
195198

196199
void
197-
BandDetector::setDataSize(const size_t Hpts,const size_t Vpts,
198-
const size_t Epts)
200+
BandDetector::setDataSize(const size_t Hpts,
201+
const size_t Vpts,
202+
const size_t Epts)
199203
/*!
200204
Set the data Size
201205
\param Hpts :: Horizontal size
@@ -228,7 +232,7 @@ BandDetector::getAxis() const
228232

229233
int
230234
BandDetector::calcCell(const MonteCarlo::particle& N,
231-
size_t& NH,size_t& NV) const
235+
size_t& NH,size_t& NV) const
232236
/*!
233237
Calc a cell
234238
Tracks from the point to the detector.

transportInc/BandDetector.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class BandDetector : public Detector
3737
{
3838
private:
3939

40-
long int nps; ///< Number of detector units
40+
size_t nps; ///< Number of detector units
4141

42-
size_t nH; ///< Number of bins horrizonal
43-
size_t nV; ///< Number of bins vertical
44-
size_t nE; ///< Number of bins [energy]
42+
size_t nH; ///< Number of bins horrizonal
43+
size_t nV; ///< Number of bins vertical
44+
size_t nE; ///< Number of bins [energy]
4545
Geometry::Vec3D Cent; ///< Cent Pos
4646
Geometry::Vec3D H; ///< Horrizontal unitVector
4747
Geometry::Vec3D V; ///< Vert extent
@@ -57,7 +57,7 @@ class BandDetector : public Detector
5757
public:
5858

5959
BandDetector();
60-
BandDetector(const int,const int,const int,
60+
BandDetector(const size_t,const size_t,const size_t,
6161
Geometry::Vec3D ,const Geometry::Vec3D&,
6262
const Geometry::Vec3D&,const double,const double);
6363
BandDetector(const BandDetector&);

0 commit comments

Comments
 (0)