World Ocean Simulation System (WOSS) library
sediment-deck41-db-logic-control.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 2025 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - WOSS@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22
33#ifndef FLOOR_CONDITIONS_H
34#define FLOOR_CONDITIONS_H
35
36
37#ifdef WOSS_NETCDF_SUPPORT
38
40
41
42namespace woss {
43
44
45 static constexpr int DECK41_FLOORTYPE_GRAVEL = 0;
47 static constexpr int DECK41_FLOORTYPE_SAND = 1;
49 static constexpr int DECK41_FLOORTYPE_SILT = 2;
51 static constexpr int DECK41_FLOORTYPE_CLAY = 3;
53 static constexpr int DECK41_FLOORTYPE_OOZE = 4;
55 static constexpr int DECK41_FLOORTYPE_MUD = 5;
57 static constexpr int DECK41_FLOORTYPE_ROCKS = 6;
59 static constexpr int DECK41_FLOORTYPE_ORGANIC = 7;
61 static constexpr int DECK41_FLOORTYPE_NODULES = 8;
63 static constexpr int DECK41_FLOORTYPE_HARDBOTTOM = 9;
65 static constexpr int DECK41_FLOORTYPE_NODATA = 11;
75
76 public:
77
78 constexpr Deck41TypeTests() = default;
79
80 ~Deck41TypeTests() = default;
81
87 constexpr bool conditionFloorA( const Deck41Types& types ) const;
88
94 constexpr bool conditionFloorB( const Deck41Types& types ) const;
95
102 constexpr bool conditionFloorC( const Deck41Types& types ) const ;
103
110 constexpr bool conditionFloorD( const Deck41Types& types ) const ;
111
118 constexpr bool conditionFloorE( const Deck41Types& types ) const ;
119
126 constexpr bool conditionFloorF( const Deck41Types& types ) const ;
127
134 constexpr bool conditionFloorG( const Deck41Types& types ) const ;
135
140 constexpr bool getConditionA() const { return condition_a; }
141
146 constexpr bool getConditionB() const { return condition_b; }
147
152 constexpr bool getConditionC() const { return condition_c; }
153
158 constexpr bool getConditionD() const { return condition_d; }
159
164 constexpr bool getConditionE() const { return condition_e; }
165
170 constexpr bool getConditionF() const { return condition_f; }
171
176 constexpr bool getConditionG() const { return condition_g; }
177
182 constexpr void updateAllConditions( const Deck41Types& types );
183
184 private:
185
186 bool condition_a = false;
187
188 bool condition_b = false;
189
190 bool condition_c = false;
191
192 bool condition_d = false;
193
194 bool condition_e = false;
195
196 bool condition_f = false;
197
198 bool condition_g = false;
199
200 };
201
202
203 //inline functions
205 inline constexpr bool Deck41TypeTests::conditionFloorA(const Deck41Types& types) const { // first = return main type
206 bool equal = (types.first == types.second);
207 bool first = (types.first == DECK41_FLOORTYPE_GRAVEL) || (types.first == DECK41_FLOORTYPE_SAND) || (types.first == DECK41_FLOORTYPE_SILT)
208 || (types.first == DECK41_FLOORTYPE_MUD) || (types.first == DECK41_FLOORTYPE_HARDBOTTOM);
209 bool second = (types.second == DECK41_FLOORTYPE_ROCKS) || (types.second == DECK41_FLOORTYPE_ORGANIC) ||
210 (types.second == DECK41_FLOORTYPE_NODULES) || (types.second == DECK41_FLOORTYPE_NODATA) ||
211 (types.second == DECK41_FLOORTYPE_HARDBOTTOM);
212
213 return ( (equal && first ) || (first && second));
214 }
215
216 inline constexpr bool Deck41TypeTests::conditionFloorB(const Deck41Types& types) const { // second = return secondary type
217 bool first = (types.first == DECK41_FLOORTYPE_NODATA);
218 bool second = (types.second == DECK41_FLOORTYPE_GRAVEL) || (types.second == DECK41_FLOORTYPE_SAND) ||
219 (types.second == DECK41_FLOORTYPE_SILT) || (types.second == DECK41_FLOORTYPE_MUD);
220
221 return (first && second);
222 }
223
224 inline constexpr bool Deck41TypeTests::conditionFloorC(const Deck41Types& types) const { // first* = try other coords, if fails get main type
225 bool first = (types.first == DECK41_FLOORTYPE_CLAY) || (types.first == DECK41_FLOORTYPE_OOZE) || (types.first == DECK41_FLOORTYPE_ORGANIC)
226 || (types.first == DECK41_FLOORTYPE_ROCKS) || (types.first == DECK41_FLOORTYPE_NODULES);
227 bool second = (types.second == DECK41_FLOORTYPE_ROCKS) || (types.second == DECK41_FLOORTYPE_ORGANIC) ||
228 (types.second == DECK41_FLOORTYPE_NODULES) || (types.second == DECK41_FLOORTYPE_NODATA) ||
229 (types.second == DECK41_FLOORTYPE_HARDBOTTOM);
230
231 return (first && second);
232 }
233
234 inline constexpr bool Deck41TypeTests::conditionFloorD(const Deck41Types& types) const { // second* = try other coords, if fails get secondary type
235 if ( types.first == DECK41_FLOORTYPE_ORGANIC ) return true;
236 else {
237 bool first = (types.first == DECK41_FLOORTYPE_ROCKS) || (types.first == DECK41_FLOORTYPE_NODULES) ||
238 (types.first == DECK41_FLOORTYPE_NODATA) ;
239 bool second = (types.second == DECK41_FLOORTYPE_GRAVEL) || (types.second == DECK41_FLOORTYPE_SAND) ||
240 (types.second == DECK41_FLOORTYPE_SILT) || (types.second == DECK41_FLOORTYPE_MUD);
241
242 return (first && second);
243 }
244 }
245
246 inline constexpr bool Deck41TypeTests::conditionFloorE(const Deck41Types& types) const { // 65%/35% = weighted avg
247 bool nequal = types.first != types.second;
248 bool first = (types.first == DECK41_FLOORTYPE_GRAVEL) || (types.first == DECK41_FLOORTYPE_SAND) || (types.first == DECK41_FLOORTYPE_SILT)
249 || (types.first == DECK41_FLOORTYPE_MUD);
250 bool second = first || (types.second == DECK41_FLOORTYPE_OOZE) || (types.second == DECK41_FLOORTYPE_CLAY);
251 bool special = (types.first == DECK41_FLOORTYPE_OOZE) && (types.second == DECK41_FLOORTYPE_CLAY);
252
253 return ( (first && second && nequal) || special );
254 }
255
256 inline constexpr bool Deck41TypeTests::conditionFloorF(const Deck41Types& types) const { // 40%/60% = weighted avg
257 bool nequal = types.first != types.second;
258 bool first = (types.first == DECK41_FLOORTYPE_CLAY) || (types.first == DECK41_FLOORTYPE_OOZE);
259 bool second = (types.second == DECK41_FLOORTYPE_GRAVEL) || (types.second == DECK41_FLOORTYPE_SAND) || (types.second == DECK41_FLOORTYPE_SILT)
260 || (types.second == DECK41_FLOORTYPE_MUD) || (types.second == DECK41_FLOORTYPE_OOZE);
261
262 return (first && second && nequal);
263 }
264
265 inline constexpr bool Deck41TypeTests::conditionFloorG(const Deck41Types& types) const { // exit* = try other coords, if fails exit program
266 return ( (types.first == DECK41_FLOORTYPE_NODATA) && (types.second == DECK41_FLOORTYPE_NODATA));
267 }
268
269 inline constexpr void Deck41TypeTests::updateAllConditions(const Deck41Types& types) {
270 condition_a = conditionFloorA(types); // first = return main type
271 condition_b = conditionFloorB(types); // second = return secondary type
272 condition_c = conditionFloorC(types); // first* = try other coords, if fails get main type
273 condition_d = conditionFloorD(types); // second* = try other coords, if fails get secondary type
274 condition_e = conditionFloorE(types); // 65%/35% = weighted avg
275 condition_f = conditionFloorF(types); // 40%/60% = weighted avg
277 }
278
279}
280
281#endif // WOSS_NETCDF_SUPPORT
282
283#endif /* FLOOR_CONDITIONS_H */
284
Abstraction layer for database and data manipulation.
Definition sediment-deck41-db-logic-control.h:74
bool condition_e
Definition sediment-deck41-db-logic-control.h:194
~Deck41TypeTests()=default
constexpr bool getConditionF() const
Definition sediment-deck41-db-logic-control.h:170
bool condition_g
Definition sediment-deck41-db-logic-control.h:198
constexpr bool conditionFloorC(const Deck41Types &types) const
Definition sediment-deck41-db-logic-control.h:224
constexpr bool getConditionA() const
Definition sediment-deck41-db-logic-control.h:140
bool condition_b
Definition sediment-deck41-db-logic-control.h:188
constexpr bool conditionFloorA(const Deck41Types &types) const
Definition sediment-deck41-db-logic-control.h:205
constexpr bool getConditionD() const
Definition sediment-deck41-db-logic-control.h:158
constexpr bool getConditionB() const
Definition sediment-deck41-db-logic-control.h:146
constexpr bool getConditionE() const
Definition sediment-deck41-db-logic-control.h:164
constexpr Deck41TypeTests()=default
constexpr bool getConditionG() const
Definition sediment-deck41-db-logic-control.h:176
constexpr void updateAllConditions(const Deck41Types &types)
Definition sediment-deck41-db-logic-control.h:269
constexpr bool conditionFloorE(const Deck41Types &types) const
Definition sediment-deck41-db-logic-control.h:246
constexpr bool getConditionC() const
Definition sediment-deck41-db-logic-control.h:152
constexpr bool conditionFloorG(const Deck41Types &types) const
Definition sediment-deck41-db-logic-control.h:265
constexpr bool conditionFloorD(const Deck41Types &types) const
Definition sediment-deck41-db-logic-control.h:234
bool condition_f
Definition sediment-deck41-db-logic-control.h:196
constexpr bool conditionFloorF(const Deck41Types &types) const
Definition sediment-deck41-db-logic-control.h:256
bool condition_d
Definition sediment-deck41-db-logic-control.h:192
constexpr bool conditionFloorB(const Deck41Types &types) const
Definition sediment-deck41-db-logic-control.h:216
bool condition_a
Definition sediment-deck41-db-logic-control.h:186
bool condition_c
Definition sediment-deck41-db-logic-control.h:190
Definition ac-toolbox-arr-asc-reader.h:44
std::pair< int, int > Deck41Types
Definition sediment-definitions.h:46
Definitions and library for woss::Sediment class.