Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
CoordRange.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
18#include "shambase/string.hpp"
21
22namespace shammath {
23
24 template<class T>
25 void throw_ill_formed(
26 T lower, T upper, SourceLocation call, SourceLocation loc = SourceLocation{}) {
28 "this range is ill formed normally upper > lower\n lower = {}, upper = {}\n "
29 "call to check_throw = {}",
30 lower,
31 upper,
32 call.format_multiline()));
33 }
34
35 template<>
36 void CoordRange<f32_3>::check_throw_ranges(SourceLocation loc) {
37 if (lower.x() >= upper.x()) {
38 throw_ill_formed(lower, upper, loc);
39 }
40 if (lower.y() >= upper.y()) {
41 throw_ill_formed(lower, upper, loc);
42 }
43 if (lower.z() >= upper.z()) {
44 throw_ill_formed(lower, upper, loc);
45 }
46 }
47
48 template<>
49 void CoordRange<f64_3>::check_throw_ranges(SourceLocation loc) {
50 if (lower.x() >= upper.x()) {
51 throw_ill_formed(lower, upper, loc);
52 }
53 if (lower.y() >= upper.y()) {
54 throw_ill_formed(lower, upper, loc);
55 }
56 if (lower.z() >= upper.z()) {
57 throw_ill_formed(lower, upper, loc);
58 }
59 }
60
61 template<>
62 void CoordRange<u16_3>::check_throw_ranges(SourceLocation loc) {
63 if (lower.x() >= upper.x()) {
64 throw_ill_formed(lower, upper, loc);
65 }
66 if (lower.y() >= upper.y()) {
67 throw_ill_formed(lower, upper, loc);
68 }
69 if (lower.z() >= upper.z()) {
70 throw_ill_formed(lower, upper, loc);
71 }
72 }
73
74 template<>
75 void CoordRange<u32_3>::check_throw_ranges(SourceLocation loc) {
76 if (lower.x() >= upper.x()) {
77 throw_ill_formed(lower, upper, loc);
78 }
79 if (lower.y() >= upper.y()) {
80 throw_ill_formed(lower, upper, loc);
81 }
82 if (lower.z() >= upper.z()) {
83 throw_ill_formed(lower, upper, loc);
84 }
85 }
86
87 template<>
88 void CoordRange<u64_3>::check_throw_ranges(SourceLocation loc) {
89 if (lower.x() >= upper.x()) {
90 throw_ill_formed(lower, upper, loc);
91 }
92 if (lower.y() >= upper.y()) {
93 throw_ill_formed(lower, upper, loc);
94 }
95 if (lower.z() >= upper.z()) {
96 throw_ill_formed(lower, upper, loc);
97 }
98 }
99
100 template<>
101 void CoordRange<i32_3>::check_throw_ranges(SourceLocation loc) {
102 if (lower.x() >= upper.x()) {
103 throw_ill_formed(lower, upper, loc);
104 }
105 if (lower.y() >= upper.y()) {
106 throw_ill_formed(lower, upper, loc);
107 }
108 if (lower.z() >= upper.z()) {
109 throw_ill_formed(lower, upper, loc);
110 }
111 }
112
113 template<>
114 void CoordRange<i64_3>::check_throw_ranges(SourceLocation loc) {
115 if (lower.x() >= upper.x()) {
116 throw_ill_formed(lower, upper, loc);
117 }
118 if (lower.y() >= upper.y()) {
119 throw_ill_formed(lower, upper, loc);
120 }
121 if (lower.z() >= upper.z()) {
122 throw_ill_formed(lower, upper, loc);
123 }
124 }
125
126} // namespace shammath
This header file contains utility functions related to exception handling in the code.
Define the fmt formatters for sycl::vec.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
namespace for math utility
Definition AABB.hpp:26
provide information about the source location
std::string format_multiline() const
format the location in multiple lines