PRISMS-PF Manual
Loading...
Searching...
No Matches
field_container.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2025 PRISMS Center at the University of Michigan
2// SPDX-License-Identifier: GNU Lesser General Public Version 2.1
3
4#pragma once
5
6#include <deal.II/base/config.h>
7#include <deal.II/base/exceptions.h>
8#include <deal.II/base/point.h>
9#include <deal.II/base/symmetric_tensor.h>
10#include <deal.II/base/tensor.h>
11#include <deal.II/lac/vector.h>
12#include <deal.II/matrix_free/evaluation_flags.h>
13#include <deal.II/matrix_free/fe_evaluation.h>
14#include <deal.II/matrix_free/matrix_free.h>
15
22#include <prismspf/core/types.h>
23
24#include <prismspf/config.h>
25
26#include <memory>
27#include <type_traits>
28#include <utility>
29#include <vector>
30
32
48template <unsigned int dim, unsigned int degree, typename number>
50{
51public:
55 using ScalarValue = dealii::VectorizedArray<number>;
56
60 using VectorValue = dealii::Tensor<1, dim, ScalarValue>;
61
62 template <TensorRank Rank>
63 using Value = std::conditional_t<Rank == TensorRank::Scalar,
65 dealii::Tensor<int(Rank), dim, ScalarValue>>;
66
67 template <TensorRank Rank>
68 using Gradient = dealii::Tensor<int(Rank) + 1, dim, ScalarValue>;
69
70 template <TensorRank Rank>
71 using Hessian = dealii::Tensor<int(Rank) + 2, dim, ScalarValue>;
72
73 template <TensorRank Rank>
74 using FEEval =
75 dealii::FEEvaluation<dim,
76 degree,
77 degree + 1,
78 dealii::Tensor<int(Rank), dim>::n_independent_components,
79 number,
81
85 template <typename ValType>
86 static constexpr TensorRank RankFromVal = []() constexpr
87 {
88 if constexpr (std::is_same_v<ValType, ScalarValue>)
89 {
90 return TensorRank::Scalar;
91 }
92 else if constexpr (std::is_same_v<ValType, ScalarValue::value_type>)
93 {
94 return TensorRank::Scalar;
95 }
96 else
97 {
98 return TensorRank(ValType::rank);
99 }
100 }();
101
105 template <typename GradType>
106 static constexpr TensorRank RankFromGrad = []() constexpr
107 {
108 if constexpr (std::is_same_v<GradType, ScalarValue>)
109 {
110 return TensorRank::Scalar;
111 }
112 else
113 {
114 return TensorRank(GradType::rank - 1);
115 }
116 }();
117
122 template <TensorRank Rank>
124 {
128 using FEEDepPair = std::pair<FEEval<Rank>, EvalFlags>;
129
134 using FEEDepPairPtr = std::shared_ptr<FEEDepPair>;
135
140
145
149 std::vector<FEEDepPairPtr> fe_eval_old;
150
155 EvalFlags integration_flags = EvalFlags::nothing;
156
164
172 unsigned int block_index = -1;
173
177 FEEValuationDeps() = default;
178
180 const Dependency &dependency,
181 const std::pair<const SolutionLevel<dim, number> *, unsigned int> &mf_id_pair,
182 bool is_dst);
183
184 template <DependencyType type>
185 const FEEval<Rank> &
186 get() const;
187
188 template <DependencyType type>
191
192 const FEEval<Rank> &
193 get(DependencyType type) const;
194
196 get(DependencyType type);
197
198 void
199 reinit(unsigned int cell);
200
201 void
202 eval(const BlockVector<number> *_src_solutions);
203
204 void
205 reinit_and_eval(unsigned int cell, const BlockVector<number> *_src_solutions);
206
207 void
208 integrate();
209
210 void
211 distribute(BlockVector<number> *dst_solutions);
212
213 void
215 };
216
229 FieldContainer(const std::vector<FieldAttributes> &_field_attributes,
230 const SolutionIndexer<dim, number> &_solution_indexer,
231 unsigned int _relative_level,
232 const DependencyMap &dependency_map,
233 const SolveGroup &_solve_group,
234 const MatrixFree<dim, number> &matrix_free);
235
239 void
240 reinit(unsigned int cell);
241
246 void
247 eval(const BlockVector<number> *src_solutions);
248
255 void
256 reinit_and_eval(unsigned int cell, const BlockVector<number> *src_solutions);
257
261 void
262 integrate();
263
267 void
268 distribute(BlockVector<number> *dst_solutions);
269
275 void
277
281 void
282 set_q_point(unsigned int q);
283
287 template <TensorRank Rank, DependencyType type>
288 [[nodiscard]] Value<Rank>
289 get_value(Types::Index global_variable_index) const;
290
294 template <TensorRank Rank>
295 [[nodiscard]] Value<Rank>
296 get_value(Types::Index global_variable_index, DependencyType type) const;
297
301 template <TensorRank Rank, DependencyType type>
302 [[nodiscard]] Gradient<Rank>
303 get_gradient(Types::Index global_variable_index) const;
304
308 template <TensorRank Rank>
309 [[nodiscard]] Gradient<Rank>
310 get_gradient(Types::Index global_variable_index, DependencyType type) const;
311
315 template <TensorRank Rank, DependencyType type>
316 [[nodiscard]] Hessian<Rank>
317 get_hessian(Types::Index global_variable_index) const;
318
322 template <TensorRank Rank>
323 [[nodiscard]] Hessian<Rank>
324 get_hessian(Types::Index global_variable_index, DependencyType type) const;
325
329 template <TensorRank Rank, DependencyType type>
330 [[nodiscard]] Gradient<Rank>
331 get_hessian_diagonal(Types::Index global_variable_index) const;
332
336 template <TensorRank Rank>
337 [[nodiscard]] Gradient<Rank>
338 get_hessian_diagonal(Types::Index global_variable_index, DependencyType type) const;
339
343 template <TensorRank Rank, DependencyType type>
344 [[nodiscard]] Value<Rank>
345 get_laplacian(Types::Index global_variable_index) const;
346
350 template <TensorRank Rank>
351 [[nodiscard]] Value<Rank>
352 get_laplacian(Types::Index global_variable_index, DependencyType type) const;
353
357 template <TensorRank Rank, DependencyType type>
358 [[nodiscard]] ScalarValue
359 get_divergence(Types::Index global_variable_index) const;
360
364 template <TensorRank Rank>
365 [[nodiscard]] ScalarValue
366 get_divergence(Types::Index global_variable_index, DependencyType type) const;
367
371 template <TensorRank Rank, DependencyType type>
372 [[nodiscard]] dealii::SymmetricTensor<2, dim, ScalarValue>
373 get_symmetric_gradient(Types::Index global_variable_index) const;
374
378 template <TensorRank Rank>
379 [[nodiscard]] dealii::SymmetricTensor<2, dim, ScalarValue>
380 get_symmetric_gradient(Types::Index global_variable_index, DependencyType type) const;
381
385 template <TensorRank Rank, DependencyType type>
386 [[nodiscard]] dealii::Tensor<1, (dim == 2 ? 1 : dim), ScalarValue>
387 get_curl(Types::Index global_variable_index) const;
388
392 template <TensorRank Rank>
393 [[nodiscard]] dealii::Tensor<1, (dim == 2 ? 1 : dim), ScalarValue>
394 get_curl(Types::Index global_variable_index, DependencyType type) const;
395
399 [[nodiscard]] dealii::Point<dim, ScalarValue>
400 get_q_point_location() const;
401
405 [[nodiscard]] ScalarValue
406 get_element_volume() const;
407
411 [[nodiscard]] unsigned int
412 get_n_q_points() const;
413
417 template <typename ValType>
418 void
419 set_value_term(Types::Index global_variable_index, const ValType &val);
420
424 template <typename GradType>
425 void
426 set_gradient_term(Types::Index global_variable_index, const GradType &val);
427
428private:
429 template <TensorRank Rank>
430 std::vector<FEEValuationDeps<Rank>> &
432
433 template <TensorRank Rank>
434 const std::vector<FEEValuationDeps<Rank>> &
436
441 void
442 feevaluation_size_valid(Types::Index field_index) const;
443
448 void
449 feevaluation_exists(Types::Index field_index, Types::Index dependency_index) const;
450
455 void
456 access_valid(Types::Index field_index,
457 DependencyType dependency_type,
458 dealii::EvaluationFlags::EvaluationFlags flag) const;
459
463 void
464 submission_valid(Types::Index field_index, DependencyType dependency_type) const;
465
469 const std::vector<FieldAttributes> *field_attributes_ptr;
470
475
479 std::vector<FEEValuationDeps<TensorRank::Scalar>> feeval_deps_scalar;
480
484 std::vector<FEEValuationDeps<TensorRank::Vector>> feeval_deps_vector;
485
490
501
505 unsigned int relative_level;
506
510 unsigned int q_point = 0;
511};
512
513template <unsigned int dim, unsigned int degree, typename number>
514template <TensorRank Rank>
516 const Dependency &dependency,
517 const std::pair<const SolutionLevel<dim, number> *, unsigned int> &mf_id_pair,
518 bool is_dst)
519 : solution_level(mf_id_pair.first)
520 , block_index(mf_id_pair.second)
521{
522 // Make an FEEvaluation if the current solution needs to be evaluated
523 if (dependency.flag)
524 {
525 fe_eval = std::make_shared<FEEDepPair>(FEEval<Rank>(solution_level->matrix_free,
527 dependency.flag);
528 }
529 // Make FEEvaluations for the the old solutions
530 fe_eval_old.resize(dependency.old_flags.size(), nullptr);
531 for (unsigned int age = 0; age < dependency.old_flags.size(); ++age)
532 {
533 if (dependency.old_flags.at(age)) // kinda redundant... maybe remove?
534 {
535 fe_eval_old[age] =
536 std::make_shared<FEEDepPair>(FEEval<Rank>(solution_level->matrix_free,
538 dependency.old_flags.at(age));
539 }
540 }
541 if (dependency.src_flag || is_dst)
542 {
544 std::make_shared<FEEDepPair>(FEEval<Rank>(solution_level->matrix_free,
546 dependency.src_flag);
547 }
548}
549
550template <unsigned int dim, unsigned int degree, typename number>
551template <TensorRank Rank>
552template <DependencyType Type>
553inline DEAL_II_ALWAYS_INLINE const typename FieldContainer<dim, degree, number>::
554 template FEEval<Rank> &
556{
557 // TODO: Assertions
558 if constexpr (Type == DependencyType::SRC || Type == DependencyType::DST)
559 {
560 return fe_eval_src_dst->first;
561 }
562 else if constexpr (Type == DependencyType::Current)
563 {
564 return fe_eval->first;
565 }
566 else
567 {
568 return fe_eval_old[int(Type) - 1]->first;
569 }
570}
571
572template <unsigned int dim, unsigned int degree, typename number>
573template <TensorRank Rank>
574template <DependencyType Type>
575inline DEAL_II_ALWAYS_INLINE
578{
579 // TODO: Assertions
580 if constexpr (Type == DependencyType::SRC || Type == DependencyType::DST)
581 {
582 return fe_eval_src_dst->first;
583 }
584 else if constexpr (Type == DependencyType::Current)
585 {
586 return fe_eval->first;
587 }
588 else
589 {
590 return fe_eval_old[int(Type) - 1]->first;
591 }
592}
593
594template <unsigned int dim, unsigned int degree, typename number>
595template <TensorRank Rank>
596inline DEAL_II_ALWAYS_INLINE const typename FieldContainer<dim, degree, number>::
597 template FEEval<Rank> &
599 DependencyType type) const
600{
601 // TODO: Assertions
602 if (type == DependencyType::SRC || type == DependencyType::DST)
603 {
604 return fe_eval_src_dst->first;
605 }
606 if (type == DependencyType::Current)
607 {
608 return fe_eval->first;
609 }
610 {
611 return fe_eval_old[type - 1]->first;
612 }
613}
614
615template <unsigned int dim, unsigned int degree, typename number>
616template <TensorRank Rank>
617inline DEAL_II_ALWAYS_INLINE
620{
621 // TODO: Assertions
622 if (type == DependencyType::SRC || type == DependencyType::DST)
623 {
624 return fe_eval_src_dst->first;
625 }
626 if (type == DependencyType::Current)
627 {
628 return fe_eval->first;
629 }
630 {
631 return fe_eval_old[type - 1]->first;
632 }
633}
634
635template <unsigned int dim, unsigned int degree, typename number>
636template <TensorRank Rank>
637inline void
639{
640 if (fe_eval)
641 {
642 fe_eval->first.reinit(cell);
643 }
644 for (auto &old_fe_eval : fe_eval_old)
645 {
646 if (old_fe_eval)
647 {
648 old_fe_eval->first.reinit(cell);
649 }
650 }
651 if (fe_eval_src_dst)
652 {
653 fe_eval_src_dst->first.reinit(cell);
654 }
655}
656
657template <unsigned int dim, unsigned int degree, typename number>
658template <TensorRank Rank>
659inline void
661 const BlockVector<number> *_src_solutions)
662{
663 // NOTE: `read_dof_values_plain` must be called here so that constraints aren't
664 // implicitly applied. This allows us to have inhomogeneous constraints.
665 if (fe_eval)
666 {
667 fe_eval->first.read_dof_values_plain(solution_level->solutions.block(block_index));
668 fe_eval->first.evaluate(fe_eval->second);
669 }
670 for (unsigned int age = 0; age < fe_eval_old.size(); ++age)
671 {
672 if (FEEDepPairPtr &old_fe_eval = fe_eval_old[age])
673 {
674 old_fe_eval->first.read_dof_values_plain(
675 solution_level->old_solutions[age].block(block_index));
676 old_fe_eval->first.evaluate(old_fe_eval->second);
677 }
678 }
679 if (fe_eval_src_dst && fe_eval_src_dst->second != EvalFlags::nothing)
680 {
681 fe_eval_src_dst->first.read_dof_values_plain(_src_solutions->block(block_index));
682 fe_eval_src_dst->first.evaluate(fe_eval_src_dst->second);
683 }
684}
685
686template <unsigned int dim, unsigned int degree, typename number>
687template <TensorRank Rank>
688inline void
690 unsigned int cell,
691 const BlockVector<number> *_src_solutions)
692{
693 // NOTE: `read_dof_values_plain` must be called here so that constraints aren't
694 // implicitly applied. This allows us to have inhomogeneous constraints.
695 if (fe_eval)
696 {
697 fe_eval->first.reinit(cell);
698 fe_eval->first.read_dof_values_plain(solution_level->solutions.block(block_index));
699 fe_eval->first.evaluate(fe_eval->second);
700 }
701 for (unsigned int age = 0; age < fe_eval_old.size(); ++age)
702 {
703 if (FEEDepPairPtr &old_fe_eval = fe_eval_old[age])
704 {
705 old_fe_eval->first.reinit(cell);
706 old_fe_eval->first.read_dof_values_plain(
707 solution_level->old_solutions[age].block(block_index));
708 old_fe_eval->first.evaluate(old_fe_eval->second);
709 }
710 }
711 if (fe_eval_src_dst)
712 {
713 fe_eval_src_dst->first.reinit(cell);
714 if (fe_eval_src_dst->second != EvalFlags::nothing)
715 {
716 fe_eval_src_dst->first.read_dof_values_plain(
717 _src_solutions->block(block_index));
718 fe_eval_src_dst->first.evaluate(fe_eval_src_dst->second);
719 }
720 }
721}
722
723template <unsigned int dim, unsigned int degree, typename number>
724template <TensorRank Rank>
725inline void
727{
728 if (fe_eval_src_dst)
729 {
730 fe_eval_src_dst->first.integrate(integration_flags);
731 }
732}
733
734template <unsigned int dim, unsigned int degree, typename number>
735template <TensorRank Rank>
736inline void
738 BlockVector<number> *dst_solutions)
739{
740 if (fe_eval_src_dst)
741 {
742 fe_eval_src_dst->first.distribute_local_to_global(
743 dst_solutions->block(block_index));
744 }
745}
746
747template <unsigned int dim, unsigned int degree, typename number>
748template <TensorRank Rank>
749inline void
751 BlockVector<number> *dst_solutions)
752{
753 if (fe_eval_src_dst)
754 {
755 fe_eval_src_dst->first.integrate_scatter(integration_flags,
756 dst_solutions->block(block_index));
757 }
758}
759
760template <unsigned int dim, unsigned int degree, typename number>
761inline void
763{
764 for (auto &fe_eval : feeval_deps_scalar)
765 {
766 fe_eval.reinit(cell);
767 }
768 for (auto &fe_eval : feeval_deps_vector)
769 {
770 fe_eval.reinit(cell);
771 }
772 shared_feeval_scalar.reinit(cell);
773}
774
775template <unsigned int dim, unsigned int degree, typename number>
776inline void
778{
779 for (auto &fe_eval : feeval_deps_scalar)
780 {
781 fe_eval.eval(src_solutions);
782 }
783 for (auto &fe_eval : feeval_deps_vector)
784 {
785 fe_eval.eval(src_solutions);
786 }
787 // Don't eval `shared_feeval_scalar` because we only use it for information.
788}
789
790template <unsigned int dim, unsigned int degree, typename number>
791inline void
793 unsigned int cell,
794 const BlockVector<number> *src_solutions)
795{
796 for (auto &fe_eval : feeval_deps_scalar)
797 {
798 fe_eval.reinit_and_eval(cell, src_solutions);
799 }
800 for (auto &fe_eval : feeval_deps_vector)
801 {
802 fe_eval.reinit_and_eval(cell, src_solutions);
803 }
804 // Don't eval `shared_feeval_scalar` because we only use it for information.
805 shared_feeval_scalar.reinit(cell);
806}
807
808template <unsigned int dim, unsigned int degree, typename number>
809inline void
811{
812 const std::vector<FieldAttributes> &field_attributes = *field_attributes_ptr;
813 for (const Types::Index &field_index : solve_group->field_indices)
814 {
815 if (field_attributes[field_index].field_type == TensorRank::Scalar)
816 {
817 feeval_deps_scalar[field_index].integrate();
818 }
819 else /* vector */
820 {
821 feeval_deps_vector[field_index].integrate();
822 }
823 }
824 // Don't integrate `shared_feeval_scalar` because we only use it for information.
825}
826
827template <unsigned int dim, unsigned int degree, typename number>
828inline void
830{
831 const std::vector<FieldAttributes> &field_attributes = *field_attributes_ptr;
832 for (const Types::Index &field_index : solve_group->field_indices)
833 {
834 if (field_attributes[field_index].field_type == TensorRank::Scalar)
835 {
836 feeval_deps_scalar[field_index].distribute(dst_solutions);
837 }
838 else /* vector */
839 {
840 feeval_deps_vector[field_index].distribute(dst_solutions);
841 }
842 }
843 // Don't distribute `shared_feeval_scalar` because we only use it for information.
844}
845
846template <unsigned int dim, unsigned int degree, typename number>
847inline void
849 BlockVector<number> *dst_solutions)
850{
851 const std::vector<FieldAttributes> &field_attributes = *field_attributes_ptr;
852 for (const Types::Index &field_index : solve_group->field_indices)
853 {
854 if (field_attributes[field_index].field_type == TensorRank::Scalar)
855 {
856 feeval_deps_scalar[field_index].integrate_and_distribute(dst_solutions);
857 }
858 else /* vector */
859 {
860 feeval_deps_vector[field_index].integrate_and_distribute(dst_solutions);
861 }
862 }
863 // Don't integrate and distribute `shared_feeval_scalar` because we only use it for
864 // information.
865}
866
867template <unsigned int dim, unsigned int degree, typename number>
868inline DEAL_II_ALWAYS_INLINE void
873
874template <unsigned int dim, unsigned int degree, typename number>
875template <TensorRank Rank, DependencyType type>
876inline DEAL_II_ALWAYS_INLINE
884
885template <unsigned int dim, unsigned int degree, typename number>
886template <TensorRank Rank>
895
896template <unsigned int dim, unsigned int degree, typename number>
897template <TensorRank Rank, DependencyType type>
907
908template <unsigned int dim, unsigned int degree, typename number>
909template <TensorRank Rank>
918
919template <unsigned int dim, unsigned int degree, typename number>
920template <TensorRank Rank, DependencyType type>
930
931template <unsigned int dim, unsigned int degree, typename number>
932template <TensorRank Rank>
941
942template <unsigned int dim, unsigned int degree, typename number>
943template <TensorRank Rank, DependencyType type>
953
954template <unsigned int dim, unsigned int degree, typename number>
955template <TensorRank Rank>
966
967template <unsigned int dim, unsigned int degree, typename number>
968template <TensorRank Rank, DependencyType type>
978
979template <unsigned int dim, unsigned int degree, typename number>
980template <TensorRank Rank>
990
991template <unsigned int dim, unsigned int degree, typename number>
992template <TensorRank Rank, DependencyType type>
996{
997 static_assert(Rank == 1, "Divergences are only available for vector fields");
999 .template get<type>()
1000 .get_divergence(q_point);
1001}
1002
1003template <unsigned int dim, unsigned int degree, typename number>
1004template <TensorRank Rank>
1007 DependencyType type) const
1008{
1009 static_assert(Rank == 1, "Divergences are only available for vector fields");
1011 .get(type)
1012 .get_divergence(q_point);
1013}
1014
1015template <unsigned int dim, unsigned int degree, typename number>
1016template <TensorRank Rank, DependencyType type>
1017inline DEAL_II_ALWAYS_INLINE dealii::
1018 SymmetricTensor<2, dim, typename FieldContainer<dim, degree, number>::ScalarValue>
1021{
1022 static_assert(Rank == 1, "Symmetric gradients are only available for vector fields");
1024 .template get<type>()
1025 .get_symmetric_gradient(q_point);
1026}
1027
1028template <unsigned int dim, unsigned int degree, typename number>
1029template <TensorRank Rank>
1030inline DEAL_II_ALWAYS_INLINE dealii::
1031 SymmetricTensor<2, dim, typename FieldContainer<dim, degree, number>::ScalarValue>
1034 DependencyType type) const
1035{
1036 static_assert(Rank == 1, "Symmetric gradients are only available for vector fields");
1038 .get(type)
1039 .get_symmetric_gradient(q_point);
1040}
1041
1042template <unsigned int dim, unsigned int degree, typename number>
1043template <TensorRank Rank, DependencyType type>
1045 dealii::Tensor<1,
1046 (dim == 2 ? 1 : dim),
1049{
1050 static_assert(Rank == 1, "Curl is only available for vector fields");
1051 Assert(dim > 1,
1052 dealii::ExcMessage(
1053 "Curl is only available for vector fields with dimension greater than 1."));
1055 .template get<type>()
1056 .get_curl(q_point);
1057}
1058
1059template <unsigned int dim, unsigned int degree, typename number>
1060template <TensorRank Rank>
1062 dealii::Tensor<1,
1063 (dim == 2 ? 1 : dim),
1066 DependencyType type) const
1067{
1068 static_assert(Rank == 1, "Curl is only available for vector fields");
1069 Assert(dim > 1,
1070 dealii::ExcMessage(
1071 "Curl is only available for vector fields with dimension greater than 1."));
1072 return get_relevant_feeval_vector<Rank>()[global_variable_index].get(type).get_curl(
1073 q_point);
1074}
1075
1076template <unsigned int dim, unsigned int degree, typename number>
1078 dealii::Point<dim, typename FieldContainer<dim, degree, number>::ScalarValue>
1083
1084template <unsigned int dim, unsigned int degree, typename number>
1091
1092template <unsigned int dim, unsigned int degree, typename number>
1093inline DEAL_II_ALWAYS_INLINE unsigned int
1098
1099template <unsigned int dim, unsigned int degree, typename number>
1100template <typename ValType>
1101inline DEAL_II_ALWAYS_INLINE void
1110
1111template <unsigned int dim, unsigned int degree, typename number>
1112template <typename GradType>
1113inline DEAL_II_ALWAYS_INLINE void
1123
1124template <unsigned int dim, unsigned int degree, typename number>
1125template <TensorRank Rank>
1126inline DEAL_II_ALWAYS_INLINE std::vector<
1129{
1130 if constexpr (Rank == TensorRank::Scalar)
1131 {
1132 return feeval_deps_scalar;
1133 }
1134 else if constexpr (Rank == TensorRank::Vector)
1135 {
1136 return feeval_deps_vector;
1137 }
1138}
1139
1140template <unsigned int dim, unsigned int degree, typename number>
1141template <TensorRank Rank>
1142inline DEAL_II_ALWAYS_INLINE const std::vector<
1145{
1146 if constexpr (Rank == TensorRank::Scalar)
1147 {
1148 return feeval_deps_scalar;
1149 }
1150 else if constexpr (Rank == TensorRank::Vector)
1151 {
1152 return feeval_deps_vector;
1153 }
1154}
1155
1156template <unsigned int dim, unsigned int degree, typename number>
1157inline DEAL_II_ALWAYS_INLINE void
1163
1164template <unsigned int dim, unsigned int degree, typename number>
1165inline DEAL_II_ALWAYS_INLINE void
1172
1173template <unsigned int dim, unsigned int degree, typename number>
1174inline DEAL_II_ALWAYS_INLINE void
1176 [[maybe_unused]] Types::Index field_index,
1178 [[maybe_unused]] dealii::EvaluationFlags::EvaluationFlags flag) const
1179{
1180 // TODO
1181}
1182
1183template <unsigned int dim, unsigned int degree, typename number>
1184inline DEAL_II_ALWAYS_INLINE void
1191
This class permits the access of a subset of indexed fields and gives an error if any non-allowed fie...
Definition field_container.h:50
dealii::SymmetricTensor< 2, dim, ScalarValue > get_symmetric_gradient(Types::Index global_variable_index, DependencyType type) const
Return the symmetric gradient of the specified field.
std::vector< FEEValuationDeps< Rank > > & get_relevant_feeval_vector()
dealii::Tensor< int(Rank)+2, dim, ScalarValue > Hessian
Definition field_container.h:71
void reinit_and_eval(unsigned int cell, const BlockVector< number > *src_solutions)
Initialize based on cell, read solution vector, and evaluate based on dependency flags for all depend...
Definition field_container.h:792
void access_valid(Types::Index field_index, DependencyType dependency_type, dealii::EvaluationFlags::EvaluationFlags flag) const
Check that a variable value/gradient/hessians was marked as needed and thus properly initialized.
Definition field_container.h:1175
Gradient< Rank > get_hessian_diagonal(Types::Index global_variable_index) const
Return the diagonal of the hessian of the specified field.
Value< Rank > get_laplacian(Types::Index global_variable_index, DependencyType type) const
Return the laplacian of the specified field.
ScalarValue get_divergence(Types::Index global_variable_index) const
Return the divergence of the specified field.
Gradient< Rank > get_hessian_diagonal(Types::Index global_variable_index, DependencyType type) const
Return the diagonal of the hessian of the specified field.
void eval(const BlockVector< number > *src_solutions)
Read solution vector, and evaluate based on dependency flags for all dependencies.
Definition field_container.h:777
FEEval< TensorRank::Scalar > shared_feeval_scalar
FEEvaluation object for generic cell operations.
Definition field_container.h:500
dealii::Tensor< 1, dim, ScalarValue > VectorValue
Typedef for the basic vector that the user manipulates.
Definition field_container.h:60
unsigned int relative_level
Multigrid level.
Definition field_container.h:505
dealii::Tensor< 1,(dim==2 ? 1 :dim), ScalarValue > get_curl(Types::Index global_variable_index, DependencyType type) const
Return the curl of the specified field.
void set_q_point(unsigned int q)
Set the current quadrature point.
Definition field_container.h:869
void submission_valid(Types::Index field_index, DependencyType dependency_type) const
Check that a value is valid for submission.
Definition field_container.h:1185
unsigned int q_point
The quadrature point.
Definition field_container.h:510
Value< Rank > get_value(Types::Index global_variable_index, DependencyType type) const
Return the value of the specified field.
dealii::Tensor< int(Rank)+1, dim, ScalarValue > Gradient
Definition field_container.h:68
dealii::VectorizedArray< number > ScalarValue
Typedef for the basic value that the user manipulates.
Definition field_container.h:55
void integrate()
Integrate the residuals.
Definition field_container.h:810
ScalarValue get_divergence(Types::Index global_variable_index, DependencyType type) const
Return the divergence of the specified field.
std::vector< FEEValuationDeps< TensorRank::Vector > > feeval_deps_vector
Collection of FEEvaluation dependencies for vector fields.
Definition field_container.h:484
const std::vector< FEEValuationDeps< Rank > > & get_relevant_feeval_vector() const
Hessian< Rank > get_hessian(Types::Index global_variable_index, DependencyType type) const
Return the hessian of the specified field.
static constexpr TensorRank RankFromVal
Return the tensor rank from the specified template value.
Definition field_container.h:86
void distribute(BlockVector< number > *dst_solutions)
Distribute the integrated residuals.
Definition field_container.h:829
void reinit(unsigned int cell)
Initialize based on cell for all dependencies.
Definition field_container.h:762
Value< Rank > get_value(Types::Index global_variable_index) const
Return the value of the specified field.
std::vector< FEEValuationDeps< TensorRank::Scalar > > feeval_deps_scalar
Collection of FEEvaluation dependencies for scalar fields.
Definition field_container.h:479
void feevaluation_exists(Types::Index field_index, Types::Index dependency_index) const
Check whether the entry for the FEEvaluation is within the bounds of the vector and not a nullptr.
Definition field_container.h:1166
void integrate_and_distribute(BlockVector< number > *dst_solutions)
Integrate the residuals and distribute from local to global.
Definition field_container.h:848
const std::vector< FieldAttributes > * field_attributes_ptr
Pointer to the vector of field attributes.
Definition field_container.h:469
dealii::SymmetricTensor< 2, dim, ScalarValue > get_symmetric_gradient(Types::Index global_variable_index) const
Return the symmetric gradient of the specified field.
const SolveGroup * solve_group
Solve group information.
Definition field_container.h:489
unsigned int get_n_q_points() const
Return the number of quadrature points.
Definition field_container.h:1094
void set_value_term(Types::Index global_variable_index, const ValType &val)
Set the residual value of the specified scalar/vector field.
dealii::Point< dim, ScalarValue > get_q_point_location() const
Return the quadrature point location.
Definition field_container.h:1079
Hessian< Rank > get_hessian(Types::Index global_variable_index) const
Return the hessian of the specified field.
ScalarValue get_element_volume() const
Return the quadrature point location.
Definition field_container.h:1086
static constexpr TensorRank RankFromGrad
Return the tensor rank from the specified template gradient.
Definition field_container.h:106
Gradient< Rank > get_gradient(Types::Index global_variable_index) const
Return the gradient of the specified field.
void set_gradient_term(Types::Index global_variable_index, const GradType &val)
Set the residual gradient of the specified scalar/vector field.
std::conditional_t< Rank==TensorRank::Scalar, ScalarValue, dealii::Tensor< int(Rank), dim, ScalarValue > > Value
Definition field_container.h:65
const SolutionIndexer< dim, number > * solution_indexer
Pointer to the solution indexer.
Definition field_container.h:474
Value< Rank > get_laplacian(Types::Index global_variable_index) const
Return the laplacian of the specified field.
Gradient< Rank > get_gradient(Types::Index global_variable_index, DependencyType type) const
Return the gradient of the specified field.
dealii::Tensor< 1,(dim==2 ? 1 :dim), ScalarValue > get_curl(Types::Index global_variable_index) const
Return the curl of the specified field.
dealii::FEEvaluation< dim, degree, degree+1, dealii::Tensor< int(Rank), dim >::n_independent_components, number, ScalarValue > FEEval
Definition field_container.h:80
void feevaluation_size_valid(Types::Index field_index) const
Check whether the entry for the FEEvaluation is within the bounds of the vector.
Definition field_container.h:1158
Class that provides access to solution vectors spread across different groups.
Definition solution_indexer.h:20
Structure to hold the attributes of a solve-group.
Definition solve_group.h:59
std::set< Types::Index > field_indices
Indices of the fields to be solved in this group.
Definition solve_group.h:98
This is the main class that handles the construction and solving of user-specified PDEs.
Definition system_wide.h:24
std::map< Types::Index, Dependency > DependencyMap
Definition dependencies.h:129
dealii::LinearAlgebra::distributed::BlockVector< number > BlockVector
Typedef for solution block vector.
Definition group_solution_handler.h:29
Definition conditional_ostreams.cc:20
unsigned int Index
Type for field indices.
Definition types.h:19
Type
Factory function to create appropriate reader based on input file type not a member of ReadFieldBase ...
Definition read_field_factory.h:30
Dependency struct containing evaluation flags for each field.
Definition dependencies.h:30
EvalFlags src_flag
Evaluation flags for the DependencyType::SRC solution.
Definition dependencies.h:42
std::vector< EvalFlags > old_flags
Collection of evaluation flags for the old solutions.
Definition dependencies.h:47
EvalFlags flag
Evaluation flags for the current solution.
Definition dependencies.h:36
Struct to hold the relevant dealii::FEEvaluation for a given solution block index.
Definition field_container.h:124
FEEDepPairPtr fe_eval_src_dst
FEEvaluation for the src and dst solutions.
Definition field_container.h:144
void eval(const BlockVector< number > *_src_solutions)
Definition field_container.h:660
void reinit_and_eval(unsigned int cell, const BlockVector< number > *_src_solutions)
Definition field_container.h:689
void integrate()
Definition field_container.h:726
std::shared_ptr< FEEDepPair > FEEDepPairPtr
Pointer the the FEEDepPair. We have to use ptrs because we don't want to construct fields we don't ne...
Definition field_container.h:134
const FEEval< Rank > & get() const
EvalFlags integration_flags
Destination integration flags. We use this to integrate value and gradient terms, if they exist.
Definition field_container.h:155
void distribute(BlockVector< number > *dst_solutions)
Definition field_container.h:737
void reinit(unsigned int cell)
Definition field_container.h:638
FEEDepPairPtr fe_eval
FEEvaluation for the current solution.
Definition field_container.h:139
FEEValuationDeps()=default
Default constructor.
std::vector< FEEDepPairPtr > fe_eval_old
Collection of FEEvaluation for old solutions (< n -1 state).
Definition field_container.h:149
void integrate_and_distribute(BlockVector< number > *dst_solutions)
Definition field_container.h:750
const SolutionLevel< dim, number > * solution_level
The solution group.
Definition field_container.h:163
std::pair< FEEval< Rank >, EvalFlags > FEEDepPair
dealii::FEEvaluation object and the evaluation flags.
Definition field_container.h:128
unsigned int block_index
The solution block index.
Definition field_container.h:172
The solution vectors and their corresponding matrix free object with respect to some multigrid level.
Definition group_solution_handler.h:61
DependencyType
Internal classification for types of variable dependencies.
Definition type_enums.h:51
@ Current
Definition type_enums.h:58
@ DST
Definition type_enums.h:52
@ SRC
Definition type_enums.h:53
TensorRank
Tensor rank of the field.
Definition type_enums.h:30
@ Vector
Definition type_enums.h:33
@ Scalar
Definition type_enums.h:32
dealii::EvaluationFlags::EvaluationFlags EvalFlags
Definition types.h:86