-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-dimensional array reordering and refactoring #8692
Conversation
src/EnergyPlus/General.cc
Outdated
@@ -1255,26 +1255,12 @@ Real64 BlindBeamBeamTrans(Real64 const ProfAng, // Solar profile angle (r | |||
} | |||
|
|||
Real64 POLYF(Real64 const X, // Cosine of angle of incidence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that in a number of callsites X
is 1, I wonder if it makes sense to make this function constexpr
.
this->rbBareVisCoef(Layer).dimension(DataSurfaces::MaxPolyCoeff, 0.0); | ||
this->afBareSolCoef(Layer).dimension(DataSurfaces::MaxPolyCoeff, 0.0); | ||
this->abBareSolCoef(Layer).dimension(DataSurfaces::MaxPolyCoeff, 0.0); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably doesn't make much of a difference given that this is done for constructions and only one time, but in general we should move away from combined allocation and initialization using dimension
and towards separate allocation and explicit initialization in which all arrays can be initialized together in a single (vectorized) loop.
This is a nice new code pattern! Thanks @xuanluo113! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xuanluo113 I'm ok with these changes. The swapped indexes in some of the 2d arrays is a bit scary, but I guess if any were missed there would be an array bounds error for sure in the CI tests.
Do you want to change the initialization method (per @amirroth comment before this merges?
@@ -7206,6 +7204,13 @@ namespace HeatBalanceManager { | |||
state.dataConstruction->Construct(ConstrNum).TotGlassLayers = NGlass(IGlSys); | |||
state.dataConstruction->Construct(ConstrNum).TotSolidLayers = NGlass(IGlSys); | |||
|
|||
for (int Layer = 1; Layer <= state.dataHeatBal->MaxSolidWinLayers; ++Layer) { | |||
for (int index = 1; index <= DataSurfaces::MaxPolyCoeff; ++index) { | |||
state.dataConstruction->Construct(ConstrNum).AbsBeamCoef(Layer)(index) = 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This syntax will take a while to sink in (for me anyway). x(i)(j)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x[i][j]
would make more sense after we change those arrays to vectors.
@@ -6234,8 +6234,8 @@ namespace HeatBalanceManager { | |||
if (thisSurface.Class == DataSurfaces::SurfaceClass::Window) { | |||
auto &thisConstruct(thisSurface.Construction); | |||
if (!state.dataConstruction->Construct(thisConstruct).WindowTypeBSDF) { | |||
state.dataHeatBal->SurfWinFenLaySurfTempFront(1, SurfNum) = state.dataHeatBalSurf->TH(1, 1, SurfNum); | |||
state.dataHeatBal->SurfWinFenLaySurfTempBack(state.dataConstruction->Construct(thisConstruct).TotLayers, SurfNum) = | |||
state.dataHeatBal->SurfWinFenLaySurfTempFront(SurfNum, 1) = state.dataHeatBalSurf->TH(1, 1, SurfNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state.dataConstruction->Construct(ConstrNum).tBareSolCoef(_, IGlass)); | ||
state.dataConstruction->Construct(ConstrNum).tBareSolCoef(IGlass)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always nice to get rid of _ ,
@mjwitte I changed the initialization method in the construction array initialization. More on this topic, I'm switching to a branch to convert surface object fields to surface HB arrays. I found the location of initialization of |
Pull request overview
This branch refactors some inefficient use of multi-dimensional array, including:
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.