LCOV - code coverage report
Current view: top level - EnergyPlus - DataOutputs.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 86.7 % 30 26
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 3 3

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // ObjexxFCL Headers
      49              : #include <ObjexxFCL/string.functions.hh>
      50              : 
      51              : // EnergyPlus Headers
      52              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      53              : #include <EnergyPlus/DataOutputs.hh>
      54              : #include <EnergyPlus/UtilityRoutines.hh>
      55              : 
      56              : namespace EnergyPlus::DataOutputs {
      57              : 
      58              : // Module containing the data and routines dealing with prescanning for
      59              : // requested output variables to limit the number being processed in OutputProcessor
      60              : // Also any input counts (such as autosize counts/records that are used
      61              : // by later program modules.
      62              : 
      63              : // MODULE INFORMATION:
      64              : //       AUTHOR         Linda Lawrie
      65              : //       DATE WRITTEN   July 2010
      66              : //       MODIFIED       April 2011; to include autosize counts
      67              : //       RE-ENGINEERED  na
      68              : 
      69              : // PURPOSE OF THIS MODULE:
      70              : // The module contains structure for output variables that are used in a small number of modules.
      71              : 
      72              : // MODULE PARAMETER DEFINITIONS:
      73              : Array1D_string const MonthlyNamedReports(NumMonthlyReports,
      74              :                                          {"ZONECOOLINGSUMMARYMONTHLY",
      75              :                                           "ZONEHEATINGSUMMARYMONTHLY",
      76              :                                           "ZONEELECTRICSUMMARYMONTHLY",
      77              :                                           "SPACEGAINSMONTHLY",
      78              :                                           "PEAKSPACEGAINSMONTHLY",
      79              :                                           "SPACEGAINCOMPONENTSATCOOLINGPEAKMONTHLY",
      80              :                                           "ENERGYCONSUMPTIONELECTRICITYNATURALGASMONTHLY",
      81              :                                           "ENERGYCONSUMPTIONELECTRICITYGENERATEDPROPANEMONTHLY",
      82              :                                           "ENERGYCONSUMPTIONDIESELFUELOILMONTHLY",
      83              :                                           "ENERGYCONSUMPTIONDISTRICTHEATINGCOOLINGMONTHLY",
      84              :                                           "ENERGYCONSUMPTIONCOALGASOLINEMONTHLY",
      85              :                                           "ENERGYCONSUMPTIONOTHERFUELSMONTHLY",
      86              :                                           "ENDUSEENERGYCONSUMPTIONELECTRICITYMONTHLY",
      87              :                                           "ENDUSEENERGYCONSUMPTIONNATURALGASMONTHLY",
      88              :                                           "ENDUSEENERGYCONSUMPTIONDIESELMONTHLY",
      89              :                                           "ENDUSEENERGYCONSUMPTIONFUELOILMONTHLY",
      90              :                                           "ENDUSEENERGYCONSUMPTIONCOALMONTHLY",
      91              :                                           "ENDUSEENERGYCONSUMPTIONPROPANEMONTHLY",
      92              :                                           "ENDUSEENERGYCONSUMPTIONGASOLINEMONTHLY",
      93              :                                           "ENDUSEENERGYCONSUMPTIONOTHERFUELSMONTHLY",
      94              :                                           "PEAKENERGYENDUSEELECTRICITYPART1MONTHLY",
      95              :                                           "PEAKENERGYENDUSEELECTRICITYPART2MONTHLY",
      96              :                                           "ELECTRICCOMPONENTSOFPEAKDEMANDMONTHLY",
      97              :                                           "PEAKENERGYENDUSENATURALGASMONTHLY",
      98              :                                           "PEAKENERGYENDUSEDIESELMONTHLY",
      99              :                                           "PEAKENERGYENDUSEFUELOILMONTHLY",
     100              :                                           "PEAKENERGYENDUSECOALMONTHLY",
     101              :                                           "PEAKENERGYENDUSEPROPANEMONTHLY",
     102              :                                           "PEAKENERGYENDUSEGASOLINEMONTHLY",
     103              :                                           "PEAKENERGYENDUSEOTHERFUELSMONTHLY",
     104              :                                           "SETPOINTSNOTMETWITHTEMPERATURESMONTHLY",
     105              :                                           "COMFORTREPORTSIMPLE55MONTHLY",
     106              :                                           "UNGLAZEDTRANSPIREDSOLARCOLLECTORSUMMARYMONTHLY",
     107              :                                           "OCCUPANTCOMFORTDATASUMMARYMONTHLY",
     108              :                                           "CHILLERREPORTMONTHLY",
     109              :                                           "TOWERREPORTMONTHLY",
     110              :                                           "BOILERREPORTMONTHLY",
     111              :                                           "DXREPORTMONTHLY",
     112              :                                           "WINDOWREPORTMONTHLY",
     113              :                                           "WINDOWENERGYREPORTMONTHLY",
     114              :                                           "WINDOWZONESUMMARYMONTHLY",
     115              :                                           "WINDOWENERGYZONESUMMARYMONTHLY",
     116              :                                           "AVERAGEOUTDOORCONDITIONSMONTHLY",
     117              :                                           "OUTDOORCONDITIONSMAXIMUMDRYBULBMONTHLY",
     118              :                                           "OUTDOORCONDITIONSMINIMUMDRYBULBMONTHLY",
     119              :                                           "OUTDOORCONDITIONSMAXIMUMWETBULBMONTHLY",
     120              :                                           "OUTDOORCONDITIONSMAXIMUMDEWPOINTMONTHLY",
     121              :                                           "OUTDOORGROUNDCONDITIONSMONTHLY",
     122              :                                           "WINDOWACREPORTMONTHLY",
     123              :                                           "WATERHEATERREPORTMONTHLY",
     124              :                                           "GENERATORREPORTMONTHLY",
     125              :                                           "DAYLIGHTINGREPORTMONTHLY",
     126              :                                           "COILREPORTMONTHLY",
     127              :                                           "PLANTLOOPDEMANDREPORTMONTHLY",
     128              :                                           "FANREPORTMONTHLY",
     129              :                                           "PUMPREPORTMONTHLY",
     130              :                                           "CONDLOOPDEMANDREPORTMONTHLY",
     131              :                                           "ZONETEMPERATUREOSCILLATIONREPORTMONTHLY",
     132              :                                           "AIRLOOPSYSTEMENERGYANDWATERUSEMONTHLY",
     133              :                                           "AIRLOOPSYSTEMCOMPONENTLOADSMONTHLY",
     134              :                                           "AIRLOOPSYSTEMCOMPONENTENERGYUSEMONTHLY",
     135              :                                           "MECHANICALVENTILATIONLOADSMONTHLY",
     136              :                                           "HEATEMISSIONSREPORTMONTHLY"});
     137              : 
     138         3633 : bool isKeyRegexLike(std::string_view key)
     139              : {
     140         3633 :     if (key == "*") {
     141         2774 :         return false;
     142              :     }
     143              : 
     144          859 :     return key.find_first_of("*+?()|[]\\.") != std::string_view::npos;
     145              : }
     146              : 
     147         2895 : OutputReportingVariables::OutputReportingVariables(EnergyPlusData &state, std::string const &KeyValue, std::string const &VariableName)
     148         2895 :     : key(KeyValue), variableName(VariableName), is_simple_string(!DataOutputs::isKeyRegexLike(KeyValue))
     149              : {
     150              : 
     151         2895 :     if (is_simple_string) {
     152         2856 :         return;
     153              :     }
     154           39 :     pattern = std::make_shared<RE2>(KeyValue);
     155           39 :     case_insensitive_pattern = std::make_shared<RE2>("(?i)" + KeyValue);
     156           39 :     if (!pattern->ok()) {
     157            0 :         ShowSevereError(state, format("Regular expression \"{}\" for variable name \"{}\" in input file is incorrect", KeyValue, VariableName));
     158            0 :         ShowContinueError(state, pattern->error());
     159            0 :         ShowFatalError(state, "Error found in regular expression. Previous error(s) cause program termination.");
     160              :     }
     161            0 : }
     162              : 
     163       176678 : bool FindItemInVariableList(const EnergyPlusData &state, std::string_view const KeyedValue, std::string_view const VariableName)
     164              : {
     165              : 
     166              :     // FUNCTION INFORMATION:
     167              :     //       AUTHOR         Linda Lawrie
     168              :     //       DATE WRITTEN   July 2010
     169              :     //       MODIFIED       December 2016
     170              : 
     171              :     // PURPOSE OF THIS FUNCTION:
     172              :     // This function looks up a key and variable name value and determines if they are
     173              :     // in the list of required variables for a simulation.
     174              : 
     175       176678 :     auto const found_variable = state.dataOutput->OutputVariablesForSimulation.find(VariableName);
     176       176678 :     if (found_variable == state.dataOutput->OutputVariablesForSimulation.end()) return false;
     177              : 
     178         5797 :     auto found_key = found_variable->second.find(KeyedValue);
     179         5797 :     if (found_key != found_variable->second.end()) return true;
     180              : 
     181         5717 :     found_key = found_variable->second.find("*");
     182         5717 :     if (found_key != found_variable->second.end()) return true;
     183              : 
     184          822 :     for (auto it = found_variable->second.begin(); it != found_variable->second.end(); ++it) {
     185          757 :         if (equali(KeyedValue, it->second.key)) return true;
     186          691 :         if (it->second.is_simple_string) continue;
     187          422 :         if ((it->second.pattern != nullptr && RE2::FullMatch(std::string{KeyedValue}, *it->second.pattern)) || // match against regex as written
     188           29 :             (it->second.case_insensitive_pattern != nullptr &&
     189          178 :              RE2::FullMatch(std::string{KeyedValue}, *it->second.case_insensitive_pattern)) // attempt case-insensitive regex comparison
     190              :         ) {
     191           66 :             return true;
     192              :         }
     193              :     }
     194          131 :     return false;
     195              : }
     196              : 
     197              : } // namespace EnergyPlus::DataOutputs
        

Generated by: LCOV version 2.0-1