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>;
90 : bdr_({boundary_spline_type(options), boundary_spline_type(options)}) {}
100 : bdr_(clone ?
std::apply(
101 [](const auto &...bspline) {
102 return std::make_tuple(bspline.clone()...);
112 : bdr_({boundary_spline_type(std::array<int64_t, 0>{},
init, options),
113 boundary_spline_type(std::array<int64_t, 0>{},
init, options)}) {}
117 const std::array<std::vector<typename Spline::value_type>, 1> &,
121 : bdr_({boundary_spline_type(std::array<int64_t, 0>{},
init, options),
122 boundary_spline_type(std::array<int64_t, 0>{},
init, options)}) {}
135 if (tensor.dim() > 1) {
136 auto tensor_view = tensor.view({Spline::geoDim(), -1, tensor.size(-1)});
138 side<west>().from_tensor(tensor_view.index({torch::indexing::Slice(), 0})
139 .reshape({-1, tensor.size(-1)}));
140 side<east>().from_tensor(tensor_view.index({torch::indexing::Slice(), -1})
141 .reshape({-1, tensor.size(-1)}));
143 auto tensor_view = tensor.view({Spline::geoDim(), -1});
146 tensor_view.index({torch::indexing::Slice(), 0}).flatten());
148 tensor_view.index({torch::indexing::Slice(), -1}).flatten());
157 template <
short_t s>
inline constexpr auto &
side()
const {
158 static_assert(s >
none && s <= nsides());
159 return std::get<s - 1>(bdr_);
163 template <
short_t s>
inline constexpr auto &
side() {
164 static_assert(s >
none && s <= nsides());
165 return std::get<s - 1>(bdr_);
170 inline constexpr auto &
sides()
const {
return bdr_; }
174 inline constexpr auto &
sides() {
return bdr_; }
187 os << name() <<
"(\n"
193 inline nlohmann::json
to_json()
const override {
222template <
typename Spline>
223 requires SplineType<Spline>
236 typename Spline::template derived_self_type<
237 typename Spline::value_type, Spline::geoDim(), Spline::degree(1)>,
238 typename Spline::template derived_self_type<
239 typename Spline::value_type, Spline::geoDim(), Spline::degree(0)>>;
243 template <
typename real_t>
245 std::tuple<
typename Spline::template derived_self_type<
246 real_t, Spline::geoDim(), Spline::degree(1)>,
247 typename Spline::template derived_self_type<
248 real_t, Spline::geoDim(), Spline::degree(0)>>;
251 std::tuple<std::tuple_element_t<0, boundary_spline_type>,
252 std::tuple_element_t<0, boundary_spline_type>,
253 std::tuple_element_t<1, boundary_spline_type>,
254 std::tuple_element_t<1, boundary_spline_type>>
271 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
272 std::tuple_element_t<0, boundary_spline_type>(options),
273 std::tuple_element_t<1, boundary_spline_type>(options),
274 std::tuple_element_t<1, boundary_spline_type>(options)}) {}
284 : bdr_(clone ?
std::apply(
285 [](const auto &...bspline) {
286 return std::make_tuple(bspline.clone()...);
296 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
297 std::array<int64_t, 1>({ncoeffs[1]}),
init, options),
298 std::tuple_element_t<0, boundary_spline_type>(
299 std::array<int64_t, 1>({ncoeffs[1]}),
init, options),
300 std::tuple_element_t<1, boundary_spline_type>(
301 std::array<int64_t, 1>({ncoeffs[0]}),
init, options),
302 std::tuple_element_t<1, boundary_spline_type>(
303 std::array<int64_t, 1>({ncoeffs[0]}),
init, options)}) {}
307 const std::array<std::vector<typename Spline::value_type>, 2> &kv,
311 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
312 std::array<std::vector<typename Spline::value_type>, 1>(
315 std::tuple_element_t<0, boundary_spline_type>(
316 std::array<std::vector<typename Spline::value_type>, 1>(
319 std::tuple_element_t<1, boundary_spline_type>(
320 std::array<std::vector<typename Spline::value_type>, 1>(
323 std::tuple_element_t<1, boundary_spline_type>(
324 std::array<std::vector<typename Spline::value_type>, 1>(
339 if (tensor.dim() > 1) {
346 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0})
347 .reshape({-1, tensor.size(-1)}));
350 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1})
351 .reshape({-1, tensor.size(-1)}));
354 .index({torch::indexing::Slice(), 0, torch::indexing::Slice()})
355 .reshape({-1, tensor.size(-1)}));
358 .index({torch::indexing::Slice(), -1, torch::indexing::Slice()})
359 .reshape({-1, tensor.size(-1)}));
366 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0})
370 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1})
374 .index({torch::indexing::Slice(), 0, torch::indexing::Slice()})
378 .index({torch::indexing::Slice(), -1, torch::indexing::Slice()})
388 template <
short_t s>
inline constexpr auto &
side()
const {
389 static_assert(s >
none && s <= nsides());
390 return std::get<s - 1>(bdr_);
394 template <
short_t s>
inline constexpr auto &
side() {
395 static_assert(s >
none && s <= nsides());
396 return std::get<s - 1>(bdr_);
400 inline constexpr auto &
sides()
const {
return bdr_; }
403 inline constexpr auto &
sides() {
return bdr_; }
418 os << name() <<
"(\n"
426 inline nlohmann::json
to_json()
const override {
462template <
typename Spline>
463 requires SplineType<Spline>
476 std::tuple<
typename Spline::template derived_self_type<
477 typename Spline::value_type, Spline::geoDim(),
478 Spline::degree(1), Spline::degree(2)>,
479 typename Spline::template derived_self_type<
480 typename Spline::value_type, Spline::geoDim(),
481 Spline::degree(0), Spline::degree(2)>,
482 typename Spline::template derived_self_type<
483 typename Spline::value_type, Spline::geoDim(),
484 Spline::degree(0), Spline::degree(1)>>;
488 template <
typename real_t>
490 typename Spline::template derived_self_type<
491 real_t, Spline::geoDim(), Spline::degree(1), Spline::degree(2)>,
492 typename Spline::template derived_self_type<
493 real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(2)>,
494 typename Spline::template derived_self_type<
495 real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(1)>>;
498 std::tuple<std::tuple_element_t<0, boundary_spline_type>,
499 std::tuple_element_t<0, boundary_spline_type>,
500 std::tuple_element_t<1, boundary_spline_type>,
501 std::tuple_element_t<1, boundary_spline_type>,
502 std::tuple_element_t<2, boundary_spline_type>,
503 std::tuple_element_t<2, boundary_spline_type>>
521 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
522 std::tuple_element_t<0, boundary_spline_type>(options),
523 std::tuple_element_t<1, boundary_spline_type>(options),
524 std::tuple_element_t<1, boundary_spline_type>(options),
525 std::tuple_element_t<2, boundary_spline_type>(options),
526 std::tuple_element_t<2, boundary_spline_type>(options)}) {}
536 : bdr_(clone ?
std::apply(
537 [](const auto &...bspline) {
538 return std::make_tuple(bspline.clone()...);
548 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
549 std::array<int64_t, 2>({ncoeffs[1], ncoeffs[2]}),
init,
551 std::tuple_element_t<0, boundary_spline_type>(
552 std::array<int64_t, 2>({ncoeffs[1], ncoeffs[2]}),
init,
554 std::tuple_element_t<1, boundary_spline_type>(
555 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[2]}),
init,
557 std::tuple_element_t<1, boundary_spline_type>(
558 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[2]}),
init,
560 std::tuple_element_t<2, boundary_spline_type>(
561 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[1]}),
init,
563 std::tuple_element_t<2, boundary_spline_type>(
564 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[1]}),
init,
569 const std::array<std::vector<typename Spline::value_type>, 3> &kv,
573 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
574 std::array<std::vector<typename Spline::value_type>, 2>(
577 std::tuple_element_t<0, boundary_spline_type>(
578 std::array<std::vector<typename Spline::value_type>, 2>(
581 std::tuple_element_t<1, boundary_spline_type>(
582 std::array<std::vector<typename Spline::value_type>, 2>(
585 std::tuple_element_t<1, boundary_spline_type>(
586 std::array<std::vector<typename Spline::value_type>, 2>(
589 std::tuple_element_t<2, boundary_spline_type>(
590 std::array<std::vector<typename Spline::value_type>, 2>(
593 std::tuple_element_t<2, boundary_spline_type>(
594 std::array<std::vector<typename Spline::value_type>, 2>(
609 if (tensor.dim() > 1) {
616 .index({torch::indexing::Slice(), torch::indexing::Slice(),
617 torch::indexing::Slice(), 0})
618 .reshape({-1, tensor.size(-1)}));
621 .index({torch::indexing::Slice(), torch::indexing::Slice(),
622 torch::indexing::Slice(), -1})
623 .reshape({-1, tensor.size(-1)}));
626 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
627 torch::indexing::Slice()})
628 .reshape({-1, tensor.size(-1)}));
631 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
632 torch::indexing::Slice()})
633 .reshape({-1, tensor.size(-1)}));
636 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
637 torch::indexing::Slice()})
638 .reshape({-1, tensor.size(-1)}));
641 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
642 torch::indexing::Slice()})
643 .reshape({-1, tensor.size(-1)}));
651 .index({torch::indexing::Slice(), torch::indexing::Slice(),
652 torch::indexing::Slice(), 0})
656 .index({torch::indexing::Slice(), torch::indexing::Slice(),
657 torch::indexing::Slice(), -1})
662 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
663 torch::indexing::Slice()})
667 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
668 torch::indexing::Slice()})
673 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
674 torch::indexing::Slice()})
678 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
679 torch::indexing::Slice()})
689 template <
short_t s>
inline constexpr auto &
side()
const {
690 static_assert(s >
none && s <= nsides());
691 return std::get<s - 1>(bdr_);
695 template <
short_t s>
inline constexpr auto &
side() {
696 static_assert(s >
none && s <= nsides());
697 return std::get<s - 1>(bdr_);
701 inline constexpr auto &
sides()
const {
return bdr_; }
704 inline constexpr auto &
sides() {
return bdr_; }
721 os << name() <<
"(\n"
731 inline nlohmann::json
to_json()
const override {
774template <
typename Spline>
775 requires SplineType<Spline>
788 std::tuple<
typename Spline::template derived_self_type<
789 typename Spline::value_type, Spline::geoDim(),
790 Spline::degree(1), Spline::degree(2), Spline::degree(3)>,
791 typename Spline::template derived_self_type<
792 typename Spline::value_type, Spline::geoDim(),
793 Spline::degree(0), Spline::degree(2), Spline::degree(3)>,
794 typename Spline::template derived_self_type<
795 typename Spline::value_type, Spline::geoDim(),
796 Spline::degree(0), Spline::degree(1), Spline::degree(3)>,
797 typename Spline::template derived_self_type<
798 typename Spline::value_type, Spline::geoDim(),
799 Spline::degree(0), Spline::degree(1), Spline::degree(2)>>;
803 template <
typename real_t>
805 std::tuple<
typename Spline::template derived_self_type<
806 real_t, Spline::geoDim(), Spline::degree(1),
807 Spline::degree(2), Spline::degree(3)>,
808 typename Spline::template derived_self_type<
809 real_t, Spline::geoDim(), Spline::degree(0),
810 Spline::degree(2), Spline::degree(3)>,
811 typename Spline::template derived_self_type<
812 real_t, Spline::geoDim(), Spline::degree(0),
813 Spline::degree(1), Spline::degree(3)>,
814 typename Spline::template derived_self_type<
815 real_t, Spline::geoDim(), Spline::degree(0),
816 Spline::degree(1), Spline::degree(2)>>;
819 std::tuple<std::tuple_element_t<0, boundary_spline_type>,
820 std::tuple_element_t<0, boundary_spline_type>,
821 std::tuple_element_t<1, boundary_spline_type>,
822 std::tuple_element_t<1, boundary_spline_type>,
823 std::tuple_element_t<2, boundary_spline_type>,
824 std::tuple_element_t<2, boundary_spline_type>,
825 std::tuple_element_t<3, boundary_spline_type>,
826 std::tuple_element_t<3, boundary_spline_type>>
845 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
846 std::tuple_element_t<0, boundary_spline_type>(options),
847 std::tuple_element_t<1, boundary_spline_type>(options),
848 std::tuple_element_t<1, boundary_spline_type>(options),
849 std::tuple_element_t<2, boundary_spline_type>(options),
850 std::tuple_element_t<2, boundary_spline_type>(options),
851 std::tuple_element_t<3, boundary_spline_type>(options),
852 std::tuple_element_t<3, boundary_spline_type>(options)}) {}
862 : bdr_(clone ?
std::apply(
863 [](const auto &...bspline) {
864 return std::make_tuple(bspline.clone()...);
874 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
875 std::array<int64_t, 3>({ncoeffs[1], ncoeffs[2], ncoeffs[3]}),
877 std::tuple_element_t<0, boundary_spline_type>(
878 std::array<int64_t, 3>({ncoeffs[1], ncoeffs[2], ncoeffs[3]}),
880 std::tuple_element_t<1, boundary_spline_type>(
881 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[2], ncoeffs[3]}),
883 std::tuple_element_t<1, boundary_spline_type>(
884 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[2], ncoeffs[3]}),
886 std::tuple_element_t<2, boundary_spline_type>(
887 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[3]}),
889 std::tuple_element_t<2, boundary_spline_type>(
890 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[3]}),
892 std::tuple_element_t<3, boundary_spline_type>(
893 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[2]}),
895 std::tuple_element_t<3, boundary_spline_type>(
896 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[2]}),
901 const std::array<std::vector<typename Spline::value_type>, 4> &kv,
905 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
906 std::array<std::vector<typename Spline::value_type>, 3>(
907 {kv[1], kv[2], kv[3]}),
909 std::tuple_element_t<0, boundary_spline_type>(
910 std::array<std::vector<typename Spline::value_type>, 3>(
911 {kv[1], kv[2], kv[3]}),
913 std::tuple_element_t<1, boundary_spline_type>(
914 std::array<std::vector<typename Spline::value_type>, 3>(
915 {kv[0], kv[2], kv[3]}),
917 std::tuple_element_t<1, boundary_spline_type>(
918 std::array<std::vector<typename Spline::value_type>, 3>(
919 {kv[0], kv[2], kv[3]}),
921 std::tuple_element_t<2, boundary_spline_type>(
922 std::array<std::vector<typename Spline::value_type>, 3>(
923 {kv[0], kv[1], kv[3]}),
925 std::tuple_element_t<2, boundary_spline_type>(
926 std::array<std::vector<typename Spline::value_type>, 3>(
927 {kv[0], kv[1], kv[3]}),
929 std::tuple_element_t<3, boundary_spline_type>(
930 std::array<std::vector<typename Spline::value_type>, 3>(
931 {kv[0], kv[1], kv[2]}),
933 std::tuple_element_t<3, boundary_spline_type>(
934 std::array<std::vector<typename Spline::value_type>, 3>(
935 {kv[0], kv[1], kv[2]}),
949 if (tensor.dim() > 1) {
950 auto tensor_view = tensor.view(
956 .index({torch::indexing::Slice(), torch::indexing::Slice(),
957 torch::indexing::Slice(), torch::indexing::Slice(), 0})
958 .reshape({-1, tensor.size(-1)}));
961 .index({torch::indexing::Slice(), torch::indexing::Slice(),
962 torch::indexing::Slice(), torch::indexing::Slice(), -1})
963 .reshape({-1, tensor.size(-1)}));
966 .index({torch::indexing::Slice(), torch::indexing::Slice(),
967 torch::indexing::Slice(), 0, torch::indexing::Slice()})
968 .reshape({-1, tensor.size(-1)}));
971 .index({torch::indexing::Slice(), torch::indexing::Slice(),
972 torch::indexing::Slice(), -1, torch::indexing::Slice()})
973 .reshape({-1, tensor.size(-1)}));
976 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
977 torch::indexing::Slice(), torch::indexing::Slice()})
978 .reshape({-1, tensor.size(-1)}));
981 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
982 torch::indexing::Slice(), torch::indexing::Slice()})
983 .reshape({-1, tensor.size(-1)}));
986 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
987 torch::indexing::Slice(), torch::indexing::Slice()})
988 .reshape({-1, tensor.size(-1)}));
991 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
992 torch::indexing::Slice(), torch::indexing::Slice()})
993 .reshape({-1, tensor.size(-1)}));
1001 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1002 torch::indexing::Slice(), torch::indexing::Slice(), 0})
1006 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1007 torch::indexing::Slice(), torch::indexing::Slice(), -1})
1012 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1013 torch::indexing::Slice(), 0, torch::indexing::Slice()})
1017 .index({torch::indexing::Slice(), torch::indexing::Slice(),
1018 torch::indexing::Slice(), -1, torch::indexing::Slice()})
1023 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
1024 torch::indexing::Slice(), torch::indexing::Slice()})
1028 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
1029 torch::indexing::Slice(), torch::indexing::Slice()})
1034 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
1035 torch::indexing::Slice(), torch::indexing::Slice()})
1039 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
1040 torch::indexing::Slice(), torch::indexing::Slice()})
1050 template <
short_t s>
inline constexpr auto &
side()
const {
1051 static_assert(s >
none && s <= nsides());
1052 return std::get<s - 1>(bdr_);
1056 template <
short_t s>
inline constexpr auto &
side() {
1057 static_assert(s >
none && s <= nsides());
1058 return std::get<s - 1>(bdr_);
1062 inline constexpr auto &
sides()
const {
return bdr_; }
1065 inline constexpr auto &
ides() {
return bdr_; }
1084 os << name() <<
"(\n"
1097 nlohmann::json json;
1138template <
typename T>
1142template <
typename BoundaryCore>
1146 using BoundaryCore::BoundaryCore;
1156 template <std::size_t... Is>
1157 inline torch::Tensor
as_tensor_(std::index_sequence<Is...>)
const {
1158 return torch::cat({std::get<Is>(BoundaryCore::bdr_).as_tensor()...});
1167 return as_tensor_(std::make_index_sequence<BoundaryCore::nsides()>{});
1175 template <std::size_t... Is>
1178 [](
auto... size) {
return (size + ...); },
1179 std::make_tuple(std::get<Is>(BoundaryCore::bdr_).
as_tensor_size()...));
1188 return as_tensor_size_(std::make_index_sequence<BoundaryCore::nsides()>{});
1198 template <std::size_t... Is>
1200 const torch::Tensor &tensor) {
1202 std::size_t start(0);
1203 auto end = [&start](std::size_t inc) {
return start += inc; };
1205 (std::get<Is>(BoundaryCore::bdr_)
1206 .from_tensor(tensor.index({torch::indexing::Slice(
1207 start, end(std::get<Is>(BoundaryCore::bdr_).ncumcoeffs() *
1208 std::get<Is>(BoundaryCore::bdr_).geoDim()))})),
1222 return from_tensor_(std::make_index_sequence<BoundaryCore::nsides()>{},
1230 size_t... Is,
typename... Xi>
1231 inline auto eval_(std::index_sequence<Is...>,
1232 const std::tuple<Xi...> &xi)
const {
1234 std::get<Is>(BoundaryCore::bdr_)
1235 .
template eval<deriv, memory_optimized>(std::get<Is>(xi))...);
1239 size_t... Is,
typename... Xi,
typename... Indices>
1240 inline auto eval_(std::index_sequence<Is...>,
const std::tuple<Xi...> &xi,
1241 const std::tuple<Indices...> &indices)
const {
1242 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1243 .
template eval<deriv, memory_optimized>(
1244 std::get<Is>(xi), std::get<Is>(indices))...);
1248 size_t... Is,
typename... Xi,
typename... Indices,
1249 typename... Coeff_Indices>
1250 inline auto eval_(std::index_sequence<Is...>,
const std::tuple<Xi...> &xi,
1251 const std::tuple<Indices...> &indices,
1252 const std::tuple<Coeff_Indices...> &coeff_indices)
const {
1253 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1254 .
template eval<deriv, memory_optimized>(
1255 std::get<Is>(xi), std::get<Is>(indices),
1256 std::get<Is>(coeff_indices))...);
1265 inline auto eval(
const std::tuple<Xi...> &xi)
const {
1266 return eval_<deriv, memory_optimized>(
1267 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1271 typename... Xi,
typename... Indices>
1272 inline auto eval(
const std::tuple<Xi...> &xi,
1273 const std::tuple<Indices...> &indices)
const {
1274 static_assert(
sizeof...(Xi) ==
sizeof...(Indices));
1275 return eval_<deriv, memory_optimized>(
1276 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices);
1280 typename... Xi,
typename... Indices,
typename... Coeff_Indices>
1281 inline auto eval(
const std::tuple<Xi...> &xi,
1282 const std::tuple<Indices...> &indices,
1283 const std::tuple<Coeff_Indices...> &coeff_indices)
const {
1284 static_assert(
sizeof...(Xi) ==
sizeof...(Indices) &&
1285 sizeof...(Xi) ==
sizeof...(Coeff_Indices));
1286 return eval_<deriv, memory_optimized>(
1287 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices,
1295 template <
size_t... Is,
typename... Basfunc,
typename... Coeff_Indices,
1296 typename... Numeval,
typename... Sizes>
1299 const std::tuple<Basfunc...> &basfunc,
1300 const std::tuple<Coeff_Indices...> &coeff_indices,
1301 const std::tuple<Numeval...> &numeval,
1302 const std::tuple<Sizes...> &sizes)
const {
1303 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1305 std::get<Is>(coeff_indices),
1306 std::get<Is>(numeval),
1307 std::get<Is>(sizes))...);
1310 template <
size_t... Is,
typename... Basfunc,
typename... Coeff_Indices,
1314 const std::tuple<Basfunc...> &basfunc,
1315 const std::tuple<Coeff_Indices...> &coeff_indices,
1316 const std::tuple<Xi...> &xi)
const {
1318 std::get<Is>(BoundaryCore::bdr_)
1320 std::get<Is>(basfunc), std::get<Is>(coeff_indices),
1321 std::get<Is>(xi)[0].numel(), std::get<Is>(xi)[0].sizes())...);
1328 template <
typename... Basfunc,
typename... Coeff_Indices,
typename... Numeval,
1332 const std::tuple<Coeff_Indices...> &coeff_indices,
1333 const std::tuple<Numeval...> &numeval,
1334 const std::tuple<Sizes...> &sizes)
const {
1335 static_assert(
sizeof...(Basfunc) ==
sizeof...(Coeff_Indices) &&
1336 sizeof...(Basfunc) ==
sizeof...(Numeval) &&
1337 sizeof...(Basfunc) ==
sizeof...(Sizes));
1339 std::make_index_sequence<BoundaryCore::nsides()>{}, basfunc,
1340 coeff_indices, numeval, sizes);
1343 template <
typename... Basfunc,
typename... Coeff_Indices,
typename... Xi>
1346 const std::tuple<Coeff_Indices...> &coeff_indices,
1347 const std::tuple<Xi...> &xi)
const {
1348 static_assert(
sizeof...(Basfunc) ==
sizeof...(Coeff_Indices) &&
1349 sizeof...(Basfunc) ==
sizeof...(Xi));
1351 std::make_index_sequence<BoundaryCore::nsides()>{}, basfunc,
1359 template <
size_t... Is,
typename... Xi>
1361 const std::tuple<Xi...> &xi)
const {
1362 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1368 template <
typename... Xi>
1371 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1379 size_t... Is,
typename... Xi>
1381 const std::tuple<Xi...> &xi)
const {
1382 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1383 .
template eval_basfunc<deriv, memory_optimized>(
1384 std::get<Is>(xi))...);
1388 size_t... Is,
typename... Xi,
typename... Indices>
1390 const std::tuple<Xi...> &xi,
1391 const std::tuple<Indices...> &indices)
const {
1392 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1393 .
template eval_basfunc<deriv, memory_optimized>(
1394 std::get<Is>(xi), std::get<Is>(indices))...);
1404 return eval_basfunc_<deriv, memory_optimized>(
1405 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1409 typename... Xi,
typename... Indices>
1411 const std::tuple<Indices...> &indices)
const {
1412 static_assert(
sizeof...(Xi) ==
sizeof...(Indices));
1413 return eval_basfunc_<deriv, memory_optimized>(
1414 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices);
1421 template <
bool memory_optimized =
false,
size_t... Is,
typename... Indices>
1423 const std::tuple<Indices...> &indices)
const {
1424 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1425 .
template find_coeff_indices<memory_optimized>(
1426 std::get<Is>(indices))...);
1432 template <
bool memory_optimized =
false,
typename... Indices>
1434 return find_coeff_indices_<memory_optimized>(
1435 std::make_index_sequence<BoundaryCore::nsides()>{}, indices);
1441 template <
size_t... Is>
1444 (std::get<Is>(BoundaryCore::bdr_).uniform_refine(numRefine, dim), ...);
1453 if constexpr (BoundaryCore::spline_type::parDim() > 1)
1456 }
else if (dim == 0) {
1457 if constexpr (BoundaryCore::nsides() == 2) {
1459 }
else if constexpr (BoundaryCore::nsides() == 4) {
1464 }
else if constexpr (BoundaryCore::nsides() == 6) {
1473 }
else if constexpr (BoundaryCore::nsides() == 8) {
1487 throw std::runtime_error(
"Invalid dimension");
1488 }
else if (dim == 1) {
1489 if constexpr (BoundaryCore::nsides() == 4) {
1494 }
else if constexpr (BoundaryCore::nsides() == 6) {
1504 }
else if constexpr (BoundaryCore::nsides() == 8) {
1518 throw std::runtime_error(
"Invalid dimension");
1519 }
else if (dim == 2) {
1520 if constexpr (BoundaryCore::nsides() == 6) {
1529 }
else if constexpr (BoundaryCore::nsides() == 8) {
1543 throw std::runtime_error(
"Invalid dimension");
1544 }
else if (dim == 3) {
1545 if constexpr (BoundaryCore::nsides() == 8) {
1559 throw std::runtime_error(
"Invalid dimension");
1561 throw std::runtime_error(
"Invalid dimension");
1568 template <
size_t... Is>
1569 inline torch::serialize::OutputArchive &
1570 write_(std::index_sequence<Is...>, torch::serialize::OutputArchive &archive,
1571 const std::string &key =
"boundary")
const {
1572 (std::get<Is>(BoundaryCore::bdr_)
1573 .write(archive, key +
".bdr[" + std::to_string(Is) +
"]"),
1580 inline void save(
const std::string &filename,
1581 const std::string &key =
"boundary")
const {
1582 torch::serialize::OutputArchive archive;
1583 write(archive, key).save_to(filename);
1588 inline torch::serialize::OutputArchive &
1589 write(torch::serialize::OutputArchive &archive,
1590 const std::string &key =
"boundary")
const {
1591 write_(std::make_index_sequence<BoundaryCore::nsides()>{}, archive, key);
1598 template <
size_t... Is>
1599 inline torch::serialize::InputArchive &
1600 read_(std::index_sequence<Is...>, torch::serialize::InputArchive &archive,
1601 const std::string &key =
"boundary") {
1602 (std::get<Is>(BoundaryCore::bdr_)
1603 .read(archive, key +
".bdr[" + std::to_string(Is) +
"]"),
1610 inline void load(
const std::string &filename,
1611 const std::string &key =
"boundary") {
1612 torch::serialize::InputArchive archive;
1613 archive.load_from(filename);
1619 inline torch::serialize::InputArchive &
1620 read(torch::serialize::InputArchive &archive,
1621 const std::string &key =
"boundary") {
1622 read_(std::make_index_sequence<BoundaryCore::nsides()>{}, archive, key);
1627 [[nodiscard]]
inline pugi::xml_document
1628 to_xml(
int id = 0,
const std::string &label =
"",
int index = -1)
const {
1629 pugi::xml_document doc;
1630 pugi::xml_node root = doc.append_child(
"xml");
1631 to_xml(root,
id, label, index);
1637 inline pugi::xml_node &
to_xml(pugi::xml_node &root,
int id = 0,
1638 const std::string &label =
"",
1639 int index = -1)
const {
1641 pugi::xml_node bdr = root.append_child(
"Boundary");
1644 bdr.append_attribute(
"id") = id;
1647 bdr.append_attribute(
"index") = index;
1650 bdr.append_attribute(
"label") = label.c_str();
1654 [&bdr, &index_](
const auto &...bspline) {
1655 (bspline.to_xml(bdr, -1,
"", index_++), ...);
1657 BoundaryCore::bdr_);
1664 const std::string &label =
"",
1666 return from_xml(doc.child(
"xml"),
id, label, index);
1671 const std::string &label =
"",
1675 for (pugi::xml_node bdr : root.children(
"Boundary")) {
1678 if ((
id >= 0 ? bdr.attribute(
"id").as_int() ==
id :
true) &&
1679 (index >= 0 ? bdr.attribute(
"index").as_int() == index :
true) &&
1680 (!label.empty() ? bdr.attribute(
"label").value() == label :
true)) {
1684 [&bdr, &index_](
auto &...bspline) {
1685 (bspline.from_xml(bdr, -1,
"", index_++), ...);
1687 BoundaryCore::bdr_);
1694 throw std::runtime_error(
"XML object does not provide geometry with given "
1695 "id, index, and/or label");
1702 template <
typename BoundaryCore_,
size_t... Is>
1705 return ((std::get<Is>(BoundaryCore::bdr_) == std::get<Is>(other.sides())) &&
1711 template <
typename BoundaryCore_>
1713 return isequal_(std::make_index_sequence<BoundaryCore::nsides()>{}, other);
1717 template <
typename BoundaryCore_>
1727 template <
typename BoundaryCore_,
size_t... Is>
1730 BoundaryCore::spline_type::value_type rtol,
1731 BoundaryCore::spline_type::value_type atol)
const {
1732 return ((std::get<Is>(BoundaryCore::bdr_)
1733 .
isclose(std::get<Is>(other.sides()))) &&
1740 template <
typename BoundaryCore_>
1743 BoundaryCore::spline_type::value_type rtol =
1744 typename BoundaryCore::spline_type::value_type{1e-5},
1745 BoundaryCore::spline_type::value_type atol =
1746 typename BoundaryCore::spline_type::value_type{1e-8})
const {
1747 return isclose_(std::make_index_sequence<BoundaryCore::nsides()>{}, other,
1751#define GENERATE_EXPR_MACRO(r, data, name) \
1753 template <bool memory_optimized = false, size_t... Is, typename... Xi> \
1754 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1755 const std::tuple<Xi...> &xi) const { \
1756 return std::tuple( \
1757 std::get<Is>(BoundaryCore::bdr_) \
1758 .template name<memory_optimized>(std::get<Is>(xi))...); \
1761 template <bool memory_optimized = false, size_t... Is, typename... Xi, \
1762 typename... Indices> \
1763 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1764 const std::tuple<Xi...> &xi, \
1765 const std::tuple<Indices...> &indices) \
1767 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1768 .template name<memory_optimized>( \
1769 std::get<Is>(xi), std::get<Is>(indices))...); \
1772 template <bool memory_optimized = false, size_t... Is, typename... Xi, \
1773 typename... Indices, typename... Coeff_Indices> \
1774 inline auto BOOST_PP_CAT(name, _)( \
1775 std::index_sequence<Is...>, const std::tuple<Xi...> &xi, \
1776 const std::tuple<Indices...> &indices, \
1777 const std::tuple<Coeff_Indices...> &coeff_indices) const { \
1778 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1779 .template name<memory_optimized>( \
1780 std::get<Is>(xi), std::get<Is>(indices), \
1781 std::get<Is>(coeff_indices))...); \
1785 template <bool memory_optimized = false, typename... Args> \
1786 inline auto name(const Args &...args) const { \
1787 return BOOST_PP_CAT(name, _)<memory_optimized>( \
1788 std::make_index_sequence<BoundaryCore::nsides()>{}, args...); \
1795#undef GENERATE_EXPR_MACRO
1797#define GENERATE_IEXPR_MACRO(r, data, name) \
1799 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1801 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1802 const std::tuple<Geometry...> &G, \
1803 const std::tuple<Xi...> &xi) const { \
1804 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1805 .template name<memory_optimized>( \
1806 std::get<Is>(G), std::get<Is>(xi))...); \
1809 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1810 typename... Xi, typename... Indices> \
1811 inline auto BOOST_PP_CAT(name, _)( \
1812 std::index_sequence<Is...>, const std::tuple<Geometry...> &G, \
1813 const std::tuple<Xi...> &xi, const std::tuple<Indices...> &indices) \
1815 return std::tuple( \
1816 std::get<Is>(BoundaryCore::bdr_) \
1817 .template name<memory_optimized>( \
1818 std::get<Is>(G), std::get<Is>(xi), std::get<Is>(indices))...); \
1821 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1822 typename... Xi, typename... Indices, typename... Coeff_Indices> \
1823 inline auto BOOST_PP_CAT(name, _)( \
1824 std::index_sequence<Is...>, const std::tuple<Geometry...> &G, \
1825 const std::tuple<Xi...> &xi, const std::tuple<Indices...> &indices, \
1826 const std::tuple<Coeff_Indices...> &coeff_indices) const { \
1827 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1828 .template name<memory_optimized>( \
1829 std::get<Is>(G), std::get<Is>(xi), \
1830 std::get<Is>(indices), \
1831 std::get<Is>(coeff_indices))...); \
1835 template <bool memory_optimized = false, typename... Args> \
1836 inline auto name(const Args &...args) const { \
1837 return BOOST_PP_CAT(name, _)<memory_optimized>( \
1838 std::make_index_sequence<BoundaryCore::nsides()>{}, args...); \
1845#undef GENERATE_IEXPR_MACRO
1850 [](
const auto &...bspline) {
1851 return std::make_tuple(bspline.device()...);
1853 BoundaryCore::bdr_);
1859 [](
const auto &...bspline) {
1860 return std::make_tuple(bspline.device_index()...);
1862 BoundaryCore::bdr_);
1868 [](
const auto &...bspline) {
1869 return std::make_tuple(bspline.dtype()...);
1871 BoundaryCore::bdr_);
1877 [](
const auto &...bspline) {
1878 return std::make_tuple(bspline.layout()...);
1880 BoundaryCore::bdr_);
1886 [](
const auto &...bspline) {
1887 return std::make_tuple(bspline.requires_grad()...);
1889 BoundaryCore::bdr_);
1895 [](
const auto &...bspline) {
1896 return std::make_tuple(bspline.pinned_memory()...);
1898 BoundaryCore::bdr_);
1904 [](
const auto &...bspline) {
1905 return std::make_tuple(bspline.is_sparse()...);
1907 BoundaryCore::bdr_);
1913 [](
const auto &...bspline) {
1914 return std::make_tuple(bspline.is_uniform()...);
1916 BoundaryCore::bdr_);
1922 [](
const auto &...bspline) {
1923 return std::make_tuple(bspline.is_nonuniform()...);
1925 BoundaryCore::bdr_);
1934 BoundaryCore::bdr_);
1942 decltype(
typename BoundaryCore::spline_type{}.to(options)),
1943 BoundaryCore::spline_type::parDim()>>;
1945 return boundary_type(std::apply(
1946 [&options](
const auto &...bspline) {
1947 return std::make_tuple(bspline.to(options)...);
1949 BoundaryCore::bdr_));
1955 [&
device](
const auto &...bspline) {
1956 return std::make_tuple(bspline.to(
device)...);
1958 BoundaryCore::bdr_));
1962 template <
typename real_t>
inline auto to()
const {
1964 decltype(
typename BoundaryCore::spline_type{}.template to<real_t>()),
1965 BoundaryCore::spline_type::parDim()>>;
1967 return boundary_type(std::apply(
1968 [](
const auto &...bspline) {
1969 return std::make_tuple(bspline.template to<real_t>()...);
1971 BoundaryCore::bdr_));
1976template <
typename Spline>
1977 requires SplineType<Spline>
1981template <
typename Spline>
1984 obj.pretty_print(os);
#define GENERATE_IEXPR_MACRO(r, data, name)
Auto-generated functions.
Definition boundary.hpp:1797
#define GENERATE_EXPR_MACRO(r, data, name)
Definition boundary.hpp:1751
#define GENERATE_EXPR_SEQ
Sequence of expression (parametric coordinates)
Definition bspline.hpp:40
#define GENERATE_IEXPR_SEQ
Sequence of expression (physical coordinates)
Definition bspline.hpp:46
Boundary base class.
Definition boundary.hpp:1134
Boundary (common high-level functionality)
Definition boundary.hpp:1143
auto find_knot_indices(const std::tuple< Xi... > &xi) const
Returns the knot indicies of knot spans containing xi
Definition boundary.hpp:1369
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:1670
auto to(torch::Device device) const
Returns a copy of the boundary object with settings from device.
Definition boundary.hpp:1953
auto dtype() const noexcept
Returns the dtype property of all splines.
Definition boundary.hpp:1866
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:1331
auto pinned_memory() const noexcept
Returns the pinned_memory property of all splines.
Definition boundary.hpp:1893
bool isequal_(std::index_sequence< Is... >, const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary spline objects are the same.
Definition boundary.hpp:1703
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:1403
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:1620
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:1663
auto eval(const std::tuple< Xi... > &xi) const
Returns the values of the spline objects in the points xi
Definition boundary.hpp:1265
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:1298
auto to() const
Returns a copy of the boundary object with real_t type.
Definition boundary.hpp:1962
auto to(Options< real_t > options) const
Returns a copy of the boundary object with settings from options.
Definition boundary.hpp:1940
auto device_index() const noexcept
Returns the device_index property of all splines.
Definition boundary.hpp:1857
auto is_uniform() const noexcept
Returns true if the B-spline is uniform of all splines.
Definition boundary.hpp:1911
torch::Tensor as_tensor_(std::index_sequence< Is... >) const
Returns all coefficients of all spline objects as a single tensor.
Definition boundary.hpp:1157
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:1742
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:1176
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:1380
auto find_knot_indices_(std::index_sequence< Is... >, const std::tuple< Xi... > &xi) const
Returns the knot indicies of boundary spline object's knot spans containing xi
Definition boundary.hpp:1360
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:1442
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:1570
auto is_nonuniform() const noexcept
Returns true if the B-spline is non-uniform if all splines.
Definition boundary.hpp:1920
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:1250
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:1433
auto requires_grad() const noexcept
Returns the requires_grad property of all splines.
Definition boundary.hpp:1884
auto eval(const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices) const
Returns the values of the spline objects in the points xi
Definition boundary.hpp:1272
BoundaryCommon clone() const
Returns a clone of the boundary object.
Definition boundary.hpp:1149
auto eval_basfunc(const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices) const
Returns the values of the spline objects' basis functions in the points xi
Definition boundary.hpp:1410
auto & from_tensor(const torch::Tensor &tensor)
Sets the coefficients of all spline objects from a single tensor.
Definition boundary.hpp:1221
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:1199
auto eval(const std::tuple< Xi... > &xi, const std::tuple< Indices... > &indices, const std::tuple< Coeff_Indices... > &coeff_indices) const
Returns the values of the spline objects in the points xi
Definition boundary.hpp:1281
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:1628
void load(const std::string &filename, const std::string &key="boundary")
Loads the boundary spline object from file.
Definition boundary.hpp:1610
torch::Tensor as_tensor() const
Returns all coefficients of all spline objects as a single tensor.
Definition boundary.hpp:1166
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:1389
BoundaryCommon & set_requires_grad(bool requires_grad)
Sets the boundary object's requires_grad property.
Definition boundary.hpp:1929
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:1231
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:1637
auto & uniform_refine(int numRefine=1, int dim=-1)
Returns the spline objects with uniformly refined knot and coefficient vectors.
Definition boundary.hpp:1451
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:1313
int64_t as_tensor_size() const
Returns the size of the single tensor representation of all spline objects.
Definition boundary.hpp:1187
auto eval_from_precomputed(const std::tuple< Basfunc... > &basfunc, const std::tuple< Coeff_Indices... > &coeff_indices, const std::tuple< Xi... > &xi) const
Returns the value of the spline objects from precomputed basis function.
Definition boundary.hpp:1345
bool operator==(const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary objects are the same.
Definition boundary.hpp:1712
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:1422
auto layout() const noexcept
Returns the layout property of all splines.
Definition boundary.hpp:1875
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:1589
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:1728
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:1600
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:1240
void save(const std::string &filename, const std::string &key="boundary") const
Saves the boundary spline to file.
Definition boundary.hpp:1580
auto device() const noexcept
Auto-generated functions.
Definition boundary.hpp:1848
bool operator!=(const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary objects are different.
Definition boundary.hpp:1718
auto is_sparse() const noexcept
Returns if the layout is sparse of all splines.
Definition boundary.hpp:1902
constexpr auto & side() const
Returns constant reference to side-th Spline.
Definition boundary.hpp:157
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:108
constexpr auto & sides()
Returns a non-constant reference to the tuple of boundary sides.
Definition boundary.hpp:174
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:186
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:99
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:93
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:116
~BoundaryCore() override=default
Destructor.
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:154
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:88
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:177
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:202
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:96
constexpr auto & side()
Returns non-constant reference to side-th Spline.
Definition boundary.hpp:163
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:193
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:170
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:82
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:210
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:133
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:239
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:417
constexpr auto & sides() const
Returns a constant reference to the tuple of boundary sides.
Definition boundary.hpp:400
constexpr auto & side()
Returns non-constant reference to the s-th side's spline.
Definition boundary.hpp:394
std::tuple< utils::TensorArray< 1 >, utils::TensorArray< 1 >, utils::TensorArray< 1 >, utils::TensorArray< 1 > > eval_type
Evaluation type.
Definition boundary.hpp:266
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:385
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:447
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:283
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:426
constexpr auto & sides()
Returns a non-constant reference to the tuple of boundary sides.
Definition boundary.hpp:403
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:437
Spline spline_type
Spline type.
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:337
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:262
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:255
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:269
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:277
Spline::value_type value_type
Value type.
Definition boundary.hpp:259
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:248
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:292
constexpr auto & side() const
Returns constant reference to the s-th side's spline.
Definition boundary.hpp:388
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:406
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:306
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:280
~BoundaryCore() override=default
Destructor.
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:744
constexpr auto & sides() const
Returns a constant reference to the tuple of boundary sides.
Definition boundary.hpp:701
Spline::value_type value_type
Value type.
Definition boundary.hpp:508
~BoundaryCore() override=default
Destructor.
constexpr auto & side() const
Returns constant reference to side-th spline.
Definition boundary.hpp:689
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:568
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:529
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:511
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:535
Spline spline_type
Spline type.
Definition boundary.hpp:472
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:484
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:532
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:519
constexpr auto & sides()
Returns a non-constant reference to the tuple of sides.
Definition boundary.hpp:704
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:544
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:707
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:607
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:504
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:495
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:731
constexpr auto & side()
Returns non-constant reference to side-th spline.
Definition boundary.hpp:695
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:516
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:686
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:720
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:756
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:870
constexpr auto & side()
Returns non-constant reference to side-th spline.
Definition boundary.hpp:1056
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:1111
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:947
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:827
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:1125
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:1068
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:858
Spline::value_type value_type
Value type.
Definition boundary.hpp:831
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:1047
~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:840
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:861
Spline spline_type
Spline type.
Definition boundary.hpp:784
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:855
constexpr auto & ides()
Returns a non-constant reference to the tuple of boundary sides.
Definition boundary.hpp:1065
constexpr auto & side() const
Returns constant reference to side-th spline.
Definition boundary.hpp:1050
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:900
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:799
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:1096
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:1083
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:843
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:834
constexpr auto & sides() const
Returns a constant reference to the tuple of boundary sides.
Definition boundary.hpp:1062
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:816
BoundaryCore.
Definition boundary.hpp:44
The Options class handles the automated determination of dtype from the template argument and the sel...
Definition options.hpp:104
Full qualified name descriptor.
Definition fqn.hpp:22
Concept to identify template parameters that are derived from iganet::Boundary_.
Definition boundary.hpp:1139
Concept to identify template parameters that are derived from iganet::Spline_.
Definition bspline.hpp:3582
std::array< torch::Tensor, N > TensorArray
Definition tensorarray.hpp:26
deriv
Enumerator for specifying the derivative of B-spline evaluation.
Definition bspline.hpp:72
std::ostream & operator<<(std::ostream &os, const MemoryDebugger< id > &obj)
Print (as string) a memory debugger object.
Definition memory.hpp:125
init
Enumerator for specifying the initialization of B-spline coefficients.
Definition bspline.hpp:55
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
Definition core.hpp:74
Serialization prototype.
Definition serialize.hpp:29