IgANet
IgANets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
igabase.hpp
Go to the documentation of this file.
1
15#pragma once
16
17#include <utils/tuple.hpp>
18
19#include <filesystem>
20
21namespace iganet {
22
24enum class collPts : short_t {
25 greville = 0,
27 greville_ref1 = 2,
29 3,
30 greville_ref2 = 4,
32 5,
33};
34
35namespace detail {
36 template <typename T>
37 concept HasAsTensor = requires(T a) {
38 { a.as_tensor() };
39 };
40}
41
46template <typename, typename, typename = void>
48
49template <detail::HasAsTensor... Inputs,
50 detail::HasAsTensor... Outputs,
51 detail::HasAsTensor... CollPts>
52class IgABase2<std::tuple<Inputs...>,
53 std::tuple<Outputs...>,
54 std::tuple<CollPts...>> {
55public:
57 using value_type =
58 typename std::common_type<typename Inputs::value_type..., typename Outputs::value_type...>::type;
59
61 using inputs_type = std::tuple<Inputs...>;
62
64 using outputs_type = std::tuple<Outputs...>;
65
68 std::tuple<std::pair<typename CollPts::eval_type,
69 typename CollPts::boundary_eval_type>...>;
70
71protected:
74
77
80
81private:
83 template <typename... Objs, std::size_t... NumCoeffs>
84 auto construct_tuple_from_arrays(const std::tuple<std::array<int64_t, NumCoeffs>...>& numCoeffs,
85 enum init init,
87 return std::make_tuple(
88 std::apply(
89 [&](auto&&... args) { return Objs(std::forward<decltype(args)>(args)..., init, options); },
90 numCoeffs
91 )...
92 );
93 }
94
98 template <typename... Objs, typename... NumCoeffsTuples, std::size_t... Is>
99 auto construct_tuple_from_arrays_impl(const std::tuple<NumCoeffsTuples...>& numCoeffs,
100 enum init init,
102 std::index_sequence<Is...>) {
103 static_assert(sizeof...(Objs) == sizeof...(NumCoeffsTuples));
104 return std::make_tuple(
105 std::apply(
106 [&](auto&&... args) { return Objs(std::forward<decltype(args)>(args)..., init, options); },
107 std::get<Is>(numCoeffs)
108 )...
109 );
110 }
111
112 template <typename... Objs, typename... NumCoeffsTuples>
113 auto construct_tuple_from_tuples(const std::tuple<NumCoeffsTuples...>& numCoeffs,
114 enum init init,
116 return construct_tuple_from_tuples_impl<Objs...>(numCoeffs,
117 init,
118 options,
119 std::index_sequence_for<Objs...>{});
120 }
122
123public:
125 explicit IgABase2(
127 : inputs_(), outputs_(), collPts_() {}
128
133 template <std::size_t NumCoeffs>
134 IgABase2(const std::array<int64_t, NumCoeffs>& ncoeffs,
135 enum init init = init::greville,
137 : IgABase2(std::tuple{ncoeffs}, std::tuple{ncoeffs}, std::tuple{ncoeffs}, init, options) {}
138
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,
147 enum init init = init::greville,
149 : IgABase2(std::tuple{ncoeffsInputs}, std::tuple{ncoeffsOutputs},
150 std::tuple{ncoeffsCollPts}, init, options) {}
151
157 template <std::size_t... NumCoeffs>
158 IgABase2(const std::tuple<std::array<int64_t, NumCoeffs>...>& ncoeffs,
159 enum init init = init::greville,
161 : IgABase2(ncoeffs, ncoeffs, ncoeffs, init, options)
162 {}
163
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,
172 enum init init = init::greville,
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))
177 {}
178
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,
188 enum init init = init::greville,
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))
193 {}
194
196 inline constexpr const auto &inputs() const {
197 return inputs_;
198 }
199
201 inline constexpr auto &inputs() {
202 return inputs_;
203 }
204
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_);
210 }
211
213 template <std::size_t index>
214 inline constexpr auto &input() {
215 static_assert(index >= 0 && index < sizeof...(Inputs));
216 return std::get<index>(inputs_);
217 }
218
220 inline constexpr const auto &outputs() const {
221 return outputs_;
222 }
223
225 inline constexpr auto &outputs() {
226 return outputs_;
227 }
228
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_);
234 }
235
237 template <std::size_t index>
238 inline constexpr auto &output() {
239 static_assert(index >= 0 && index < sizeof...(Outputs));
240 return std::get<index>(outputs_);
241 }
242
244 inline constexpr const auto &collPts() const {
245 return collPts_;
246 }
247
249 inline constexpr auto &collPts() {
250 return collPts_;
251 }
252
253private:
260 template <std::size_t index, std::size_t... Is>
261 std::tuple_element_t<index, collPts_type>
262 collPts(enum collPts collPtsType, std::index_sequence<Is...>) const {
263 std::tuple_element_t<index, collPts_type> collPts;
264
265 switch (collPtsType) {
266
268 // Get Greville abscissae inside the domain and at the boundary
269 ((std::get<Is>(collPts.first) =
270 std::get<index>(collPts_).template space<Is>().greville(/* interior */ false)),
271 ...);
272
273 // Get Greville abscissae at the domain
274 ((std::get<Is>(collPts.second) = std::get<index>(collPts_).template boundary<Is>().greville()),
275 ...);
276 break;
277
279 // Get Greville abscissae inside the domain
280 ((std::get<Is>(collPts.first) =
281 std::get<index>(collPts_).template space<Is>().greville(/* interior */ true)),
282 ...);
283
284 // Get Greville abscissae at the domain
285 ((std::get<Is>(collPts.second) = std::get<index>(collPts_).template boundary<Is>().greville()),
286 ...);
287 break;
288
290 // Get Greville abscissae inside the domain and at the boundary
291 ((std::get<Is>(collPts.first) =
292 std::get<index>(collPts_).template space<Is>().clone().uniform_refine().greville(
293 /* interior */ false)),
294 ...);
295
296 // Get Greville abscissae at the domain
297 ((std::get<Is>(collPts.second) =
298 std::get<index>(collPts_).template boundary<Is>().clone().uniform_refine().greville()),
299 ...);
300 break;
301
303 // Get Greville abscissae inside the domain
304 ((std::get<Is>(collPts.first) =
305 std::get<index>(collPts_).template space<Is>().clone().uniform_refine().greville(
306 /* interior */ true)),
307 ...);
308
309 // Get Greville abscissae at the domain
310 ((std::get<Is>(collPts.second) =
311 std::get<index>(collPts_).template boundary<Is>().clone().uniform_refine().greville()),
312 ...);
313 break;
314
316 // Get Greville abscissae inside the domain and at the boundary
317 ((std::get<Is>(collPts.first) =
318 std::get<index>(collPts_).template space<Is>().clone().uniform_refine(2, -1).greville(
319 /* interior */ false)),
320 ...);
321
322 // Get Greville abscissae at the domain
323 ((std::get<Is>(collPts.second) = std::get<index>(collPts_).template boundary<Is>()
324 .clone()
325 .uniform_refine(2, -1)
326 .greville()),
327 ...);
328 break;
329
331 // Get Greville abscissae inside the domain
332 ((std::get<Is>(collPts.first) =
333 std::get<index>(collPts_).template space<Is>().clone().uniform_refine(2, -1).greville(
334 /* interior */ true)),
335 ...);
336
337 // Get Greville abscissae at the domain
338 ((std::get<Is>(collPts.second) = std::get<index>(collPts_).template boundary<Is>()
339 .clone()
340 .uniform_refine(2, -1)
341 .greville()),
342 ...);
343 break;
344
345 default:
346 throw std::runtime_error("Invalid collocation point specifier");
347 }
348
349 return collPts;
350 }
351
352public:
359 template<std::size_t index>
360 std::tuple_element_t<index, collPts_type>
361 collPts(enum collPts collPts) const {
362 if constexpr (std::tuple_element_t<index, inputs_type>::nspaces() == 1)
363
364 switch (collPts) {
365
367 return {std::get<index>(collPts_).space().greville(/* interior */ false),
368 std::get<index>(collPts_).boundary().greville()};
369
371 return {std::get<index>(collPts_).space().greville(/* interior */ true),
372 std::get<index>(collPts_).boundary().greville()};
373
375 return {
376 std::get<index>(collPts_).space().clone().uniform_refine().greville(/* interior */ false),
377 std::get<index>(collPts_).boundary().clone().uniform_refine().greville()};
378
380 return {
381 std::get<index>(collPts_).space().clone().uniform_refine().greville(/* interior */ true),
382 std::get<index>(collPts_).boundary().clone().uniform_refine().greville()};
383
385 return {std::get<index>(collPts_).space().clone().uniform_refine(2, -1).greville(
386 /* interior */ false),
387 std::get<index>(collPts_).boundary().clone().uniform_refine(2, -1).greville()};
388
390 return {std::get<index>(collPts_).space().clone().uniform_refine(2, -1).greville(
391 /* interior */ true),
392 std::get<index>(collPts_).boundary().clone().uniform_refine(2, -1).greville()};
393
394 default:
395 throw std::runtime_error("Invalid collocation point specifier");
396 }
397
398 else
399 return collPts(
400 collPts, std::make_index_sequence<std::tuple_element_t<index, inputs_type>::nspaces()>{});
401 }
402
403};
404
405template <detail::HasAsTensor... Inputs,
406 detail::HasAsTensor... Outputs>
407class IgABase2<std::tuple<Inputs...>,
408 std::tuple<Outputs...>, void> {
409public:
412 typename std::common_type<typename Inputs::value_type..., typename Outputs::value_type...>::type;
413
415 using inputs_type = std::tuple<Inputs...>;
416
418 template<std::size_t index>
419 using input_t = typename std::tuple_element_t<index, inputs_type>;
420
422 using outputs_type = std::tuple<Outputs...>;
423
425 template<std::size_t index>
426 using output_t = typename std::tuple_element_t<index, outputs_type>;
427
430 std::tuple<std::pair<typename Outputs::eval_type,
431 typename Outputs::boundary_eval_type>...>;
432
434 template<std::size_t index>
435 using collPts_t = typename std::tuple_element_t<index, collPts_type>;
436
437protected:
440
443
444private:
446 template <typename... Objs, std::size_t... NumCoeffs>
447 auto construct_tuple_from_arrays(const std::tuple<std::array<int64_t, NumCoeffs>...>& numCoeffs,
448 enum init init,
450 return std::make_tuple(
451 std::apply(
452 [&](auto&&... args) { return Objs(std::forward<decltype(args)>(args)..., init, options); },
453 numCoeffs
454 )...
455 );
456 }
457
461 template <typename... Objs, typename... NumCoeffsTuples, std::size_t... Is>
462 auto construct_tuple_from_arrays_impl(const std::tuple<NumCoeffsTuples...>& numCoeffs,
463 enum init init,
465 std::index_sequence<Is...>) {
466 static_assert(sizeof...(Objs) == sizeof...(NumCoeffsTuples));
467 return std::make_tuple(
468 std::apply(
469 [&](auto&&... args) { return Objs(std::forward<decltype(args)>(args)..., init, options); },
470 std::get<Is>(numCoeffs)
471 )...
472 );
473 }
474
475 template <typename... Objs, typename... NumCoeffsTuples>
476 auto construct_tuple_from_tuples(const std::tuple<NumCoeffsTuples...>& numCoeffs,
477 enum init init,
479 return construct_tuple_from_tuples_impl<Objs...>(numCoeffs,
480 init,
481 options,
482 std::index_sequence_for<Objs...>{});
483 }
485
486public:
488 explicit IgABase2(
490 : inputs_(), outputs_() {}
491
496 template <std::size_t NumCoeffs>
497 IgABase2(const std::array<int64_t, NumCoeffs>& ncoeffs,
498 enum init init = init::greville,
500 : IgABase2(std::tuple{ncoeffs}, std::tuple{ncoeffs}, init, options) {}
501
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,
509 enum init init = init::greville,
511 : IgABase2(std::tuple{ncoeffsInputs}, std::tuple{ncoeffsOutputs},
512 init, options) {}
513
519 template <std::size_t... NumCoeffs>
520 IgABase2(const std::tuple<std::array<int64_t, NumCoeffs>...>& ncoeffs,
521 enum init init = init::greville,
523 : IgABase2(ncoeffs, ncoeffs, init, options)
524 {}
525
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,
533 enum init init = init::greville,
535 : inputs_(construct_tuple_from_arrays<Inputs...>(ncoeffsInputs, init, options)),
536 outputs_(construct_tuple_from_arrays<Outputs...>(ncoeffsOutputs, init, options))
537 {}
538
543 template<typename... CoeffsInputs, typename... CoeffsOutputs>
544 IgABase2(const std::tuple<CoeffsInputs...>& coeffsInputs,
545 const std::tuple<CoeffsOutputs...>& coeffsOutputs,
546 enum init init = init::greville,
548 : inputs_(construct_tuple_from_tuples<Inputs...>(coeffsInputs, init, options)),
549 outputs_(construct_tuple_from_tuples<Outputs...>(coeffsOutputs, init, options))
550 {}
551
553 inline constexpr const auto &inputs() const {
554 return inputs_;
555 }
556
558 inline constexpr auto &inputs() {
559 return inputs_;
560 }
561
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_);
567 }
568
570 template <std::size_t index>
571 inline constexpr auto &input() {
572 static_assert(index >= 0 && index < sizeof...(Inputs));
573 return std::get<index>(inputs_);
574 }
575
577 inline constexpr const auto &outputs() const {
578 return outputs_;
579 }
580
582 inline constexpr auto &outputs() {
583 return outputs_;
584 }
585
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_);
591 }
592
594 template <std::size_t index>
595 inline constexpr auto &output() {
596 static_assert(index >= 0 && index < sizeof...(Outputs));
597 return std::get<index>(outputs_);
598 }
599
601 inline constexpr const auto &collPts() const {
602 return outputs_;
603 }
604
606 inline constexpr auto &collPts() {
607 return outputs_;
608 }
609
610private:
617 template <std::size_t index, std::size_t... Is>
618 std::tuple_element_t<index, collPts_type>
619 collPts(enum collPts collPtsType, std::index_sequence<Is...>) const {
620 std::tuple_element_t<index, collPts_type> collPts;
621
622 switch (collPtsType) {
623
625 // Get Greville abscissae inside the domain and at the boundary
626 ((std::get<Is>(collPts.first) =
627 std::get<index>(outputs_).template space<Is>().greville(/* interior */ false)),
628 ...);
629
630 // Get Greville abscissae at the domain
631 ((std::get<Is>(collPts.second) = std::get<index>(outputs_).template boundary<Is>().greville()),
632 ...);
633 break;
634
636 // Get Greville abscissae inside the domain
637 ((std::get<Is>(collPts.first) =
638 std::get<index>(outputs_).template space<Is>().greville(/* interior */ true)),
639 ...);
640
641 // Get Greville abscissae at the domain
642 ((std::get<Is>(collPts.second) = std::get<index>(outputs_).template boundary<Is>().greville()),
643 ...);
644 break;
645
647 // Get Greville abscissae inside the domain and at the boundary
648 ((std::get<Is>(collPts.first) =
649 std::get<index>(outputs_).template space<Is>().clone().uniform_refine().greville(
650 /* interior */ false)),
651 ...);
652
653 // Get Greville abscissae at the domain
654 ((std::get<Is>(collPts.second) =
655 std::get<index>(outputs_).template boundary<Is>().clone().uniform_refine().greville()),
656 ...);
657 break;
658
660 // Get Greville abscissae inside the domain
661 ((std::get<Is>(collPts.first) =
662 std::get<index>(outputs_).template space<Is>().clone().uniform_refine().greville(
663 /* interior */ true)),
664 ...);
665
666 // Get Greville abscissae at the domain
667 ((std::get<Is>(collPts.second) =
668 std::get<index>(outputs_).template boundary<Is>().clone().uniform_refine().greville()),
669 ...);
670 break;
671
673 // Get Greville abscissae inside the domain and at the boundary
674 ((std::get<Is>(collPts.first) =
675 std::get<index>(outputs_).template space<Is>().clone().uniform_refine(2, -1).greville(
676 /* interior */ false)),
677 ...);
678
679 // Get Greville abscissae at the domain
680 ((std::get<Is>(collPts.second) = std::get<index>(outputs_).template boundary<Is>()
681 .clone()
682 .uniform_refine(2, -1)
683 .greville()),
684 ...);
685 break;
686
688 // Get Greville abscissae inside the domain
689 ((std::get<Is>(collPts.first) =
690 std::get<index>(outputs_).template space<Is>().clone().uniform_refine(2, -1).greville(
691 /* interior */ true)),
692 ...);
693
694 // Get Greville abscissae at the domain
695 ((std::get<Is>(collPts.second) = std::get<index>(outputs_).template boundary<Is>()
696 .clone()
697 .uniform_refine(2, -1)
698 .greville()),
699 ...);
700 break;
701
702 default:
703 throw std::runtime_error("Invalid collocation point specifier");
704 }
705
706 return collPts;
707 }
708
709public:
716 template<std::size_t index>
717 std::tuple_element_t<index, collPts_type>
718 collPts(enum collPts collPts) const {
719 if constexpr (std::tuple_element_t<index, outputs_type>::nspaces() == 1)
720
721 switch (collPts) {
722
724 return {std::get<index>(outputs_).space().greville(/* interior */ false),
725 std::get<index>(outputs_).boundary().greville()};
726
728 return {std::get<index>(outputs_).space().greville(/* interior */ true),
729 std::get<index>(outputs_).boundary().greville()};
730
732 return {
733 std::get<index>(outputs_).space().clone().uniform_refine().greville(/* interior */ false),
734 std::get<index>(outputs_).boundary().clone().uniform_refine().greville()};
735
737 return {
738 std::get<index>(outputs_).space().clone().uniform_refine().greville(/* interior */ true),
739 std::get<index>(outputs_).boundary().clone().uniform_refine().greville()};
740
742 return {std::get<index>(outputs_).space().clone().uniform_refine(2, -1).greville(
743 /* interior */ false),
744 std::get<index>(outputs_).boundary().clone().uniform_refine(2, -1).greville()};
745
747 return {std::get<index>(outputs_).space().clone().uniform_refine(2, -1).greville(
748 /* interior */ true),
749 std::get<index>(outputs_).boundary().clone().uniform_refine(2, -1).greville()};
750
751 default:
752 throw std::runtime_error("Invalid collocation point specifier");
753 }
754
755 else
756 return collPts(
757 collPts, std::make_index_sequence<std::tuple_element_t<index, outputs_type>::nspaces()>{});
758 }
759};
761
762
763
764
765
766
767
768
773 template <typename GeometryMap, typename Variable>
774 requires FunctionSpaceType<GeometryMap> && FunctionSpaceType<Variable>
776public:
779 typename std::common_type<typename GeometryMap::value_type,
780 typename Variable::value_type>::type;
781
783 using geometryMap_type = GeometryMap;
784
786 using variable_type = Variable;
787
790 std::pair<typename GeometryMap::eval_type,
791 typename GeometryMap::boundary_eval_type>;
792
795 std::pair<typename Variable::eval_type,
796 typename Variable::boundary_eval_type>;
797
799 bool static constexpr has_GeometryMap = true;
800
802 bool static constexpr has_RefData = false;
803
805 bool static constexpr has_Solution = true;
806
807protected:
809 GeometryMap G_;
810
812 Variable u_;
813
814private:
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...>,
826 : // Construct the different spline objects individually
827 G_(std::get<Is>(geometryMapNumCoeffs)..., init::greville, options),
828 u_(std::get<Js>(variableNumCoeffs)..., init::random, options) {}
829
830public:
835
839 template <std::size_t NumCoeffs>
841 std::array<int64_t, NumCoeffs> numCoeffs,
843 : IgABaseNoRefData(std::tuple{numCoeffs}, std::tuple{numCoeffs}, options) {}
844
845 template <std::size_t... NumCoeffs>
847 std::tuple<std::array<int64_t, NumCoeffs>...> numCoeffs,
849 : IgABaseNoRefData(numCoeffs, numCoeffs, options) {}
851
855 template <std::size_t GeometryMapNumCoeffs, std::size_t VariableNumCoeffs>
857 std::array<int64_t, GeometryMapNumCoeffs> geometryMapNumCoeffs,
858 std::array<int64_t, VariableNumCoeffs> variableNumCoeffs,
860 : IgABaseNoRefData(std::tuple{geometryMapNumCoeffs},
861 std::tuple{variableNumCoeffs}, options) {}
862
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)>{},
873 variableNumCoeffs,
874 std::make_index_sequence<sizeof...(VariableNumCoeffs)>{}, options) {
875 }
877
880 inline const GeometryMap &G() const { return G_; }
881
884 inline GeometryMap &G() { return G_; }
885
888 inline const Variable &u() const { return u_; }
889
892 inline Variable &u() { return u_; }
893
894private:
901 template <std::size_t... Is>
903 geometryMap_collPts(enum collPts collPtsType, std::index_sequence<Is...>) const {
905
906 switch (collPtsType) {
907
909 // Get Greville abscissae inside the domain and at the boundary
910 ((std::get<Is>(collPts.first) =
911 G_.template space<Is>().greville(/* interior */ false)),
912 ...);
913
914 // Get Greville abscissae at the domain
915 ((std::get<Is>(collPts.second) = G_.template boundary<Is>().greville()),
916 ...);
917 break;
918
920 // Get Greville abscissae inside the domain
921 ((std::get<Is>(collPts.first) =
922 G_.template space<Is>().greville(/* interior */ true)),
923 ...);
924
925 // Get Greville abscissae at the domain
926 ((std::get<Is>(collPts.second) = G_.template boundary<Is>().greville()),
927 ...);
928 break;
929
931 // Get Greville abscissae inside the domain and at the boundary
932 ((std::get<Is>(collPts.first) =
933 G_.template space<Is>().clone().uniform_refine().greville(
934 /* interior */ false)),
935 ...);
936
937 // Get Greville abscissae at the domain
938 ((std::get<Is>(collPts.second) =
939 G_.template boundary<Is>().clone().uniform_refine().greville()),
940 ...);
941 break;
942
944 // Get Greville abscissae inside the domain
945 ((std::get<Is>(collPts.first) =
946 G_.template space<Is>().clone().uniform_refine().greville(
947 /* interior */ true)),
948 ...);
949
950 // Get Greville abscissae at the domain
951 ((std::get<Is>(collPts.second) =
952 G_.template boundary<Is>().clone().uniform_refine().greville()),
953 ...);
954 break;
955
957 // Get Greville abscissae inside the domain and at the boundary
958 ((std::get<Is>(collPts.first) =
959 G_.template space<Is>().clone().uniform_refine(2, -1).greville(
960 /* interior */ false)),
961 ...);
962
963 // Get Greville abscissae at the domain
964 ((std::get<Is>(collPts.second) = G_.template boundary<Is>()
965 .clone()
966 .uniform_refine(2, -1)
967 .greville()),
968 ...);
969 break;
970
972 // Get Greville abscissae inside the domain
973 ((std::get<Is>(collPts.first) =
974 G_.template space<Is>().clone().uniform_refine(2, -1).greville(
975 /* interior */ true)),
976 ...);
977
978 // Get Greville abscissae at the domain
979 ((std::get<Is>(collPts.second) = G_.template boundary<Is>()
980 .clone()
981 .uniform_refine(2, -1)
982 .greville()),
983 ...);
984 break;
985
986 default:
987 throw std::runtime_error("Invalid collocation point specifier");
988 }
989
990 return collPts;
991 }
992
999 template <std::size_t... Is>
1001 std::index_sequence<Is...>) const {
1003
1004 switch (collPtsType) {
1005
1006 case collPts::greville:
1007 // Get Greville abscissae inside the domain and at the boundary
1008 ((std::get<Is>(collPts.first) =
1009 u_.template space<Is>().greville(/* interior */ false)),
1010 ...);
1011
1012 // Get Greville abscissae at the domain
1013 ((std::get<Is>(collPts.second) = u_.template boundary<Is>().greville()),
1014 ...);
1015 break;
1016
1018 // Get Greville abscissae inside the domain and at the boundary
1019 ((std::get<Is>(collPts.first) =
1020 u_.template space<Is>().greville(/* interior */ true)),
1021 ...);
1022
1023 // Get Greville abscissae at the domain
1024 ((std::get<Is>(collPts.second) = u_.template boundary<Is>().greville()),
1025 ...);
1026 break;
1027
1029 // Get Greville abscissae inside the domain and at the boundary
1030 ((std::get<Is>(collPts.first) =
1031 u_.template space<Is>().clone().uniform_refine().greville(
1032 /* interior */ false)),
1033 ...);
1034
1035 // Get Greville abscissae at the domain
1036 ((std::get<Is>(collPts.second) =
1037 u_.template boundary<Is>().clone().uniform_refine().greville()),
1038 ...);
1039 break;
1040
1042 // Get Greville abscissae inside the domain and at the boundary
1043 ((std::get<Is>(collPts.first) =
1044 u_.template space<Is>().clone().uniform_refine().greville(
1045 /* interior */ true)),
1046 ...);
1047
1048 // Get Greville abscissae at the domain
1049 ((std::get<Is>(collPts.second) =
1050 u_.template boundary<Is>().clone().uniform_refine().greville()),
1051 ...);
1052 break;
1053
1055 // Get Greville abscissae inside the domain and at the boundary
1056 ((std::get<Is>(collPts.first) =
1057 u_.template space<Is>().clone().uniform_refine(2, -1).greville(
1058 /* interior */ false)),
1059 ...);
1060
1061 // Get Greville abscissae at the domain
1062 ((std::get<Is>(collPts.second) = u_.template boundary<Is>()
1063 .clone()
1064 .uniform_refine(2, -1)
1065 .greville()),
1066 ...);
1067 break;
1068
1070 // Get Greville abscissae inside the domain and at the boundary
1071 ((std::get<Is>(collPts.first) =
1072 u_.template space<Is>().clone().uniform_refine(2, -1).greville(
1073 /* interior */ true)),
1074 ...);
1075
1076 // Get Greville abscissae at the domain
1077 ((std::get<Is>(collPts.second) = u_.template boundary<Is>()
1078 .clone()
1079 .uniform_refine(2, -1)
1080 .greville()),
1081 ...);
1082 break;
1083
1084 default:
1085 throw std::runtime_error("Invalid collocation point specifier");
1086 }
1087
1088 return collPts;
1089 }
1090
1091public:
1100 if constexpr (GeometryMap::nspaces() == 1)
1101
1102 switch (collPts) {
1103
1104 case collPts::greville:
1105 return {G_.space().greville(/* interior */ false),
1106 G_.boundary().greville()};
1107
1109 return {G_.space().greville(/* interior */ true),
1110 G_.boundary().greville()};
1111
1113 return {
1114 G_.space().clone().uniform_refine().greville(/* interior */ false),
1115 G_.boundary().clone().uniform_refine().greville()};
1116
1118 return {
1119 G_.space().clone().uniform_refine().greville(/* interior */ true),
1120 G_.boundary().clone().uniform_refine().greville()};
1121
1123 return {G_.space().clone().uniform_refine(2, -1).greville(
1124 /* interior */ false),
1125 G_.boundary().clone().uniform_refine(2, -1).greville()};
1126
1128 return {G_.space().clone().uniform_refine(2, -1).greville(
1129 /* interior */ true),
1130 G_.boundary().clone().uniform_refine(2, -1).greville()};
1131
1132 default:
1133 throw std::runtime_error("Invalid collocation point specifier");
1134 }
1135
1136 else
1137 return geometryMap_collPts(
1138 collPts, std::make_index_sequence<GeometryMap::nspaces()>{});
1139 }
1140
1148 if constexpr (Variable::nspaces() == 1)
1149
1150 switch (collPts) {
1151
1152 case collPts::greville:
1153 return {u_.space().greville(/* interior */ false),
1154 u_.boundary().greville()};
1155
1157 return {u_.space().greville(/* interior */ true),
1158 u_.boundary().greville()};
1159
1161 return {
1162 u_.space().clone().uniform_refine().greville(/* interior */ false),
1163 u_.boundary().clone().uniform_refine().greville()};
1164
1166 return {
1167 u_.space().clone().uniform_refine().greville(/* interior */ true),
1168 u_.boundary().clone().uniform_refine().greville()};
1169
1171 return {u_.space().clone().uniform_refine(2, -1).greville(
1172 /* interior */ false),
1173 u_.boundary().clone().uniform_refine(2, -1).greville()};
1174
1176 return {u_.space().clone().uniform_refine(2, -1).greville(
1177 /* interior */ true),
1178 u_.boundary().clone().uniform_refine(2, -1).greville()};
1179
1180 default:
1181 throw std::runtime_error("Invalid collocation point specifier");
1182 }
1183
1184 else
1186 std::make_index_sequence<Variable::nspaces()>{});
1187 }
1188};
1189
1193 template <typename GeometryMap, typename Variable>
1194 requires FunctionSpaceType<GeometryMap> && FunctionSpaceType<Variable>
1195class IgABase : public IgABaseNoRefData<GeometryMap, Variable> {
1196public:
1199
1202
1204 using geometryMap_type = GeometryMap;
1205
1207 using variable_type = Variable;
1208
1211
1214
1216 bool static constexpr has_GeometryMap = true;
1217
1219 bool static constexpr has_RefData = true;
1220
1222 bool static constexpr has_Solution = true;
1223
1224protected:
1226 Variable f_;
1227
1228private:
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...>,
1240 : // Construct the different spline objects individually
1241 Base(geometryMapNumCoeffs, variableNumCoeffs, options),
1242 f_(std::get<Js>(variableNumCoeffs)..., init::zeros, options) {}
1243
1244public:
1246 explicit IgABase(
1248 : Base::G_(), f_(), Base::u_() {}
1249
1253 template <std::size_t NumCoeffs>
1254 IgABase(std::array<int64_t, NumCoeffs> numCoeffs,
1256 : IgABase(std::tuple{numCoeffs}, std::tuple{numCoeffs}, options) {}
1257
1258 template <std::size_t... NumCoeffs>
1259 IgABase(std::tuple<std::array<int64_t, NumCoeffs>...> numCoeffs,
1261 : IgABase(numCoeffs, numCoeffs, options) {}
1263
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},
1272 options) {}
1273
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)>{},
1283 variableNumCoeffs,
1284 std::make_index_sequence<sizeof...(VariableNumCoeffs)>{},
1285 options) {}
1287
1290 inline const Variable &f() const { return f_; }
1291
1294 inline Variable &f() { return f_; }
1295};
1296
1302protected:
1304 template <typename T>
1305 inline void read_from_xml(std::string location, T &obj,
1306 std::vector<torch::Tensor> &v) {
1307
1308 std::filesystem::path path(location);
1309
1310 if (std::filesystem::exists(path)) {
1311 if (std::filesystem::is_regular_file(path)) {
1312 try {
1313 pugi::xml_document doc;
1314 doc.load_file(path.c_str());
1315 v.emplace_back(obj.from_xml(doc).as_tensor());
1316 } catch (...) {
1317 }
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") {
1321 try {
1322 pugi::xml_document doc;
1323 doc.load_file(file.path().c_str());
1324 v.emplace_back(obj.from_xml(doc).as_tensor());
1325 } catch (...) {
1326 }
1327 }
1328 }
1329 } else
1330 throw std::runtime_error(
1331 "The path refers to neither a file nor a directory");
1332 } else
1333 throw std::runtime_error("The path does not exist");
1334 }
1335};
1336
1342template <bool solution = false> class IgADataset;
1343
1344template <>
1345class IgADataset<false>
1346 : public IgADatasetBase,
1347 public torch::data::Dataset<
1348 IgADataset<false>,
1349 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>> {
1350private:
1352 std::vector<torch::Tensor> G_;
1353
1355 std::vector<torch::Tensor> f_;
1356
1357public:
1360 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>;
1361
1364 template <typename T> void add_geometryMap(T &obj, std::string location) {
1365 read_from_xml(location, obj, G_);
1366 }
1367
1368 template <typename T> void add_geometryMap(T &&obj, std::string location) {
1369 read_from_xml(location, obj, G_);
1370 }
1372
1375 template <typename T>
1376 void add_geometryMap(T &obj, const pugi::xml_document &doc, int id = 0,
1377 std::string label = "") {
1378 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1379 }
1380
1381 template <typename T>
1382 void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id = 0,
1383 std::string label = "") {
1384 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1385 }
1387
1390 template <typename T>
1391 void add_geometryMap(T &obj, const pugi::xml_node &root, int id = 0,
1392 std::string label = "") {
1393 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1394 }
1395
1396 template <typename T>
1397 void add_geometryMap(T &&obj, const pugi::xml_node &root, int id = 0,
1398 std::string label = "") {
1399 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1400 }
1402
1405 template <typename T> void add_referenceData(T &obj, std::string location) {
1406 read_from_xml(location, obj, f_);
1407 }
1408
1409 template <typename T> void add_referenceData(T &&obj, std::string location) {
1410 read_from_xml(location, obj, f_);
1411 }
1413
1416 template <typename T>
1417 void add_referenceData(T &obj, const pugi::xml_document &doc, int id = 0,
1418 std::string label = "") {
1419 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1420 }
1421
1422 template <typename T>
1423 void add_referenceData(T &&obj, const pugi::xml_document &doc, int id = 0,
1424 std::string label = "") {
1425 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1426 }
1428
1431 template <typename T>
1432 void add_referenceData(T &obj, const pugi::xml_node &root, int id = 0,
1433 std::string label = "") {
1434 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1435 }
1436
1437 template <typename T>
1438 void add_referenceData(T &&obj, const pugi::xml_node &root, int id = 0,
1439 std::string label = "") {
1440 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1441 }
1443
1446 template <typename T, typename Func>
1447 void add_referenceData(T &obj, Func func) {
1448 f_.emplace_back(obj.transform(func).as_tensor());
1449 }
1450
1451 template <typename T, typename Func>
1452 void add_referenceData(T &&obj, Func func) {
1453 f_.emplace_back(obj.transform(func).as_tensor());
1454 }
1456
1458 inline example_type get(std::size_t index) override {
1459
1460 std::size_t geo_index = index / (f_.empty() ? 1 : f_.size());
1461 std::size_t ref_index = index - geo_index * f_.size();
1462
1463 if (!G_.empty()) {
1464 if (!f_.empty())
1465 return torch::cat({G_.at(geo_index), f_.at(ref_index)});
1466 else
1467 return G_.at(geo_index);
1468 } else {
1469 if (!f_.empty())
1470 return f_.at(ref_index);
1471 else
1472 throw std::runtime_error("No geometry maps and reference data");
1473 }
1474 };
1475
1476 // @brief Return the total size of the data set
1477 inline torch::optional<std::size_t> size() const override {
1478 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
1479 }
1480};
1481
1482template <>
1483class IgADataset<true>
1484 : public IgADatasetBase,
1485 public torch::data::Dataset<IgADataset<true>, torch::data::Example<>> {
1486private:
1488 std::vector<torch::Tensor> G_;
1489
1491 std::vector<torch::Tensor> f_;
1492
1494 std::vector<torch::Tensor> u_;
1495
1496public:
1499 template <typename T> void add_geometryMap(T &obj, std::string location) {
1500 read_from_xml(location, obj, G_);
1501 }
1502
1503 template <typename T> void add_geometryMap(T &&obj, std::string location) {
1504 read_from_xml(location, obj, G_);
1505 }
1507
1510 template <typename T>
1511 void add_geometryMap(T &obj, const pugi::xml_document &doc, int id = 0,
1512 std::string label = "") {
1513 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1514 }
1515
1516 template <typename T>
1517 void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id = 0,
1518 std::string label = "") {
1519 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1520 }
1522
1525 template <typename T>
1526 void add_geometryMap(T &obj, const pugi::xml_node &root, int id = 0,
1527 std::string label = "") {
1528 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1529 }
1530
1531 template <typename T>
1532 void add_geometryMap(T &&obj, const pugi::xml_node &root, int id = 0,
1533 std::string label = "") {
1534 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1535 }
1537
1540 template <typename T> void add_referenceData(T &obj, std::string location) {
1541 read_from_xml(location, obj, f_);
1542 }
1543
1544 template <typename T> void add_referenceData(T &&obj, std::string location) {
1545 read_from_xml(location, obj, f_);
1546 }
1548
1551 template <typename T>
1552 void add_referenceData(T &obj, const pugi::xml_document &doc, int id = 0,
1553 std::string label = "") {
1554 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1555 }
1556
1557 template <typename T>
1558 void add_referenceData(T &&obj, const pugi::xml_document &doc, int id = 0,
1559 std::string label = "") {
1560 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1561 }
1563
1566 template <typename T>
1567 void add_referenceData(T &obj, const pugi::xml_node &root, int id = 0,
1568 std::string label = "") {
1569 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1570 }
1571
1572 template <typename T>
1573 void add_referenceData(T &&obj, const pugi::xml_node &root, int id = 0,
1574 std::string label = "") {
1575 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1576 }
1578
1581 template <typename T, typename Func>
1582 void add_referenceData(T &obj, Func func) {
1583 f_.emplace_back(obj.transform(func).as_tensor());
1584 }
1585
1586 template <typename T, typename Func>
1587 void add_referenceData(T &&obj, Func func) {
1588 f_.emplace_back(obj.transform(func).as_tensor());
1589 }
1591
1594 template <typename T> void add_solution(T &obj, std::string location) {
1595 read_from_xml(location, obj, u_);
1596 }
1597
1598 template <typename T> void add_solution(T &&obj, std::string location) {
1599 read_from_xml(location, obj, u_);
1600 }
1602
1605 template <typename T>
1606 void add_solution(T &obj, const pugi::xml_document &doc, int id = 0,
1607 std::string label = "") {
1608 u_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1609 }
1610
1611 template <typename T>
1612 void add_solution(T &&obj, const pugi::xml_document &doc, int id = 0,
1613 std::string label = "") {
1614 u_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
1615 }
1617
1620 template <typename T>
1621 void add_solution(T &obj, const pugi::xml_node &root, int id = 0,
1622 std::string label = "") {
1623 u_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1624 }
1625
1626 template <typename T>
1627 void add_solution(T &&obj, const pugi::xml_node &root, int id = 0,
1628 std::string label = "") {
1629 u_.emplace_back(obj.from_xml(root, id, label).as_tensor());
1630 }
1632
1634 inline torch::data::Example<> get(std::size_t index) override {
1635
1636 std::size_t geo_index = index / (f_.empty() ? 1 : f_.size());
1637 std::size_t ref_index = index - geo_index * f_.size();
1638
1639 if (!G_.empty()) {
1640 if (!f_.empty())
1641 return {torch::cat({G_.at(geo_index), f_.at(ref_index)}), u_.at(index)};
1642 else
1643 return {G_.at(geo_index), u_.at(index)};
1644 } else {
1645 if (!f_.empty())
1646 return {f_.at(ref_index), u_.at(index)};
1647 else
1648 throw std::runtime_error("No geometry maps and reference data");
1649 }
1650 };
1651
1652 // @brief Return the total size of the data set
1653 inline torch::optional<std::size_t> size() const override {
1654 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
1655 }
1656};
1658
1659} // namespace iganet
IgABase2(const std::array< int64_t, NumCoeffs > &ncoeffs, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:134
auto construct_tuple_from_arrays_impl(const std::tuple< NumCoeffsTuples... > &numCoeffs, enum init init, iganet::Options< value_type > options, std::index_sequence< Is... >)
Constructs a tuple from tuples.
Definition igabase.hpp:99
auto construct_tuple_from_arrays(const std::tuple< std::array< int64_t, NumCoeffs >... > &numCoeffs, enum init init, iganet::Options< value_type > options)
Constructs a tuple from arrays.
Definition igabase.hpp:84
std::tuple< Inputs... > inputs_type
Type of the inputs.
Definition igabase.hpp:61
constexpr auto & outputs()
Returns a non-constant reference to the tuple of output objects.
Definition igabase.hpp:225
std::tuple_element_t< index, collPts_type > collPts(enum collPts collPts) const
Returns the collocation points of the index-th function spaces.
Definition igabase.hpp:361
constexpr auto & input()
Returns a non-constant reference to the index-th input object.
Definition igabase.hpp:214
auto construct_tuple_from_tuples(const std::tuple< NumCoeffsTuples... > &numCoeffs, enum init init, iganet::Options< value_type > options)
Constructs a tuple from tuples.
Definition igabase.hpp:113
typename std::common_type< typename Inputs::value_type..., typename Outputs::value_type... >::type value_type
Value type.
Definition igabase.hpp:58
constexpr const auto & collPts() const
Returns a constant reference to the tuple of collocation points objects.
Definition igabase.hpp:244
constexpr const auto & input() const
Returns a constant reference to the index-th input object.
Definition igabase.hpp:207
IgABase2(const std::tuple< std::array< int64_t, NumCoeffs >... > &ncoeffs, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:158
constexpr auto & inputs()
Returns a non-constant reference to the tuple of input objects.
Definition igabase.hpp:201
constexpr const auto & outputs() const
Returns a constant reference to the tuple of output objects.
Definition igabase.hpp:220
std::tuple< std::pair< typename CollPts::eval_type, typename CollPts::boundary_eval_type >... > collPts_type
Type of the collocation points.
Definition igabase.hpp:69
constexpr auto & collPts()
Returns a non-constant reference to the tuple of collocation points objects.
Definition igabase.hpp:249
constexpr const auto & output() const
Returns a constant reference to the index-th output object.
Definition igabase.hpp:231
constexpr auto & output()
Returns a non-constant reference to the index-th output object.
Definition igabase.hpp:238
IgABase2(const std::tuple< std::array< int64_t, NumCoeffsInputs >... > &ncoeffsInputs, const std::tuple< std::array< int64_t, NumCoeffsOutputs >... > &ncoeffsOutputs, const std::tuple< std::array< int64_t, NumCoeffsCollPts >... > &ncoeffsCollPts, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:169
constexpr const auto & inputs() const
Returns a constant reference to the tuple of input objects.
Definition igabase.hpp:196
IgABase2(iganet::Options< value_type > options=iganet::Options< value_type >{})
Default constructor.
Definition igabase.hpp:125
std::tuple< Outputs... > outputs_type
Type of the outputs.
Definition igabase.hpp:64
IgABase2(const std::array< int64_t, NumCoeffsInputs > &ncoeffsInputs, const std::array< int64_t, NumCoeffsOutputs > &ncoeffsOutputs, const std::array< int64_t, NumCoeffsCollPts > &ncoeffsCollPts, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:144
IgABase2(const std::tuple< CoeffsInputs... > &coeffsInputs, const std::tuple< CoeffsOutputs... > &coeffsOutputs, const std::tuple< CoeffsCollPts... > &coeffsCollPts, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:185
std::tuple_element_t< index, collPts_type > collPts(enum collPts collPtsType, std::index_sequence< Is... >) const
Returns the collocation points of the index-th function space.
Definition igabase.hpp:262
auto construct_tuple_from_tuples(const std::tuple< NumCoeffsTuples... > &numCoeffs, enum init init, iganet::Options< value_type > options)
Constructs a tuple from tuples.
Definition igabase.hpp:476
IgABase2(const std::tuple< std::array< int64_t, NumCoeffs >... > &ncoeffs, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:520
constexpr const auto & outputs() const
Returns a constant reference to the tuple of output objects.
Definition igabase.hpp:577
std::tuple_element_t< index, collPts_type > collPts(enum collPts collPtsType, std::index_sequence< Is... >) const
Returns the collocation points of the index-th function space.
Definition igabase.hpp:619
auto construct_tuple_from_arrays_impl(const std::tuple< NumCoeffsTuples... > &numCoeffs, enum init init, iganet::Options< value_type > options, std::index_sequence< Is... >)
Constructs a tuple from tuples.
Definition igabase.hpp:462
std::tuple< Outputs... > outputs_type
Type of the outputs.
Definition igabase.hpp:422
constexpr auto & collPts()
Returns a non-constant reference to the tuple of collocation points objects.
Definition igabase.hpp:606
IgABase2(const std::tuple< CoeffsInputs... > &coeffsInputs, const std::tuple< CoeffsOutputs... > &coeffsOutputs, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:544
auto construct_tuple_from_arrays(const std::tuple< std::array< int64_t, NumCoeffs >... > &numCoeffs, enum init init, iganet::Options< value_type > options)
Constructs a tuple from arrays.
Definition igabase.hpp:447
IgABase2(const std::array< int64_t, NumCoeffs > &ncoeffs, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:497
IgABase2(const std::tuple< std::array< int64_t, NumCoeffsInputs >... > &ncoeffsInputs, const std::tuple< std::array< int64_t, NumCoeffsOutputs >... > &ncoeffsOutputs, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:531
constexpr auto & inputs()
Returns a non-constant reference to the tuple of input objects.
Definition igabase.hpp:558
constexpr const auto & output() const
Returns a constant reference to the index-th output object.
Definition igabase.hpp:588
typename std::tuple_element_t< index, inputs_type > input_t
Type alias for the type of the index-th inputs object.
Definition igabase.hpp:419
std::tuple< Inputs... > inputs_type
Type of the inputs.
Definition igabase.hpp:415
std::tuple< std::pair< typename Outputs::eval_type, typename Outputs::boundary_eval_type >... > collPts_type
Type of the collocation points.
Definition igabase.hpp:431
constexpr const auto & input() const
Returns a constant reference to the index-th input object.
Definition igabase.hpp:564
constexpr auto & outputs()
Returns a non-constant reference to the tuple of output objects.
Definition igabase.hpp:582
typename std::common_type< typename Inputs::value_type..., typename Outputs::value_type... >::type value_type
Value type.
Definition igabase.hpp:412
IgABase2(iganet::Options< value_type > options=iganet::Options< value_type >{})
Default constructor.
Definition igabase.hpp:488
std::tuple_element_t< index, collPts_type > collPts(enum collPts collPts) const
Returns the collocation points of the index-th function spaces.
Definition igabase.hpp:718
constexpr auto & input()
Returns a non-constant reference to the index-th input object.
Definition igabase.hpp:571
IgABase2(const std::array< int64_t, NumCoeffsInputs > &ncoeffsInputs, const std::array< int64_t, NumCoeffsOutputs > &ncoeffsOutputs, enum init init=init::greville, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor.
Definition igabase.hpp:507
typename std::tuple_element_t< index, outputs_type > output_t
Type alias for the type of the index-th outputs object.
Definition igabase.hpp:426
constexpr const auto & inputs() const
Returns a constant reference to the tuple of input objects.
Definition igabase.hpp:553
constexpr const auto & collPts() const
Returns a constant reference to the tuple of collocation points objects.
Definition igabase.hpp:601
constexpr auto & output()
Returns a non-constant reference to the index-th output object.
Definition igabase.hpp:595
typename std::tuple_element_t< index, collPts_type > collPts_t
Type alias for the type of the index-th collocation points object.
Definition igabase.hpp:435
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
STL namespace.
Tuple utility functions.