17#include <boost/preprocessor/cat.hpp>
18#include <boost/preprocessor/seq/for_each.hpp>
42template <
typename Spline,
short_t>
43 requires SplineType<Spline>
51template <
typename Spline>
65 Spline::template derived_self_type<
typename Spline::value_type,
70 template <
typename real_t>
72 Spline::template derived_self_type<real_t, Spline::geoDim()>;
75 std::tuple<boundary_spline_type, boundary_spline_type>
bdr_;
85 using eval_type = std::tuple<torch::Tensor, torch::Tensor>;
91 : bdr_({boundary_spline_type(options), boundary_spline_type(options)}) {}
105 : bdr_(clone ?
std::apply(
106 [](const auto &...bspline) {
107 return std::make_tuple(bspline.clone()...);
119 : bdr_({boundary_spline_type(std::array<int64_t, 0>{},
init, options),
120 boundary_spline_type(std::array<int64_t, 0>{},
init, options)}) {}
126 const std::array<std::vector<typename Spline::value_type>, 1> &,
130 : bdr_({boundary_spline_type(std::array<int64_t, 0>{},
init, options),
131 boundary_spline_type(std::array<int64_t, 0>{},
init, options)}) {}
144 if (tensor.dim() > 1) {
145 auto tensor_view = tensor.view({Spline::geoDim(), -1, tensor.size(-1)});
147 side<west>().from_tensor(tensor_view.index({torch::indexing::Slice(), 0})
148 .reshape({-1, tensor.size(-1)}));
149 side<east>().from_tensor(tensor_view.index({torch::indexing::Slice(), -1})
150 .reshape({-1, tensor.size(-1)}));
152 auto tensor_view = tensor.view({Spline::geoDim(), -1});
155 tensor_view.index({torch::indexing::Slice(), 0}).flatten());
157 tensor_view.index({torch::indexing::Slice(), -1}).flatten());
169 template <
short_t s>
inline constexpr auto &
side()
const {
170 static_assert(s >
none && s <= nsides());
171 return std::get<s - 1>(bdr_);
177 template <
short_t s>
inline constexpr auto &
side() {
178 static_assert(s >
none && s <= nsides());
179 return std::get<s - 1>(bdr_);
185 inline constexpr auto &
sides()
const {
return bdr_; }
190 inline constexpr auto &
sides() {
return bdr_; }
205 os << name() <<
"(\n"
212 inline nlohmann::json
to_json()
const override {
244template <
typename Spline>
245 requires SplineType<Spline>
258 typename Spline::template derived_self_type<
259 typename Spline::value_type, Spline::geoDim(), Spline::degree(1)>,
260 typename Spline::template derived_self_type<
261 typename Spline::value_type, Spline::geoDim(), Spline::degree(0)>>;
265 template <
typename real_t>
267 std::tuple<
typename Spline::template derived_self_type<
268 real_t, Spline::geoDim(), Spline::degree(1)>,
269 typename Spline::template derived_self_type<
270 real_t, Spline::geoDim(), Spline::degree(0)>>;
273 std::tuple<std::tuple_element_t<0, boundary_spline_type>,
274 std::tuple_element_t<0, boundary_spline_type>,
275 std::tuple_element_t<1, boundary_spline_type>,
276 std::tuple_element_t<1, boundary_spline_type>>
294 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
295 std::tuple_element_t<0, boundary_spline_type>(options),
296 std::tuple_element_t<1, boundary_spline_type>(options),
297 std::tuple_element_t<1, boundary_spline_type>(options)}) {}
311 : bdr_(clone ?
std::apply(
312 [](const auto &...bspline) {
313 return std::make_tuple(bspline.clone()...);
326 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
327 std::array<int64_t, 1>({ncoeffs[1]}),
init, options),
328 std::tuple_element_t<0, boundary_spline_type>(
329 std::array<int64_t, 1>({ncoeffs[1]}),
init, options),
330 std::tuple_element_t<1, boundary_spline_type>(
331 std::array<int64_t, 1>({ncoeffs[0]}),
init, options),
332 std::tuple_element_t<1, boundary_spline_type>(
333 std::array<int64_t, 1>({ncoeffs[0]}),
init, options)}) {}
340 const std::array<std::vector<typename Spline::value_type>, 2> &kv,
344 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
345 std::array<std::vector<typename Spline::value_type>, 1>(
348 std::tuple_element_t<0, boundary_spline_type>(
349 std::array<std::vector<typename Spline::value_type>, 1>(
352 std::tuple_element_t<1, boundary_spline_type>(
353 std::array<std::vector<typename Spline::value_type>, 1>(
356 std::tuple_element_t<1, boundary_spline_type>(
357 std::array<std::vector<typename Spline::value_type>, 1>(
372 if (tensor.dim() > 1) {
379 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0})
380 .reshape({-1, tensor.size(-1)}));
383 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1})
384 .reshape({-1, tensor.size(-1)}));
387 .index({torch::indexing::Slice(), 0, torch::indexing::Slice()})
388 .reshape({-1, tensor.size(-1)}));
391 .index({torch::indexing::Slice(), -1, torch::indexing::Slice()})
392 .reshape({-1, tensor.size(-1)}));
399 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0})
403 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1})
407 .index({torch::indexing::Slice(), 0, torch::indexing::Slice()})
411 .index({torch::indexing::Slice(), -1, torch::indexing::Slice()})
424 template <
short_t s>
inline constexpr auto &
side()
const {
425 static_assert(s >
none && s <= nsides());
426 return std::get<s - 1>(bdr_);
432 template <
short_t s>
inline constexpr auto &
side() {
433 static_assert(s >
none && s <= nsides());
434 return std::get<s - 1>(bdr_);
439 inline constexpr auto &
sides()
const {
return bdr_; }
443 inline constexpr auto &
sides() {
return bdr_; }
460 os << name() <<
"(\n"
469 inline nlohmann::json
to_json()
const override {
508template <
typename Spline>
509 requires SplineType<Spline>
522 std::tuple<
typename Spline::template derived_self_type<
523 typename Spline::value_type, Spline::geoDim(),
524 Spline::degree(1), Spline::degree(2)>,
525 typename Spline::template derived_self_type<
526 typename Spline::value_type, Spline::geoDim(),
527 Spline::degree(0), Spline::degree(2)>,
528 typename Spline::template derived_self_type<
529 typename Spline::value_type, Spline::geoDim(),
530 Spline::degree(0), Spline::degree(1)>>;
534 template <
typename real_t>
536 typename Spline::template derived_self_type<
537 real_t, Spline::geoDim(), Spline::degree(1), Spline::degree(2)>,
538 typename Spline::template derived_self_type<
539 real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(2)>,
540 typename Spline::template derived_self_type<
541 real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(1)>>;
544 std::tuple<std::tuple_element_t<0, boundary_spline_type>,
545 std::tuple_element_t<0, boundary_spline_type>,
546 std::tuple_element_t<1, boundary_spline_type>,
547 std::tuple_element_t<1, boundary_spline_type>,
548 std::tuple_element_t<2, boundary_spline_type>,
549 std::tuple_element_t<2, boundary_spline_type>>
568 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
569 std::tuple_element_t<0, boundary_spline_type>(options),
570 std::tuple_element_t<1, boundary_spline_type>(options),
571 std::tuple_element_t<1, boundary_spline_type>(options),
572 std::tuple_element_t<2, boundary_spline_type>(options),
573 std::tuple_element_t<2, boundary_spline_type>(options)}) {}
587 : bdr_(clone ?
std::apply(
588 [](const auto &...bspline) {
589 return std::make_tuple(bspline.clone()...);
602 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
603 std::array<int64_t, 2>({ncoeffs[1], ncoeffs[2]}),
init,
605 std::tuple_element_t<0, boundary_spline_type>(
606 std::array<int64_t, 2>({ncoeffs[1], ncoeffs[2]}),
init,
608 std::tuple_element_t<1, boundary_spline_type>(
609 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[2]}),
init,
611 std::tuple_element_t<1, boundary_spline_type>(
612 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[2]}),
init,
614 std::tuple_element_t<2, boundary_spline_type>(
615 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[1]}),
init,
617 std::tuple_element_t<2, boundary_spline_type>(
618 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[1]}),
init,
626 const std::array<std::vector<typename Spline::value_type>, 3> &kv,
630 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
631 std::array<std::vector<typename Spline::value_type>, 2>(
634 std::tuple_element_t<0, boundary_spline_type>(
635 std::array<std::vector<typename Spline::value_type>, 2>(
638 std::tuple_element_t<1, boundary_spline_type>(
639 std::array<std::vector<typename Spline::value_type>, 2>(
642 std::tuple_element_t<1, boundary_spline_type>(
643 std::array<std::vector<typename Spline::value_type>, 2>(
646 std::tuple_element_t<2, boundary_spline_type>(
647 std::array<std::vector<typename Spline::value_type>, 2>(
650 std::tuple_element_t<2, boundary_spline_type>(
651 std::array<std::vector<typename Spline::value_type>, 2>(
666 if (tensor.dim() > 1) {
673 .index({torch::indexing::Slice(), torch::indexing::Slice(),
674 torch::indexing::Slice(), 0})
675 .reshape({-1, tensor.size(-1)}));
678 .index({torch::indexing::Slice(), torch::indexing::Slice(),
679 torch::indexing::Slice(), -1})
680 .reshape({-1, tensor.size(-1)}));
683 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
684 torch::indexing::Slice()})
685 .reshape({-1, tensor.size(-1)}));
688 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
689 torch::indexing::Slice()})
690 .reshape({-1, tensor.size(-1)}));
693 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
694 torch::indexing::Slice()})
695 .reshape({-1, tensor.size(-1)}));
698 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
699 torch::indexing::Slice()})
700 .reshape({-1, tensor.size(-1)}));
708 .index({torch::indexing::Slice(), torch::indexing::Slice(),
709 torch::indexing::Slice(), 0})
713 .index({torch::indexing::Slice(), torch::indexing::Slice(),
714 torch::indexing::Slice(), -1})
719 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
720 torch::indexing::Slice()})
724 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
725 torch::indexing::Slice()})
730 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
731 torch::indexing::Slice()})
735 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
736 torch::indexing::Slice()})
749 template <
short_t s>
inline constexpr auto &
side()
const {
750 static_assert(s >
none && s <= nsides());
751 return std::get<s - 1>(bdr_);
757 template <
short_t s>
inline constexpr auto &
side() {
758 static_assert(s >
none && s <= nsides());
759 return std::get<s - 1>(bdr_);
764 inline constexpr auto &
sides()
const {
return bdr_; }
768 inline constexpr auto &
sides() {
return bdr_; }
787 os << name() <<
"(\n"
798 inline nlohmann::json
to_json()
const override {
844template <
typename Spline>
845 requires SplineType<Spline>
858 std::tuple<
typename Spline::template derived_self_type<
859 typename Spline::value_type, Spline::geoDim(),
860 Spline::degree(1), Spline::degree(2), Spline::degree(3)>,
861 typename Spline::template derived_self_type<
862 typename Spline::value_type, Spline::geoDim(),
863 Spline::degree(0), Spline::degree(2), Spline::degree(3)>,
864 typename Spline::template derived_self_type<
865 typename Spline::value_type, Spline::geoDim(),
866 Spline::degree(0), Spline::degree(1), Spline::degree(3)>,
867 typename Spline::template derived_self_type<
868 typename Spline::value_type, Spline::geoDim(),
869 Spline::degree(0), Spline::degree(1), Spline::degree(2)>>;
873 template <
typename real_t>
875 std::tuple<
typename Spline::template derived_self_type<
876 real_t, Spline::geoDim(), Spline::degree(1),
877 Spline::degree(2), Spline::degree(3)>,
878 typename Spline::template derived_self_type<
879 real_t, Spline::geoDim(), Spline::degree(0),
880 Spline::degree(2), Spline::degree(3)>,
881 typename Spline::template derived_self_type<
882 real_t, Spline::geoDim(), Spline::degree(0),
883 Spline::degree(1), Spline::degree(3)>,
884 typename Spline::template derived_self_type<
885 real_t, Spline::geoDim(), Spline::degree(0),
886 Spline::degree(1), Spline::degree(2)>>;
889 std::tuple<std::tuple_element_t<0, boundary_spline_type>,
890 std::tuple_element_t<0, boundary_spline_type>,
891 std::tuple_element_t<1, boundary_spline_type>,
892 std::tuple_element_t<1, boundary_spline_type>,
893 std::tuple_element_t<2, boundary_spline_type>,
894 std::tuple_element_t<2, boundary_spline_type>,
895 std::tuple_element_t<3, boundary_spline_type>,
896 std::tuple_element_t<3, boundary_spline_type>>
916 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
917 std::tuple_element_t<0, boundary_spline_type>(options),
918 std::tuple_element_t<1, boundary_spline_type>(options),
919 std::tuple_element_t<1, boundary_spline_type>(options),
920 std::tuple_element_t<2, boundary_spline_type>(options),
921 std::tuple_element_t<2, boundary_spline_type>(options),
922 std::tuple_element_t<3, boundary_spline_type>(options),
923 std::tuple_element_t<3, boundary_spline_type>(options)}) {}
937 : bdr_(clone ?
std::apply(
938 [](const auto &...bspline) {
939 return std::make_tuple(bspline.clone()...);
952 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
953 std::array<int64_t, 3>({ncoeffs[1], ncoeffs[2], ncoeffs[3]}),
955 std::tuple_element_t<0, boundary_spline_type>(
956 std::array<int64_t, 3>({ncoeffs[1], ncoeffs[2], ncoeffs[3]}),
958 std::tuple_element_t<1, boundary_spline_type>(
959 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[2], ncoeffs[3]}),
961 std::tuple_element_t<1, boundary_spline_type>(
962 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[2], ncoeffs[3]}),
964 std::tuple_element_t<2, boundary_spline_type>(
965 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[3]}),
967 std::tuple_element_t<2, boundary_spline_type>(
968 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[3]}),
970 std::tuple_element_t<3, boundary_spline_type>(
971 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[2]}),
973 std::tuple_element_t<3, boundary_spline_type>(
974 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[2]}),
982 const std::array<std::vector<typename Spline::value_type>, 4> &kv,
986 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
987 std::array<std::vector<typename Spline::value_type>, 3>(
988 {kv[1], kv[2], kv[3]}),
990 std::tuple_element_t<0, boundary_spline_type>(
991 std::array<std::vector<typename Spline::value_type>, 3>(
992 {kv[1], kv[2], kv[3]}),
994 std::tuple_element_t<1, boundary_spline_type>(
995 std::array<std::vector<typename Spline::value_type>, 3>(
996 {kv[0], kv[2], kv[3]}),
998 std::tuple_element_t<1, boundary_spline_type>(
999 std::array<std::vector<typename Spline::value_type>, 3>(
1000 {kv[0], kv[2], kv[3]}),
1002 std::tuple_element_t<2, boundary_spline_type>(
1003 std::array<std::vector<typename Spline::value_type>, 3>(
1004 {kv[0], kv[1], kv[3]}),
1006 std::tuple_element_t<2, boundary_spline_type>(
1007 std::array<std::vector<typename Spline::value_type>, 3>(
1008 {kv[0], kv[1], kv[3]}),
1010 std::tuple_element_t<3, boundary_spline_type>(
1011 std::array<std::vector<typename Spline::value_type>, 3>(
1012 {kv[0], kv[1], kv[2]}),
1014 std::tuple_element_t<3, boundary_spline_type>(
1015 std::array<std::vector<typename Spline::value_type>, 3>(
1016 {kv[0], kv[1], kv[2]}),
1030 if (tensor.dim() > 1) {
1031 auto tensor_view = tensor.view(
1037 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1038 torch::indexing::Slice(), torch::indexing::Slice(), 0})
1039 .reshape({-1, tensor.size(-1)}));
1042 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1043 torch::indexing::Slice(), torch::indexing::Slice(), -1})
1044 .reshape({-1, tensor.size(-1)}));
1047 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1048 torch::indexing::Slice(), 0, torch::indexing::Slice()})
1049 .reshape({-1, tensor.size(-1)}));
1052 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1053 torch::indexing::Slice(), -1, torch::indexing::Slice()})
1054 .reshape({-1, tensor.size(-1)}));
1057 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
1058 torch::indexing::Slice(), torch::indexing::Slice()})
1059 .reshape({-1, tensor.size(-1)}));
1062 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
1063 torch::indexing::Slice(), torch::indexing::Slice()})
1064 .reshape({-1, tensor.size(-1)}));
1067 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
1068 torch::indexing::Slice(), torch::indexing::Slice()})
1069 .reshape({-1, tensor.size(-1)}));
1072 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
1073 torch::indexing::Slice(), torch::indexing::Slice()})
1074 .reshape({-1, tensor.size(-1)}));
1082 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1083 torch::indexing::Slice(), torch::indexing::Slice(), 0})
1087 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1088 torch::indexing::Slice(), torch::indexing::Slice(), -1})
1093 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1094 torch::indexing::Slice(), 0, torch::indexing::Slice()})
1098 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1099 torch::indexing::Slice(), -1, torch::indexing::Slice()})
1104 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
1105 torch::indexing::Slice(), torch::indexing::Slice()})
1109 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
1110 torch::indexing::Slice(), torch::indexing::Slice()})
1115 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
1116 torch::indexing::Slice(), torch::indexing::Slice()})
1120 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
1121 torch::indexing::Slice(), torch::indexing::Slice()})
1134 template <
short_t s>
inline constexpr auto &
side()
const {
1135 static_assert(s >
none && s <= nsides());
1136 return std::get<s - 1>(bdr_);
1142 template <
short_t s>
inline constexpr auto &
side() {
1143 static_assert(s >
none && s <= nsides());
1144 return std::get<s - 1>(bdr_);
1149 inline constexpr auto &
sides()
const {
return bdr_; }
1153 inline constexpr auto &
ides() {
return bdr_; }
1174 os << name() <<
"(\n"
1188 nlohmann::json json;
1232template <
typename T>
1236template <
typename BoundaryCore>
1240 using BoundaryCore::BoundaryCore;
1251 template <std::size_t... Is>
1252 inline torch::Tensor
as_tensor_(std::index_sequence<Is...>)
const {
1253 return torch::cat({std::get<Is>(BoundaryCore::bdr_).as_tensor()...});
1262 return as_tensor_(std::make_index_sequence<BoundaryCore::nsides()>{});
1270 template <std::size_t... Is>
1273 [](
auto... size) {
return (size + ...); },
1274 std::make_tuple(std::get<Is>(BoundaryCore::bdr_).
as_tensor_size()...));
1283 return as_tensor_size_(std::make_index_sequence<BoundaryCore::nsides()>{});
1293 template <std::size_t... Is>
1295 const torch::Tensor &tensor) {
1297 std::size_t start(0);
1298 auto end = [&start](std::size_t inc) {
return start += inc; };
1300 (std::get<Is>(BoundaryCore::bdr_)
1301 .from_tensor(tensor.index({torch::indexing::Slice(
1302 start, end(std::get<Is>(BoundaryCore::bdr_).ncumcoeffs() *
1303 std::get<Is>(BoundaryCore::bdr_).geoDim()))})),
1317 return from_tensor_(std::make_index_sequence<BoundaryCore::nsides()>{},
1325 size_t... Is,
typename... Xi>
1326 inline auto eval_(std::index_sequence<Is...>,
1327 const std::tuple<Xi...> &xi)
const {
1329 std::get<Is>(BoundaryCore::bdr_)
1330 .
template eval<deriv, memory_optimized>(std::get<Is>(xi))...);
1334 size_t... Is,
typename... Xi,
typename... Indices>
1335 inline auto eval_(std::index_sequence<Is...>,
const std::tuple<Xi...> &xi,
1336 const std::tuple<Indices...> &indices)
const {
1337 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1338 .
template eval<deriv, memory_optimized>(
1339 std::get<Is>(xi), std::get<Is>(indices))...);
1343 size_t... Is,
typename... Xi,
typename... Indices,
1344 typename... Coeff_Indices>
1345 inline auto eval_(std::index_sequence<Is...>,
const std::tuple<Xi...> &xi,
1346 const std::tuple<Indices...> &indices,
1347 const std::tuple<Coeff_Indices...> &coeff_indices)
const {
1348 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1349 .
template eval<deriv, memory_optimized>(
1350 std::get<Is>(xi), std::get<Is>(indices),
1351 std::get<Is>(coeff_indices))...);
1362 inline auto eval(
const std::tuple<Xi...> &xi)
const {
1363 return eval_<deriv, memory_optimized>(
1364 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1372 typename... Xi,
typename... Indices>
1373 inline auto eval(
const std::tuple<Xi...> &xi,
1374 const std::tuple<Indices...> &indices)
const {
1375 static_assert(
sizeof...(Xi) ==
sizeof...(Indices));
1376 return eval_<deriv, memory_optimized>(
1377 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices);
1386 typename... Xi,
typename... Indices,
typename... Coeff_Indices>
1387 inline auto eval(
const std::tuple<Xi...> &xi,
1388 const std::tuple<Indices...> &indices,
1389 const std::tuple<Coeff_Indices...> &coeff_indices)
const {
1390 static_assert(
sizeof...(Xi) ==
sizeof...(Indices) &&
1391 sizeof...(Xi) ==
sizeof...(Coeff_Indices));
1392 return eval_<deriv, memory_optimized>(
1393 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices,
1401 template <
size_t... Is,
typename... Basfunc,
typename... Coeff_Indices,
1402 typename... Numeval,
typename... Sizes>
1405 const std::tuple<Basfunc...> &basfunc,
1406 const std::tuple<Coeff_Indices...> &coeff_indices,
1407 const std::tuple<Numeval...> &numeval,
1408 const std::tuple<Sizes...> &sizes)
const {
1409 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1411 std::get<Is>(coeff_indices),
1412 std::get<Is>(numeval),
1413 std::get<Is>(sizes))...);
1416 template <
size_t... Is,
typename... Basfunc,
typename... Coeff_Indices,
1420 const std::tuple<Basfunc...> &basfunc,
1421 const std::tuple<Coeff_Indices...> &coeff_indices,
1422 const std::tuple<Xi...> &xi)
const {
1424 std::get<Is>(BoundaryCore::bdr_)
1426 std::get<Is>(basfunc), std::get<Is>(coeff_indices),
1427 std::get<Is>(xi)[0].numel(), std::get<Is>(xi)[0].sizes())...);
1439 template <
typename... Basfunc,
typename... Coeff_Indices,
typename... Numeval,
1443 const std::tuple<Coeff_Indices...> &coeff_indices,
1444 const std::tuple<Numeval...> &numeval,
1445 const std::tuple<Sizes...> &sizes)
const {
1446 static_assert(
sizeof...(Basfunc) ==
sizeof...(Coeff_Indices) &&
1447 sizeof...(Basfunc) ==
sizeof...(Numeval) &&
1448 sizeof...(Basfunc) ==
sizeof...(Sizes));
1450 std::make_index_sequence<BoundaryCore::nsides()>{}, basfunc,
1451 coeff_indices, numeval, sizes);
1462 template <
typename... Basfunc,
typename... Coeff_Indices,
typename... Xi>
1465 const std::tuple<Coeff_Indices...> &coeff_indices,
1466 const std::tuple<Xi...> &xi)
const {
1467 static_assert(
sizeof...(Basfunc) ==
sizeof...(Coeff_Indices) &&
1468 sizeof...(Basfunc) ==
sizeof...(Xi));
1470 std::make_index_sequence<BoundaryCore::nsides()>{}, basfunc,
1478 template <
size_t... Is,
typename... Xi>
1480 const std::tuple<Xi...> &xi)
const {
1481 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1490 template <
typename... Xi>
1493 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1501 size_t... Is,
typename... Xi>
1503 const std::tuple<Xi...> &xi)
const {
1504 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1505 .
template eval_basfunc<deriv, memory_optimized>(
1506 std::get<Is>(xi))...);
1510 size_t... Is,
typename... Xi,
typename... Indices>
1512 const std::tuple<Xi...> &xi,
1513 const std::tuple<Indices...> &indices)
const {
1514 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1515 .
template eval_basfunc<deriv, memory_optimized>(
1516 std::get<Is>(xi), std::get<Is>(indices))...);
1528 return eval_basfunc_<deriv, memory_optimized>(
1529 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1537 typename... Xi,
typename... Indices>
1539 const std::tuple<Indices...> &indices)
const {
1540 static_assert(
sizeof...(Xi) ==
sizeof...(Indices));
1541 return eval_basfunc_<deriv, memory_optimized>(
1542 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices);
1549 template <
bool memory_optimized =
false,
size_t... Is,
typename... Indices>
1551 const std::tuple<Indices...> &indices)
const {
1552 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1553 .
template find_coeff_indices<memory_optimized>(
1554 std::get<Is>(indices))...);
1564 template <
bool memory_optimized =
false,
typename... Indices>
1566 return find_coeff_indices_<memory_optimized>(
1567 std::make_index_sequence<BoundaryCore::nsides()>{}, indices);
1573 template <
size_t... Is>
1576 (std::get<Is>(BoundaryCore::bdr_).uniform_refine(numRefine, dim), ...);
1588 if constexpr (BoundaryCore::spline_type::parDim() > 1)
1591 }
else if (dim == 0) {
1592 if constexpr (BoundaryCore::nsides() == 2) {
1594 }
else if constexpr (BoundaryCore::nsides() == 4) {
1599 }
else if constexpr (BoundaryCore::nsides() == 6) {
1608 }
else if constexpr (BoundaryCore::nsides() == 8) {
1622 throw std::runtime_error(
"Invalid dimension");
1623 }
else if (dim == 1) {
1624 if constexpr (BoundaryCore::nsides() == 4) {
1629 }
else if constexpr (BoundaryCore::nsides() == 6) {
1639 }
else if constexpr (BoundaryCore::nsides() == 8) {
1653 throw std::runtime_error(
"Invalid dimension");
1654 }
else if (dim == 2) {
1655 if constexpr (BoundaryCore::nsides() == 6) {
1664 }
else if constexpr (BoundaryCore::nsides() == 8) {
1678 throw std::runtime_error(
"Invalid dimension");
1679 }
else if (dim == 3) {
1680 if constexpr (BoundaryCore::nsides() == 8) {
1694 throw std::runtime_error(
"Invalid dimension");
1696 throw std::runtime_error(
"Invalid dimension");
1703 template <
size_t... Is>
1704 inline torch::serialize::OutputArchive &
1705 write_(std::index_sequence<Is...>, torch::serialize::OutputArchive &archive,
1706 const std::string &key =
"boundary")
const {
1707 (std::get<Is>(BoundaryCore::bdr_)
1708 .write(archive, key +
".bdr[" + std::to_string(Is) +
"]"),
1717 inline void save(
const std::string &filename,
1718 const std::string &key =
"boundary")
const {
1719 torch::serialize::OutputArchive archive;
1720 write(archive, key).save_to(filename);
1728 inline torch::serialize::OutputArchive &
1729 write(torch::serialize::OutputArchive &archive,
1730 const std::string &key =
"boundary")
const {
1731 write_(std::make_index_sequence<BoundaryCore::nsides()>{}, archive, key);
1738 template <
size_t... Is>
1739 inline torch::serialize::InputArchive &
1740 read_(std::index_sequence<Is...>, torch::serialize::InputArchive &archive,
1741 const std::string &key =
"boundary") {
1742 (std::get<Is>(BoundaryCore::bdr_)
1743 .read(archive, key +
".bdr[" + std::to_string(Is) +
"]"),
1752 inline void load(
const std::string &filename,
1753 const std::string &key =
"boundary") {
1754 torch::serialize::InputArchive archive;
1755 archive.load_from(filename);
1764 inline torch::serialize::InputArchive &
1765 read(torch::serialize::InputArchive &archive,
1766 const std::string &key =
"boundary") {
1767 read_(std::make_index_sequence<BoundaryCore::nsides()>{}, archive, key);
1776 [[nodiscard]]
inline pugi::xml_document
1777 to_xml(
int id = 0,
const std::string &label =
"",
int index = -1)
const {
1778 pugi::xml_document doc;
1779 pugi::xml_node root = doc.append_child(
"xml");
1780 to_xml(root,
id, label, index);
1791 inline pugi::xml_node &
to_xml(pugi::xml_node &root,
int id = 0,
1792 const std::string &label =
"",
1793 int index = -1)
const {
1795 pugi::xml_node bdr = root.append_child(
"Boundary");
1798 bdr.append_attribute(
"id") = id;
1801 bdr.append_attribute(
"index") = index;
1804 bdr.append_attribute(
"label") = label.c_str();
1808 [&bdr, &index_](
const auto &...bspline) {
1809 (bspline.to_xml(bdr, -1,
"", index_++), ...);
1811 BoundaryCore::bdr_);
1823 const std::string &label =
"",
1825 return from_xml(doc.child(
"xml"),
id, label, index);
1835 const std::string &label =
"",
1839 for (pugi::xml_node bdr : root.children(
"Boundary")) {
1842 if ((
id >= 0 ? bdr.attribute(
"id").as_int() ==
id :
true) &&
1843 (index >= 0 ? bdr.attribute(
"index").as_int() == index :
true) &&
1844 (!label.empty() ? bdr.attribute(
"label").value() == label :
true)) {
1848 [&bdr, &index_](
auto &...bspline) {
1849 (bspline.from_xml(bdr, -1,
"", index_++), ...);
1851 BoundaryCore::bdr_);
1858 throw std::runtime_error(
"XML object does not provide geometry with given "
1859 "id, index, and/or label");
1866 template <
typename BoundaryCore_,
size_t... Is>
1869 return ((std::get<Is>(BoundaryCore::bdr_) == std::get<Is>(other.sides())) &&
1878 template <
typename BoundaryCore_>
1880 return isequal_(std::make_index_sequence<BoundaryCore::nsides()>{}, other);
1887 template <
typename BoundaryCore_>
1897 template <
typename BoundaryCore_,
size_t... Is>
1900 BoundaryCore::spline_type::value_type rtol,
1901 BoundaryCore::spline_type::value_type atol)
const {
1902 return ((std::get<Is>(BoundaryCore::bdr_)
1903 .
isclose(std::get<Is>(other.sides()))) &&
1915 template <
typename BoundaryCore_>
1918 BoundaryCore::spline_type::value_type rtol =
1919 typename BoundaryCore::spline_type::value_type{1e-5},
1920 BoundaryCore::spline_type::value_type atol =
1921 typename BoundaryCore::spline_type::value_type{1e-8})
const {
1922 return isclose_(std::make_index_sequence<BoundaryCore::nsides()>{}, other,
1926#define GENERATE_EXPR_MACRO(r, data, name) \
1928 template <bool memory_optimized = false, size_t... Is, typename... Xi> \
1929 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1930 const std::tuple<Xi...> &xi) const { \
1931 return std::tuple( \
1932 std::get<Is>(BoundaryCore::bdr_) \
1933 .template name<memory_optimized>(std::get<Is>(xi))...); \
1936 template <bool memory_optimized = false, size_t... Is, typename... Xi, \
1937 typename... Indices> \
1938 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1939 const std::tuple<Xi...> &xi, \
1940 const std::tuple<Indices...> &indices) \
1942 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1943 .template name<memory_optimized>( \
1944 std::get<Is>(xi), std::get<Is>(indices))...); \
1947 template <bool memory_optimized = false, size_t... Is, typename... Xi, \
1948 typename... Indices, typename... Coeff_Indices> \
1949 inline auto BOOST_PP_CAT(name, _)( \
1950 std::index_sequence<Is...>, const std::tuple<Xi...> &xi, \
1951 const std::tuple<Indices...> &indices, \
1952 const std::tuple<Coeff_Indices...> &coeff_indices) const { \
1953 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1954 .template name<memory_optimized>( \
1955 std::get<Is>(xi), std::get<Is>(indices), \
1956 std::get<Is>(coeff_indices))...); \
1960 template <bool memory_optimized = false, typename... Args> \
1961 inline auto name(const Args &...args) const { \
1962 return BOOST_PP_CAT(name, _)<memory_optimized>( \
1963 std::make_index_sequence<BoundaryCore::nsides()>{}, args...); \
1970#undef GENERATE_EXPR_MACRO
1972#define GENERATE_IEXPR_MACRO(r, data, name) \
1974 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1976 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1977 const std::tuple<Geometry...> &G, \
1978 const std::tuple<Xi...> &xi) const { \
1979 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1980 .template name<memory_optimized>( \
1981 std::get<Is>(G), std::get<Is>(xi))...); \
1984 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1985 typename... Xi, typename... Indices> \
1986 inline auto BOOST_PP_CAT(name, _)( \
1987 std::index_sequence<Is...>, const std::tuple<Geometry...> &G, \
1988 const std::tuple<Xi...> &xi, const std::tuple<Indices...> &indices) \
1990 return std::tuple( \
1991 std::get<Is>(BoundaryCore::bdr_) \
1992 .template name<memory_optimized>( \
1993 std::get<Is>(G), std::get<Is>(xi), std::get<Is>(indices))...); \
1996 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1997 typename... Xi, typename... Indices, typename... Coeff_Indices> \
1998 inline auto BOOST_PP_CAT(name, _)( \
1999 std::index_sequence<Is...>, const std::tuple<Geometry...> &G, \
2000 const std::tuple<Xi...> &xi, const std::tuple<Indices...> &indices, \
2001 const std::tuple<Coeff_Indices...> &coeff_indices) const { \
2002 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
2003 .template name<memory_optimized>( \
2004 std::get<Is>(G), std::get<Is>(xi), \
2005 std::get<Is>(indices), \
2006 std::get<Is>(coeff_indices))...); \
2010 template <bool memory_optimized = false, typename... Args> \
2011 inline auto name(const Args &...args) const { \
2012 return BOOST_PP_CAT(name, _)<memory_optimized>( \
2013 std::make_index_sequence<BoundaryCore::nsides()>{}, args...); \
2020#undef GENERATE_IEXPR_MACRO
2026 [](
const auto &...bspline) {
2027 return std::make_tuple(bspline.device()...);
2029 BoundaryCore::bdr_);
2036 [](
const auto &...bspline) {
2037 return std::make_tuple(bspline.device_index()...);
2039 BoundaryCore::bdr_);
2046 [](
const auto &...bspline) {
2047 return std::make_tuple(bspline.dtype()...);
2049 BoundaryCore::bdr_);
2056 [](
const auto &...bspline) {
2057 return std::make_tuple(bspline.layout()...);
2059 BoundaryCore::bdr_);
2066 [](
const auto &...bspline) {
2067 return std::make_tuple(bspline.requires_grad()...);
2069 BoundaryCore::bdr_);
2076 [](
const auto &...bspline) {
2077 return std::make_tuple(bspline.pinned_memory()...);
2079 BoundaryCore::bdr_);
2086 [](
const auto &...bspline) {
2087 return std::make_tuple(bspline.is_sparse()...);
2089 BoundaryCore::bdr_);
2096 [](
const auto &...bspline) {
2097 return std::make_tuple(bspline.is_uniform()...);
2099 BoundaryCore::bdr_);
2106 [](
const auto &...bspline) {
2107 return std::make_tuple(bspline.is_nonuniform()...);
2109 BoundaryCore::bdr_);
2120 BoundaryCore::bdr_);
2131 decltype(
typename BoundaryCore::spline_type{}.to(options)),
2132 BoundaryCore::spline_type::parDim()>>;
2134 return boundary_type(std::apply(
2135 [&options](
const auto &...bspline) {
2136 return std::make_tuple(bspline.to(options)...);
2138 BoundaryCore::bdr_));
2146 [&
device](
const auto &...bspline) {
2147 return std::make_tuple(bspline.to(
device)...);
2149 BoundaryCore::bdr_));
2155 template <
typename real_t>
inline auto to()
const {
2157 decltype(
typename BoundaryCore::spline_type{}.template to<real_t>()),
2158 BoundaryCore::spline_type::parDim()>>;
2160 return boundary_type(std::apply(
2161 [](
const auto &...bspline) {
2162 return std::make_tuple(bspline.template to<real_t>()...);
2164 BoundaryCore::bdr_));
2169template <
typename Spline>
2170 requires SplineType<Spline>
2179template <
typename Spline>
2182 obj.pretty_print(os);
#define GENERATE_IEXPR_MACRO(r, data, name)
Auto-generated functions.
Definition boundary.hpp:1972
#define GENERATE_EXPR_MACRO(r, data, name)
Definition boundary.hpp:1926
#define GENERATE_EXPR_SEQ
Sequence of expression (parametric coordinates).
Definition bspline.hpp:43
#define GENERATE_IEXPR_SEQ
Sequence of expression (physical coordinates).
Definition bspline.hpp:49
Boundary base class.
Definition boundary.hpp:1228
Boundary (common high-level functionality).
Definition boundary.hpp:1237
auto find_knot_indices(const std::tuple< Xi... > &xi) const
Returns the knot indices of knot spans containing xi.
Definition boundary.hpp:1491
BoundaryCommon & from_xml(const pugi::xml_node &root, int id=0, const std::string &label="", int index=-1)
Updates the boundary object from XML node.
Definition boundary.hpp:1834
auto to(torch::Device device) const
Returns a copy of the boundary object with settings from device.
Definition boundary.hpp:2144
auto dtype() const noexcept
Returns the dtype property of all splines.
Definition boundary.hpp:2044
auto eval_from_precomputed(const std::tuple< Basfunc... > &basfunc, const std::tuple< Coeff_Indices... > &coeff_indices, const std::tuple< Numeval... > &numeval, const std::tuple< Sizes... > &sizes) const
Returns the value of the spline objects from precomputed basis function.
Definition boundary.hpp:1442
auto pinned_memory() const noexcept
Returns the pinned_memory property of all splines.
Definition boundary.hpp:2074
bool isequal_(std::index_sequence< Is... >, const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary spline objects are the same.
Definition boundary.hpp:1867
auto eval_basfunc(const std::tuple< Xi... > &xi) const
Returns the values of the spline objects' basis functions in the points xi
Definition boundary.hpp:1527
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="boundary")
Loads the boundary spline object from a torch::serialize::InputArchive object.
Definition boundary.hpp:1765
BoundaryCommon & from_xml(const pugi::xml_document &doc, int id=0, const std::string &label="", int index=-1)
Updates the boundary object from XML object.
Definition boundary.hpp:1822
auto eval(const std::tuple< Xi... > &xi) const
Returns the values of the spline objects in the points xi
Definition boundary.hpp:1362
auto eval_from_precomputed_(std::index_sequence< Is... >, const std::tuple< Basfunc... > &basfunc, const std::tuple< Coeff_Indices... > &coeff_indices, const std::tuple< Numeval... > &numeval, const std::tuple< Sizes... > &sizes) const
Returns the value of the boundary spline objects from precomputed basis function.
Definition boundary.hpp:1404
auto to() const
Returns a copy of the boundary object with real_t type.
Definition boundary.hpp:2155
auto to(Options< real_t > options) const
Returns a copy of the boundary object with settings from options.
Definition boundary.hpp:2129
auto device_index() const noexcept
Returns the device_index property of all splines.
Definition boundary.hpp:2034
auto is_uniform() const noexcept
Returns whether each B-spline is uniform.
Definition boundary.hpp:2094
torch::Tensor as_tensor_(std::index_sequence< Is... >) const
Returns all coefficients of all spline objects as a single tensor.
Definition boundary.hpp:1252
bool isclose(const BoundaryCommon< BoundaryCore_ > &other, BoundaryCore::spline_type::value_type rtol=typename BoundaryCore::spline_type::value_type{1e-5}, BoundaryCore::spline_type::value_type atol=typename BoundaryCore::spline_type::value_type{1e-8}) const
Returns true if both boundary objects are close up to the given tolerances.
Definition boundary.hpp:1917
int64_t as_tensor_size_(std::index_sequence< Is... >) const
Returns the size of the single tensor representation of all spline objects.
Definition boundary.hpp:1271
auto eval_basfunc_(std::index_sequence< Is... >, const std::tuple< Xi... > &xi) const
Returns the values of the boundary spline object's basis functions in the points xi
Definition boundary.hpp:1502
auto find_knot_indices_(std::index_sequence< Is... >, const std::tuple< Xi... > &xi) const
Returns the knot indices of the boundary spline object knot spans containing xi.
Definition boundary.hpp:1479
auto & uniform_refine_(std::index_sequence< Is... >, int numRefine=1, int dim=-1)
Returns the boundary spline object with uniformly refined knot and coefficient vectors.
Definition boundary.hpp:1574
torch::serialize::OutputArchive & write_(std::index_sequence< Is... >, torch::serialize::OutputArchive &archive, const std::string &key="boundary") const
Writes the boundary spline object into a torch::serialize::OutputArchive object.
Definition boundary.hpp:1705
auto is_nonuniform() const noexcept
Returns whether each B-spline is non-uniform.
Definition boundary.hpp:2104
auto eval_(std::index_sequence< Is... >, const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices, const std::tuple< Coeff_Indices... > &coeff_indices) const
Returns the values of the boundary spline objects in the points xi
Definition boundary.hpp:1345
auto find_coeff_indices(const std::tuple< Indices... > &indices) const
Returns the indices of the spline objects' coefficients corresponding to the knot indices indices.
Definition boundary.hpp:1565
auto requires_grad() const noexcept
Returns the requires_grad property of all splines.
Definition boundary.hpp:2064
auto eval(const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices) const
Provides the eval operation.
Definition boundary.hpp:1373
BoundaryCommon clone() const
Returns a clone of the boundary object.
Definition boundary.hpp:1244
auto eval_basfunc(const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices) const
Provides the eval_basfunc operation.
Definition boundary.hpp:1538
auto & from_tensor(const torch::Tensor &tensor)
Sets the coefficients of all spline objects from a single tensor.
Definition boundary.hpp:1316
auto & from_tensor_(std::index_sequence< Is... >, const torch::Tensor &tensor)
Sets the coefficients of all spline objects from a single tensor.
Definition boundary.hpp:1294
auto eval(const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices, const std::tuple< Coeff_Indices... > &coeff_indices) const
Provides the eval operation.
Definition boundary.hpp:1387
pugi::xml_document to_xml(int id=0, const std::string &label="", int index=-1) const
Returns the boundary object as XML object.
Definition boundary.hpp:1777
void load(const std::string &filename, const std::string &key="boundary")
Loads the boundary spline object from file.
Definition boundary.hpp:1752
torch::Tensor as_tensor() const
Returns all coefficients of all spline objects as a single tensor.
Definition boundary.hpp:1261
auto eval_basfunc_(std::index_sequence< Is... >, const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices) const
Returns the values of the boundary spline object's basis functions in the points xi
Definition boundary.hpp:1511
BoundaryCommon & set_requires_grad(bool requires_grad)
Sets the boundary object's requires_grad property.
Definition boundary.hpp:2115
auto eval_(std::index_sequence< Is... >, const std::tuple< Xi... > &xi) const
Returns the values of the boundary spline objects in the points xi
Definition boundary.hpp:1326
pugi::xml_node & to_xml(pugi::xml_node &root, int id=0, const std::string &label="", int index=-1) const
Returns the boundary object as XML node.
Definition boundary.hpp:1791
auto & uniform_refine(int numRefine=1, int dim=-1)
Returns the spline objects with uniformly refined knot and coefficient vectors.
Definition boundary.hpp:1586
auto eval_from_precomputed_(std::index_sequence< Is... >, const std::tuple< Basfunc... > &basfunc, const std::tuple< Coeff_Indices... > &coeff_indices, const std::tuple< Xi... > &xi) const
Returns the value of the boundary spline objects from precomputed basis function.
Definition boundary.hpp:1419
int64_t as_tensor_size() const
Returns the size of the single tensor representation of all spline objects.
Definition boundary.hpp:1282
auto eval_from_precomputed(const std::tuple< Basfunc... > &basfunc, const std::tuple< Coeff_Indices... > &coeff_indices, const std::tuple< Xi... > &xi) const
Provides the eval_from_precomputed operation.
Definition boundary.hpp:1464
bool operator==(const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary objects are the same.
Definition boundary.hpp:1879
auto find_coeff_indices_(std::index_sequence< Is... >, const std::tuple< Indices... > &indices) const
Returns the indices of the boundary spline object's coefficients corresponding to the knot indices in...
Definition boundary.hpp:1550
auto layout() const noexcept
Returns the layout property of all splines.
Definition boundary.hpp:2054
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="boundary") const
Writes the boundary spline object into a torch::serialize::OutputArchive object.
Definition boundary.hpp:1729
bool isclose_(std::index_sequence< Is... >, const BoundaryCommon< BoundaryCore_ > &other, BoundaryCore::spline_type::value_type rtol, BoundaryCore::spline_type::value_type atol) const
Returns true if both boundary spline objects are close up to the given tolerances.
Definition boundary.hpp:1898
torch::serialize::InputArchive & read_(std::index_sequence< Is... >, torch::serialize::InputArchive &archive, const std::string &key="boundary")
Loads the function space object from a torch::serialize::InputArchive object.
Definition boundary.hpp:1740
auto eval_(std::index_sequence< Is... >, const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices) const
Returns the values of the boundary spline objects in the points xi
Definition boundary.hpp:1335
void save(const std::string &filename, const std::string &key="boundary") const
Saves the boundary spline to file.
Definition boundary.hpp:1717
auto device() const noexcept
Auto-generated functions.
Definition boundary.hpp:2024
bool operator!=(const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary objects are different.
Definition boundary.hpp:1888
auto is_sparse() const noexcept
Returns whether the layout of each spline is sparse.
Definition boundary.hpp:2084
constexpr auto & side() const
Returns constant reference to side-th Spline.
Definition boundary.hpp:169
BoundaryCore(const std::array< int64_t, 1 > &, enum init init=init::zeros, Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Constructor.
Definition boundary.hpp:115
constexpr auto & sides()
Returns a non-constant reference to the tuple of boundary sides.
Definition boundary.hpp:190
std::tuple< boundary_spline_type, boundary_spline_type > bdr_
Tuple of splines.
Definition boundary.hpp:75
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:204
Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim()> boundary_spline_type
Boundary spline type.
Definition boundary.hpp:66
std::tuple< torch::Tensor, torch::Tensor > eval_type
Evaluation type.
Definition boundary.hpp:85
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:104
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:95
BoundaryCore(const std::array< std::vector< typename Spline::value_type >, 1 > &, enum init init=init::zeros, Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Constructor.
Definition boundary.hpp:125
~BoundaryCore() override=default
Destructor.
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:164
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:89
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:194
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:223
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:99
constexpr auto & side()
Returns non-constant reference to side-th Spline.
Definition boundary.hpp:177
Spline::value_type value_type
Value type.
Definition boundary.hpp:79
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:212
Spline spline_type
Spline type.
Definition boundary.hpp:61
constexpr auto & sides() const
Returns a constant reference to the tuple of boundary sides.
Definition boundary.hpp:185
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:82
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:232
auto & from_full_tensor(const torch::Tensor &tensor)
Sets the coefficients of all spline objects from a single tensor that holds both boundary and inner c...
Definition boundary.hpp:142
Spline::template derived_self_type< real_t, Spline::geoDim()> real_derived_boundary_spline_type
Deduces the derived boundary spline type when exposed to a different class template parameter real_t.
Definition boundary.hpp:72
std::tuple< typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(1)>, typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(0)> > boundary_spline_type
Boundary spline type.
Definition boundary.hpp:261
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:459
constexpr auto & sides() const
Returns a constant reference to the tuple of boundary sides.
Definition boundary.hpp:439
constexpr auto & side()
Returns non-constant reference to the s-th side's spline.
Definition boundary.hpp:432
std::tuple< utils::TensorArray< 1 >, utils::TensorArray< 1 >, utils::TensorArray< 1 >, utils::TensorArray< 1 > > eval_type
Evaluation type.
Definition boundary.hpp:288
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:419
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:493
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:310
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:469
constexpr auto & sides()
Returns a non-constant reference to the tuple of boundary sides.
Definition boundary.hpp:443
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:482
Spline spline_type
Spline type.
Definition boundary.hpp:254
auto & from_full_tensor(const torch::Tensor &tensor)
Sets the coefficients of all spline objects from a single tensor that holds both boundary and inner c...
Definition boundary.hpp:370
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:284
std::tuple< std::tuple_element_t< 0, boundary_spline_type >, std::tuple_element_t< 0, boundary_spline_type >, std::tuple_element_t< 1, boundary_spline_type >, std::tuple_element_t< 1, boundary_spline_type > > bdr_
Tuple of splines.
Definition boundary.hpp:277
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:292
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:301
Spline::value_type value_type
Value type.
Definition boundary.hpp:281
std::tuple< typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(1)>, typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(0)> > real_derived_boundary_spline_type
Deduces the derived boundary spline type when exposed to a different class template parameter real_t.
Definition boundary.hpp:270
BoundaryCore(const std::array< int64_t, 2 > &ncoeffs, enum init init=init::zeros, Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Constructor.
Definition boundary.hpp:322
constexpr auto & side() const
Returns constant reference to the s-th side's spline.
Definition boundary.hpp:424
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:447
BoundaryCore(const std::array< std::vector< typename Spline::value_type >, 2 > &kv, enum init init=init::zeros, Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Constructor.
Definition boundary.hpp:339
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:305
~BoundaryCore() override=default
Destructor.
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:813
constexpr auto & sides() const
Returns a constant reference to the tuple of boundary sides.
Definition boundary.hpp:764
Spline::value_type value_type
Value type.
Definition boundary.hpp:554
~BoundaryCore() override=default
Destructor.
constexpr auto & side() const
Returns constant reference to side-th spline.
Definition boundary.hpp:749
BoundaryCore(const std::array< std::vector< typename Spline::value_type >, 3 > &kv, enum init init=init::zeros, Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Constructor.
Definition boundary.hpp:625
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:577
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:557
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:586
Spline spline_type
Spline type.
Definition boundary.hpp:518
std::tuple< typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(1), Spline::degree(2)>, typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(0), Spline::degree(2)>, typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(0), Spline::degree(1)> > boundary_spline_type
Boundary spline type.
Definition boundary.hpp:530
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:581
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:566
constexpr auto & sides()
Returns a non-constant reference to the tuple of sides.
Definition boundary.hpp:768
BoundaryCore(const std::array< int64_t, 3 > &ncoeffs, enum init init=init::zeros, Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Constructor.
Definition boundary.hpp:598
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:772
auto & from_full_tensor(const torch::Tensor &tensor)
Sets the coefficients of all spline objects from a single tensor that holds both boundary and inner c...
Definition boundary.hpp:664
std::tuple< std::tuple_element_t< 0, boundary_spline_type >, std::tuple_element_t< 0, boundary_spline_type >, std::tuple_element_t< 1, boundary_spline_type >, std::tuple_element_t< 1, boundary_spline_type >, std::tuple_element_t< 2, boundary_spline_type >, std::tuple_element_t< 2, boundary_spline_type > > bdr_
Tuple of splines.
Definition boundary.hpp:550
std::tuple< typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(1), Spline::degree(2)>, typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(2)>, typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(1)> > real_derived_boundary_spline_type
Deduces the derived boundary spline type when exposed to a different class template parameter real_t.
Definition boundary.hpp:541
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:798
constexpr auto & side()
Returns non-constant reference to side-th spline.
Definition boundary.hpp:757
std::tuple< utils::TensorArray< 2 >, utils::TensorArray< 2 >, utils::TensorArray< 2 >, utils::TensorArray< 2 >, utils::TensorArray< 2 >, utils::TensorArray< 2 > > eval_type
Evaluation type.
Definition boundary.hpp:562
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:744
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:786
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:826
BoundaryCore(const std::array< int64_t, 4 > &ncoeffs, enum init init=init::zeros, Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Constructor.
Definition boundary.hpp:948
constexpr auto & side()
Returns non-constant reference to side-th spline.
Definition boundary.hpp:1142
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:1204
auto & from_full_tensor(const torch::Tensor &tensor)
Sets the coefficients of all spline objects from a single tensor that holds both boundary and inner c...
Definition boundary.hpp:1028
std::tuple< std::tuple_element_t< 0, boundary_spline_type >, std::tuple_element_t< 0, boundary_spline_type >, std::tuple_element_t< 1, boundary_spline_type >, std::tuple_element_t< 1, boundary_spline_type >, std::tuple_element_t< 2, boundary_spline_type >, std::tuple_element_t< 2, boundary_spline_type >, std::tuple_element_t< 3, boundary_spline_type >, std::tuple_element_t< 3, boundary_spline_type > > bdr_
Tuple of splines.
Definition boundary.hpp:897
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:1219
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:1157
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:931
Spline::value_type value_type
Value type.
Definition boundary.hpp:901
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:1129
~BoundaryCore() override=default
Destructor.
std::tuple< utils::TensorArray< 3 >, utils::TensorArray< 3 >, utils::TensorArray< 3 >, utils::TensorArray< 3 >, utils::TensorArray< 3 >, utils::TensorArray< 3 >, utils::TensorArray< 3 >, utils::TensorArray< 3 > > eval_type
Evaluation type.
Definition boundary.hpp:910
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:936
Spline spline_type
Spline type.
Definition boundary.hpp:854
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:927
constexpr auto & ides()
Returns a non-constant reference to the tuple of boundary sides.
Definition boundary.hpp:1153
constexpr auto & side() const
Returns constant reference to side-th spline.
Definition boundary.hpp:1134
BoundaryCore(const std::array< std::vector< typename Spline::value_type >, 4 > &kv, enum init init=init::zeros, Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Constructor.
Definition boundary.hpp:981
std::tuple< typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(1), Spline::degree(2), Spline::degree(3)>, typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(0), Spline::degree(2), Spline::degree(3)>, typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(0), Spline::degree(1), Spline::degree(3)>, typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim(), Spline::degree(0), Spline::degree(1), Spline::degree(2)> > boundary_spline_type
Array storing the degrees.
Definition boundary.hpp:869
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:1187
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:1173
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:914
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:904
constexpr auto & sides() const
Returns a constant reference to the tuple of boundary sides.
Definition boundary.hpp:1149
std::tuple< typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(1), Spline::degree(2), Spline::degree(3)>, typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(2), Spline::degree(3)>, typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(1), Spline::degree(3)>, typename Spline::template derived_self_type< real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(1), Spline::degree(2)> > real_derived_boundary_spline_type
Deduces the derived boundary spline type when exposed to a different class template parameter real_t.
Definition boundary.hpp:886
BoundaryCore.
Definition boundary.hpp:44
The Options class handles the automated determination of dtype from the template argument and the sel...
Definition options.hpp:47
Full qualified name descriptor.
Definition fqn.hpp:22
Concept to identify template parameters that are derived from iganet::Boundary_.
Definition boundary.hpp:1233
Concept to identify template parameters that are derived from iganet::Spline_.
Definition bspline.hpp:3858
std::array< torch::Tensor, N > TensorArray
Definition tensorarray.hpp:26
deriv
Enumerator for specifying the derivative of B-spline evaluation.
Definition bspline.hpp:76
std::ostream & operator<<(std::ostream &os, const MemoryDebugger< id > &obj)
Prints a memory debugger object.
Definition memory.hpp:145
init
Enumerator for specifying the initialization of B-spline coefficients.
Definition bspline.hpp:58
side
Identifiers for topological sides.
Definition boundary.hpp:25
@ stime
Definition boundary.hpp:32
@ down
Definition boundary.hpp:36
@ right
Definition boundary.hpp:35
@ left
Definition boundary.hpp:34
@ back
Definition boundary.hpp:31
@ east
Definition boundary.hpp:27
@ etime
Definition boundary.hpp:33
@ front
Definition boundary.hpp:30
@ north
Definition boundary.hpp:29
@ south
Definition boundary.hpp:28
@ west
Definition boundary.hpp:26
@ up
Definition boundary.hpp:37
@ none
Definition boundary.hpp:38
short int short_t
Signed short integer type used by IgANet's compact enumerations.
Definition core.hpp:76
Serialization prototype.
Definition serialize.hpp:29