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 <filesystem>
18
19namespace iganet {
20
22enum class collPts : short_t {
23 greville = 0,
25 greville_ref1 = 2,
27 3,
28 greville_ref2 = 4,
30 5,
31};
32
37 template <typename GeometryMap, typename Variable>
38 requires FunctionSpaceType<GeometryMap> && FunctionSpaceType<Variable>
40public:
42 using value_type =
43 typename std::common_type<typename GeometryMap::value_type,
44 typename Variable::value_type>::type;
45
47 using geometryMap_type = GeometryMap;
48
50 using variable_type = Variable;
51
54 std::pair<typename GeometryMap::eval_type,
55 typename GeometryMap::boundary_eval_type>;
56
59 std::pair<typename Variable::eval_type,
60 typename Variable::boundary_eval_type>;
61
63 bool static constexpr has_GeometryMap = true;
64
66 bool static constexpr has_RefData = false;
67
69 bool static constexpr has_Solution = true;
70
71protected:
73 GeometryMap G_;
74
76 Variable u_;
77
78private:
81 template <std::size_t... GeometryMapNumCoeffs, size_t... Is,
82 std::size_t... VariableNumCoeffs, size_t... Js>
84 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
85 geometryMapNumCoeffs,
86 std::index_sequence<Is...>,
87 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
88 std::index_sequence<Js...>,
90 : // Construct the different spline objects individually
91 G_(std::get<Is>(geometryMapNumCoeffs)..., init::greville, options),
92 u_(std::get<Js>(variableNumCoeffs)..., init::random, options) {}
93
94public:
99
103 template <std::size_t NumCoeffs>
105 std::array<int64_t, NumCoeffs> ncoeffs,
107 : IgABaseNoRefData(std::tuple{ncoeffs}, std::tuple{ncoeffs}, options) {}
108
109 template <std::size_t... NumCoeffs>
111 std::tuple<std::array<int64_t, NumCoeffs>...> ncoeffs,
113 : IgABaseNoRefData(ncoeffs, ncoeffs, options) {}
115
119 template <std::size_t GeometryMapNumCoeffs, std::size_t VariableNumCoeffs>
121 std::array<int64_t, GeometryMapNumCoeffs> geometryMapNumCoeffs,
122 std::array<int64_t, VariableNumCoeffs> variableNumCoeffs,
124 : IgABaseNoRefData(std::tuple{geometryMapNumCoeffs},
125 std::tuple{variableNumCoeffs}, options) {}
126
127 template <std::size_t... GeometryMapNumCoeffs,
128 std::size_t... VariableNumCoeffs>
130 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
131 geometryMapNumCoeffs,
132 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
135 geometryMapNumCoeffs,
136 std::make_index_sequence<sizeof...(GeometryMapNumCoeffs)>{},
137 variableNumCoeffs,
138 std::make_index_sequence<sizeof...(VariableNumCoeffs)>{}, options) {
139 }
141
144 inline const GeometryMap &G() const { return G_; }
145
148 inline GeometryMap &G() { return G_; }
149
152 inline const Variable &u() const { return u_; }
153
156 inline Variable &u() { return u_; }
157
158private:
165 template <size_t... Is>
167 geometryMap_collPts(enum collPts collPts, std::index_sequence<Is...>) const {
169
170 switch (collPts) {
171
173 // Get Greville abscissae inside the domain and at the boundary
174 ((std::get<Is>(collPts_.first) =
175 G_.template space<Is>().greville(/* interior */ false)),
176 ...);
177
178 // Get Greville abscissae at the domain
179 ((std::get<Is>(collPts_.second) = G_.template boundary<Is>().greville()),
180 ...);
181 break;
182
184 // Get Greville abscissae inside the domain
185 ((std::get<Is>(collPts_.first) =
186 G_.template space<Is>().greville(/* interior */ true)),
187 ...);
188
189 // Get Greville abscissae at the domain
190 ((std::get<Is>(collPts_.second) = G_.template boundary<Is>().greville()),
191 ...);
192 break;
193
195 // Get Greville abscissae inside the domain and at the boundary
196 ((std::get<Is>(collPts_.first) =
197 G_.template space<Is>().clone().uniform_refine().greville(
198 /* interior */ false)),
199 ...);
200
201 // Get Greville abscissae at the domain
202 ((std::get<Is>(collPts_.second) =
203 G_.template boundary<Is>().clone().uniform_refine().greville()),
204 ...);
205 break;
206
208 // Get Greville abscissae inside the domain
209 ((std::get<Is>(collPts_.first) =
210 G_.template space<Is>().clone().uniform_refine().greville(
211 /* interior */ true)),
212 ...);
213
214 // Get Greville abscissae at the domain
215 ((std::get<Is>(collPts_.second) =
216 G_.template boundary<Is>().clone().uniform_refine().greville()),
217 ...);
218 break;
219
221 // Get Greville abscissae inside the domain and at the boundary
222 ((std::get<Is>(collPts_.first) =
223 G_.template space<Is>().clone().uniform_refine(2, -1).greville(
224 /* interior */ false)),
225 ...);
226
227 // Get Greville abscissae at the domain
228 ((std::get<Is>(collPts_.second) = G_.template boundary<Is>()
229 .clone()
230 .uniform_refine(2, -1)
231 .greville()),
232 ...);
233 break;
234
236 // Get Greville abscissae inside the domain
237 ((std::get<Is>(collPts_.first) =
238 G_.template space<Is>().clone().uniform_refine(2, -1).greville(
239 /* interior */ true)),
240 ...);
241
242 // Get Greville abscissae at the domain
243 ((std::get<Is>(collPts_.second) = G_.template boundary<Is>()
244 .clone()
245 .uniform_refine(2, -1)
246 .greville()),
247 ...);
248 break;
249
250 default:
251 throw std::runtime_error("Invalid collocation point specifier");
252 }
253
254 return collPts_;
255 }
256
263 template <size_t... Is>
265 std::index_sequence<Is...>) const {
266 variable_collPts_type collPts_;
267
268 switch (collPts) {
269
271 // Get Greville abscissae inside the domain and at the boundary
272 ((std::get<Is>(collPts_.first) =
273 u_.template space<Is>().greville(/* interior */ false)),
274 ...);
275
276 // Get Greville abscissae at the domain
277 ((std::get<Is>(collPts_.second) = u_.template boundary<Is>().greville()),
278 ...);
279 break;
280
282 // Get Greville abscissae inside the domain and at the boundary
283 ((std::get<Is>(collPts_.first) =
284 u_.template space<Is>().greville(/* interior */ true)),
285 ...);
286
287 // Get Greville abscissae at the domain
288 ((std::get<Is>(collPts_.second) = u_.template boundary<Is>().greville()),
289 ...);
290 break;
291
293 // Get Greville abscissae inside the domain and at the boundary
294 ((std::get<Is>(collPts_.first) =
295 u_.template space<Is>().clone().uniform_refine().greville(
296 /* interior */ false)),
297 ...);
298
299 // Get Greville abscissae at the domain
300 ((std::get<Is>(collPts_.second) =
301 u_.template boundary<Is>().clone().uniform_refine().greville()),
302 ...);
303 break;
304
306 // Get Greville abscissae inside the domain and at the boundary
307 ((std::get<Is>(collPts_.first) =
308 u_.template space<Is>().clone().uniform_refine().greville(
309 /* interior */ true)),
310 ...);
311
312 // Get Greville abscissae at the domain
313 ((std::get<Is>(collPts_.second) =
314 u_.template boundary<Is>().clone().uniform_refine().greville()),
315 ...);
316 break;
317
319 // Get Greville abscissae inside the domain and at the boundary
320 ((std::get<Is>(collPts_.first) =
321 u_.template space<Is>().clone().uniform_refine(2, -1).greville(
322 /* interior */ false)),
323 ...);
324
325 // Get Greville abscissae at the domain
326 ((std::get<Is>(collPts_.second) = u_.template boundary<Is>()
327 .clone()
328 .uniform_refine(2, -1)
329 .greville()),
330 ...);
331 break;
332
334 // Get Greville abscissae inside the domain and at the boundary
335 ((std::get<Is>(collPts_.first) =
336 u_.template space<Is>().clone().uniform_refine(2, -1).greville(
337 /* interior */ true)),
338 ...);
339
340 // Get Greville abscissae at the domain
341 ((std::get<Is>(collPts_.second) = u_.template boundary<Is>()
342 .clone()
343 .uniform_refine(2, -1)
344 .greville()),
345 ...);
346 break;
347
348 default:
349 throw std::runtime_error("Invalid collocation point specifier");
350 }
351
352 return collPts_;
353 }
354
355public:
364 if constexpr (GeometryMap::nspaces() == 1)
365
366 switch (collPts) {
367
369 return {G_.space().greville(/* interior */ false),
370 G_.boundary().greville()};
371
373 return {G_.space().greville(/* interior */ true),
374 G_.boundary().greville()};
375
377 return {
378 G_.space().clone().uniform_refine().greville(/* interior */ false),
379 G_.boundary().clone().uniform_refine().greville()};
380
382 return {
383 G_.space().clone().uniform_refine().greville(/* interior */ true),
384 G_.boundary().clone().uniform_refine().greville()};
385
387 return {G_.space().clone().uniform_refine(2, -1).greville(
388 /* interior */ false),
389 G_.boundary().clone().uniform_refine(2, -1).greville()};
390
392 return {G_.space().clone().uniform_refine(2, -1).greville(
393 /* interior */ true),
394 G_.boundary().clone().uniform_refine(2, -1).greville()};
395
396 default:
397 throw std::runtime_error("Invalid collocation point specifier");
398 }
399
400 else
401 return geometryMap_collPts(
402 collPts, std::make_index_sequence<GeometryMap::nspaces()>{});
403 }
404
412 if constexpr (Variable::nspaces() == 1)
413
414 switch (collPts) {
415
417 return {u_.space().greville(/* interior */ false),
418 u_.boundary().greville()};
419
421 return {u_.space().greville(/* interior */ true),
422 u_.boundary().greville()};
423
425 return {
426 u_.space().clone().uniform_refine().greville(/* interior */ false),
427 u_.boundary().clone().uniform_refine().greville()};
428
430 return {
431 u_.space().clone().uniform_refine().greville(/* interior */ true),
432 u_.boundary().clone().uniform_refine().greville()};
433
435 return {u_.space().clone().uniform_refine(2, -1).greville(
436 /* interior */ false),
437 u_.boundary().clone().uniform_refine(2, -1).greville()};
438
440 return {u_.space().clone().uniform_refine(2, -1).greville(
441 /* interior */ true),
442 u_.boundary().clone().uniform_refine(2, -1).greville()};
443
444 default:
445 throw std::runtime_error("Invalid collocation point specifier");
446 }
447
448 else
450 std::make_index_sequence<Variable::nspaces()>{});
451 }
452};
453
457 template <typename GeometryMap, typename Variable>
458 requires FunctionSpaceType<GeometryMap> && FunctionSpaceType<Variable>
459class IgABase : public IgABaseNoRefData<GeometryMap, Variable> {
460public:
463
465 using value_type = typename Base::value_type;
466
468 using geometryMap_type = GeometryMap;
469
471 using variable_type = Variable;
472
475
478
480 bool static constexpr has_GeometryMap = true;
481
483 bool static constexpr has_RefData = true;
484
486 bool static constexpr has_Solution = true;
487
488protected:
490 Variable f_;
491
492private:
495 template <std::size_t... GeometryMapNumCoeffs, size_t... Is,
496 std::size_t... VariableNumCoeffs, size_t... Js>
498 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
499 geometryMapNumCoeffs,
500 std::index_sequence<Is...>,
501 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
502 std::index_sequence<Js...>,
504 : // Construct the different spline objects individually
505 Base(geometryMapNumCoeffs, variableNumCoeffs, options),
506 f_(std::get<Js>(variableNumCoeffs)..., init::zeros, options) {}
507
508public:
510 explicit IgABase(
512 : Base::G_(), f_(), Base::u_() {}
513
517 template <size_t NumCoeffs>
518 IgABase(std::array<int64_t, NumCoeffs> ncoeffs,
520 : IgABase(std::tuple{ncoeffs}, std::tuple{ncoeffs}, options) {}
521
522 template <size_t... NumCoeffs>
523 IgABase(std::tuple<std::array<int64_t, NumCoeffs>...> ncoeffs,
525 : IgABase(ncoeffs, ncoeffs, options) {}
527
531 template <std::size_t GeometryMapNumCoeffs, std::size_t VariableNumCoeffs>
532 IgABase(std::array<int64_t, GeometryMapNumCoeffs> geometryMapNumCoeffs,
533 std::array<int64_t, VariableNumCoeffs> variableNumCoeffs,
535 : IgABase(std::tuple{geometryMapNumCoeffs}, std::tuple{variableNumCoeffs},
536 options) {}
537
538 template <std::size_t... GeometryMapNumCoeffs,
539 std::size_t... VariableNumCoeffs>
541 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
542 geometryMapNumCoeffs,
543 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
545 : IgABase(geometryMapNumCoeffs,
546 std::make_index_sequence<sizeof...(GeometryMapNumCoeffs)>{},
547 variableNumCoeffs,
548 std::make_index_sequence<sizeof...(VariableNumCoeffs)>{},
549 options) {}
551
554 inline const Variable &f() const { return f_; }
555
558 inline Variable &f() { return f_; }
559};
560
566protected:
568 template <typename T>
569 inline void read_from_xml(std::string location, T &obj,
570 std::vector<torch::Tensor> &v) {
571
572 std::filesystem::path path(location);
573
574 if (std::filesystem::exists(path)) {
575 if (std::filesystem::is_regular_file(path)) {
576 try {
577 pugi::xml_document doc;
578 doc.load_file(path.c_str());
579 v.emplace_back(obj.from_xml(doc).as_tensor());
580 } catch (...) {
581 }
582 } else if (std::filesystem::is_directory(path)) {
583 for (const auto &file : std::filesystem::directory_iterator(path)) {
584 if (file.is_regular_file() && file.path().extension() == ".xml") {
585 try {
586 pugi::xml_document doc;
587 doc.load_file(file.path().c_str());
588 v.emplace_back(obj.from_xml(doc).as_tensor());
589 } catch (...) {
590 }
591 }
592 }
593 } else
594 throw std::runtime_error(
595 "The path refers to neither a file nor a directory");
596 } else
597 throw std::runtime_error("The path does not exist");
598 }
599};
600
606template <bool solution = false> class IgADataset;
607
608template <>
609class IgADataset<false>
610 : public IgADatasetBase,
611 public torch::data::Dataset<
612 IgADataset<false>,
613 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>> {
614private:
616 std::vector<torch::Tensor> G_;
617
619 std::vector<torch::Tensor> f_;
620
621public:
624 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>;
625
628 template <typename T> void add_geometryMap(T &obj, std::string location) {
629 read_from_xml(location, obj, G_);
630 }
631
632 template <typename T> void add_geometryMap(T &&obj, std::string location) {
633 read_from_xml(location, obj, G_);
634 }
636
639 template <typename T>
640 void add_geometryMap(T &obj, const pugi::xml_document &doc, int id = 0,
641 std::string label = "") {
642 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
643 }
644
645 template <typename T>
646 void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id = 0,
647 std::string label = "") {
648 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
649 }
651
654 template <typename T>
655 void add_geometryMap(T &obj, const pugi::xml_node &root, int id = 0,
656 std::string label = "") {
657 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
658 }
659
660 template <typename T>
661 void add_geometryMap(T &&obj, const pugi::xml_node &root, int id = 0,
662 std::string label = "") {
663 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
664 }
666
669 template <typename T> void add_referenceData(T &obj, std::string location) {
670 read_from_xml(location, obj, f_);
671 }
672
673 template <typename T> void add_referenceData(T &&obj, std::string location) {
674 read_from_xml(location, obj, f_);
675 }
677
680 template <typename T>
681 void add_referenceData(T &obj, const pugi::xml_document &doc, int id = 0,
682 std::string label = "") {
683 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
684 }
685
686 template <typename T>
687 void add_referenceData(T &&obj, const pugi::xml_document &doc, int id = 0,
688 std::string label = "") {
689 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
690 }
692
695 template <typename T>
696 void add_referenceData(T &obj, const pugi::xml_node &root, int id = 0,
697 std::string label = "") {
698 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
699 }
700
701 template <typename T>
702 void add_referenceData(T &&obj, const pugi::xml_node &root, int id = 0,
703 std::string label = "") {
704 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
705 }
707
710 template <typename T, typename Func>
711 void add_referenceData(T &obj, Func func) {
712 f_.emplace_back(obj.transform(func).as_tensor());
713 }
714
715 template <typename T, typename Func>
716 void add_referenceData(T &&obj, Func func) {
717 f_.emplace_back(obj.transform(func).as_tensor());
718 }
720
722 inline example_type get(std::size_t index) override {
723
724 std::size_t geo_index = index / (f_.empty() ? 1 : f_.size());
725 std::size_t ref_index = index - geo_index * f_.size();
726
727 if (!G_.empty()) {
728 if (!f_.empty())
729 return torch::cat({G_.at(geo_index), f_.at(ref_index)});
730 else
731 return G_.at(geo_index);
732 } else {
733 if (!f_.empty())
734 return f_.at(ref_index);
735 else
736 throw std::runtime_error("No geometry maps and reference data");
737 }
738 };
739
740 // @brief Return the total size of the data set
741 inline torch::optional<std::size_t> size() const override {
742 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
743 }
744};
745
746template <>
747class IgADataset<true>
748 : public IgADatasetBase,
749 public torch::data::Dataset<IgADataset<true>, torch::data::Example<>> {
750private:
752 std::vector<torch::Tensor> G_;
753
755 std::vector<torch::Tensor> f_;
756
758 std::vector<torch::Tensor> u_;
759
760public:
763 template <typename T> void add_geometryMap(T &obj, std::string location) {
764 read_from_xml(location, obj, G_);
765 }
766
767 template <typename T> void add_geometryMap(T &&obj, std::string location) {
768 read_from_xml(location, obj, G_);
769 }
771
774 template <typename T>
775 void add_geometryMap(T &obj, const pugi::xml_document &doc, int id = 0,
776 std::string label = "") {
777 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
778 }
779
780 template <typename T>
781 void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id = 0,
782 std::string label = "") {
783 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
784 }
786
789 template <typename T>
790 void add_geometryMap(T &obj, const pugi::xml_node &root, int id = 0,
791 std::string label = "") {
792 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
793 }
794
795 template <typename T>
796 void add_geometryMap(T &&obj, const pugi::xml_node &root, int id = 0,
797 std::string label = "") {
798 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
799 }
801
804 template <typename T> void add_referenceData(T &obj, std::string location) {
805 read_from_xml(location, obj, f_);
806 }
807
808 template <typename T> void add_referenceData(T &&obj, std::string location) {
809 read_from_xml(location, obj, f_);
810 }
812
815 template <typename T>
816 void add_referenceData(T &obj, const pugi::xml_document &doc, int id = 0,
817 std::string label = "") {
818 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
819 }
820
821 template <typename T>
822 void add_referenceData(T &&obj, const pugi::xml_document &doc, int id = 0,
823 std::string label = "") {
824 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
825 }
827
830 template <typename T>
831 void add_referenceData(T &obj, const pugi::xml_node &root, int id = 0,
832 std::string label = "") {
833 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
834 }
835
836 template <typename T>
837 void add_referenceData(T &&obj, const pugi::xml_node &root, int id = 0,
838 std::string label = "") {
839 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
840 }
842
845 template <typename T, typename Func>
846 void add_referenceData(T &obj, Func func) {
847 f_.emplace_back(obj.transform(func).as_tensor());
848 }
849
850 template <typename T, typename Func>
851 void add_referenceData(T &&obj, Func func) {
852 f_.emplace_back(obj.transform(func).as_tensor());
853 }
855
858 template <typename T> void add_solution(T &obj, std::string location) {
859 read_from_xml(location, obj, u_);
860 }
861
862 template <typename T> void add_solution(T &&obj, std::string location) {
863 read_from_xml(location, obj, u_);
864 }
866
869 template <typename T>
870 void add_solution(T &obj, const pugi::xml_document &doc, int id = 0,
871 std::string label = "") {
872 u_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
873 }
874
875 template <typename T>
876 void add_solution(T &&obj, const pugi::xml_document &doc, int id = 0,
877 std::string label = "") {
878 u_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
879 }
881
884 template <typename T>
885 void add_solution(T &obj, const pugi::xml_node &root, int id = 0,
886 std::string label = "") {
887 u_.emplace_back(obj.from_xml(root, id, label).as_tensor());
888 }
889
890 template <typename T>
891 void add_solution(T &&obj, const pugi::xml_node &root, int id = 0,
892 std::string label = "") {
893 u_.emplace_back(obj.from_xml(root, id, label).as_tensor());
894 }
896
898 inline torch::data::Example<> get(std::size_t index) override {
899
900 std::size_t geo_index = index / (f_.empty() ? 1 : f_.size());
901 std::size_t ref_index = index - geo_index * f_.size();
902
903 if (!G_.empty()) {
904 if (!f_.empty())
905 return {torch::cat({G_.at(geo_index), f_.at(ref_index)}), u_.at(index)};
906 else
907 return {G_.at(geo_index), u_.at(index)};
908 } else {
909 if (!f_.empty())
910 return {f_.at(ref_index), u_.at(index)};
911 else
912 throw std::runtime_error("No geometry maps and reference data");
913 }
914 };
915
916 // @brief Return the total size of the data set
917 inline torch::optional<std::size_t> size() const override {
918 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
919 }
920};
922
923} // namespace iganet
IgA base class.
Definition igabase.hpp:459
Variable f_
Spline representation of the reference data.
Definition igabase.hpp:490
IgABase(std::array< int64_t, NumCoeffs > ncoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:518
const Variable & f() const
Returns a constant reference to the spline representation of the reference data.
Definition igabase.hpp:554
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:540
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:532
IgABaseNoRefData< GeometryMap, Variable > Base
Base type.
Definition igabase.hpp:462
Variable & f()
Returns a non-constant reference to the spline representation of the reference data.
Definition igabase.hpp:558
Variable variable_type
Type of the variable function space(s)
Definition igabase.hpp:471
typename Base::value_type value_type
Value type.
Definition igabase.hpp:465
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:497
typename Base::variable_collPts_type variable_collPts_type
Type of the variable collocation points.
Definition igabase.hpp:477
IgABase(iganet::Options< value_type > options=iganet::Options< value_type >{})
Default constructor.
Definition igabase.hpp:510
IgABase(std::tuple< std::array< int64_t, NumCoeffs >... > ncoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:523
GeometryMap geometryMap_type
Type of the geometry map function space(s)
Definition igabase.hpp:468
static bool constexpr has_GeometryMap
Indicates whether this class provides a geometry map.
Definition igabase.hpp:480
typename Base::geometryMap_collPts_type geometryMap_collPts_type
Type of the geometry map collocation points.
Definition igabase.hpp:474
static bool constexpr has_Solution
Indicates whether this class provides a solution.
Definition igabase.hpp:486
static bool constexpr has_RefData
Indicates whether this class provides a reference solution.
Definition igabase.hpp:483
IgA base class (no reference data)
Definition igabase.hpp:39
virtual variable_collPts_type variable_collPts(enum collPts collPts) const
Returns the variable collocation points.
Definition igabase.hpp:411
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:129
virtual geometryMap_collPts_type geometryMap_collPts(enum collPts collPts) const
Returns the geometry map collocation points.
Definition igabase.hpp:363
GeometryMap geometryMap_type
Type of the geometry map function space(s)
Definition igabase.hpp:47
geometryMap_collPts_type geometryMap_collPts(enum collPts collPts, std::index_sequence< Is... >) const
Returns the geometry map collocation points.
Definition igabase.hpp:167
typename std::common_type< typename GeometryMap::value_type, typename Variable::value_type >::type value_type
Value type.
Definition igabase.hpp:44
IgABaseNoRefData(std::tuple< std::array< int64_t, NumCoeffs >... > ncoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:110
std::pair< typename Variable::eval_type, typename Variable::boundary_eval_type > variable_collPts_type
Type of the variable collocation points.
Definition igabase.hpp:60
const Variable & u() const
Returns a constant reference to the spline representation of the solution.
Definition igabase.hpp:152
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:120
Variable variable_type
Type of the variable function space(s)
Definition igabase.hpp:50
IgABaseNoRefData(iganet::Options< value_type > options=iganet::Options< value_type >{})
Default constructor.
Definition igabase.hpp:96
IgABaseNoRefData(std::array< int64_t, NumCoeffs > ncoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:104
static bool constexpr has_GeometryMap
Indicates whether this class provides a geometry map.
Definition igabase.hpp:63
static bool constexpr has_RefData
Indicates whether this class provides reference data.
Definition igabase.hpp:66
variable_collPts_type variable_collPts(enum collPts collPts, std::index_sequence< Is... >) const
Returns the variable collocation points.
Definition igabase.hpp:264
GeometryMap G_
Spline representation of the geometry map.
Definition igabase.hpp:73
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:83
Variable u_
Spline representation of the solution.
Definition igabase.hpp:76
static bool constexpr has_Solution
Indicates whether this class provides a solution.
Definition igabase.hpp:69
GeometryMap & G()
Returns a non-constant reference to the spline representation of the geometry map.
Definition igabase.hpp:148
Variable & u()
Returns a non-constant reference to the spline representation of the solution.
Definition igabase.hpp:156
std::pair< typename GeometryMap::eval_type, typename GeometryMap::boundary_eval_type > geometryMap_collPts_type
Type of the geometry map collocation points.
Definition igabase.hpp:55
const GeometryMap & G() const
Returns a constant reference to the spline representation of the geometry map.
Definition igabase.hpp:144
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:702
void add_referenceData(T &&obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:673
void add_referenceData(T &obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:711
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:696
std::vector< torch::Tensor > G_
Vector of tensors representing the geometry maps.
Definition igabase.hpp:616
std::vector< torch::Tensor > f_
Vector of tensors representing the reference data.
Definition igabase.hpp:619
void add_referenceData(T &obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:669
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:661
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:640
void add_geometryMap(T &&obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:632
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:687
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:646
torch::data::Example< torch::Tensor, torch::data::example::NoTarget > example_type
Example type.
Definition igabase.hpp:624
void add_geometryMap(T &obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:628
void add_referenceData(T &&obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:716
example_type get(std::size_t index) override
Returns the data set at location index.
Definition igabase.hpp:722
torch::optional< std::size_t > size() const override
Definition igabase.hpp:741
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:681
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:655
torch::optional< std::size_t > size() const override
Definition igabase.hpp:917
std::vector< torch::Tensor > G_
Vector of tensors representing the geometry maps.
Definition igabase.hpp:752
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:796
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:775
void add_referenceData(T &obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:846
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:822
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:870
std::vector< torch::Tensor > f_
Vector of tensors representing the reference data.
Definition igabase.hpp:755
void add_referenceData(T &&obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:851
void add_geometryMap(T &&obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:767
void add_referenceData(T &&obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:808
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:876
torch::data::Example get(std::size_t index) override
Returns the data set at location index.
Definition igabase.hpp:898
void add_referenceData(T &obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:804
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:837
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:891
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:816
void add_solution(T &obj, std::string location)
Adds a solution from file.
Definition igabase.hpp:858
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:885
void add_solution(T &&obj, std::string location)
Adds a solution from file.
Definition igabase.hpp:862
std::vector< torch::Tensor > u_
Vector of tensors representing the solution data.
Definition igabase.hpp:758
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:781
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:831
void add_geometryMap(T &obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:763
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:790
IgA dataset base class.
Definition igabase.hpp:565
void read_from_xml(std::string location, T &obj, std::vector< torch::Tensor > &v)
Reads a function space from file.
Definition igabase.hpp:569
The Options class handles the automated determination of dtype from the template argument and the sel...
Definition options.hpp:107
Definition boundary.hpp:22
collPts
Enumerator for the collocation point specifier.
Definition igabase.hpp:22
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:606
STL namespace.