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 : // EnergyPlus Headers
49 : #include <EnergyPlus/Data/EnergyPlusData.hh>
50 : #include <EnergyPlus/GlobalNames.hh>
51 : #include <EnergyPlus/UtilityRoutines.hh>
52 :
53 : namespace EnergyPlus::GlobalNames {
54 :
55 : // Module containing the routines dealing with matching and assuring that
56 : // various component types are unique by name (e.g. Chillers).
57 :
58 : // MODULE INFORMATION:
59 : // AUTHOR Linda Lawrie
60 : // DATE WRITTEN October 2005
61 : // MODIFIED na
62 : // RE-ENGINEERED na
63 :
64 : // PURPOSE OF THIS MODULE:
65 : // This module allows for verification of uniqueness (by name) across
66 : // certain component names (esp. Chillers, Boilers)
67 :
68 5752 : void IntraObjUniquenessCheck(EnergyPlusData &state,
69 : std::string &NameToVerify,
70 : std::string const &CurrentModuleObject,
71 : std::string_view FieldName,
72 : std::unordered_set<std::string> &UniqueStrings,
73 : bool &ErrorsFound)
74 : {
75 5752 : if (NameToVerify.empty()) {
76 0 : ShowSevereError(state, "E+ object type " + CurrentModuleObject + " cannot have a blank " + std::string{FieldName} + " field");
77 0 : ErrorsFound = true;
78 0 : NameToVerify = "xxxxx";
79 0 : return;
80 : }
81 :
82 11504 : auto const &find_string = UniqueStrings.find(NameToVerify);
83 5752 : if (find_string == UniqueStrings.end()) {
84 5752 : UniqueStrings.emplace(NameToVerify);
85 : } else {
86 0 : ErrorsFound = true;
87 0 : ShowSevereError(state, CurrentModuleObject + " has a duplicate field " + NameToVerify);
88 : }
89 : }
90 :
91 96062 : bool VerifyUniqueInterObjectName(EnergyPlusData &state,
92 : std::unordered_map<std::string, std::string> &names,
93 : std::string &object_name,
94 : std::string_view object_type,
95 : std::string_view field_name,
96 : bool &ErrorsFound)
97 : {
98 96062 : if (object_name.empty()) {
99 0 : ShowSevereError(state, "E+ object type " + object_name + " cannot have blank " + std::string{field_name} + " field");
100 0 : ErrorsFound = true;
101 0 : object_name = "xxxxx";
102 0 : return true;
103 : }
104 192124 : auto const &names_iter = names.find(object_name);
105 96062 : if (names_iter == names.end()) {
106 96062 : names.emplace(object_name, object_type);
107 : } else {
108 0 : ErrorsFound = true;
109 0 : ShowSevereError(state,
110 0 : object_name + " with object type " + std::string{object_type} + " duplicates a name in object type " + names_iter->second);
111 0 : return true;
112 : }
113 96062 : return false;
114 : }
115 :
116 8023 : bool VerifyUniqueInterObjectName(EnergyPlusData &state,
117 : std::unordered_map<std::string, std::string> &names,
118 : std::string &object_name,
119 : std::string const &object_type,
120 : bool &ErrorsFound)
121 : {
122 8023 : if (object_name.empty()) {
123 0 : ShowSevereError(state, "E+ object type " + object_name + " has a blank field");
124 0 : ErrorsFound = true;
125 0 : object_name = "xxxxx";
126 0 : return true;
127 : }
128 16046 : auto const &names_iter = names.find(object_name);
129 8023 : if (names_iter == names.end()) {
130 8023 : names.emplace(object_name, object_type);
131 : } else {
132 0 : ErrorsFound = true;
133 0 : ShowSevereError(state, object_name + " with object type " + object_type + " duplicates a name in object type " + names_iter->second);
134 0 : return true;
135 : }
136 8023 : return false;
137 : }
138 :
139 420 : void VerifyUniqueChillerName(
140 : EnergyPlusData &state, std::string const &TypeToVerify, std::string const &NameToVerify, bool &ErrorsFound, std::string const &StringToDisplay)
141 : {
142 :
143 : // SUBROUTINE INFORMATION:
144 : // AUTHOR Linda Lawrie
145 : // DATE WRITTEN October 2005
146 : // MODIFIED na
147 : // RE-ENGINEERED na
148 :
149 : // PURPOSE OF THIS SUBROUTINE:
150 : // This subroutine verifies that a new name will be unique in the list of
151 : // chillers. If not found in the list, it is added before returning.
152 :
153 840 : auto const iter = state.dataGlobalNames->ChillerNames.find(NameToVerify);
154 420 : if (iter != state.dataGlobalNames->ChillerNames.end()) {
155 0 : ShowSevereError(state, StringToDisplay + ", duplicate name=" + NameToVerify + ", Chiller Type=\"" + iter->second + "\".");
156 0 : ShowContinueError(state, "...Current entry is Chiller Type=\"" + TypeToVerify + "\".");
157 0 : ErrorsFound = true;
158 : } else {
159 420 : state.dataGlobalNames->ChillerNames.emplace(NameToVerify, UtilityRoutines::MakeUPPERCase(TypeToVerify));
160 420 : state.dataGlobalNames->NumChillers = static_cast<int>(state.dataGlobalNames->ChillerNames.size());
161 : }
162 420 : }
163 :
164 114 : void VerifyUniqueBaseboardName(EnergyPlusData &state,
165 : std::string_view const &TypeToVerify,
166 : std::string const &NameToVerify,
167 : bool &ErrorsFound,
168 : std::string const &StringToDisplay)
169 : {
170 :
171 : // SUBROUTINE INFORMATION:
172 : // AUTHOR Linda Lawrie
173 : // DATE WRITTEN July 2008
174 : // MODIFIED na
175 : // RE-ENGINEERED na
176 :
177 : // PURPOSE OF THIS SUBROUTINE:
178 : // This subroutine verifies that a new name will be unique in the list of
179 : // Baseboards. If not found in the list, it is added before returning.
180 :
181 228 : auto const iter = state.dataGlobalNames->BaseboardNames.find(NameToVerify);
182 114 : if (iter != state.dataGlobalNames->BaseboardNames.end()) {
183 0 : ShowSevereError(state, StringToDisplay + ", duplicate name=" + NameToVerify + ", Baseboard Type=\"" + iter->second + "\".");
184 0 : ShowContinueError(state, format("...Current entry is Baseboard Type=\"{}\".", TypeToVerify));
185 0 : ErrorsFound = true;
186 : } else {
187 114 : state.dataGlobalNames->BaseboardNames.emplace(NameToVerify, UtilityRoutines::MakeUPPERCase(TypeToVerify));
188 114 : state.dataGlobalNames->NumBaseboards = static_cast<int>(state.dataGlobalNames->BaseboardNames.size());
189 : }
190 114 : }
191 :
192 205 : void VerifyUniqueBoilerName(
193 : EnergyPlusData &state, std::string const &TypeToVerify, std::string const &NameToVerify, bool &ErrorsFound, std::string const &StringToDisplay)
194 : {
195 :
196 : // SUBROUTINE INFORMATION:
197 : // AUTHOR Linda Lawrie
198 : // DATE WRITTEN October 2005
199 : // MODIFIED na
200 : // RE-ENGINEERED na
201 :
202 : // PURPOSE OF THIS SUBROUTINE:
203 : // This subroutine verifies that a new name will be unique in the list of
204 : // Boilers. If not found in the list, it is added before returning.
205 :
206 410 : auto const iter = state.dataGlobalNames->BoilerNames.find(NameToVerify);
207 205 : if (iter != state.dataGlobalNames->BoilerNames.end()) {
208 0 : ShowSevereError(state, StringToDisplay + ", duplicate name=" + NameToVerify + ", Boiler Type=\"" + iter->second + "\".");
209 0 : ShowContinueError(state, "...Current entry is Boiler Type=\"" + TypeToVerify + "\".");
210 0 : ErrorsFound = true;
211 : } else {
212 205 : state.dataGlobalNames->BoilerNames.emplace(NameToVerify, UtilityRoutines::MakeUPPERCase(TypeToVerify));
213 205 : state.dataGlobalNames->NumBoilers = static_cast<int>(state.dataGlobalNames->BoilerNames.size());
214 : }
215 205 : }
216 :
217 5877 : void VerifyUniqueCoilName(
218 : EnergyPlusData &state, std::string const &TypeToVerify, std::string &NameToVerify, bool &ErrorsFound, std::string const &StringToDisplay)
219 : {
220 :
221 : // SUBROUTINE INFORMATION:
222 : // AUTHOR Linda Lawrie
223 : // DATE WRITTEN October 2005
224 : // MODIFIED na
225 : // RE-ENGINEERED na
226 :
227 : // PURPOSE OF THIS SUBROUTINE:
228 : // This subroutine verifies that a new name will be unique in the list of
229 : // Coils. If not found in the list, it is added before returning.
230 :
231 5877 : if (NameToVerify.empty()) {
232 0 : ShowSevereError(state, "\"" + TypeToVerify + "\" cannot have a blank field");
233 0 : ErrorsFound = true;
234 0 : NameToVerify = "xxxxx";
235 0 : return;
236 : }
237 :
238 11754 : auto const iter = state.dataGlobalNames->CoilNames.find(NameToVerify);
239 5877 : if (iter != state.dataGlobalNames->CoilNames.end()) {
240 0 : ShowSevereError(state, StringToDisplay + ", duplicate name=" + NameToVerify + ", Coil Type=\"" + iter->second + "\".");
241 0 : ShowContinueError(state, "...Current entry is Coil Type=\"" + TypeToVerify + "\".");
242 0 : ErrorsFound = true;
243 : } else {
244 5877 : state.dataGlobalNames->CoilNames.emplace(NameToVerify, UtilityRoutines::MakeUPPERCase(TypeToVerify));
245 5877 : state.dataGlobalNames->NumCoils = static_cast<int>(state.dataGlobalNames->CoilNames.size());
246 : }
247 : }
248 :
249 15 : void VerifyUniqueADUName(
250 : EnergyPlusData &state, std::string const &TypeToVerify, std::string const &NameToVerify, bool &ErrorsFound, std::string const &StringToDisplay)
251 : {
252 30 : auto const iter = state.dataGlobalNames->aDUNames.find(NameToVerify);
253 15 : if (iter != state.dataGlobalNames->aDUNames.end()) {
254 0 : ShowSevereError(state, StringToDisplay + ", duplicate name=" + NameToVerify + ", ADU Type=\"" + iter->second + "\".");
255 0 : ShowContinueError(state, "...Current entry is Air Distribution Unit Type=\"" + TypeToVerify + "\".");
256 0 : ErrorsFound = true;
257 : } else {
258 15 : state.dataGlobalNames->aDUNames.emplace(NameToVerify, UtilityRoutines::MakeUPPERCase(TypeToVerify));
259 15 : state.dataGlobalNames->numAirDistUnits = static_cast<int>(state.dataGlobalNames->aDUNames.size());
260 : }
261 15 : }
262 :
263 2313 : } // namespace EnergyPlus::GlobalNames
|