LCOV - code coverage report
Current view: top level - EnergyPlus - DataOutputs.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 22 32 68.8 %
Date: 2023-01-17 19:17:23 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, 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         771 : 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         771 :                                           "HEATEMISSIONSREPORTMONTHLY"});
     137             : 
     138       56324 : bool isKeyRegexLike(std::string_view key)
     139             : {
     140       56324 :     if (key == "*") {
     141       28190 :         return false;
     142             :     }
     143             : 
     144       28134 :     return key.find_first_of("*+?()|[]\\.") != std::string_view::npos;
     145             : }
     146             : 
     147       35967 : OutputReportingVariables::OutputReportingVariables(EnergyPlusData &state, std::string const &KeyValue, std::string const &VariableName)
     148       35967 :     : key(KeyValue), variableName(VariableName), is_simple_string(!DataOutputs::isKeyRegexLike(KeyValue))
     149             : {
     150             : 
     151       35967 :     if (is_simple_string) {
     152       35967 :         return;
     153             :     }
     154           0 :     pattern = std::make_shared<RE2>(KeyValue);
     155           0 :     case_insensitive_pattern = std::make_shared<RE2>("(?i)" + KeyValue);
     156           0 :     if (!pattern->ok()) {
     157           0 :         ShowSevereError(state, "Regular expression \"" + KeyValue + "\" for variable name \"" + VariableName + "\" in input file is incorrect");
     158           0 :         ShowContinueError(state, pattern->error());
     159           0 :         ShowFatalError(state, "Error found in regular expression. Previous error(s) cause program termination.");
     160             :     }
     161             : }
     162             : 
     163     6082900 : bool FindItemInVariableList(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             :     //       RE-ENGINEERED  na
     171             : 
     172             :     // PURPOSE OF THIS FUNCTION:
     173             :     // This function looks up a key and variable name value and determines if they are
     174             :     // in the list of required variables for a simulation.
     175             : 
     176    12165800 :     auto const found_variable = state.dataOutput->OutputVariablesForSimulation.find(VariableName);
     177     6082900 :     if (found_variable == state.dataOutput->OutputVariablesForSimulation.end()) return false;
     178             : 
     179      396718 :     auto found_key = found_variable->second.find(KeyedValue);
     180      198359 :     if (found_key != found_variable->second.end()) return true;
     181             : 
     182      190936 :     found_key = found_variable->second.find("*");
     183      190936 :     if (found_key != found_variable->second.end()) return true;
     184             : 
     185     1025560 :     for (auto it = found_variable->second.begin(); it != found_variable->second.end(); ++it) {
     186      950579 :         if (equali(KeyedValue, it->second.key)) return true;
     187      950579 :         if (it->second.is_simple_string) continue;
     188           0 :         if ((it->second.pattern != nullptr && RE2::FullMatch(std::string{KeyedValue}, *it->second.pattern)) || // match against regex as written
     189           0 :             (it->second.case_insensitive_pattern != nullptr &&
     190           0 :              RE2::FullMatch(std::string{KeyedValue}, *it->second.case_insensitive_pattern)) // attempt case-insensitive regex comparison
     191             :         ) {
     192           0 :             return true;
     193             :         }
     194             :     }
     195       74981 :     return false;
     196             : }
     197             : 
     198        2313 : } // namespace EnergyPlus::DataOutputs

Generated by: LCOV version 1.13