46template <
typename,
typename,
typename =
void>
53 std::tuple<Outputs...>,
54 std::tuple<CollPts...>> {
58 typename std::common_type<
typename Inputs::value_type...,
typename Outputs::value_type...>::type;
68 std::tuple<std::pair<
typename CollPts::eval_type,
69 typename CollPts::boundary_eval_type>...>;
83 template <
typename... Objs, std::size_t... NumCoeffs>
87 return std::make_tuple(
89 [&](
auto&&... args) {
return Objs(std::forward<
decltype(args)>(args)...,
init, options); },
98 template <
typename... Objs,
typename... NumCoeffsTuples, std::size_t... Is>
102 std::index_sequence<Is...>) {
103 static_assert(
sizeof...(Objs) ==
sizeof...(NumCoeffsTuples));
104 return std::make_tuple(
106 [&](
auto&&... args) {
return Objs(std::forward<
decltype(args)>(args)...,
init, options); },
107 std::get<Is>(numCoeffs)
112 template <
typename... Objs,
typename... NumCoeffsTuples>
116 return construct_tuple_from_tuples_impl<Objs...>(numCoeffs,
119 std::index_sequence_for<Objs...>{});
127 : inputs_(), outputs_(), collPts_() {}
133 template <std::
size_t NumCoeffs>
134 IgABase2(
const std::array<int64_t, NumCoeffs>& ncoeffs,
143 template <std::
size_t NumCoeffsInputs, std::
size_t NumCoeffsOutputs, std::
size_t NumCoeffsCollPts>
144 IgABase2(
const std::array<int64_t, NumCoeffsInputs>& ncoeffsInputs,
145 const std::array<int64_t, NumCoeffsOutputs>& ncoeffsOutputs,
146 const std::array<int64_t, NumCoeffsCollPts>& ncoeffsCollPts,
150 std::tuple{ncoeffsCollPts},
init, options) {}
157 template <std::size_t... NumCoeffs>
158 IgABase2(
const std::tuple<std::array<int64_t, NumCoeffs>...>& ncoeffs,
168 template <std::size_t... NumCoeffsInputs, std::size_t... NumCoeffsOutputs, std::size_t... NumCoeffsCollPts>
169 IgABase2(
const std::tuple<std::array<int64_t, NumCoeffsInputs>...>& ncoeffsInputs,
170 const std::tuple<std::array<int64_t, NumCoeffsOutputs>...>& ncoeffsOutputs,
171 const std::tuple<std::array<int64_t, NumCoeffsCollPts>...>& ncoeffsCollPts,
174 : inputs_(construct_tuple_from_arrays<Inputs...>(ncoeffsInputs,
init, options)),
175 outputs_(construct_tuple_from_arrays<Outputs...>(ncoeffsOutputs,
init, options)),
176 collPts_(construct_tuple_from_arrays<Outputs...>(ncoeffsCollPts,
init, options))
184 template<
typename... CoeffsInputs,
typename... CoeffsOutputs,
typename... CoeffsCollPts>
185 IgABase2(
const std::tuple<CoeffsInputs...>& coeffsInputs,
186 const std::tuple<CoeffsOutputs...>& coeffsOutputs,
187 const std::tuple<CoeffsCollPts...>& coeffsCollPts,
190 : inputs_(construct_tuple_from_tuples<Inputs...>(coeffsInputs,
init, options)),
191 outputs_(construct_tuple_from_tuples<Outputs...>(coeffsOutputs,
init, options)),
192 collPts_(construct_tuple_from_tuples<CollPts...>(coeffsCollPts,
init, options))
196 inline constexpr const auto &
inputs()
const {
206 template <std::
size_t index>
207 inline constexpr const auto &
input()
const {
208 static_assert(index >= 0 && index <
sizeof...(Inputs));
209 return std::get<index>(inputs_);
213 template <std::
size_t index>
215 static_assert(index >= 0 && index <
sizeof...(Inputs));
216 return std::get<index>(inputs_);
220 inline constexpr const auto &
outputs()
const {
230 template <std::
size_t index>
231 inline constexpr const auto &
output()
const {
232 static_assert(index >= 0 && index <
sizeof...(Outputs));
233 return std::get<index>(outputs_);
237 template <std::
size_t index>
239 static_assert(index >= 0 && index <
sizeof...(Outputs));
240 return std::get<index>(outputs_);
244 inline constexpr const auto &
collPts()
const {
260 template <std::size_t index, std::size_t... Is>
261 std::tuple_element_t<index, collPts_type>
263 std::tuple_element_t<index, collPts_type>
collPts;
265 switch (collPtsType) {
269 ((std::get<Is>(
collPts.first) =
270 std::get<index>(collPts_).template space<Is>().greville(
false)),
274 ((std::get<Is>(
collPts.second) = std::get<index>(collPts_).template boundary<Is>().greville()),
280 ((std::get<Is>(
collPts.first) =
281 std::get<index>(collPts_).template space<Is>().greville(
true)),
285 ((std::get<Is>(
collPts.second) = std::get<index>(collPts_).template boundary<Is>().greville()),
291 ((std::get<Is>(
collPts.first) =
292 std::get<index>(collPts_).template space<Is>().clone().uniform_refine().greville(
297 ((std::get<Is>(
collPts.second) =
298 std::get<index>(collPts_).template boundary<Is>().clone().uniform_refine().greville()),
304 ((std::get<Is>(
collPts.first) =
305 std::get<index>(collPts_).template space<Is>().clone().uniform_refine().greville(
310 ((std::get<Is>(
collPts.second) =
311 std::get<index>(collPts_).template boundary<Is>().clone().uniform_refine().greville()),
317 ((std::get<Is>(
collPts.first) =
318 std::get<index>(collPts_).template space<Is>().clone().uniform_refine(2, -1).greville(
323 ((std::get<Is>(
collPts.second) = std::get<index>(collPts_).template boundary<Is>()
325 .uniform_refine(2, -1)
332 ((std::get<Is>(
collPts.first) =
333 std::get<index>(collPts_).template space<Is>().clone().uniform_refine(2, -1).greville(
338 ((std::get<Is>(
collPts.second) = std::get<index>(collPts_).template boundary<Is>()
340 .uniform_refine(2, -1)
346 throw std::runtime_error(
"Invalid collocation point specifier");
359 template<std::
size_t index>
360 std::tuple_element_t<index, collPts_type>
362 if constexpr (std::tuple_element_t<index, inputs_type>::nspaces() == 1)
367 return {std::get<index>(collPts_).space().greville(
false),
368 std::get<index>(collPts_).boundary().greville()};
371 return {std::get<index>(collPts_).space().greville(
true),
372 std::get<index>(collPts_).boundary().greville()};
376 std::get<index>(collPts_).space().clone().uniform_refine().greville(
false),
377 std::get<index>(collPts_).boundary().clone().uniform_refine().greville()};
381 std::get<index>(collPts_).space().clone().uniform_refine().greville(
true),
382 std::get<index>(collPts_).boundary().clone().uniform_refine().greville()};
385 return {std::get<index>(collPts_).space().clone().uniform_refine(2, -1).greville(
387 std::get<index>(collPts_).boundary().clone().uniform_refine(2, -1).greville()};
390 return {std::get<index>(collPts_).space().clone().uniform_refine(2, -1).greville(
392 std::get<index>(collPts_).boundary().clone().uniform_refine(2, -1).greville()};
395 throw std::runtime_error(
"Invalid collocation point specifier");
400 collPts, std::make_index_sequence<std::tuple_element_t<index, inputs_type>::nspaces()>{});
405template <detail::HasAsTensor... Inputs,
406 detail::HasAsTensor... Outputs>
408 std::tuple<Outputs...>, void> {
412 typename std::common_type<
typename Inputs::value_type...,
typename Outputs::value_type...>::type;
418 template<std::
size_t index>
419 using input_t =
typename std::tuple_element_t<index, inputs_type>;
425 template<std::
size_t index>
426 using output_t =
typename std::tuple_element_t<index, outputs_type>;
430 std::tuple<std::pair<
typename Outputs::eval_type,
431 typename Outputs::boundary_eval_type>...>;
434 template<std::
size_t index>
435 using collPts_t =
typename std::tuple_element_t<index, collPts_type>;
446 template <
typename... Objs, std::size_t... NumCoeffs>
450 return std::make_tuple(
452 [&](
auto&&... args) {
return Objs(std::forward<
decltype(args)>(args)...,
init, options); },
461 template <
typename... Objs,
typename... NumCoeffsTuples, std::size_t... Is>
465 std::index_sequence<Is...>) {
466 static_assert(
sizeof...(Objs) ==
sizeof...(NumCoeffsTuples));
467 return std::make_tuple(
469 [&](
auto&&... args) {
return Objs(std::forward<
decltype(args)>(args)...,
init, options); },
470 std::get<Is>(numCoeffs)
475 template <
typename... Objs,
typename... NumCoeffsTuples>
479 return construct_tuple_from_tuples_impl<Objs...>(numCoeffs,
482 std::index_sequence_for<Objs...>{});
490 : inputs_(), outputs_() {}
496 template <std::
size_t NumCoeffs>
497 IgABase2(
const std::array<int64_t, NumCoeffs>& ncoeffs,
506 template <std::
size_t NumCoeffsInputs, std::
size_t NumCoeffsOutputs>
507 IgABase2(
const std::array<int64_t, NumCoeffsInputs>& ncoeffsInputs,
508 const std::array<int64_t, NumCoeffsOutputs>& ncoeffsOutputs,
519 template <std::size_t... NumCoeffs>
520 IgABase2(
const std::tuple<std::array<int64_t, NumCoeffs>...>& ncoeffs,
530 template <std::size_t... NumCoeffsInputs, std::size_t... NumCoeffsOutputs>
531 IgABase2(
const std::tuple<std::array<int64_t, NumCoeffsInputs>...>& ncoeffsInputs,
532 const std::tuple<std::array<int64_t, NumCoeffsOutputs>...>& ncoeffsOutputs,
535 : inputs_(construct_tuple_from_arrays<Inputs...>(ncoeffsInputs,
init, options)),
536 outputs_(construct_tuple_from_arrays<Outputs...>(ncoeffsOutputs,
init, options))
543 template<
typename... CoeffsInputs,
typename... CoeffsOutputs>
544 IgABase2(
const std::tuple<CoeffsInputs...>& coeffsInputs,
545 const std::tuple<CoeffsOutputs...>& coeffsOutputs,
548 : inputs_(construct_tuple_from_tuples<Inputs...>(coeffsInputs,
init, options)),
549 outputs_(construct_tuple_from_tuples<Outputs...>(coeffsOutputs,
init, options))
553 inline constexpr const auto &
inputs()
const {
563 template <std::
size_t index>
564 inline constexpr const auto &
input()
const {
565 static_assert(index >= 0 && index <
sizeof...(Inputs));
566 return std::get<index>(inputs_);
570 template <std::
size_t index>
572 static_assert(index >= 0 && index <
sizeof...(Inputs));
573 return std::get<index>(inputs_);
577 inline constexpr const auto &
outputs()
const {
587 template <std::
size_t index>
588 inline constexpr const auto &
output()
const {
589 static_assert(index >= 0 && index <
sizeof...(Outputs));
590 return std::get<index>(outputs_);
594 template <std::
size_t index>
596 static_assert(index >= 0 && index <
sizeof...(Outputs));
597 return std::get<index>(outputs_);
601 inline constexpr const auto &
collPts()
const {
617 template <std::size_t index, std::size_t... Is>
618 std::tuple_element_t<index, collPts_type>
620 std::tuple_element_t<index, collPts_type>
collPts;
622 switch (collPtsType) {
626 ((std::get<Is>(
collPts.first) =
627 std::get<index>(outputs_).template space<Is>().greville(
false)),
631 ((std::get<Is>(
collPts.second) = std::get<index>(outputs_).template boundary<Is>().greville()),
637 ((std::get<Is>(
collPts.first) =
638 std::get<index>(outputs_).template space<Is>().greville(
true)),
642 ((std::get<Is>(
collPts.second) = std::get<index>(outputs_).template boundary<Is>().greville()),
648 ((std::get<Is>(
collPts.first) =
649 std::get<index>(outputs_).template space<Is>().clone().uniform_refine().greville(
654 ((std::get<Is>(
collPts.second) =
655 std::get<index>(outputs_).template boundary<Is>().clone().uniform_refine().greville()),
661 ((std::get<Is>(
collPts.first) =
662 std::get<index>(outputs_).template space<Is>().clone().uniform_refine().greville(
667 ((std::get<Is>(
collPts.second) =
668 std::get<index>(outputs_).template boundary<Is>().clone().uniform_refine().greville()),
674 ((std::get<Is>(
collPts.first) =
675 std::get<index>(outputs_).template space<Is>().clone().uniform_refine(2, -1).greville(
680 ((std::get<Is>(
collPts.second) = std::get<index>(outputs_).template boundary<Is>()
682 .uniform_refine(2, -1)
689 ((std::get<Is>(
collPts.first) =
690 std::get<index>(outputs_).template space<Is>().clone().uniform_refine(2, -1).greville(
695 ((std::get<Is>(
collPts.second) = std::get<index>(outputs_).template boundary<Is>()
697 .uniform_refine(2, -1)
703 throw std::runtime_error(
"Invalid collocation point specifier");
716 template<std::
size_t index>
717 std::tuple_element_t<index, collPts_type>
719 if constexpr (std::tuple_element_t<index, outputs_type>::nspaces() == 1)
724 return {std::get<index>(outputs_).space().greville(
false),
725 std::get<index>(outputs_).boundary().greville()};
728 return {std::get<index>(outputs_).space().greville(
true),
729 std::get<index>(outputs_).boundary().greville()};
733 std::get<index>(outputs_).space().clone().uniform_refine().greville(
false),
734 std::get<index>(outputs_).boundary().clone().uniform_refine().greville()};
738 std::get<index>(outputs_).space().clone().uniform_refine().greville(
true),
739 std::get<index>(outputs_).boundary().clone().uniform_refine().greville()};
742 return {std::get<index>(outputs_).space().clone().uniform_refine(2, -1).greville(
744 std::get<index>(outputs_).boundary().clone().uniform_refine(2, -1).greville()};
747 return {std::get<index>(outputs_).space().clone().uniform_refine(2, -1).greville(
749 std::get<index>(outputs_).boundary().clone().uniform_refine(2, -1).greville()};
752 throw std::runtime_error(
"Invalid collocation point specifier");
757 collPts, std::make_index_sequence<std::tuple_element_t<index, outputs_type>::nspaces()>{});
773 template <
typename GeometryMap,
typename Variable>
774 requires FunctionSpaceType<GeometryMap> && FunctionSpaceType<Variable>
779 typename std::common_type<
typename GeometryMap::value_type,
780 typename Variable::value_type>::type;
790 std::pair<
typename GeometryMap::eval_type,
791 typename GeometryMap::boundary_eval_type>;
795 std::pair<
typename Variable::eval_type,
796 typename Variable::boundary_eval_type>;
817 template <std::size_t... GeometryMapNumCoeffs, std::size_t... Is,
818 std::size_t... VariableNumCoeffs, std::size_t... Js>
820 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
821 geometryMapNumCoeffs,
822 std::index_sequence<Is...>,
823 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
824 std::index_sequence<Js...>,
839 template <std::
size_t NumCoeffs>
841 std::array<int64_t, NumCoeffs> numCoeffs,
845 template <std::size_t... NumCoeffs>
847 std::tuple<std::array<int64_t, NumCoeffs>...> numCoeffs,
855 template <std::
size_t GeometryMapNumCoeffs, std::
size_t VariableNumCoeffs>
857 std::array<int64_t, GeometryMapNumCoeffs> geometryMapNumCoeffs,
858 std::array<int64_t, VariableNumCoeffs> variableNumCoeffs,
861 std::tuple{variableNumCoeffs}, options) {}
863 template <std::size_t... GeometryMapNumCoeffs,
864 std::size_t... VariableNumCoeffs>
866 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
867 geometryMapNumCoeffs,
868 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
871 geometryMapNumCoeffs,
872 std::make_index_sequence<sizeof...(GeometryMapNumCoeffs)>{},
874 std::make_index_sequence<
sizeof...(VariableNumCoeffs)>{}, options) {
880 inline const GeometryMap &
G()
const {
return G_; }
884 inline GeometryMap &
G() {
return G_; }
888 inline const Variable &
u()
const {
return u_; }
892 inline Variable &
u() {
return u_; }
901 template <std::size_t... Is>
906 switch (collPtsType) {
910 ((std::get<Is>(
collPts.first) =
911 G_.template space<Is>().greville(
false)),
915 ((std::get<Is>(
collPts.second) =
G_.template boundary<Is>().greville()),
921 ((std::get<Is>(
collPts.first) =
922 G_.template space<Is>().greville(
true)),
926 ((std::get<Is>(
collPts.second) =
G_.template boundary<Is>().greville()),
932 ((std::get<Is>(
collPts.first) =
933 G_.template space<Is>().clone().uniform_refine().greville(
938 ((std::get<Is>(
collPts.second) =
939 G_.template boundary<Is>().clone().uniform_refine().greville()),
945 ((std::get<Is>(
collPts.first) =
946 G_.template space<Is>().clone().uniform_refine().greville(
951 ((std::get<Is>(
collPts.second) =
952 G_.template boundary<Is>().clone().uniform_refine().greville()),
958 ((std::get<Is>(
collPts.first) =
959 G_.template space<Is>().clone().uniform_refine(2, -1).greville(
964 ((std::get<Is>(
collPts.second) =
G_.template boundary<Is>()
966 .uniform_refine(2, -1)
973 ((std::get<Is>(
collPts.first) =
974 G_.template space<Is>().clone().uniform_refine(2, -1).greville(
979 ((std::get<Is>(
collPts.second) =
G_.template boundary<Is>()
981 .uniform_refine(2, -1)
987 throw std::runtime_error(
"Invalid collocation point specifier");
999 template <std::size_t... Is>
1001 std::index_sequence<Is...>)
const {
1004 switch (collPtsType) {
1008 ((std::get<Is>(
collPts.first) =
1009 u_.template space<Is>().greville(
false)),
1013 ((std::get<Is>(
collPts.second) =
u_.template boundary<Is>().greville()),
1019 ((std::get<Is>(
collPts.first) =
1020 u_.template space<Is>().greville(
true)),
1024 ((std::get<Is>(
collPts.second) =
u_.template boundary<Is>().greville()),
1030 ((std::get<Is>(
collPts.first) =
1031 u_.template space<Is>().clone().uniform_refine().greville(
1036 ((std::get<Is>(
collPts.second) =
1037 u_.template boundary<Is>().clone().uniform_refine().greville()),
1043 ((std::get<Is>(
collPts.first) =
1044 u_.template space<Is>().clone().uniform_refine().greville(
1049 ((std::get<Is>(
collPts.second) =
1050 u_.template boundary<Is>().clone().uniform_refine().greville()),
1056 ((std::get<Is>(
collPts.first) =
1057 u_.template space<Is>().clone().uniform_refine(2, -1).greville(
1062 ((std::get<Is>(
collPts.second) =
u_.template boundary<Is>()
1064 .uniform_refine(2, -1)
1071 ((std::get<Is>(
collPts.first) =
1072 u_.template space<Is>().clone().uniform_refine(2, -1).greville(
1077 ((std::get<Is>(
collPts.second) =
u_.template boundary<Is>()
1079 .uniform_refine(2, -1)
1085 throw std::runtime_error(
"Invalid collocation point specifier");
1100 if constexpr (GeometryMap::nspaces() == 1)
1105 return {
G_.space().greville(
false),
1106 G_.boundary().greville()};
1109 return {
G_.space().greville(
true),
1110 G_.boundary().greville()};
1114 G_.space().clone().uniform_refine().greville(
false),
1115 G_.boundary().clone().uniform_refine().greville()};
1119 G_.space().clone().uniform_refine().greville(
true),
1120 G_.boundary().clone().uniform_refine().greville()};
1123 return {
G_.space().clone().uniform_refine(2, -1).greville(
1125 G_.boundary().clone().uniform_refine(2, -1).greville()};
1128 return {
G_.space().clone().uniform_refine(2, -1).greville(
1130 G_.boundary().clone().uniform_refine(2, -1).greville()};
1133 throw std::runtime_error(
"Invalid collocation point specifier");
1138 collPts, std::make_index_sequence<GeometryMap::nspaces()>{});
1148 if constexpr (Variable::nspaces() == 1)
1153 return {
u_.space().greville(
false),
1154 u_.boundary().greville()};
1157 return {
u_.space().greville(
true),
1158 u_.boundary().greville()};
1162 u_.space().clone().uniform_refine().greville(
false),
1163 u_.boundary().clone().uniform_refine().greville()};
1167 u_.space().clone().uniform_refine().greville(
true),
1168 u_.boundary().clone().uniform_refine().greville()};
1171 return {
u_.space().clone().uniform_refine(2, -1).greville(
1173 u_.boundary().clone().uniform_refine(2, -1).greville()};
1176 return {
u_.space().clone().uniform_refine(2, -1).greville(
1178 u_.boundary().clone().uniform_refine(2, -1).greville()};
1181 throw std::runtime_error(
"Invalid collocation point specifier");
1186 std::make_index_sequence<Variable::nspaces()>{});
1193 template <
typename GeometryMap,
typename Variable>
1194 requires FunctionSpaceType<GeometryMap> && FunctionSpaceType<Variable>
1231 template <std::size_t... GeometryMapNumCoeffs, std::size_t... Is,
1232 std::size_t... VariableNumCoeffs, std::size_t... Js>
1234 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
1235 geometryMapNumCoeffs,
1236 std::index_sequence<Is...>,
1237 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
1238 std::index_sequence<Js...>,
1241 Base(geometryMapNumCoeffs, variableNumCoeffs, options),
1253 template <std::
size_t NumCoeffs>
1256 :
IgABase(
std::tuple{numCoeffs},
std::tuple{numCoeffs}, options) {}
1258 template <std::size_t... NumCoeffs>
1259 IgABase(std::tuple<std::array<int64_t, NumCoeffs>...> numCoeffs,
1261 :
IgABase(numCoeffs, numCoeffs, options) {}
1267 template <std::
size_t GeometryMapNumCoeffs, std::
size_t VariableNumCoeffs>
1268 IgABase(std::array<int64_t, GeometryMapNumCoeffs> geometryMapNumCoeffs,
1269 std::array<int64_t, VariableNumCoeffs> variableNumCoeffs,
1271 :
IgABase(
std::tuple{geometryMapNumCoeffs},
std::tuple{variableNumCoeffs},
1274 template <std::size_t... GeometryMapNumCoeffs,
1275 std::size_t... VariableNumCoeffs>
1277 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
1278 geometryMapNumCoeffs,
1279 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
1281 :
IgABase(geometryMapNumCoeffs,
1282 std::make_index_sequence<sizeof...(GeometryMapNumCoeffs)>{},
1284 std::make_index_sequence<
sizeof...(VariableNumCoeffs)>{},
1290 inline const Variable &
f()
const {
return f_; }
1294 inline Variable &
f() {
return f_; }
1304 template <
typename T>
1306 std::vector<torch::Tensor> &v) {
1308 std::filesystem::path path(location);
1310 if (std::filesystem::exists(path)) {
1311 if (std::filesystem::is_regular_file(path)) {
1313 pugi::xml_document doc;
1314 doc.load_file(path.c_str());
1315 v.emplace_back(obj.from_xml(doc).as_tensor());
1318 }
else if (std::filesystem::is_directory(path)) {
1319 for (
const auto &file : std::filesystem::directory_iterator(path)) {
1320 if (file.is_regular_file() && file.path().extension() ==
".xml") {
1322 pugi::xml_document doc;
1323 doc.load_file(file.path().c_str());
1324 v.emplace_back(obj.from_xml(doc).as_tensor());
1330 throw std::runtime_error(
1331 "The path refers to neither a file nor a directory");
1333 throw std::runtime_error(
"The path does not exist");
1347 public torch::data::Dataset<
1349 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>> {
1352 std::vector<torch::Tensor>
G_;
1355 std::vector<torch::Tensor>
f_;
1360 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>;
1365 read_from_xml(location, obj, G_);
1369 read_from_xml(location, obj, G_);
1375 template <
typename T>
1377 std::string label =
"") {
1378 G_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1381 template <
typename T>
1383 std::string label =
"") {
1384 G_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1390 template <
typename T>
1392 std::string label =
"") {
1393 G_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1396 template <
typename T>
1398 std::string label =
"") {
1399 G_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1406 read_from_xml(location, obj, f_);
1410 read_from_xml(location, obj, f_);
1416 template <
typename T>
1418 std::string label =
"") {
1419 f_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1422 template <
typename T>
1424 std::string label =
"") {
1425 f_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1431 template <
typename T>
1433 std::string label =
"") {
1434 f_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1437 template <
typename T>
1439 std::string label =
"") {
1440 f_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1446 template <
typename T,
typename Func>
1448 f_.emplace_back(obj.transform(
func).as_tensor());
1451 template <
typename T,
typename Func>
1453 f_.emplace_back(obj.transform(
func).as_tensor());
1460 std::size_t geo_index = index / (f_.empty() ? 1 : f_.size());
1461 std::size_t ref_index = index - geo_index * f_.size();
1465 return torch::cat({G_.at(geo_index), f_.at(ref_index)});
1467 return G_.at(geo_index);
1470 return f_.at(ref_index);
1472 throw std::runtime_error(
"No geometry maps and reference data");
1477 inline torch::optional<std::size_t>
size()
const override {
1478 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
1485 public torch::data::Dataset<IgADataset<true>, torch::data::Example<>> {
1488 std::vector<torch::Tensor>
G_;
1491 std::vector<torch::Tensor>
f_;
1494 std::vector<torch::Tensor>
u_;
1500 read_from_xml(location, obj, G_);
1504 read_from_xml(location, obj, G_);
1510 template <
typename T>
1512 std::string label =
"") {
1513 G_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1516 template <
typename T>
1518 std::string label =
"") {
1519 G_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1525 template <
typename T>
1527 std::string label =
"") {
1528 G_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1531 template <
typename T>
1533 std::string label =
"") {
1534 G_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1541 read_from_xml(location, obj, f_);
1545 read_from_xml(location, obj, f_);
1551 template <
typename T>
1553 std::string label =
"") {
1554 f_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1557 template <
typename T>
1559 std::string label =
"") {
1560 f_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1566 template <
typename T>
1568 std::string label =
"") {
1569 f_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1572 template <
typename T>
1574 std::string label =
"") {
1575 f_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1581 template <
typename T,
typename Func>
1583 f_.emplace_back(obj.transform(
func).as_tensor());
1586 template <
typename T,
typename Func>
1588 f_.emplace_back(obj.transform(
func).as_tensor());
1595 read_from_xml(location, obj, u_);
1599 read_from_xml(location, obj, u_);
1605 template <
typename T>
1607 std::string label =
"") {
1608 u_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1611 template <
typename T>
1613 std::string label =
"") {
1614 u_.emplace_back(obj.from_xml(doc.child(
"xml"),
id, label).as_tensor());
1620 template <
typename T>
1622 std::string label =
"") {
1623 u_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1626 template <
typename T>
1628 std::string label =
"") {
1629 u_.emplace_back(obj.from_xml(root,
id, label).as_tensor());
1634 inline torch::data::Example<>
get(std::size_t index)
override {
1636 std::size_t geo_index = index / (f_.empty() ? 1 : f_.size());
1637 std::size_t ref_index = index - geo_index * f_.size();
1641 return {torch::cat({G_.at(geo_index), f_.at(ref_index)}), u_.at(index)};
1643 return {G_.at(geo_index), u_.at(index)};
1646 return {f_.at(ref_index), u_.at(index)};
1648 throw std::runtime_error(
"No geometry maps and reference data");
1653 inline torch::optional<std::size_t>
size()
const override {
1654 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
namespace detail
Definition igabase.hpp:47
IgA base class.
Definition igabase.hpp:1195
Variable f_
Spline representation of the reference data.
Definition igabase.hpp:1226
const Variable & f() const
Returns a constant reference to the spline representation of the reference data.
Definition igabase.hpp:1290
IgABase(std::tuple< std::array< int64_t, GeometryMapNumCoeffs >... > geometryMapNumCoeffs, std::tuple< std::array< int64_t, VariableNumCoeffs >... > variableNumCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for geometry map and variables)
Definition igabase.hpp:1276
IgABase(std::array< int64_t, GeometryMapNumCoeffs > geometryMapNumCoeffs, std::array< int64_t, VariableNumCoeffs > variableNumCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for geometry map and variables)
Definition igabase.hpp:1268
IgABase(std::array< int64_t, NumCoeffs > numCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:1254
IgABaseNoRefData< GeometryMap, Variable > Base
Base type.
Definition igabase.hpp:1198
Variable & f()
Returns a non-constant reference to the spline representation of the reference data.
Definition igabase.hpp:1294
Variable variable_type
Type of the variable function space(s)
Definition igabase.hpp:1207
typename Base::value_type value_type
Value type.
Definition igabase.hpp:1201
IgABase(std::tuple< std::array< int64_t, GeometryMapNumCoeffs >... > geometryMapNumCoeffs, std::index_sequence< Is... >, std::tuple< std::array< int64_t, VariableNumCoeffs >... > variableNumCoeffs, std::index_sequence< Js... >, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for Geometry and Variable types)
Definition igabase.hpp:1233
typename Base::variable_collPts_type variable_collPts_type
Type of the variable collocation points.
Definition igabase.hpp:1213
IgABase(iganet::Options< value_type > options=iganet::Options< value_type >{})
Default constructor.
Definition igabase.hpp:1246
GeometryMap geometryMap_type
Type of the geometry map function space(s)
Definition igabase.hpp:1204
IgABase(std::tuple< std::array< int64_t, NumCoeffs >... > numCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:1259
static bool constexpr has_GeometryMap
Indicates whether this class provides a geometry map.
Definition igabase.hpp:1216
typename Base::geometryMap_collPts_type geometryMap_collPts_type
Type of the geometry map collocation points.
Definition igabase.hpp:1210
static bool constexpr has_Solution
Indicates whether this class provides a solution.
Definition igabase.hpp:1222
static bool constexpr has_RefData
Indicates whether this class provides a reference solution.
Definition igabase.hpp:1219
IgA base class (no reference data)
Definition igabase.hpp:775
variable_collPts_type variable_collPts(enum collPts collPtsType, std::index_sequence< Is... >) const
Returns the variable collocation points.
Definition igabase.hpp:1000
virtual variable_collPts_type variable_collPts(enum collPts collPts) const
Returns the variable collocation points.
Definition igabase.hpp:1147
IgABaseNoRefData(std::tuple< std::array< int64_t, GeometryMapNumCoeffs >... > geometryMapNumCoeffs, std::tuple< std::array< int64_t, VariableNumCoeffs >... > variableNumCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for geometry map and variables)
Definition igabase.hpp:865
virtual geometryMap_collPts_type geometryMap_collPts(enum collPts collPts) const
Returns the geometry map collocation points.
Definition igabase.hpp:1099
GeometryMap geometryMap_type
Type of the geometry map function space(s)
Definition igabase.hpp:783
typename std::common_type< typename GeometryMap::value_type, typename Variable::value_type >::type value_type
Value type.
Definition igabase.hpp:780
std::pair< typename Variable::eval_type, typename Variable::boundary_eval_type > variable_collPts_type
Type of the variable collocation points.
Definition igabase.hpp:796
const Variable & u() const
Returns a constant reference to the spline representation of the solution.
Definition igabase.hpp:888
IgABaseNoRefData(std::array< int64_t, GeometryMapNumCoeffs > geometryMapNumCoeffs, std::array< int64_t, VariableNumCoeffs > variableNumCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for geometry map and variables)
Definition igabase.hpp:856
IgABaseNoRefData(std::tuple< std::array< int64_t, NumCoeffs >... > numCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:846
Variable variable_type
Type of the variable function space(s)
Definition igabase.hpp:786
IgABaseNoRefData(iganet::Options< value_type > options=iganet::Options< value_type >{})
Default constructor.
Definition igabase.hpp:832
static bool constexpr has_GeometryMap
Indicates whether this class provides a geometry map.
Definition igabase.hpp:799
static bool constexpr has_RefData
Indicates whether this class provides reference data.
Definition igabase.hpp:802
geometryMap_collPts_type geometryMap_collPts(enum collPts collPtsType, std::index_sequence< Is... >) const
Returns the geometry map collocation points.
Definition igabase.hpp:903
GeometryMap G_
Spline representation of the geometry map.
Definition igabase.hpp:809
IgABaseNoRefData(std::tuple< std::array< int64_t, GeometryMapNumCoeffs >... > geometryMapNumCoeffs, std::index_sequence< Is... >, std::tuple< std::array< int64_t, VariableNumCoeffs >... > variableNumCoeffs, std::index_sequence< Js... >, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for Geometry and Variable types)
Definition igabase.hpp:819
Variable u_
Spline representation of the solution.
Definition igabase.hpp:812
IgABaseNoRefData(std::array< int64_t, NumCoeffs > numCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:840
static bool constexpr has_Solution
Indicates whether this class provides a solution.
Definition igabase.hpp:805
GeometryMap & G()
Returns a non-constant reference to the spline representation of the geometry map.
Definition igabase.hpp:884
Variable & u()
Returns a non-constant reference to the spline representation of the solution.
Definition igabase.hpp:892
std::pair< typename GeometryMap::eval_type, typename GeometryMap::boundary_eval_type > geometryMap_collPts_type
Type of the geometry map collocation points.
Definition igabase.hpp:791
const GeometryMap & G() const
Returns a constant reference to the spline representation of the geometry map.
Definition igabase.hpp:880
void add_referenceData(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a reference data set from XML node.
Definition igabase.hpp:1438
void add_referenceData(T &&obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:1409
void add_referenceData(T &obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:1447
void add_referenceData(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a reference data set from XML node.
Definition igabase.hpp:1432
std::vector< torch::Tensor > G_
Vector of tensors representing the geometry maps.
Definition igabase.hpp:1352
std::vector< torch::Tensor > f_
Vector of tensors representing the reference data.
Definition igabase.hpp:1355
void add_referenceData(T &obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:1405
void add_geometryMap(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a geometry map from XML node.
Definition igabase.hpp:1397
void add_geometryMap(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a geometry map from XML object.
Definition igabase.hpp:1376
void add_geometryMap(T &&obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:1368
void add_referenceData(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a reference data set from XML object.
Definition igabase.hpp:1423
void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a geometry map from XML object.
Definition igabase.hpp:1382
torch::data::Example< torch::Tensor, torch::data::example::NoTarget > example_type
Example type.
Definition igabase.hpp:1360
void add_geometryMap(T &obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:1364
void add_referenceData(T &&obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:1452
example_type get(std::size_t index) override
Returns the data set at location index.
Definition igabase.hpp:1458
torch::optional< std::size_t > size() const override
Definition igabase.hpp:1477
void add_referenceData(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a reference data set from XML object.
Definition igabase.hpp:1417
void add_geometryMap(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a geometry map from XML node.
Definition igabase.hpp:1391
torch::optional< std::size_t > size() const override
Definition igabase.hpp:1653
std::vector< torch::Tensor > G_
Vector of tensors representing the geometry maps.
Definition igabase.hpp:1488
void add_geometryMap(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a geometry map from XML node.
Definition igabase.hpp:1532
void add_geometryMap(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a geometry map from XML object.
Definition igabase.hpp:1511
void add_referenceData(T &obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:1582
void add_referenceData(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a reference data set from XML object.
Definition igabase.hpp:1558
void add_solution(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a solution from XML object.
Definition igabase.hpp:1606
std::vector< torch::Tensor > f_
Vector of tensors representing the reference data.
Definition igabase.hpp:1491
void add_referenceData(T &&obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:1587
void add_geometryMap(T &&obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:1503
void add_referenceData(T &&obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:1544
void add_solution(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a solution from XML object.
Definition igabase.hpp:1612
torch::data::Example get(std::size_t index) override
Returns the data set at location index.
Definition igabase.hpp:1634
void add_referenceData(T &obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:1540
void add_referenceData(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a reference data set from XML node.
Definition igabase.hpp:1573
void add_solution(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a solution from XML node.
Definition igabase.hpp:1627
void add_referenceData(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a reference data set from XML object.
Definition igabase.hpp:1552
void add_solution(T &obj, std::string location)
Adds a solution from file.
Definition igabase.hpp:1594
void add_solution(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a solution from XML node.
Definition igabase.hpp:1621
void add_solution(T &&obj, std::string location)
Adds a solution from file.
Definition igabase.hpp:1598
std::vector< torch::Tensor > u_
Vector of tensors representing the solution data.
Definition igabase.hpp:1494
void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a geometry map from XML object.
Definition igabase.hpp:1517
void add_referenceData(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a reference data set from XML node.
Definition igabase.hpp:1567
void add_geometryMap(T &obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:1499
void add_geometryMap(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a geometry map from XML node.
Definition igabase.hpp:1526
IgA dataset base class.
Definition igabase.hpp:1301
void read_from_xml(std::string location, T &obj, std::vector< torch::Tensor > &v)
Reads a function space from file.
Definition igabase.hpp:1305
The Options class handles the automated determination of dtype from the template argument and the sel...
Definition options.hpp:107
Definition igabase.hpp:37
Definition boundary.hpp:22
collPts
Enumerator for the collocation point specifier.
Definition igabase.hpp:24
init
Enumerator for specifying the initialization of B-spline coefficients.
Definition bspline.hpp:55
short int short_t
Definition core.hpp:74
IgA dataset class.
Definition igabase.hpp:1342