Skip to content
amirroth edited this page Apr 21, 2022 · 8 revisions

We have been working in the C++ version of EnergyPlus for almost ten years now, but the code still has a lot of "Fortran" in it. There have been a few targeted refactoring efforts focused on specific areas (e.g., plant) and there will be more, but a few sweeps through the code to remove some old idioms and replace with new and better ones will create a better environment in which to perform those future efforts and establish new patterns that new and updated code can mimic. I estimate that we need to do about 12-15 passes of various "sizes". The way I would characterize the size of a pass is:

  • small: can be done by one person in two months or less.
  • medium: can be done by two people in one iteration or less.
  • large: requires more than two people and/or more than one iteration. Here are the passes that I am thinking of along with my effort estimates, which may be completely off. I've tried to order them "topologically", i.e., the ones that don't depend on other passes first.
  1. Enum. Medium. This pass is already underway and about 60% completed. It consists of three sub-passes. The first converts collections of constexpr int constants into enum class enumerations with a standard format in which the first item is Invalid = -1 and the last item is Num. This part may require some thinking and rejiggering (technical term) as in several places the code exhibits an undue reliance on the actual values of enumerations rather than on their symbolic names. The second sub-pass creates a constexpr std::array<std::string_view, static_cast<int>(ec::Num)> = ecNamesUC = {}; array of upper-cased names for each enum class ec that appears in the IDF and replaces the if-else ladders used to convert the enumeration strings to their values with calls to static_cast<ec>getEnumerationValue(str, ecNamesUC);. The third sub-pass replaces the SELECT_CASE_var if-else ladders that use these enumerations with switch/case statements.
  2. EPVector. Small.
  3. Namespace. Small.
  4. epJSON. Large.
  5. Insensitive. Small.
  6. Initialization. Large.
  7. Unstring. Medium.
Clone this wiki locally