17#include <boost/preprocessor/cat.hpp>
18#include <boost/preprocessor/seq/for_each.hpp>
49 template <
typename Spline>
63 typename Spline::template derived_self_type<
typename Spline::value_type,
68 template <
typename real_t>
70 typename Spline::template derived_self_type<real_t, Spline::geoDim()>;
73 std::tuple<boundary_spline_type, boundary_spline_type>
bdr_;
80 using eval_type = std::tuple<torch::Tensor, torch::Tensor>;
85 : bdr_({boundary_spline_type(options), boundary_spline_type(options)}) {}
95 : bdr_(clone ?
std::apply(
96 [](const auto &...bspline) {
97 return std::make_tuple(bspline.clone()...);
106 : bdr_({boundary_spline_type(std::array<int64_t, 0>{},
init, options),
107 boundary_spline_type(std::array<int64_t, 0>{},
init, options)}) {}
110 BoundaryCore(
const std::array<std::vector<typename Spline::value_type>, 1> &,
114 : bdr_({boundary_spline_type(std::array<int64_t, 0>{},
init, options),
115 boundary_spline_type(std::array<int64_t, 0>{},
init, options)}) {}
125 if (tensor.dim() > 1) {
126 auto tensor_view = tensor.view({Spline::geoDim(), -1, tensor.size(-1)});
128 side<west>().from_tensor(tensor_view.index({torch::indexing::Slice(), 0})
129 .reshape({-1, tensor.size(-1)}));
130 side<east>().from_tensor(tensor_view.index({torch::indexing::Slice(), -1})
131 .reshape({-1, tensor.size(-1)}));
133 auto tensor_view = tensor.view({Spline::geoDim(), -1});
136 tensor_view.index({torch::indexing::Slice(), 0}).flatten());
138 tensor_view.index({torch::indexing::Slice(), -1}).flatten());
147 template <
short_t s>
inline constexpr auto &
side()
const {
148 static_assert(s >
none && s <= nsides());
149 return std::get<s - 1>(bdr_);
153 template <
short_t s>
inline constexpr auto &
side() {
154 static_assert(s >
none && s <= nsides());
155 return std::get<s - 1>(bdr_);
160 inline constexpr auto &
coeffs()
const {
return bdr_; }
164 inline constexpr auto &
coeffs() {
return bdr_; }
178 os << name() <<
"(\n"
184 inline nlohmann::json
to_json()
const override {
213 template <
typename Spline>
214 requires SplineType<Spline>
227 typename Spline::template derived_self_type<
228 typename Spline::value_type, Spline::geoDim(), Spline::degree(1)>,
229 typename Spline::template derived_self_type<
230 typename Spline::value_type, Spline::geoDim(), Spline::degree(0)>>;
234 template <
typename real_t>
236 std::tuple<
typename Spline::template derived_self_type<
237 real_t, Spline::geoDim(), Spline::degree(1)>,
238 typename Spline::template derived_self_type<
239 real_t, Spline::geoDim(), Spline::degree(0)>>;
242 std::tuple<typename std::tuple_element_t<0, boundary_spline_type>,
243 typename std::tuple_element_t<0, boundary_spline_type>,
244 typename std::tuple_element_t<1, boundary_spline_type>,
245 typename std::tuple_element_t<1, boundary_spline_type>>
259 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
260 std::tuple_element_t<0, boundary_spline_type>(options),
261 std::tuple_element_t<1, boundary_spline_type>(options),
262 std::tuple_element_t<1, boundary_spline_type>(options)}) {}
272 : bdr_(clone ?
std::apply(
273 [](const auto &...bspline) {
274 return std::make_tuple(bspline.clone()...);
284 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
285 std::array<int64_t, 1>({ncoeffs[1]}),
init, options),
286 std::tuple_element_t<0, boundary_spline_type>(
287 std::array<int64_t, 1>({ncoeffs[1]}),
init, options),
288 std::tuple_element_t<1, boundary_spline_type>(
289 std::array<int64_t, 1>({ncoeffs[0]}),
init, options),
290 std::tuple_element_t<1, boundary_spline_type>(
291 std::array<int64_t, 1>({ncoeffs[0]}),
init, options)}) {}
295 const std::array<std::vector<typename Spline::value_type>, 2> &kv,
299 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
300 std::array<std::vector<typename Spline::value_type>, 1>(
303 std::tuple_element_t<0, boundary_spline_type>(
304 std::array<std::vector<typename Spline::value_type>, 1>(
307 std::tuple_element_t<1, boundary_spline_type>(
308 std::array<std::vector<typename Spline::value_type>, 1>(
311 std::tuple_element_t<1, boundary_spline_type>(
312 std::array<std::vector<typename Spline::value_type>, 1>(
324 if (tensor.dim() > 1) {
331 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0})
332 .reshape({-1, tensor.size(-1)}));
335 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1})
336 .reshape({-1, tensor.size(-1)}));
339 .index({torch::indexing::Slice(), 0, torch::indexing::Slice()})
340 .reshape({-1, tensor.size(-1)}));
343 .index({torch::indexing::Slice(), -1, torch::indexing::Slice()})
344 .reshape({-1, tensor.size(-1)}));
351 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0})
355 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1})
359 .index({torch::indexing::Slice(), 0, torch::indexing::Slice()})
363 .index({torch::indexing::Slice(), -1, torch::indexing::Slice()})
373 template <
short_t s>
inline constexpr auto &
side()
const {
374 static_assert(s >
none && s <= nsides());
375 return std::get<s - 1>(bdr_);
379 template <
short_t s>
inline constexpr auto &
side() {
380 static_assert(s >
none && s <= nsides());
381 return std::get<s - 1>(bdr_);
386 inline constexpr auto &
coeffs()
const {
return bdr_; }
390 inline constexpr auto &
coeffs() {
return bdr_; }
406 os << name() <<
"(\n"
414 inline nlohmann::json
to_json()
const override {
450 template <
typename Spline>
451 requires SplineType<Spline>
464 std::tuple<
typename Spline::template derived_self_type<
465 typename Spline::value_type, Spline::geoDim(),
466 Spline::degree(1), Spline::degree(2)>,
467 typename Spline::template derived_self_type<
468 typename Spline::value_type, Spline::geoDim(),
469 Spline::degree(0), Spline::degree(2)>,
470 typename Spline::template derived_self_type<
471 typename Spline::value_type, Spline::geoDim(),
472 Spline::degree(0), Spline::degree(1)>>;
476 template <
typename real_t>
478 typename Spline::template derived_self_type<
479 real_t, Spline::geoDim(), Spline::degree(1), Spline::degree(2)>,
480 typename Spline::template derived_self_type<
481 real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(2)>,
482 typename Spline::template derived_self_type<
483 real_t, Spline::geoDim(), Spline::degree(0), Spline::degree(1)>>;
486 std::tuple<typename std::tuple_element_t<0, boundary_spline_type>,
487 typename std::tuple_element_t<0, boundary_spline_type>,
488 typename std::tuple_element_t<1, boundary_spline_type>,
489 typename std::tuple_element_t<1, boundary_spline_type>,
490 typename std::tuple_element_t<2, boundary_spline_type>,
491 typename std::tuple_element_t<2, boundary_spline_type>>
506 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
507 std::tuple_element_t<0, boundary_spline_type>(options),
508 std::tuple_element_t<1, boundary_spline_type>(options),
509 std::tuple_element_t<1, boundary_spline_type>(options),
510 std::tuple_element_t<2, boundary_spline_type>(options),
511 std::tuple_element_t<2, boundary_spline_type>(options)}) {}
521 : bdr_(clone ?
std::apply(
522 [](const auto &...bspline) {
523 return std::make_tuple(bspline.clone()...);
533 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
534 std::array<int64_t, 2>({ncoeffs[1], ncoeffs[2]}),
init,
536 std::tuple_element_t<0, boundary_spline_type>(
537 std::array<int64_t, 2>({ncoeffs[1], ncoeffs[2]}),
init,
539 std::tuple_element_t<1, boundary_spline_type>(
540 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[2]}),
init,
542 std::tuple_element_t<1, boundary_spline_type>(
543 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[2]}),
init,
545 std::tuple_element_t<2, boundary_spline_type>(
546 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[1]}),
init,
548 std::tuple_element_t<2, boundary_spline_type>(
549 std::array<int64_t, 2>({ncoeffs[0], ncoeffs[1]}),
init,
554 const std::array<std::vector<typename Spline::value_type>, 3> &kv,
558 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
559 std::array<std::vector<typename Spline::value_type>, 2>(
562 std::tuple_element_t<0, boundary_spline_type>(
563 std::array<std::vector<typename Spline::value_type>, 2>(
566 std::tuple_element_t<1, boundary_spline_type>(
567 std::array<std::vector<typename Spline::value_type>, 2>(
570 std::tuple_element_t<1, boundary_spline_type>(
571 std::array<std::vector<typename Spline::value_type>, 2>(
574 std::tuple_element_t<2, boundary_spline_type>(
575 std::array<std::vector<typename Spline::value_type>, 2>(
578 std::tuple_element_t<2, boundary_spline_type>(
579 std::array<std::vector<typename Spline::value_type>, 2>(
591 if (tensor.dim() > 1) {
598 .index({torch::indexing::Slice(), torch::indexing::Slice(),
599 torch::indexing::Slice(), 0})
600 .reshape({-1, tensor.size(-1)}));
603 .index({torch::indexing::Slice(), torch::indexing::Slice(),
604 torch::indexing::Slice(), -1})
605 .reshape({-1, tensor.size(-1)}));
608 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
609 torch::indexing::Slice()})
610 .reshape({-1, tensor.size(-1)}));
613 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
614 torch::indexing::Slice()})
615 .reshape({-1, tensor.size(-1)}));
618 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
619 torch::indexing::Slice()})
620 .reshape({-1, tensor.size(-1)}));
623 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
624 torch::indexing::Slice()})
625 .reshape({-1, tensor.size(-1)}));
633 .index({torch::indexing::Slice(), torch::indexing::Slice(),
634 torch::indexing::Slice(), 0})
638 .index({torch::indexing::Slice(), torch::indexing::Slice(),
639 torch::indexing::Slice(), -1})
644 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
645 torch::indexing::Slice()})
649 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
650 torch::indexing::Slice()})
655 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
656 torch::indexing::Slice()})
660 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
661 torch::indexing::Slice()})
671 template <
short_t s>
inline constexpr auto &
side()
const {
672 static_assert(s >
none && s <= nsides());
673 return std::get<s - 1>(bdr_);
677 template <
short_t s>
inline constexpr auto &
side() {
678 static_assert(s >
none && s <= nsides());
679 return std::get<s - 1>(bdr_);
684 inline constexpr auto &
coeffs()
const {
return bdr_; }
688 inline constexpr auto &
coeffs() {
return bdr_; }
706 os << name() <<
"(\n"
716 inline nlohmann::json
to_json()
const override {
759 template <
typename Spline>
760 requires SplineType<Spline>
773 std::tuple<
typename Spline::template derived_self_type<
774 typename Spline::value_type, Spline::geoDim(),
775 Spline::degree(1), Spline::degree(2), Spline::degree(3)>,
776 typename Spline::template derived_self_type<
777 typename Spline::value_type, Spline::geoDim(),
778 Spline::degree(0), Spline::degree(2), Spline::degree(3)>,
779 typename Spline::template derived_self_type<
780 typename Spline::value_type, Spline::geoDim(),
781 Spline::degree(0), Spline::degree(1), Spline::degree(3)>,
782 typename Spline::template derived_self_type<
783 typename Spline::value_type, Spline::geoDim(),
784 Spline::degree(0), Spline::degree(1), Spline::degree(2)>>;
788 template <
typename real_t>
790 std::tuple<
typename Spline::template derived_self_type<
791 real_t, Spline::geoDim(), Spline::degree(1),
792 Spline::degree(2), Spline::degree(3)>,
793 typename Spline::template derived_self_type<
794 real_t, Spline::geoDim(), Spline::degree(0),
795 Spline::degree(2), Spline::degree(3)>,
796 typename Spline::template derived_self_type<
797 real_t, Spline::geoDim(), Spline::degree(0),
798 Spline::degree(1), Spline::degree(3)>,
799 typename Spline::template derived_self_type<
800 real_t, Spline::geoDim(), Spline::degree(0),
801 Spline::degree(1), Spline::degree(2)>>;
804 std::tuple<typename std::tuple_element_t<0, boundary_spline_type>,
805 typename std::tuple_element_t<0, boundary_spline_type>,
806 typename std::tuple_element_t<1, boundary_spline_type>,
807 typename std::tuple_element_t<1, boundary_spline_type>,
808 typename std::tuple_element_t<2, boundary_spline_type>,
809 typename std::tuple_element_t<2, boundary_spline_type>,
810 typename std::tuple_element_t<3, boundary_spline_type>,
811 typename std::tuple_element_t<3, boundary_spline_type>>
827 : bdr_({std::tuple_element_t<0, boundary_spline_type>(options),
828 std::tuple_element_t<0, boundary_spline_type>(options),
829 std::tuple_element_t<1, boundary_spline_type>(options),
830 std::tuple_element_t<1, boundary_spline_type>(options),
831 std::tuple_element_t<2, boundary_spline_type>(options),
832 std::tuple_element_t<2, boundary_spline_type>(options),
833 std::tuple_element_t<3, boundary_spline_type>(options),
834 std::tuple_element_t<3, boundary_spline_type>(options)}) {}
844 : bdr_(clone ?
std::apply(
845 [](const auto &...bspline) {
846 return std::make_tuple(bspline.clone()...);
856 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
857 std::array<int64_t, 3>({ncoeffs[1], ncoeffs[2], ncoeffs[3]}),
859 std::tuple_element_t<0, boundary_spline_type>(
860 std::array<int64_t, 3>({ncoeffs[1], ncoeffs[2], ncoeffs[3]}),
862 std::tuple_element_t<1, boundary_spline_type>(
863 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[2], ncoeffs[3]}),
865 std::tuple_element_t<1, boundary_spline_type>(
866 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[2], ncoeffs[3]}),
868 std::tuple_element_t<2, boundary_spline_type>(
869 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[3]}),
871 std::tuple_element_t<2, boundary_spline_type>(
872 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[3]}),
874 std::tuple_element_t<3, boundary_spline_type>(
875 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[2]}),
877 std::tuple_element_t<3, boundary_spline_type>(
878 std::array<int64_t, 3>({ncoeffs[0], ncoeffs[1], ncoeffs[2]}),
883 const std::array<std::vector<typename Spline::value_type>, 4> &kv,
887 : bdr_({std::tuple_element_t<0, boundary_spline_type>(
888 std::array<std::vector<typename Spline::value_type>, 3>(
889 {kv[1], kv[2], kv[3]}),
891 std::tuple_element_t<0, boundary_spline_type>(
892 std::array<std::vector<typename Spline::value_type>, 3>(
893 {kv[1], kv[2], kv[3]}),
895 std::tuple_element_t<1, boundary_spline_type>(
896 std::array<std::vector<typename Spline::value_type>, 3>(
897 {kv[0], kv[2], kv[3]}),
899 std::tuple_element_t<1, boundary_spline_type>(
900 std::array<std::vector<typename Spline::value_type>, 3>(
901 {kv[0], kv[2], kv[3]}),
903 std::tuple_element_t<2, boundary_spline_type>(
904 std::array<std::vector<typename Spline::value_type>, 3>(
905 {kv[0], kv[1], kv[3]}),
907 std::tuple_element_t<2, boundary_spline_type>(
908 std::array<std::vector<typename Spline::value_type>, 3>(
909 {kv[0], kv[1], kv[3]}),
911 std::tuple_element_t<3, boundary_spline_type>(
912 std::array<std::vector<typename Spline::value_type>, 3>(
913 {kv[0], kv[1], kv[2]}),
915 std::tuple_element_t<3, boundary_spline_type>(
916 std::array<std::vector<typename Spline::value_type>, 3>(
917 {kv[0], kv[1], kv[2]}),
928 if (tensor.dim() > 1) {
929 auto tensor_view = tensor.view(
935 .index({torch::indexing::Slice(), torch::indexing::Slice(),
936 torch::indexing::Slice(), torch::indexing::Slice(), 0})
937 .reshape({-1, tensor.size(-1)}));
940 .index({torch::indexing::Slice(), torch::indexing::Slice(),
941 torch::indexing::Slice(), torch::indexing::Slice(), -1})
942 .reshape({-1, tensor.size(-1)}));
945 .index({torch::indexing::Slice(), torch::indexing::Slice(),
946 torch::indexing::Slice(), 0, torch::indexing::Slice()})
947 .reshape({-1, tensor.size(-1)}));
950 .index({torch::indexing::Slice(), torch::indexing::Slice(),
951 torch::indexing::Slice(), -1, torch::indexing::Slice()})
952 .reshape({-1, tensor.size(-1)}));
955 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
956 torch::indexing::Slice(), torch::indexing::Slice()})
957 .reshape({-1, tensor.size(-1)}));
960 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
961 torch::indexing::Slice(), torch::indexing::Slice()})
962 .reshape({-1, tensor.size(-1)}));
965 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
966 torch::indexing::Slice(), torch::indexing::Slice()})
967 .reshape({-1, tensor.size(-1)}));
970 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
971 torch::indexing::Slice(), torch::indexing::Slice()})
972 .reshape({-1, tensor.size(-1)}));
980 .index({torch::indexing::Slice(), torch::indexing::Slice(),
981 torch::indexing::Slice(), torch::indexing::Slice(), 0})
985 .index({torch::indexing::Slice(), torch::indexing::Slice(),
986 torch::indexing::Slice(), torch::indexing::Slice(), -1})
991 .index({torch::indexing::Slice(), torch::indexing::Slice(),
992 torch::indexing::Slice(), 0, torch::indexing::Slice()})
996 .index({torch::indexing::Slice(), torch::indexing::Slice(),
997 torch::indexing::Slice(), -1, torch::indexing::Slice()})
1002 .index({torch::indexing::Slice(), torch::indexing::Slice(), 0,
1003 torch::indexing::Slice(), torch::indexing::Slice()})
1007 .index({torch::indexing::Slice(), torch::indexing::Slice(), -1,
1008 torch::indexing::Slice(), torch::indexing::Slice()})
1013 .index({torch::indexing::Slice(), 0, torch::indexing::Slice(),
1014 torch::indexing::Slice(), torch::indexing::Slice()})
1018 .index({torch::indexing::Slice(), -1, torch::indexing::Slice(),
1019 torch::indexing::Slice(), torch::indexing::Slice()})
1029 template <
short_t s>
inline constexpr auto &
side()
const {
1030 static_assert(s >
none && s <= nsides());
1031 return std::get<s - 1>(bdr_);
1035 template <
short_t s>
inline constexpr auto &
side() {
1036 static_assert(s >
none && s <= nsides());
1037 return std::get<s - 1>(bdr_);
1042 inline constexpr auto &
coeffs()
const {
return bdr_; }
1046 inline constexpr auto &
coeffs() {
return bdr_; }
1066 os << name() <<
"(\n"
1079 nlohmann::json json;
1119 template<
typename T>
1123template <
typename BoundaryCore>
1127 using BoundaryCore::BoundaryCore;
1137 template <std::size_t... Is>
1138 inline torch::Tensor
as_tensor_(std::index_sequence<Is...>)
const {
1139 return torch::cat({std::get<Is>(BoundaryCore::bdr_).as_tensor()...});
1148 return as_tensor_(std::make_index_sequence<BoundaryCore::nsides()>{});
1156 template <std::size_t... Is>
1159 [](
auto... size) {
return (size + ...); },
1160 std::make_tuple(std::get<Is>(BoundaryCore::bdr_).
as_tensor_size()...));
1169 return as_tensor_size_(std::make_index_sequence<BoundaryCore::nsides()>{});
1179 template <std::size_t... Is>
1181 const torch::Tensor &tensor) {
1183 std::size_t start(0);
1184 auto end = [&start](std::size_t inc) {
return start += inc; };
1186 (std::get<Is>(BoundaryCore::bdr_)
1187 .from_tensor(tensor.index({torch::indexing::Slice(
1188 start, end(std::get<Is>(BoundaryCore::bdr_).ncumcoeffs() *
1189 std::get<Is>(BoundaryCore::bdr_).geoDim()))})),
1203 return from_tensor_(std::make_index_sequence<BoundaryCore::nsides()>{},
1211 size_t... Is,
typename... Xi>
1212 inline auto eval_(std::index_sequence<Is...>,
1213 const std::tuple<Xi...> &xi)
const {
1215 std::get<Is>(BoundaryCore::bdr_)
1216 .
template eval<deriv, memory_optimized>(std::get<Is>(xi))...);
1220 size_t... Is,
typename... Xi,
typename... Indices>
1221 inline auto eval_(std::index_sequence<Is...>,
const std::tuple<Xi...> &xi,
1222 const std::tuple<Indices...> &indices)
const {
1223 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1224 .
template eval<deriv, memory_optimized>(
1225 std::get<Is>(xi), std::get<Is>(indices))...);
1229 size_t... Is,
typename... Xi,
typename... Indices,
1230 typename... Coeff_Indices>
1231 inline auto eval_(std::index_sequence<Is...>,
const std::tuple<Xi...> &xi,
1232 const std::tuple<Indices...> &indices,
1233 const std::tuple<Coeff_Indices...> &coeff_indices)
const {
1234 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1235 .
template eval<deriv, memory_optimized>(
1236 std::get<Is>(xi), std::get<Is>(indices),
1237 std::get<Is>(coeff_indices))...);
1246 inline auto eval(
const std::tuple<Xi...> &xi)
const {
1247 return eval_<deriv, memory_optimized>(
1248 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1252 typename... Xi,
typename... Indices>
1253 inline auto eval(
const std::tuple<Xi...> &xi,
1254 const std::tuple<Indices...> &indices)
const {
1255 static_assert(
sizeof...(Xi) ==
sizeof...(Indices));
1256 return eval_<deriv, memory_optimized>(
1257 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices);
1261 typename... Xi,
typename... Indices,
typename... Coeff_Indices>
1262 inline auto eval(
const std::tuple<Xi...> &xi,
1263 const std::tuple<Indices...> &indices,
1264 const std::tuple<Coeff_Indices...> &coeff_indices)
const {
1265 static_assert(
sizeof...(Xi) ==
sizeof...(Indices) &&
1266 sizeof...(Xi) ==
sizeof...(Coeff_Indices));
1267 return eval_<deriv, memory_optimized>(
1268 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices,
1276 template <
size_t... Is,
typename... Basfunc,
typename... Coeff_Indices,
1277 typename... Numeval,
typename... Sizes>
1280 const std::tuple<Basfunc...> &basfunc,
1281 const std::tuple<Coeff_Indices...> &coeff_indices,
1282 const std::tuple<Numeval...> &numeval,
1283 const std::tuple<Sizes...> &sizes)
const {
1284 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1286 std::get<Is>(coeff_indices),
1287 std::get<Is>(numeval),
1288 std::get<Is>(sizes))...);
1291 template <
size_t... Is,
typename... Basfunc,
typename... Coeff_Indices,
1295 const std::tuple<Basfunc...> &basfunc,
1296 const std::tuple<Coeff_Indices...> &coeff_indices,
1297 const std::tuple<Xi...> &xi)
const {
1299 std::get<Is>(BoundaryCore::bdr_)
1301 std::get<Is>(basfunc), std::get<Is>(coeff_indices),
1302 std::get<Is>(xi)[0].numel(), std::get<Is>(xi)[0].sizes())...);
1309 template <
typename... Basfunc,
typename... Coeff_Indices,
typename... Numeval,
1313 const std::tuple<Coeff_Indices...> &coeff_indices,
1314 const std::tuple<Numeval...> &numeval,
1315 const std::tuple<Sizes...> &sizes)
const {
1316 static_assert(
sizeof...(Basfunc) ==
sizeof...(Coeff_Indices) &&
1317 sizeof...(Basfunc) ==
sizeof...(Numeval) &&
1318 sizeof...(Basfunc) ==
sizeof...(Sizes));
1320 std::make_index_sequence<BoundaryCore::nsides()>{}, basfunc,
1321 coeff_indices, numeval, sizes);
1324 template <
typename... Basfunc,
typename... Coeff_Indices,
typename... Xi>
1327 const std::tuple<Coeff_Indices...> &coeff_indices,
1328 const std::tuple<Xi...> &xi)
const {
1329 static_assert(
sizeof...(Basfunc) ==
sizeof...(Coeff_Indices) &&
1330 sizeof...(Basfunc) ==
sizeof...(Xi));
1332 std::make_index_sequence<BoundaryCore::nsides()>{}, basfunc,
1340 template <
size_t... Is,
typename... Xi>
1342 const std::tuple<Xi...> &xi)
const {
1343 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1349 template <
typename... Xi>
1352 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1360 size_t... Is,
typename... Xi>
1362 const std::tuple<Xi...> &xi)
const {
1363 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1364 .
template eval_basfunc<deriv, memory_optimized>(
1365 std::get<Is>(xi))...);
1369 size_t... Is,
typename... Xi,
typename... Indices>
1371 const std::tuple<Xi...> &xi,
1372 const std::tuple<Indices...> &indices)
const {
1373 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1374 .
template eval_basfunc<deriv, memory_optimized>(
1375 std::get<Is>(xi), std::get<Is>(indices))...);
1385 return eval_basfunc_<deriv, memory_optimized>(
1386 std::make_index_sequence<BoundaryCore::nsides()>{}, xi);
1390 typename... Xi,
typename... Indices>
1392 const std::tuple<Indices...> &indices)
const {
1393 static_assert(
sizeof...(Xi) ==
sizeof...(Indices));
1394 return eval_basfunc_<deriv, memory_optimized>(
1395 std::make_index_sequence<BoundaryCore::nsides()>{}, xi, indices);
1402 template <
bool memory_optimized =
false,
size_t... Is,
typename... Indices>
1404 const std::tuple<Indices...> &indices)
const {
1405 return std::tuple(std::get<Is>(BoundaryCore::bdr_)
1406 .
template find_coeff_indices<memory_optimized>(
1407 std::get<Is>(indices))...);
1413 template <
bool memory_optimized =
false,
typename... Indices>
1415 return find_coeff_indices_<memory_optimized>(
1416 std::make_index_sequence<BoundaryCore::nsides()>{}, indices);
1422 template <
size_t... Is>
1425 (std::get<Is>(BoundaryCore::bdr_).uniform_refine(numRefine, dim), ...);
1434 if constexpr (BoundaryCore::spline_type::parDim() > 1)
1437 }
else if (dim == 0) {
1438 if constexpr (BoundaryCore::nsides() == 2) {
1440 }
else if constexpr (BoundaryCore::nsides() == 4) {
1445 }
else if constexpr (BoundaryCore::nsides() == 6) {
1454 }
else if constexpr (BoundaryCore::nsides() == 8) {
1468 throw std::runtime_error(
"Invalid dimension");
1469 }
else if (dim == 1) {
1470 if constexpr (BoundaryCore::nsides() == 4) {
1475 }
else if constexpr (BoundaryCore::nsides() == 6) {
1485 }
else if constexpr (BoundaryCore::nsides() == 8) {
1499 throw std::runtime_error(
"Invalid dimension");
1500 }
else if (dim == 2) {
1501 if constexpr (BoundaryCore::nsides() == 6) {
1510 }
else if constexpr (BoundaryCore::nsides() == 8) {
1524 throw std::runtime_error(
"Invalid dimension");
1525 }
else if (dim == 3) {
1526 if constexpr (BoundaryCore::nsides() == 8) {
1540 throw std::runtime_error(
"Invalid dimension");
1542 throw std::runtime_error(
"Invalid dimension");
1549 template <
size_t... Is>
1550 inline torch::serialize::OutputArchive &
1551 write_(std::index_sequence<Is...>, torch::serialize::OutputArchive &archive,
1552 const std::string &key =
"boundary")
const {
1553 (std::get<Is>(BoundaryCore::bdr_)
1554 .write(archive, key +
".bdr[" + std::to_string(Is) +
"]"),
1561 inline void save(
const std::string &filename,
1562 const std::string &key =
"boundary")
const {
1563 torch::serialize::OutputArchive archive;
1564 write(archive, key).save_to(filename);
1569 inline torch::serialize::OutputArchive &
1570 write(torch::serialize::OutputArchive &archive,
1571 const std::string &key =
"boundary")
const {
1572 write_(std::make_index_sequence<BoundaryCore::nsides()>{}, archive, key);
1579 template <
size_t... Is>
1580 inline torch::serialize::InputArchive &
1581 read_(std::index_sequence<Is...>, torch::serialize::InputArchive &archive,
1582 const std::string &key =
"boundary") {
1583 (std::get<Is>(BoundaryCore::bdr_)
1584 .read(archive, key +
".bdr[" + std::to_string(Is) +
"]"),
1591 inline void load(
const std::string &filename,
1592 const std::string &key =
"boundary") {
1593 torch::serialize::InputArchive archive;
1594 archive.load_from(filename);
1600 inline torch::serialize::InputArchive &
1601 read(torch::serialize::InputArchive &archive,
1602 const std::string &key =
"boundary") {
1603 read_(std::make_index_sequence<BoundaryCore::nsides()>{}, archive, key);
1608 inline pugi::xml_document
to_xml(
int id = 0, std::string label =
"",
1609 int index = -1)
const {
1610 pugi::xml_document doc;
1611 pugi::xml_node root = doc.append_child(
"xml");
1612 to_xml(root,
id, label, index);
1618 inline pugi::xml_node &
to_xml(pugi::xml_node &root,
int id = 0,
1619 std::string label =
"",
int index = -1)
const {
1621 pugi::xml_node bdr = root.append_child(
"Boundary");
1624 bdr.append_attribute(
"id") = id;
1627 bdr.append_attribute(
"index") = index;
1630 bdr.append_attribute(
"label") = label.c_str();
1634 [&bdr, &index_](
const auto &...bspline) {
1635 (bspline.to_xml(bdr, -1,
"", index_++), ...);
1637 BoundaryCore::bdr_);
1644 std::string label =
"",
int index = -1) {
1645 return from_xml(doc.child(
"xml"),
id, label, index);
1650 std::string label =
"",
int index = -1) {
1653 for (pugi::xml_node bdr : root.children(
"Boundary")) {
1656 if ((
id >= 0 ? bdr.attribute(
"id").as_int() ==
id :
true) &&
1657 (index >= 0 ? bdr.attribute(
"index").as_int() == index :
true) &&
1658 (!label.empty() ? bdr.attribute(
"label").value() == label :
true)) {
1662 [&bdr, &index_](
auto &...bspline) {
1663 (bspline.from_xml(bdr, -1,
"", index_++), ...);
1665 BoundaryCore::bdr_);
1672 throw std::runtime_error(
"XML object does not provide geometry with given "
1673 "id, index, and/or label");
1680 template <
typename BoundaryCore_,
size_t... Is>
1684 (std::get<Is>(BoundaryCore::bdr_) == std::get<Is>(other.coeffs())) &&
1690 template <
typename BoundaryCore_>
1692 return isequal_(std::make_index_sequence<BoundaryCore::nsides()>{}, other);
1696 template <
typename BoundaryCore_>
1706 template <
typename BoundaryCore_,
size_t... Is>
1710 typename BoundaryCore::spline_type::value_type rtol,
1711 typename BoundaryCore::spline_type::value_type atol)
const {
1712 return ((std::get<Is>(BoundaryCore::bdr_)
1713 .
isclose(std::get<Is>(other.coeffs()))) &&
1720 template <
typename BoundaryCore_>
1723 typename BoundaryCore::spline_type::value_type rtol =
1724 typename BoundaryCore::spline_type::value_type{1e-5},
1725 typename BoundaryCore::spline_type::value_type atol =
1726 typename BoundaryCore::spline_type::value_type{1e-8})
const {
1727 return isclose_(std::make_index_sequence<BoundaryCore::nsides()>{}, other,
1731#define GENERATE_EXPR_MACRO(r, data, name) \
1733 template <bool memory_optimized = false, size_t... Is, typename... Xi> \
1734 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1735 const std::tuple<Xi...> &xi) const { \
1736 return std::tuple( \
1737 std::get<Is>(BoundaryCore::bdr_) \
1738 .template name<memory_optimized>(std::get<Is>(xi))...); \
1741 template <bool memory_optimized = false, size_t... Is, typename... Xi, \
1742 typename... Indices> \
1743 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1744 const std::tuple<Xi...> &xi, \
1745 const std::tuple<Indices...> &indices) \
1747 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1748 .template name<memory_optimized>( \
1749 std::get<Is>(xi), std::get<Is>(indices))...); \
1752 template <bool memory_optimized = false, size_t... Is, typename... Xi, \
1753 typename... Indices, typename... Coeff_Indices> \
1754 inline auto BOOST_PP_CAT(name, _)( \
1755 std::index_sequence<Is...>, const std::tuple<Xi...> &xi, \
1756 const std::tuple<Indices...> &indices, \
1757 const std::tuple<Coeff_Indices...> &coeff_indices) const { \
1758 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1759 .template name<memory_optimized>( \
1760 std::get<Is>(xi), std::get<Is>(indices), \
1761 std::get<Is>(coeff_indices))...); \
1765 template <bool memory_optimized = false, typename... Args> \
1766 inline auto name(const Args &...args) const { \
1767 return BOOST_PP_CAT(name, _)<memory_optimized>( \
1768 std::make_index_sequence<BoundaryCore::nsides()>{}, args...); \
1775#undef GENERATE_EXPR_MACRO
1777#define GENERATE_IEXPR_MACRO(r, data, name) \
1779 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1781 inline auto BOOST_PP_CAT(name, _)(std::index_sequence<Is...>, \
1782 const std::tuple<Geometry...> &G, \
1783 const std::tuple<Xi...> &xi) const { \
1784 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1785 .template name<memory_optimized>( \
1786 std::get<Is>(G), std::get<Is>(xi))...); \
1789 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1790 typename... Xi, typename... Indices> \
1791 inline auto BOOST_PP_CAT(name, _)( \
1792 std::index_sequence<Is...>, const std::tuple<Geometry...> &G, \
1793 const std::tuple<Xi...> &xi, const std::tuple<Indices...> &indices) \
1795 return std::tuple( \
1796 std::get<Is>(BoundaryCore::bdr_) \
1797 .template name<memory_optimized>( \
1798 std::get<Is>(G), std::get<Is>(xi), std::get<Is>(indices))...); \
1801 template <bool memory_optimized = false, size_t... Is, typename... Geometry, \
1802 typename... Xi, typename... Indices, typename... Coeff_Indices> \
1803 inline auto BOOST_PP_CAT(name, _)( \
1804 std::index_sequence<Is...>, const std::tuple<Geometry...> &G, \
1805 const std::tuple<Xi...> &xi, const std::tuple<Indices...> &indices, \
1806 const std::tuple<Coeff_Indices...> &coeff_indices) const { \
1807 return std::tuple(std::get<Is>(BoundaryCore::bdr_) \
1808 .template name<memory_optimized>( \
1809 std::get<Is>(G), std::get<Is>(xi), \
1810 std::get<Is>(indices), \
1811 std::get<Is>(coeff_indices))...); \
1815 template <bool memory_optimized = false, typename... Args> \
1816 inline auto name(const Args &...args) const { \
1817 return BOOST_PP_CAT(name, _)<memory_optimized>( \
1818 std::make_index_sequence<BoundaryCore::nsides()>{}, args...); \
1825#undef GENERATE_IEXPR_MACRO
1830 [](
const auto &...bspline) {
1831 return std::make_tuple(bspline.device()...);
1833 BoundaryCore::bdr_);
1839 [](
const auto &...bspline) {
1840 return std::make_tuple(bspline.device_index()...);
1842 BoundaryCore::bdr_);
1848 [](
const auto &...bspline) {
1849 return std::make_tuple(bspline.dtype()...);
1851 BoundaryCore::bdr_);
1857 [](
const auto &...bspline) {
1858 return std::make_tuple(bspline.layout()...);
1860 BoundaryCore::bdr_);
1866 [](
const auto &...bspline) {
1867 return std::make_tuple(bspline.requires_grad()...);
1869 BoundaryCore::bdr_);
1875 [](
const auto &...bspline) {
1876 return std::make_tuple(bspline.pinned_memory()...);
1878 BoundaryCore::bdr_);
1884 [](
const auto &...bspline) {
1885 return std::make_tuple(bspline.is_sparse()...);
1887 BoundaryCore::bdr_);
1893 [](
const auto &...bspline) {
1894 return std::make_tuple(bspline.is_uniform()...);
1896 BoundaryCore::bdr_);
1902 [](
const auto &...bspline) {
1903 return std::make_tuple(bspline.is_nonuniform()...);
1905 BoundaryCore::bdr_);
1914 BoundaryCore::bdr_);
1922 decltype(
typename BoundaryCore::spline_type{}.to(options)),
1923 BoundaryCore::spline_type::parDim()>>;
1925 return boundary_type(std::apply(
1926 [&options](
const auto &...bspline) {
1927 return std::make_tuple(bspline.to(options)...);
1929 BoundaryCore::bdr_));
1935 [&
device](
const auto &...bspline) {
1936 return std::make_tuple(bspline.to(
device)...);
1938 BoundaryCore::bdr_));
1942 template <
typename real_t>
inline auto to()
const {
1944 decltype(
typename BoundaryCore::spline_type{}.template to<real_t>()),
1945 BoundaryCore::spline_type::parDim()>>;
1947 return boundary_type(std::apply(
1948 [](
const auto &...bspline) {
1949 return std::make_tuple(bspline.template to<real_t>()...);
1951 BoundaryCore::bdr_));
1956 template <
typename Spline>
1957 requires SplineType<Spline>
1961 template <
typename Spline>
1964 obj.pretty_print(os);
#define GENERATE_IEXPR_MACRO(r, data, name)
Auto-generated functions.
Definition boundary.hpp:1777
#define GENERATE_EXPR_MACRO(r, data, name)
Definition boundary.hpp:1731
#define GENERATE_EXPR_SEQ
Sequence of expression (parametric coordinates)
Definition bspline.hpp:41
#define GENERATE_IEXPR_SEQ
Sequence of expression (physical coordinates)
Definition bspline.hpp:47
Boundary base class
Definition boundary.hpp:1116
Boundary (common high-level functionality)
Definition boundary.hpp:1124
auto find_knot_indices(const std::tuple< Xi... > &xi) const
Returns the knot indicies of knot spans containing xi
Definition boundary.hpp:1350
auto to(torch::Device device) const
Returns a copy of the boundary object with settings from device.
Definition boundary.hpp:1933
auto dtype() const noexcept
Returns the dtype property of all splines.
Definition boundary.hpp:1846
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:1312
auto pinned_memory() const noexcept
Returns the pinned_memory property of all splines.
Definition boundary.hpp:1873
bool isequal_(std::index_sequence< Is... >, const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary spline objects are the same.
Definition boundary.hpp:1681
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:1384
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:1601
auto eval(const std::tuple< Xi... > &xi) const
Returns the values of the spline objects in the points xi
Definition boundary.hpp:1246
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:1279
auto to() const
Returns a copy of the boundary object with real_t type.
Definition boundary.hpp:1942
bool isclose_(std::index_sequence< Is... >, const BoundaryCommon< BoundaryCore_ > &other, typename BoundaryCore::spline_type::value_type rtol, typename BoundaryCore::spline_type::value_type atol) const
Returns true if both boundary spline objects are close up to the given tolerances.
Definition boundary.hpp:1708
auto to(Options< real_t > options) const
Returns a copy of the boundary object with settings from options.
Definition boundary.hpp:1920
auto device_index() const noexcept
Returns the device_index property of all splines.
Definition boundary.hpp:1837
auto is_uniform() const noexcept
Returns true if the B-spline is uniform of all splines.
Definition boundary.hpp:1891
BoundaryCommon & from_xml(const pugi::xml_document &doc, int id=0, std::string label="", int index=-1)
Updates the boundary object from XML object.
Definition boundary.hpp:1643
torch::Tensor as_tensor_(std::index_sequence< Is... >) const
Returns all coefficients of all spline objects as a single tensor.
Definition boundary.hpp:1138
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:1157
auto eval_basfunc_(std::index_sequence< Is... >, const std::tuple< Xi... > &xi) const
Returns the values of the boundary spline spline object's basis functions in the points xi
Definition boundary.hpp:1361
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:1341
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:1423
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:1551
pugi::xml_document to_xml(int id=0, std::string label="", int index=-1) const
Returns the boundary object as XML object.
Definition boundary.hpp:1608
auto is_nonuniform() const noexcept
Returns true if the B-spline is non-uniform if all splines.
Definition boundary.hpp:1900
BoundaryCommon & from_xml(const pugi::xml_node &root, int id=0, std::string label="", int index=-1)
Updates the boundary object from XML node.
Definition boundary.hpp:1649
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:1231
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:1414
auto requires_grad() const noexcept
Returns the requires_grad property of all splines.
Definition boundary.hpp:1864
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:1253
BoundaryCommon clone() const
Returns a clone of the boundary object.
Definition boundary.hpp:1130
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:1391
auto & from_tensor(const torch::Tensor &tensor)
Sets the coefficients of all spline objects from a single tensor.
Definition boundary.hpp:1202
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:1180
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:1262
void load(const std::string &filename, const std::string &key="boundary")
Loads the boundary spline object from file.
Definition boundary.hpp:1591
torch::Tensor as_tensor() const
Returns all coefficients of all spline objects as a single tensor.
Definition boundary.hpp:1147
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 spline object's basis functions in the points xi
Definition boundary.hpp:1370
BoundaryCommon & set_requires_grad(bool requires_grad)
Sets the boundary object's requires_grad property.
Definition boundary.hpp:1909
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:1212
pugi::xml_node & to_xml(pugi::xml_node &root, int id=0, std::string label="", int index=-1) const
Returns the boundary object as XML node.
Definition boundary.hpp:1618
bool isclose(const BoundaryCommon< BoundaryCore_ > &other, typename BoundaryCore::spline_type::value_type rtol=typename BoundaryCore::spline_type::value_type{1e-5}, typename 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:1722
auto & uniform_refine(int numRefine=1, int dim=-1)
Returns the spline objects with uniformly refined knot and coefficient vectors.
Definition boundary.hpp:1432
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:1294
int64_t as_tensor_size() const
Returns the size of the single tensor representation of all spline objects.
Definition boundary.hpp:1168
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:1326
bool operator==(const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary objects are the same.
Definition boundary.hpp:1691
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:1403
auto layout() const noexcept
Returns the layout property of all splines.
Definition boundary.hpp:1855
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:1570
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:1581
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:1221
void save(const std::string &filename, const std::string &key="boundary") const
Saves the boundary spline to file.
Definition boundary.hpp:1561
auto device() const noexcept
Auto-generated functions.
Definition boundary.hpp:1828
bool operator!=(const BoundaryCommon< BoundaryCore_ > &other) const
Returns true if both boundary objects are different.
Definition boundary.hpp:1697
auto is_sparse() const noexcept
Returns if the layout is sparse of all splines.
Definition boundary.hpp:1882
constexpr auto & side() const
Returns constant reference to side-th Spline.
Definition boundary.hpp:147
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:103
std::tuple< boundary_spline_type, boundary_spline_type > bdr_
Tuple of splines.
Definition boundary.hpp:73
std::tuple< torch::Tensor, torch::Tensor > eval_type
Evaluation type.
Definition boundary.hpp:80
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:94
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:88
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:110
constexpr auto & coeffs() const
Returns a constant reference to the array of coefficients for all boundary segments.
Definition boundary.hpp:160
typename 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:70
constexpr auto & coeffs()
Returns a non-constant reference to the array of coefficients for all boundary segments.
Definition boundary.hpp:164
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:144
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:83
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:167
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:193
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:91
constexpr auto & side()
Returns non-constant reference to side-th Spline.
Definition boundary.hpp:153
typename Spline::template derived_self_type< typename Spline::value_type, Spline::geoDim()> boundary_spline_type
Boundary spline type.
Definition boundary.hpp:64
virtual void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:177
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:184
Spline spline_type
Spline type.
Definition boundary.hpp:59
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:77
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:201
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:123
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:230
constexpr auto & side()
Returns non-constant reference to the s-th side's spline.
Definition boundary.hpp:379
std::tuple< utils::TensorArray< 1 >, utils::TensorArray< 1 >, utils::TensorArray< 1 >, utils::TensorArray< 1 > > eval_type
Evaluation type.
Definition boundary.hpp:254
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:370
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:435
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:271
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:414
constexpr auto & coeffs()
Returns a non-constant reference to the array of coefficients for all boundary segments.
Definition boundary.hpp:390
constexpr auto & coeffs() const
Returns a constant reference to the array of coefficients for all boundary segments.
Definition boundary.hpp:386
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:425
Spline spline_type
Spline type.
Definition boundary.hpp:223
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:322
virtual void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:405
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:250
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:257
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:265
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:239
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:280
constexpr auto & side() const
Returns constant reference to the s-th side's spline.
Definition boundary.hpp:373
std::tuple< typename std::tuple_element_t< 0, boundary_spline_type >, typename std::tuple_element_t< 0, boundary_spline_type >, typename std::tuple_element_t< 1, boundary_spline_type >, typename std::tuple_element_t< 1, boundary_spline_type > > bdr_
Tuple of splines.
Definition boundary.hpp:246
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:393
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:294
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:268
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:729
constexpr auto & side() const
Returns constant reference to side-th spline.
Definition boundary.hpp:671
constexpr auto & coeffs() const
Returns a constant reference to the array of coefficients for all boundary segments.
Definition boundary.hpp:684
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:553
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:514
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:496
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:520
Spline spline_type
Spline type.
Definition boundary.hpp:460
std::tuple< typename std::tuple_element_t< 0, boundary_spline_type >, typename std::tuple_element_t< 0, boundary_spline_type >, typename std::tuple_element_t< 1, boundary_spline_type >, typename std::tuple_element_t< 1, boundary_spline_type >, typename std::tuple_element_t< 2, boundary_spline_type >, typename std::tuple_element_t< 2, boundary_spline_type > > bdr_
Tuple of splines.
Definition boundary.hpp:492
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:472
virtual void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:705
constexpr auto & coeffs()
Returns a non-constant reference to the array of coefficients for all boundary segments.
Definition boundary.hpp:688
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:517
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:504
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:529
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:691
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:589
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:483
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:716
constexpr auto & side()
Returns non-constant reference to side-th spline.
Definition boundary.hpp:677
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:501
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:668
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:741
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:852
constexpr auto & side()
Returns non-constant reference to side-th spline.
Definition boundary.hpp:1035
BoundaryCore & from_json(const nlohmann::json &json)
Updates the boundary object from JSON object.
Definition boundary.hpp:1093
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:926
eval_type greville() const
Returns the Greville abscissae.
Definition boundary.hpp:1107
int64_t ncumcoeffs() const
Returns the total number of coefficients.
Definition boundary.hpp:1049
std::tuple< typename std::tuple_element_t< 0, boundary_spline_type >, typename std::tuple_element_t< 0, boundary_spline_type >, typename std::tuple_element_t< 1, boundary_spline_type >, typename std::tuple_element_t< 1, boundary_spline_type >, typename std::tuple_element_t< 2, boundary_spline_type >, typename std::tuple_element_t< 2, boundary_spline_type >, typename std::tuple_element_t< 3, boundary_spline_type >, typename std::tuple_element_t< 3, boundary_spline_type > > bdr_
Tuple of splines.
Definition boundary.hpp:812
BoundaryCore(boundary_type &&bdr_)
Move constructor.
Definition boundary.hpp:840
virtual void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the Boundary object.
Definition boundary.hpp:1065
static constexpr short_t nsides()
Returns the number of sides.
Definition boundary.hpp:1026
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:822
BoundaryCore(const BoundaryCore &other, bool clone)
Copy/clone constructor.
Definition boundary.hpp:843
constexpr auto & coeffs()
Returns a non-constant reference to the array of coefficients for all boundary segments.
Definition boundary.hpp:1046
Spline spline_type
Spline type.
Definition boundary.hpp:769
BoundaryCore(const boundary_type &bdr_)
Copy constructor.
Definition boundary.hpp:837
constexpr auto & side() const
Returns constant reference to side-th spline.
Definition boundary.hpp:1029
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:882
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:784
nlohmann::json to_json() const override
Returns the boundary object as JSON object.
Definition boundary.hpp:1078
BoundaryCore(Options< typename Spline::value_type > options=Options< typename Spline::value_type >{})
Default constructor.
Definition boundary.hpp:825
decltype(bdr_) boundary_type
Boundary type.
Definition boundary.hpp:816
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:801
constexpr auto & coeffs() const
Returns a constant reference to the array of coefficients for all boundary segments.
Definition boundary.hpp:1042
BoundaryCore.
Definition boundary.hpp:42
The Options class handles the automated determination of dtype from the template argument and the sel...
Definition options.hpp:107
Full qualified name descriptor.
Definition fqn.hpp:26
Concept to identify template parameters that are derived from iganet::Boundary_.
Definition boundary.hpp:1120
Concept to identify template parameters that are derived from iganet::Spline_.
Definition bspline.hpp:3259
std::array< torch::Tensor, N > TensorArray
Definition tensorarray.hpp:28
Definition boundary.hpp:22
deriv
Enumerator for specifying the derivative of B-spline evaluation.
Definition bspline.hpp:74
struct iganet::@0 Log
Logger.
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
std::ostream & operator<<(std::ostream &os, const Boundary< Spline > &obj)
Print (as string) a Boundary object.
Definition boundary.hpp:1963
Serialization prototype.
Definition serialize.hpp:31