GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 1 / 0 / 1
Functions: 100.0% 1 / 0 / 1
Branches: -% 0 / 0 / 0

src/airflow/contam/PrjModel.hpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #ifndef AIRFLOW_CONTAM_PRJMODEL_HPP
7 #define AIRFLOW_CONTAM_PRJMODEL_HPP
8
9 #include "PrjDefines.hpp"
10 #include "PrjReader.hpp"
11 #include "PrjObjects.hpp"
12 #include "PrjAirflowElements.hpp"
13
14 #include "../../utilities/core/Path.hpp"
15 #include "../../utilities/data/TimeSeries.hpp"
16
17 #include "../AirflowAPI.hpp"
18
19 namespace openstudio {
20 namespace contam {
21
22 class SimFile;
23 namespace detail {
24 class IndexModelImpl;
25 }
26
27 /** IndexModel is primarily a container for CONTAM airflow model data.
28 *
29 * IndexModel contains CONTAM airflow model elements and has several methods
30 * to produce the PRJ file. The PRJ file is a positional text file and is
31 * the primary way in which data is provided to the ContamX solver. The
32 * format is documented here:
33 *
34 * www.bfrl.nist.gov/IAQanalysis/CONTAM/manual/Content/html/PRJ/PRJ_PRJ_Sections.htm
35 *
36 * Note that the representation in this object is not very sophisticated. In
37 * particular, links between many items are based upon array indices, so
38 * modifications to the model should be made with care.
39 *
40 */
41 class AIRFLOW_API IndexModel
42 {
43 public:
44 /** @name Constructors and Destructors */
45 //@{
46
47 /** Creates a new, empty PRJ model. */
48 IndexModel();
49 /** Creates a new PRJ model from input file at specified path. */
50 explicit IndexModel(openstudio::path path);
51 /** Creates a new PRJ model from named input file. */
52 explicit IndexModel(std::string filename);
53 /** Creates a new PRJ model from an input object. */
54 explicit IndexModel(Reader& input);
55 /** Creates a new PRJ model from another PRJ model. */
56 IndexModel(const IndexModel& other);
57 /** Destroy the model. */
58 17 ~IndexModel() = default;
59
60 //@}
61 /** @name Operators */
62 //@{
63
64 /** Copy operator */
65 IndexModel& operator=(const IndexModel& other);
66 /** Equality operator */
67 bool operator==(const IndexModel& other) const;
68 /** Inequality operator */
69 bool operator!=(const IndexModel& other) const;
70
71 //@}
72 /** @name Getters and Setters */
73 //@{
74
75 /** Returns the program name, should be "ContamW". */
76 std::string programName() const;
77 /** Sets the program name. */
78 void setProgramName(const std::string& name);
79 /** Returns the CONTAM version. */
80 std::string version() const;
81 /** Sets the CONTAM version. */
82 void setVersion(const std::string& version);
83 /** Returns the input echo flag: 0 - no echo, 1 - echo input files to the log file. */
84 int echo() const;
85 /** Sets the input echo flag: 0 - no echo, 1 - echo input files to the log file. */
86 void setEcho(const int echo);
87 /** Returns the project description. */
88 std::string desc() const;
89 /** Sets the project description. */
90 void setDesc(const std::string& prjdesc);
91 /** Returns the SketchPad height [cells]. */
92 int skheight() const;
93 /** Sets the SketchPad height [cells]. */
94 void setSkheight(const int skheight);
95 /** Returns the SketchPad width [cells]. */
96 int skwidth() const;
97 /** Sets the SketchPad width [cells]. */
98 void setSkwidth(const int skwidth);
99 /** Returns the default display units: 0 = SI, 1 = US. */
100 int def_units() const;
101 /** Sets the default display units: 0 = SI, 1 = US. */
102 void setDef_units(const int def_units);
103 /** Returns the default flows: 0 = mass, 1 = volume. */
104 int def_flows() const;
105 /** Sets the default flows: 0 = mass, 1 = volume. */
106 void setDef_flows(const int def_flows);
107 /** Returns the default temperature for zones [K]. */
108 double def_T() const;
109 /** Sets the default temperature for zones [K]. */
110 bool setDef_T(const double def_T);
111 /** Sets the default temperature for zones [K]. */
112 bool setDef_T(const std::string& def_T);
113 /** Returns the display units for temperature. */
114 int udefT() const;
115 /** Sets the display units for temperature. */
116 void setUdefT(const int udefT);
117 /** Returns the angle to true north [degrees]. */
118 double rel_N() const;
119 /** Sets the angle to true north [degrees]. */
120 bool setRel_N(const double rel_N);
121 /** Sets the angle to true north [degrees]. */
122 bool setRel_N(const std::string& rel_N);
123 /** Returns the elevation for reference wind speed [m]. */
124 double wind_H() const;
125 /** Sets the elevation for reference wind speed [m]. */
126 bool setWind_H(const double wind_H);
127 /** Sets the elevation for reference wind speed [m]. */
128 bool setWind_H(const std::string& wind_H);
129 /** Returns the display units for elevation for reference wind speed. */
130 int uwH() const;
131 /** Sets the display units for elevation for reference wind speed. */
132 void setUwH(const int uwH);
133 /** Returns the local terrain constant for wind. */
134 double wind_Ao() const;
135 /** Sets the local terrain constant for wind. */
136 bool setWind_Ao(const double wind_Ao);
137 /** Sets the local terrain constant for wind. */
138 bool setWind_Ao(const std::string& wind_Ao);
139 /** Returns the velocity profile exponent for wind. */
140 double wind_a() const;
141 /** Sets the velocity profile exponent for wind. */
142 bool setWind_a(const double wind_a);
143 /** Sets the velocity profile exponent for wind. */
144 bool setWind_a(const std::string& wind_a);
145 /** Returns the cell scaling factor. */
146 double scale() const;
147 /** Sets the cell scaling factor. */
148 bool setScale(const double scale);
149 /** Sets the cell scaling factor. */
150 bool setScale(const std::string& scale);
151 /** Returns the units of scaling factor: 0 = m, 1 = ft. */
152 int uScale() const;
153 /** Sets the units of scaling factor: 0 = m, 1 = ft. */
154 void setUScale(const int uScale);
155 /** Returns the row of the origin. */
156 int orgRow() const;
157 /** Sets the row of the origin. */
158 void setOrgRow(const int orgRow);
159 /** Returns the column of the origin. */
160 int orgCol() const;
161 /** Sets the column of the origin. */
162 void setOrgCol(const int orgCol);
163 /** Returns the y-axis inversion flag: 0 = positive above origin, 1 = negative above origin. */
164 int invYaxis() const;
165 /** Sets the y-axis inversion flag: 0 = positive above origin, 1 = negative above origin. */
166 void setInvYaxis(const int invYaxis);
167 /** Returns the pseudo-geometry display flag: 0 = don't show, 1 = show in status bar. */
168 int showGeom() const;
169 /** Sets the pseudo-geometry display flag: 0 = don't show, 1 = show in status bar. */
170 void setShowGeom(const int showGeom);
171 /** Returns the weather data for steady-state simulation. */
172 WeatherData ssWeather() const;
173 /** Sets the weather data for steady-state simulation. */
174 void setSsWeather(const WeatherData& ssWeather);
175 /** Returns the weather data the wind pressure test. */
176 WeatherData wptWeather() const;
177 /** Sets the weather data the wind pressure test. */
178 void setWptWeather(const WeatherData& wptWeather);
179 /** Returns the full name of weather file. */
180 std::string WTHpath() const;
181 /** Sets the full name of weather file. */
182 void setWTHpath(const std::string& WTHpath);
183 /** Returns the full name of contaminant file. */
184 std::string CTMpath() const;
185 /** Sets the full name of contaminant file. */
186 void setCTMpath(const std::string& CTMpath);
187 /** Returns the full name of continuous values file. */
188 std::string CVFpath() const;
189 /** Sets the full name of continuous values file. */
190 void setCVFpath(const std::string& CVFpath);
191 /** Returns the full name of discrete values file. */
192 std::string DVFpath() const;
193 /** Sets the full name of discrete values file. */
194 void setDVFpath(const std::string& DVFpath);
195 /** Returns the full name of WPC file. */
196 std::string WPCfile() const;
197 /** Sets the full name of WPC file. */
198 void setWPCfile(const std::string& WPCfile);
199 /** Returns the full name of EWC data source file. */
200 std::string EWCfile() const;
201 /** Sets the full name of EWC data source file. */
202 void setEWCfile(const std::string& EWCfile);
203 /** Returns the WPC description. */
204 std::string WPCdesc() const;
205 /** Sets the WPC description. */
206 void setWPCdesc(const std::string& WPCdesc);
207 /** Returns the X-value of ContamW origin in EWC coordinates [m]. */
208 double X0() const;
209 /** Sets the X-value of ContamW origin in EWC coordinates [m]. */
210 bool setX0(const double X0);
211 /** Sets the X-value of ContamW origin in EWC coordinates [m]. */
212 bool setX0(const std::string& X0);
213 /** Returns the Y-value of ContamW origin in EWC coordinates [m]. */
214 double Y0() const;
215 /** Sets the Y-value of ContamW origin in EWC coordinates [m]. */
216 bool setY0(const double Y0);
217 /** Sets the Y-value of ContamW origin in EWC coordinates [m]. */
218 bool setY0(const std::string& Y0);
219 /** Returns the Z-value of ContamW origin in EWC coordinates [m]. */
220 double Z0() const;
221 /** Sets the Z-value of ContamW origin in EWC coordinates [m]. */
222 bool setZ0(const double Z0);
223 /** Sets the Z-value of ContamW origin in EWC coordinates [m]. */
224 bool setZ0(const std::string& Z0);
225 /** Returns the rotation of ContamW relative to EWC coordinates. */
226 double angle() const;
227 /** Sets the rotation of ContamW relative to EWC coordinates. */
228 bool setAngle(const double angle);
229 /** Sets the rotation of ContamW relative to EWC coordinates. */
230 bool setAngle(const std::string& angle);
231 /** Returns the units of coordinates. */
232 int u_XYZ() const;
233 /** Sets the units of coordinates. */
234 void setU_XYZ(const int u_XYZ);
235 /** Returns the tolerance for matching path locations. */
236 double epsPath() const;
237 /** Sets the tolerance for matching path locations. */
238 bool setEpsPath(const double epsPath);
239 /** Sets the tolerance for matching path locations. */
240 bool setEpsPath(const std::string& epsPath);
241 /** Returns the tolerance for matching species. */
242 double epsSpcs() const;
243 /** Sets the tolerance for matching species. */
244 bool setEpsSpcs(const double epsSpcs);
245 /** Sets the tolerance for matching species. */
246 bool setEpsSpcs(const std::string& epsSpcs);
247 /** Returns the time shift of EWC data [hh:mm:ss]. */
248 std::string tShift() const;
249 /** Sets the time shift of EWC data [hh:mm:ss]. */
250 void setTShift(const std::string& tShift);
251 /** Returns the date WPC data starts [mm/dd]. */
252 std::string dStart() const;
253 /** Sets the date WPC data starts [mm/dd]. */
254 void setDStart(const std::string& dStart);
255 /** Returns the date WPC data ends [mm/dd]. */
256 std::string dEnd() const;
257 /** Sets the date WPC data ends [mm/dd]. */
258 void setDEnd(const std::string& dEnd);
259 /** Returns the WPC file wind pressure flag: 0 = don't use, 1 = use. */
260 int useWPCwp() const;
261 /** Sets the WPC file wind pressure flag: 0 = don't use, 1 = use. */
262 void setUseWPCwp(const int useWPCwp);
263 /** Returns the WPC file mass fraction flag: 0 = don't use, 1 = use. */
264 int useWPCmf() const;
265 /** Sets the WPC file mass fraction flag: 0 = don't use, 1 = use. */
266 void setUseWPCmf(const int useWPCmf);
267 /** Returns the WPC trigger flag: 0 = don't trigger, 1 = trigger airflow calculation by WPC data. */
268 int wpctrig() const;
269 /** Setss the WPC trigger flag: 0 = don't trigger, 1 = trigger airflow calculation by WPC data. */
270 void setWpctrig(const int wpctrig);
271 /** Returns the latitude (degrees: north +, south -). */
272 double latd() const;
273 /** Sets the latitude (degrees: north +, south -). */
274 bool setLatd(const double latd);
275 /** Sets the latitude (degrees: north +, south -). */
276 bool setLatd(const std::string& latd);
277 /** Returns the longitude (degrees: east +, west -). */
278 double lgtd() const;
279 /** Sets the longitude (degrees: east +, west -). */
280 bool setLgtd(const double lgtd);
281 /** Sets the longitude (degrees: east +, west -). */
282 bool setLgtd(const std::string& lgtd);
283 /** Returns the time zone (Greenwich = 0, Eastern = -5, etc.). */
284 double Tznr() const;
285 /** Sets the time zone (Greenwich = 0, Eastern = -5, etc.). */
286 bool setTznr(const double Tznr);
287 /** Sets the time zone (Greenwich = 0, Eastern = -5, etc.). */
288 bool setTznr(const std::string& Tznr);
289 /** Returns the elevation above sea level [m]. */
290 double altd() const;
291 /** Sets the elevation above sea level [m]. */
292 bool setAltd(const double altd);
293 /** Sets the elevation above sea level [m]. */
294 bool setAltd(const std::string& altd);
295 /** Returns the ground temperature [K]. */
296 double Tgrnd() const;
297 /** Sets the ground temperature [K]. */
298 bool setTgrnd(const double Tgrnd);
299 /** Sets the ground temperature [K]. */
300 bool setTgrnd(const std::string& Tgrnd);
301 /** Returns the display units for ground temperatures. */
302 int utg() const;
303 /** Sets the display units for ground temperatures. */
304 void setUtg(const int utg);
305 /** Returns the display units for elevation. */
306 int u_a() const;
307 /** Sets the display units for elevation. */
308 void setU_a(const int u_a);
309
310 /** Returns the model run control object. */
311 RunControl rc() const;
312 /** Sets the model run control object. */
313 void setRc(const RunControl& rc);
314
315 /** Returns a vector of CONTAM indices of all the active species in the model. */
316 std::vector<int> contaminants() const;
317
318 /** Returns a vector of the species in the model. */
319 std::vector<Species> species() const;
320 /** Sets the model species vector. */
321 void setSpecies(const std::vector<Species>& species);
322 /** Add a species to the model. */
323 void addSpecies(Species& species);
324 /** Remove a species from the model. */
325 bool removeSpecies(const Species& species);
326
327 /** Returns a vector of the levels in the model. */
328 std::vector<Level> levels() const;
329 /** Sets the model level vector. */
330 void setLevels(const std::vector<Level>& levels);
331 /** Add a level to the model. */
332 void addLevel(Level& level);
333
334 /** Returns a vector of the day schedules in the model. */
335 std::vector<DaySchedule> daySchedules() const;
336 /** Sets the model day schedule vector. */
337 void setDaySchedules(const std::vector<DaySchedule>& daySchedules);
338
339 /** Returns a vector of the week schedules in the model. */
340 std::vector<WeekSchedule> weekSchedules() const;
341 /** Sets the model week schedule vector. */
342 void setWeekSchedules(const std::vector<WeekSchedule>& weekSchedules);
343
344 /** Returns a vector of the wind pressure profiles in the model. */
345 std::vector<WindPressureProfile> windPressureProfiles() const;
346 /** Sets the model wind pressure profiles vector. */
347 void setWindPressureProfiles(const std::vector<WindPressureProfile>& windPressureProfiles);
348
349 /** Returns a vector of all PlrTest1 airflow elements in the model. */
350 std::vector<PlrTest1> getPlrTest1() const;
351 /** Returns a vector of all PlrTest2 airflow elements in the model. */
352 std::vector<PlrTest2> getPlrTest2() const;
353 /** Returns a vector of all PlrLeak2 airflow elements in the model. */
354 std::vector<PlrLeak2> getPlrLeak2() const;
355 /** Add a PlrTest1 airflow element to the model. */
356 bool addAirflowElement(PlrTest1 element);
357 /** Add a PlrLeak2 airflow element to the model. */
358 bool addAirflowElement(PlrLeak2 element);
359 /** Return the element number of the named airflow element */
360 int airflowElementNrByName(std::string name) const;
361 /** Replace an airflow element with a PlrTest1 airflow element */
362 bool replaceAirflowElement(int nr, PlrTest1 element);
363
364 /** Returns a vector of all CvfDat control nodes in the model. */
365 std::vector<CvfDat> getCvfDat() const;
366 /** Add an CvfDat airflow element to the model. */
367 bool addControlNode(CvfDat element, bool sequence = true);
368
369 /** Returns a vector of all simple air handling systems in the model. */
370 std::vector<Ahs> ahs() const;
371 /** Sets the model simple air handling systems vector. */
372 void setAhs(const std::vector<Ahs>& ahs);
373 /** Add a simple air handling system to the model. */
374 void addAhs(Ahs ahs);
375
376 /** Returns a vector of all airflow zones in the model. */
377 std::vector<Zone> zones() const;
378 /** Sets the model airflow zones vector. */
379 void setZones(const std::vector<Zone>& zones);
380 /** Add an airflow zone to the model. */
381 void addZone(Zone zone);
382
383 /** Returns a vector of all airflow paths in the model. */
384 std::vector<AirflowPath> airflowPaths() const;
385 /** Sets the model airflow paths vector. */
386 void setAirflowPaths(const std::vector<AirflowPath>& paths);
387 /** Add an airflow path to the model. */
388 void addAirflowPath(AirflowPath path);
389
390 /** Returns false if the model is not a legitimate PRJ model. */
391 bool valid() const;
392
393 //@}
394 /** @name Input and Output */
395 //@{
396
397 /** Creates a new PRJ model from input file at specified path. */
398 bool read(openstudio::path path);
399 /** Creates a new PRJ model from named input file. */
400 bool read(std::string filename);
401 /** Creates a new PRJ model from an input object. */
402 bool read(Reader& input);
403
404 /** Write the model in PRJ format to a string. */
405 std::string toString();
406
407 //@}
408 /** @name Other Functions */
409 //@{
410
411 /** Return a vector of vectors of the CONTAM indices of all plot paths to the exterior of each zone. */
412 std::vector<std::vector<int>> zoneExteriorFlowPaths();
413 /** Compute the infiltration on a per zone basis from simulation results. */
414 std::vector<TimeSeries> zoneInfiltration(SimFile* sim);
415 /** Compute the infiltration on a per path basis from simulation results. */
416 std::vector<TimeSeries> pathInfiltration(std::vector<int> pathNrs, SimFile* sim);
417 //@}
418
419 private:
420 std::shared_ptr<detail::IndexModelImpl> m_impl;
421 };
422
423 } // namespace contam
424 } // namespace openstudio
425
426 #endif // AIRFLOW_CONTAM_PRJMODEL_HPP
427