https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MooseFunctor.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include <tuple>
13
14#include "MooseFunctorForward.h"
16#include "FaceArgInterface.h"
17#include "MooseMesh.h"
18#include "MooseTypes.h"
19#include "MooseError.h"
20#include "MooseUtils.h"
21
22#include "libmesh/remote_elem.h"
23#include "libmesh/tensor_tools.h"
24
25#include "metaphysicl/ct_types.h"
26
27#include <unordered_map>
28#include <functional>
29
30namespace Moose
31{
37{
38 Value,
40 Dot,
42};
43
48template <typename, FunctorEvaluationKind>
50
54template <typename T>
56{
57 typedef T type;
58};
59
66template <typename T>
68{
69 typedef typename MetaPhysicL::ReplaceAlgebraicType<
70 T,
72 typename MetaPhysicL::ValueType<T>::type>::type>::type type;
73};
74
78template <typename T>
80{
81 typedef T type;
82};
83
87template <typename T>
92
97template <FunctorEvaluationKind>
99
103template <>
108
112template <>
117
122{
123public:
124 virtual void residualSetup() = 0;
125 virtual void jacobianSetup() = 0;
126 virtual void timestepSetup() = 0;
127 virtual void customSetup(const ExecFlagType & exec_type) = 0;
128};
129
136template <typename T>
138{
139public:
141 using ValueType = T;
151
152 virtual ~FunctorBase() = default;
153 FunctorBase(const MooseFunctorName & name,
154 const std::set<ExecFlagType> & clearance_schedule = {EXEC_ALWAYS})
155 : _always_evaluate(true), _functor_name(name)
156 {
157 setCacheClearanceSchedule(clearance_schedule);
158 }
159
160#ifdef MOOSE_KOKKOS_ENABLED
165#endif
166
171 template <FunctorEvaluationKind FET, typename Space, typename State>
173 const State & state) const;
174
176 const MooseFunctorName & functorName() const { return _functor_name; }
177
179
183 ValueType operator()(const ElemArg & elem, const StateArg & state) const;
184 ValueType operator()(const FaceArg & face, const StateArg & state) const;
185 ValueType operator()(const ElemQpArg & qp, const StateArg & state) const;
186 ValueType operator()(const ElemSideQpArg & qp, const StateArg & state) const;
187 ValueType operator()(const ElemPointArg & elem_point, const StateArg & state) const;
188 ValueType operator()(const NodeArg & node, const StateArg & state) const;
189 ValueType operator()(const PointArg & point, const StateArg & state) const;
191
193
197 GradientType gradient(const ElemArg & elem, const StateArg & state) const;
198 GradientType gradient(const FaceArg & face, const StateArg & state) const;
199 GradientType gradient(const ElemQpArg & qp, const StateArg & state) const;
200 GradientType gradient(const ElemSideQpArg & qp, const StateArg & state) const;
201 GradientType gradient(const ElemPointArg & elem_point, const StateArg & state) const;
202 GradientType gradient(const NodeArg & node, const StateArg & state) const;
203 GradientType gradient(const PointArg & point, const StateArg & state) const;
205
207
211 DotType dot(const ElemArg & elem, const StateArg & state) const;
212 DotType dot(const FaceArg & face, const StateArg & state) const;
213 DotType dot(const ElemQpArg & qp, const StateArg & state) const;
214 DotType dot(const ElemSideQpArg & qp, const StateArg & state) const;
215 DotType dot(const ElemPointArg & elem_point, const StateArg & state) const;
216 DotType dot(const NodeArg & node, const StateArg & state) const;
217 DotType dot(const PointArg & point, const StateArg & state) const;
219
221
225 GradientType gradDot(const ElemArg & elem, const StateArg & state) const;
226 GradientType gradDot(const FaceArg & face, const StateArg & state) const;
227 GradientType gradDot(const ElemQpArg & qp, const StateArg & state) const;
228 GradientType gradDot(const ElemSideQpArg & qp, const StateArg & state) const;
229 GradientType gradDot(const ElemPointArg & elem_point, const StateArg & state) const;
230 GradientType gradDot(const NodeArg & node, const StateArg & state) const;
231 GradientType gradDot(const PointArg & point, const StateArg & state) const;
233
234 virtual void residualSetup() override;
235 virtual void jacobianSetup() override;
236 virtual void timestepSetup() override;
237 virtual void customSetup(const ExecFlagType & exec_type) override;
238
242 void setCacheClearanceSchedule(const std::set<ExecFlagType> & clearance_schedule);
243
247 virtual bool hasBlocks(SubdomainID /* id */) const
248 {
249 mooseError("Block restriction has not been implemented for functor " + functorName());
250 return false;
251 }
252
257 virtual bool isExtrapolatedBoundaryFace(const FaceInfo &, const Elem *, const StateArg &) const
258 {
259 mooseError("not implemented");
260 }
261
265 bool isInternalFace(const FaceInfo &) const;
266
270 virtual bool isConstant() const { return false; }
271
272 virtual bool hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const override;
273
284 void checkFace(const Moose::FaceArg & face) const;
285
289 virtual bool supportsFaceArg() const = 0;
290
294 virtual bool supportsElemSideQpArg() const = 0;
295
296protected:
303
307 virtual ValueType evaluate(const ElemArg & elem, const StateArg & state) const = 0;
308
314 virtual ValueType evaluate(const FaceArg & face, const StateArg & state) const = 0;
315
321 virtual ValueType evaluate(const ElemQpArg & qp, const StateArg & state) const = 0;
322
328 virtual ValueType evaluate(const ElemSideQpArg & side_qp, const StateArg & state) const = 0;
329
334 virtual ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const = 0;
335
336 virtual ValueType evaluate(const NodeArg & node, const StateArg & state) const = 0;
337
342 virtual ValueType evaluate(const PointArg &, const StateArg &) const
343 {
344 mooseError("Evaluation at a point is not supported for functor " + functorName());
345 }
346
351 virtual GradientType evaluateGradient(const ElemArg &, const StateArg &) const
352 {
353 mooseError("Element gradient not implemented for functor " + functorName());
354 }
355
361 virtual GradientType evaluateGradient(const FaceArg &, const StateArg &) const
362 {
363 mooseError("Face gradient not implemented for functor " + functorName());
364 }
365
371 virtual GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const
372 {
373 mooseError("Element quadrature point gradient not implemented for functor " + functorName());
374 }
375
381 virtual GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const
382 {
383 mooseError("Element side quadrature point gradient not implemented for functor " +
384 functorName());
385 }
386
390 virtual GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const
391 {
392 mooseError("Element-point gradient not implemented for functor " + functorName());
393 }
394
395 virtual GradientType evaluateGradient(const NodeArg &, const StateArg &) const
396 {
397 mooseError("Gradient at node not implemented for functor " + functorName());
398 }
399
400 virtual GradientType evaluateGradient(const PointArg &, const StateArg &) const
401 {
402 mooseError("Gradient at point not implemented for functor " + functorName());
403 }
404
409 virtual DotType evaluateDot(const ElemArg &, const StateArg &) const
410 {
411 mooseError("Element time derivative not implemented for functor " + functorName());
412 }
413
419 virtual DotType evaluateDot(const FaceArg &, const StateArg &) const
420 {
421 mooseError("Face time derivative not implemented for functor " + functorName());
422 }
423
429 virtual DotType evaluateDot(const ElemQpArg &, const StateArg &) const
430 {
431 mooseError("Element quadrature point time derivative not implemented for functor " +
432 functorName());
433 }
434
440 virtual DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const
441 {
442 mooseError("Element side quadrature point time derivative not implemented for functor " +
443 functorName());
444 }
445
449 virtual DotType evaluateDot(const ElemPointArg &, const StateArg &) const
450 {
451 mooseError("Element-point time derivative not implemented for functor " + functorName());
452 }
453
454 virtual DotType evaluateDot(const NodeArg &, const StateArg &) const
455 {
456 mooseError("Time derivative at node not implemented for functor " + functorName());
457 }
458
459 virtual DotType evaluateDot(const PointArg &, const StateArg &) const
460 {
461 mooseError("Time derivative at point not implemented for functor " + functorName());
462 }
463
468 virtual GradientType evaluateGradDot(const ElemArg &, const StateArg &) const
469 {
470 mooseError("Element gradient-dot not implemented for functor " + functorName());
471 }
472
478 virtual GradientType evaluateGradDot(const FaceArg &, const StateArg &) const
479 {
480 mooseError("Face gradient-dot not implemented for functor " + functorName());
481 }
482
488 virtual GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const
489 {
490 mooseError("Element quadrature point gradient-dot not implemented for functor " +
491 functorName());
492 }
493
499 virtual GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const
500 {
501 mooseError("Element side quadrature point gradient-dot not implemented for functor " +
502 functorName());
503 }
504
508 virtual GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const
509 {
510 mooseError("Element-point gradient-dot not implemented for functor " + functorName());
511 }
512
513 virtual GradientType evaluateGradDot(const NodeArg &, const StateArg &) const
514 {
515 mooseError("Gradient-dot at node not implemented for functor " + functorName());
516 }
517
518 virtual GradientType evaluateGradDot(const PointArg &, const StateArg &) const
519 {
520 mooseError("Gradient-dot at point not implemented for functor " + functorName());
521 }
523
524private:
529
533 template <typename SpaceArg, typename StateArg>
534 ValueType queryQpCache(unsigned int qp,
535 const libMesh::QBase & qrule,
536 std::vector<std::pair<bool, T>> & qp_cache_data,
537 const SpaceArg & space,
538 const StateArg & state) const;
539
543 template <typename SpaceArg>
544 ValueType queryFVArgCache(std::map<SpaceArg, ValueType> & cache_data,
545 const SpaceArg & space) const;
546
548 std::set<ExecFlagType> _clearance_schedule;
549
552
553 // Data for traditional element-quadrature point property evaluations which are useful for
554 // caching implementation
555
558
560 mutable std::vector<std::pair<bool, ValueType>> * _current_qp_map_value = nullptr;
561
567 mutable std::unordered_map<dof_id_type, std::vector<std::pair<bool, ValueType>>> _qp_to_value;
568
569 // Data for traditional element-side-quadrature point property evaluations which are useful for
570 // caching implementation
571
574
576 mutable std::vector<std::vector<std::pair<bool, ValueType>>> * _current_side_qp_map_value =
577 nullptr;
578
585 mutable std::unordered_map<dof_id_type, std::vector<std::vector<std::pair<bool, ValueType>>>>
587
589 mutable std::map<ElemArg, ValueType> _elem_arg_to_value;
590
592 mutable std::map<FaceArg, ValueType> _face_arg_to_value;
593
595 mutable std::map<NodeArg, ValueType> _node_arg_to_value;
596
598 MooseFunctorName _functor_name;
599};
600
601template <typename T>
602bool
604{
605 if (!fi.neighborPtr())
606 return false;
607
608 return hasBlocks(fi.elem().subdomain_id()) && hasBlocks(fi.neighborPtr()->subdomain_id());
609}
610
611template <typename T>
612template <typename SpaceArg>
614FunctorBase<T>::queryFVArgCache(std::map<SpaceArg, ValueType> & cache_data,
615 const SpaceArg & space) const
616{
617 // We don't want to evaluate if the key already exists, so instead we value initialize
618 auto [it, inserted] = cache_data.try_emplace(space, ValueType());
619 auto & value = it->second;
620
621 if (inserted)
622 // value not ready to go
623 // this function is only called from functions that assert we are in the current time state
624 value = evaluate(space, currentState());
625
626 return value;
627}
628
629template <typename T>
631FunctorBase<T>::operator()(const ElemArg & elem, const StateArg & state) const
632{
633 if (_always_evaluate)
634 return evaluate(elem, state);
635
636 mooseAssert(state.state == 0,
637 "Cached evaluations are only currently supported for the current state.");
638
639 return queryFVArgCache(_elem_arg_to_value, elem);
640}
641
642template <typename T>
644FunctorBase<T>::operator()(const FaceArg & face_in, const StateArg & state) const
645{
646 checkFace(face_in);
647
648 if (_always_evaluate)
649 return evaluate(face_in, state);
650
651 mooseAssert(state.state == 0,
652 "Cached evaluations are only currently supported for the current state.");
653
654 return queryFVArgCache(_face_arg_to_value, face_in);
655}
656
657template <typename T>
658template <typename SpaceArg, typename StateArg>
660FunctorBase<T>::queryQpCache(const unsigned int qp,
661 const libMesh::QBase & qrule,
662 std::vector<std::pair<bool, ValueType>> & qp_cache_data,
663 const SpaceArg & space,
664 const StateArg & state) const
665{
666 // Check and see whether we even have sized for this quadrature point. If we haven't then we
667 // must evaluate
668 if (qp >= qp_cache_data.size())
669 {
670 qp_cache_data.resize(qrule.n_points(), std::make_pair(false, ValueType()));
671 auto & pr = qp_cache_data[qp];
672 pr.second = evaluate(space, state);
673 pr.first = true;
674 return pr.second;
675 }
676
677 // We've already sized for this qp, so let's see whether we have a valid cache value
678 auto & pr = qp_cache_data[qp];
679 if (pr.first)
680 return pr.second;
681
682 // No valid cache value so evaluate
683 pr.second = evaluate(space, state);
684 pr.first = true;
685 return pr.second;
686}
687
688template <typename T>
690FunctorBase<T>::operator()(const ElemQpArg & elem_qp, const StateArg & state) const
691{
692 if (_always_evaluate)
693 return evaluate(elem_qp, state);
694
695 const auto elem_id = elem_qp.elem->id();
696 if (elem_id != _current_qp_map_key)
697 {
698 _current_qp_map_key = elem_id;
699 _current_qp_map_value = &_qp_to_value[elem_id];
700 }
701 auto & qp_data = *_current_qp_map_value;
702 const auto qp = elem_qp.qp;
703 const auto * const qrule = elem_qp.qrule;
704 mooseAssert(qrule, "qrule must be non-null");
705
706 return queryQpCache(qp, *qrule, qp_data, elem_qp, state);
707}
708
709template <typename T>
711FunctorBase<T>::operator()(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
712{
713 if (_always_evaluate)
714 return evaluate(elem_side_qp, state);
715
716 const Elem * const elem = elem_side_qp.elem;
717 mooseAssert(elem, "elem must be non-null");
718 const auto elem_id = elem->id();
719 if (elem_id != _current_side_qp_map_key)
720 {
721 _current_side_qp_map_key = elem_id;
722 _current_side_qp_map_value = &_side_qp_to_value[elem_id];
723 }
724 auto & side_qp_data = *_current_side_qp_map_value;
725 const auto side = elem_side_qp.side;
726 const auto qp = elem_side_qp.qp;
727 const auto * const qrule = elem_side_qp.qrule;
728 mooseAssert(qrule, "qrule must be non-null");
729
730 // Check and see whether we even have sized for this side
731 if (side >= side_qp_data.size())
732 side_qp_data.resize(elem->n_sides());
733
734 // Ok we were sized enough for our side
735 auto & qp_data = side_qp_data[side];
736 return queryQpCache(qp, *qrule, qp_data, elem_side_qp, state);
737}
738
739template <typename T>
741FunctorBase<T>::operator()(const ElemPointArg & elem_point, const StateArg & state) const
742{
743 return evaluate(elem_point, state);
744}
745
746template <typename T>
747void
748FunctorBase<T>::setCacheClearanceSchedule(const std::set<ExecFlagType> & clearance_schedule)
749{
750 if (clearance_schedule.count(EXEC_ALWAYS))
751 _always_evaluate = true;
752
753 _clearance_schedule = clearance_schedule;
754}
755
756template <typename T>
758FunctorBase<T>::operator()(const NodeArg & node, const StateArg & state) const
759{
760 mooseAssert(node.subdomain_ids, "Subdomain IDs must be supplied to the node argument");
761 return evaluate(node, state);
762}
763
764template <typename T>
766FunctorBase<T>::operator()(const PointArg & point, const StateArg & state) const
767{
768 return evaluate(point, state);
769}
770
771template <typename T>
772void
774#if DEBUG
775 face
776#endif
777) const
778{
779#if DEBUG
780 const Elem * const elem = face.face_side;
781 const FaceInfo * const fi = face.fi;
782 mooseAssert(fi, "face info should be non-null");
783 bool check_elem_def = false;
784 bool check_neighbor_def = false;
785 // We check if the functor is defined on both sides of the face
786 if (!elem)
787 {
788 if (!hasFaceSide(*fi, true))
789 check_neighbor_def = true;
790 else if (!hasFaceSide(*fi, false))
791 check_elem_def = true;
792 }
793 else if (elem == fi->elemPtr())
794 check_elem_def = true;
795 else
796 {
797 mooseAssert(elem == fi->neighborPtr(), "This has to match something");
798 check_neighbor_def = true;
799 }
800
801 if (check_elem_def && !hasFaceSide(*fi, true))
802 {
803 std::string additional_message = "It is not defined on the neighbor side either.";
804 if (hasFaceSide(*fi, false))
805 additional_message = "It is however defined on the neighbor side.";
806 additional_message += " Face centroid: " + Moose::stringify(fi->faceCentroid());
807 mooseError(_functor_name,
808 " is not defined on the element side of the face information, but a face argument "
809 "producer "
810 "(e.g. residual object, postprocessor, etc.) has requested evaluation there.\n",
811 additional_message);
812 }
813 if (check_neighbor_def && !hasFaceSide(*fi, false))
814 {
815 std::string additional_message = "It is not defined on the element side either.";
816 if (hasFaceSide(*fi, true))
817 additional_message = "It is however defined on the element side.";
818 additional_message += " Face centroid: " + Moose::stringify(fi->faceCentroid());
820 _functor_name,
821 " is not defined on the neighbor side of the face information, but a face argument "
822 "producer (e.g. residual object, postprocessor, etc.) has requested evaluation there.\n",
823 additional_message);
824 }
825#endif
826}
827
828template <typename T>
829void
831{
832 for (auto & map_pr : _qp_to_value)
833 for (auto & pr : map_pr.second)
834 pr.first = false;
835
836 for (auto & map_pr : _side_qp_to_value)
837 {
838 auto & side_vector = map_pr.second;
839 for (auto & qp_vector : side_vector)
840 for (auto & pr : qp_vector)
841 pr.first = false;
842 }
843
844 _current_qp_map_key = libMesh::DofObject::invalid_id;
845 _current_qp_map_value = nullptr;
846 _current_side_qp_map_key = libMesh::DofObject::invalid_id;
847 _current_side_qp_map_value = nullptr;
848
849 _elem_arg_to_value.clear();
850 _face_arg_to_value.clear();
851 _node_arg_to_value.clear();
852}
853
854template <typename T>
855void
857{
858 if (_clearance_schedule.count(EXEC_TIMESTEP_BEGIN))
859 clearCacheData();
860}
861
862template <typename T>
863void
865{
866 if (_clearance_schedule.count(EXEC_LINEAR))
867 clearCacheData();
868}
869
870template <typename T>
871void
873{
874 if (_clearance_schedule.count(EXEC_NONLINEAR))
875 clearCacheData();
876}
877
878template <typename T>
879void
881{
882 if (_clearance_schedule.count(exec_type))
883 clearCacheData();
884}
885
886template <typename T>
888FunctorBase<T>::gradient(const ElemArg & elem, const StateArg & state) const
889{
890 return evaluateGradient(elem, state);
891}
892
893template <typename T>
895FunctorBase<T>::gradient(const FaceArg & face, const StateArg & state) const
896{
897 checkFace(face);
898 return evaluateGradient(face, state);
899}
900
901template <typename T>
903FunctorBase<T>::gradient(const ElemQpArg & elem_qp, const StateArg & state) const
904{
905 return evaluateGradient(elem_qp, state);
906}
907
908template <typename T>
910FunctorBase<T>::gradient(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
911{
912 return evaluateGradient(elem_side_qp, state);
913}
914
915template <typename T>
917FunctorBase<T>::gradient(const ElemPointArg & elem_point, const StateArg & state) const
918{
919 return evaluateGradient(elem_point, state);
920}
921
922template <typename T>
924FunctorBase<T>::gradient(const NodeArg & node, const StateArg & state) const
925{
926 return evaluateGradient(node, state);
927}
928
929template <typename T>
931FunctorBase<T>::gradient(const PointArg & point, const StateArg & state) const
932{
933 return evaluateGradient(point, state);
934}
935
936template <typename T>
938FunctorBase<T>::dot(const ElemArg & elem, const StateArg & state) const
939{
940 return evaluateDot(elem, state);
941}
942
943template <typename T>
945FunctorBase<T>::dot(const FaceArg & face, const StateArg & state) const
946{
947 checkFace(face);
948 return evaluateDot(face, state);
949}
950
951template <typename T>
953FunctorBase<T>::dot(const ElemQpArg & elem_qp, const StateArg & state) const
954{
955 return evaluateDot(elem_qp, state);
956}
957
958template <typename T>
960FunctorBase<T>::dot(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
961{
962 return evaluateDot(elem_side_qp, state);
963}
964
965template <typename T>
967FunctorBase<T>::dot(const ElemPointArg & elem_point, const StateArg & state) const
968{
969 return evaluateDot(elem_point, state);
970}
971
972template <typename T>
974FunctorBase<T>::dot(const NodeArg & node, const StateArg & state) const
975{
976 return evaluateDot(node, state);
977}
978
979template <typename T>
981FunctorBase<T>::dot(const PointArg & point, const StateArg & state) const
982{
983 return evaluateDot(point, state);
984}
985
986template <typename T>
988FunctorBase<T>::gradDot(const ElemArg & elem, const StateArg & state) const
989{
990 return evaluateGradDot(elem, state);
991}
992
993template <typename T>
995FunctorBase<T>::gradDot(const FaceArg & face, const StateArg & state) const
996{
997 checkFace(face);
998 return evaluateGradDot(face, state);
999}
1000
1001template <typename T>
1003FunctorBase<T>::gradDot(const ElemQpArg & elem_qp, const StateArg & state) const
1004{
1005 return evaluateGradDot(elem_qp, state);
1006}
1007
1008template <typename T>
1010FunctorBase<T>::gradDot(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
1011{
1012 return evaluateGradDot(elem_side_qp, state);
1013}
1014
1015template <typename T>
1017FunctorBase<T>::gradDot(const ElemPointArg & elem_point, const StateArg & state) const
1018{
1019 return evaluateGradDot(elem_point, state);
1020}
1021
1022template <typename T>
1024FunctorBase<T>::gradDot(const NodeArg & node, const StateArg & state) const
1025{
1026 return evaluateGradDot(node, state);
1027}
1028
1029template <typename T>
1031FunctorBase<T>::gradDot(const PointArg & point, const StateArg & state) const
1032{
1033 return evaluateGradDot(point, state);
1034}
1035
1036template <typename T>
1037bool
1038FunctorBase<T>::hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const
1039{
1040 if (fi_elem_side)
1041 return hasBlocks(fi.elem().subdomain_id());
1042 else
1043 return fi.neighborPtr() && hasBlocks(fi.neighbor().subdomain_id());
1044}
1045
1046template <typename T>
1047template <FunctorEvaluationKind FET, typename Space, typename State>
1049FunctorBase<T>::genericEvaluate(const Space & r, const State & state) const
1050{
1051 if constexpr (FET == FunctorEvaluationKind::Value)
1052 return (*this)(r, state);
1053 else if constexpr (FET == FunctorEvaluationKind::Gradient)
1054 return gradient(r, state);
1055 else if constexpr (FET == FunctorEvaluationKind::Dot)
1056 return dot(r, state);
1057 else
1058 return gradDot(r, state);
1059}
1060
1066{
1067public:
1069 virtual ~FunctorEnvelopeBase() = default;
1070
1074 virtual bool wrapsNull() const = 0;
1075
1079 virtual std::string returnType() const = 0;
1080
1084 virtual bool isConstant() const = 0;
1085
1093 virtual bool ownsWrappedFunctor() const = 0;
1094};
1095
1101template <typename T>
1102class FunctorEnvelope final : public FunctorBase<T>, public FunctorEnvelopeBase
1103{
1104public:
1105 using typename Moose::FunctorBase<T>::ValueType;
1107 using typename Moose::FunctorBase<T>::DotType;
1108
1113 : FunctorBase<T>("wraps_" + wrapped.functorName()), FunctorEnvelopeBase(), _wrapped(&wrapped)
1114 {
1115 }
1116
1122 FunctorEnvelope(std::unique_ptr<FunctorBase<T>> && wrapped)
1123 : FunctorBase<T>("wraps_" + wrapped->functorName()),
1125 _owned(std::move(wrapped)),
1126 _wrapped(_owned.get())
1127 {
1128 }
1129
1135
1140 void assign(const FunctorBase<T> & wrapped)
1141 {
1142 _owned.reset();
1143 _wrapped = &wrapped;
1144 }
1145
1150 void assign(std::unique_ptr<FunctorBase<T>> && wrapped)
1151 {
1152 _owned = std::move(wrapped);
1153 _wrapped = _owned.get();
1154 }
1155
1160 void assign(FunctorBase<T> &&) = delete;
1161
1166
1167 virtual ~FunctorEnvelope() = default;
1168
1172 virtual bool wrapsNull() const override { return wrapsType<NullFunctor<T>>(); }
1173
1177 virtual std::string returnType() const override { return libMesh::demangle(typeid(T).name()); }
1178
1179 virtual bool ownsWrappedFunctor() const override { return _owned.get(); }
1180
1184 template <typename T2>
1185 bool wrapsType() const
1186 {
1187 return dynamic_cast<const T2 *>(_wrapped);
1188 }
1189
1190 virtual bool isExtrapolatedBoundaryFace(const FaceInfo & fi,
1191 const Elem * const elem,
1192 const StateArg & state) const override
1193 {
1194 return _wrapped->isExtrapolatedBoundaryFace(fi, elem, state);
1195 }
1196 virtual bool isConstant() const override { return _wrapped->isConstant(); }
1197 virtual bool hasBlocks(const SubdomainID id) const override { return _wrapped->hasBlocks(id); }
1198 virtual bool hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const override
1199 {
1200 return _wrapped->hasFaceSide(fi, fi_elem_side);
1201 }
1202
1203 bool supportsFaceArg() const override final { return true; }
1204 bool supportsElemSideQpArg() const override final { return true; }
1205
1206protected:
1208
1211 virtual ValueType evaluate(const ElemArg & elem, const StateArg & state) const override
1212 {
1213 return _wrapped->operator()(elem, state);
1214 }
1215 virtual ValueType evaluate(const FaceArg & face, const StateArg & state) const override
1216 {
1217 return _wrapped->operator()(face, state);
1218 }
1219 virtual ValueType evaluate(const ElemQpArg & qp, const StateArg & state) const override
1220 {
1221 return _wrapped->operator()(qp, state);
1222 }
1223 virtual ValueType evaluate(const ElemSideQpArg & qp, const StateArg & state) const override
1224 {
1225 return _wrapped->operator()(qp, state);
1226 }
1227 virtual ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const override
1228 {
1229 return _wrapped->operator()(elem_point, state);
1230 }
1231 virtual ValueType evaluate(const NodeArg & node, const StateArg & state) const override
1232 {
1233 return _wrapped->operator()(node, state);
1234 }
1235 virtual ValueType evaluate(const PointArg & point, const StateArg & state) const override
1236 {
1237 return _wrapped->operator()(point, state);
1238 }
1239
1240 virtual GradientType evaluateGradient(const ElemArg & elem, const StateArg & state) const override
1241 {
1242 return _wrapped->gradient(elem, state);
1243 }
1244 virtual GradientType evaluateGradient(const FaceArg & face, const StateArg & state) const override
1245 {
1246 return _wrapped->gradient(face, state);
1247 }
1248 virtual GradientType evaluateGradient(const ElemQpArg & qp, const StateArg & state) const override
1249 {
1250 return _wrapped->gradient(qp, state);
1251 }
1253 const StateArg & state) const override
1254 {
1255 return _wrapped->gradient(qp, state);
1256 }
1257 virtual GradientType evaluateGradient(const ElemPointArg & elem_point,
1258 const StateArg & state) const override
1259 {
1260 return _wrapped->gradient(elem_point, state);
1261 }
1262 virtual GradientType evaluateGradient(const NodeArg & node, const StateArg & state) const override
1263 {
1264 return _wrapped->gradient(node, state);
1265 }
1267 const StateArg & state) const override
1268 {
1269 return _wrapped->gradient(point, state);
1270 }
1271
1272 virtual DotType evaluateDot(const ElemArg & elem, const StateArg & state) const override
1273 {
1274 return _wrapped->dot(elem, state);
1275 }
1276 virtual DotType evaluateDot(const FaceArg & face, const StateArg & state) const override
1277 {
1278 return _wrapped->dot(face, state);
1279 }
1280 virtual DotType evaluateDot(const ElemQpArg & qp, const StateArg & state) const override
1281 {
1282 return _wrapped->dot(qp, state);
1283 }
1284 virtual DotType evaluateDot(const ElemSideQpArg & qp, const StateArg & state) const override
1285 {
1286 return _wrapped->dot(qp, state);
1287 }
1288 virtual DotType evaluateDot(const ElemPointArg & elem_point,
1289 const StateArg & state) const override
1290 {
1291 return _wrapped->dot(elem_point, state);
1292 }
1293 virtual DotType evaluateDot(const NodeArg & node, const StateArg & state) const override
1294 {
1295 return _wrapped->dot(node, state);
1296 }
1297 virtual DotType evaluateDot(const PointArg & point, const StateArg & state) const override
1298 {
1299 return _wrapped->dot(point, state);
1300 }
1301
1302 virtual GradientType evaluateGradDot(const ElemArg & elem, const StateArg & state) const override
1303 {
1304 return _wrapped->gradDot(elem, state);
1305 }
1306 virtual GradientType evaluateGradDot(const FaceArg & face, const StateArg & state) const override
1307 {
1308 return _wrapped->gradDot(face, state);
1309 }
1310 virtual GradientType evaluateGradDot(const ElemQpArg & qp, const StateArg & state) const override
1311 {
1312 return _wrapped->gradDot(qp, state);
1313 }
1315 const StateArg & state) const override
1316 {
1317 return _wrapped->gradDot(qp, state);
1318 }
1319 virtual GradientType evaluateGradDot(const ElemPointArg & elem_point,
1320 const StateArg & state) const override
1321 {
1322 return _wrapped->gradDot(elem_point, state);
1323 }
1324 virtual GradientType evaluateGradDot(const NodeArg & node, const StateArg & state) const override
1325 {
1326 return _wrapped->gradDot(node, state);
1327 }
1329 const StateArg & state) const override
1330 {
1331 return _wrapped->gradDot(point, state);
1332 }
1334
1335private:
1337 std::unique_ptr<FunctorBase<T>> _owned;
1339
1340 friend class ::SubProblem;
1341};
1342
1346template <typename T>
1347class ConstantFunctor final : public FunctorBase<T>
1348{
1349public:
1350 using typename FunctorBase<T>::FunctorType;
1351 using typename FunctorBase<T>::ValueType;
1352 using typename FunctorBase<T>::GradientType;
1353 using typename FunctorBase<T>::DotType;
1354
1356 : FunctorBase<T>("constant_" + std::to_string(value)), _value(value)
1357 {
1358 }
1360 : FunctorBase<T>("constant_" + std::to_string(MetaPhysicL::raw_value(value))), _value(value)
1361 {
1362 }
1363
1364 virtual bool isConstant() const override { return true; }
1365
1366 bool hasBlocks(SubdomainID /* id */) const override { return true; }
1367
1368 bool supportsFaceArg() const override final { return true; }
1369 bool supportsElemSideQpArg() const override final { return true; }
1370
1371private:
1372 ValueType evaluate(const ElemArg &, const StateArg &) const override { return _value; }
1373 ValueType evaluate(const FaceArg &, const StateArg &) const override { return _value; }
1374 ValueType evaluate(const ElemQpArg &, const StateArg &) const override { return _value; }
1375 ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override { return _value; }
1376 ValueType evaluate(const ElemPointArg &, const StateArg &) const override { return _value; }
1377 ValueType evaluate(const NodeArg &, const StateArg &) const override { return _value; }
1378 ValueType evaluate(const PointArg &, const StateArg &) const override { return _value; }
1379
1380 GradientType evaluateGradient(const ElemArg &, const StateArg &) const override { return 0; }
1381 GradientType evaluateGradient(const FaceArg &, const StateArg &) const override { return 0; }
1382 GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const override { return 0; }
1383 GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const override
1384 {
1385 return 0;
1386 }
1387 GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const override { return 0; }
1388 GradientType evaluateGradient(const NodeArg &, const StateArg &) const override { return 0; }
1389 GradientType evaluateGradient(const PointArg &, const StateArg &) const override { return 0; }
1390
1391 DotType evaluateDot(const ElemArg &, const StateArg &) const override { return 0; }
1392 DotType evaluateDot(const FaceArg &, const StateArg &) const override { return 0; }
1393 DotType evaluateDot(const ElemQpArg &, const StateArg &) const override { return 0; }
1394 DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const override { return 0; }
1395 DotType evaluateDot(const ElemPointArg &, const StateArg &) const override { return 0; }
1396 DotType evaluateDot(const NodeArg &, const StateArg &) const override { return 0; }
1397 DotType evaluateDot(const PointArg &, const StateArg &) const override { return 0; }
1398
1399 GradientType evaluateGradDot(const ElemArg &, const StateArg &) const override { return 0; }
1400 GradientType evaluateGradDot(const FaceArg &, const StateArg &) const override { return 0; }
1401 GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const override { return 0; }
1402 GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const override { return 0; }
1403 GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const override { return 0; }
1404 GradientType evaluateGradDot(const NodeArg &, const StateArg &) const override { return 0; }
1405 GradientType evaluateGradDot(const PointArg &, const StateArg &) const override { return 0; }
1406
1407private:
1409};
1410
1415template <typename T>
1416class NullFunctor final : public FunctorBase<T>
1417{
1418public:
1419 using typename FunctorBase<T>::FunctorType;
1420 using typename FunctorBase<T>::ValueType;
1421 using typename FunctorBase<T>::GradientType;
1422 using typename FunctorBase<T>::DotType;
1423
1424 NullFunctor() : FunctorBase<T>("null") {}
1425
1426 // For backwards compatiblity of unit testing
1427 bool hasFaceSide(const FaceInfo & fi, bool) const override;
1428
1429 bool supportsFaceArg() const override final { return false; }
1430 bool supportsElemSideQpArg() const override final { return false; }
1431
1432private:
1433 ValueType evaluate(const ElemArg &, const StateArg &) const override
1434 {
1435 mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1436 "they've written broken code");
1437 }
1438 ValueType evaluate(const FaceArg &, const StateArg &) const override
1439 {
1440 mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1441 "they've written broken code");
1442 }
1443 ValueType evaluate(const ElemQpArg &, const StateArg &) const override
1444 {
1445 mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1446 "they've written broken code");
1447 }
1448 ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override
1449 {
1450 mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1451 "they've written broken code");
1452 }
1453 ValueType evaluate(const ElemPointArg &, const StateArg &) const override
1454 {
1455 mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1456 "they've written broken code");
1457 }
1458 ValueType evaluate(const NodeArg &, const StateArg &) const override
1459 {
1460 mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1461 "they've written broken code");
1462 }
1463 ValueType evaluate(const PointArg &, const StateArg &) const override
1464 {
1465 mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1466 "they've written broken code");
1467 }
1468};
1469
1470template <typename T>
1471bool
1472NullFunctor<T>::hasFaceSide(const FaceInfo &, const bool) const
1473{
1474 // For backwards compatiblity of unit testing
1475 return true;
1476}
1477}
subdomain_id_type SubdomainID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
T evaluate(Real, const Point &)
The general evaluation method is not defined.
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition Moose.C:38
const ExecFlagType EXEC_ALWAYS
Definition Moose.C:54
const ExecFlagType EXEC_LINEAR
Definition Moose.C:32
const ExecFlagType EXEC_NONLINEAR
Definition Moose.C:34
A base class interface for both producers and consumers of functor face arguments,...
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
const Elem & elem() const
Definition FaceInfo.h:85
const Elem * neighborPtr() const
Definition FaceInfo.h:88
const Elem * elemPtr() const
Definition FaceInfo.h:86
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition FaceInfo.h:75
const Elem & neighbor() const
Definition FaceInfo.h:220
Class for containing MooseEnum item information.
Class template for creating constant functors.
ValueType evaluate(const NodeArg &, const StateArg &) const override
GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const override
DotType evaluateDot(const PointArg &, const StateArg &) const override
ConstantFunctor(ValueType &&value)
ConstantFunctor(const ValueType &value)
virtual bool isConstant() const override
Returns true if this functor is a constant.
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const override
Evaluate the functor gradient with a given element and point.
ValueType evaluate(const ElemQpArg &, const StateArg &) const override
DotType evaluateDot(const NodeArg &, const StateArg &) const override
GradientType evaluateGradient(const NodeArg &, const StateArg &) const override
GradientType evaluateGradDot(const NodeArg &, const StateArg &) const override
ValueType evaluate(const ElemArg &, const StateArg &) const override
Evaluate the functor with a given element.
GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const override
GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const override
DotType evaluateDot(const ElemPointArg &, const StateArg &) const override
Evaluate the functor time derivative with a given element and point.
DotType evaluateDot(const ElemQpArg &, const StateArg &) const override
DotType evaluateDot(const FaceArg &, const StateArg &) const override
DotType evaluateDot(const ElemArg &, const StateArg &) const override
Evaluate the functor time derivative with a given element.
GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const override
ValueType evaluate(const ElemPointArg &, const StateArg &) const override
Evaluate the functor with a given element and point.
GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const override
Evaluate the functor gradient-dot with a given element and point.
GradientType evaluateGradDot(const ElemArg &, const StateArg &) const override
Evaluate the functor gradient-dot with a given element.
ValueType evaluate(const PointArg &, const StateArg &) const override
Evaluate the functor at a physical point without any mesh information.
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const override
GradientType evaluateGradDot(const FaceArg &, const StateArg &) const override
GradientType evaluateGradient(const FaceArg &, const StateArg &) const override
GradientType evaluateGradDot(const PointArg &, const StateArg &) const override
GradientType evaluateGradient(const ElemArg &, const StateArg &) const override
Evaluate the functor gradient with a given element.
bool hasBlocks(SubdomainID) const override
Returns whether the functor is defined on this block.
ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override
ValueType evaluate(const FaceArg &, const StateArg &) const override
GradientType evaluateGradient(const PointArg &, const StateArg &) const override
Abstract base class that can be used to hold collections of functors.
virtual void residualSetup()=0
virtual void timestepSetup()=0
virtual void jacobianSetup()=0
virtual void customSetup(const ExecFlagType &exec_type)=0
Base class template for functor objects.
virtual DotType evaluateDot(const FaceArg &, const StateArg &) const
virtual GradientType evaluateGradDot(const PointArg &, const StateArg &) const
DotType dot(const ElemQpArg &qp, const StateArg &state) const
DotType dot(const ElemArg &elem, const StateArg &state) const
Same as their evaluateDot overloads with the same arguments but allows for caching implementation.
GradientType gradient(const NodeArg &node, const StateArg &state) const
GradientType gradient(const FaceArg &face, const StateArg &state) const
DotType dot(const NodeArg &node, const StateArg &state) const
virtual GradientType evaluateGradDot(const NodeArg &, const StateArg &) const
GradientType gradDot(const NodeArg &node, const StateArg &state) const
virtual bool isExtrapolatedBoundaryFace(const FaceInfo &, const Elem *, const StateArg &) const
Returns whether this (sided) face is an extrapolated boundary face for this functor.
GradientType gradient(const ElemSideQpArg &qp, const StateArg &state) const
virtual GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const
ValueType operator()(const ElemArg &elem, const StateArg &state) const
Same as their evaluate overloads with the same arguments but allows for caching implementation.
virtual GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const
Evaluate the functor gradient with a given element and point.
FunctorReturnType< T, FET >::type genericEvaluate(const Space &r, const State &state) const
Perform a generic evaluation based on the supplied template argument FET and supplied spatial and tem...
void setCacheClearanceSchedule(const std::set< ExecFlagType > &clearance_schedule)
Set how often to clear the functor evaluation cache.
virtual GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const
virtual GradientType evaluateGradDot(const ElemArg &, const StateArg &) const
Evaluate the functor gradient-dot with a given element.
bool _always_evaluate
Boolean to check if we always need evaluation.
ValueType operator()(const NodeArg &node, const StateArg &state) const
void clearCacheData()
clear cache data
GradientType gradient(const ElemPointArg &elem_point, const StateArg &state) const
void checkFace(const Moose::FaceArg &face) const
Examines the incoming face argument.
typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector,...
dof_id_type _current_qp_map_key
Current key for qp map cache.
GradientType gradient(const PointArg &point, const StateArg &state) const
virtual bool supportsFaceArg() const =0
Whether this functor supports evaluation with FaceArg.
virtual DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const
virtual GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const
Evaluate the functor gradient-dot with a given element and point.
virtual ValueType evaluate(const ElemArg &elem, const StateArg &state) const =0
Evaluate the functor with a given element.
ValueType operator()(const ElemSideQpArg &qp, const StateArg &state) const
const MooseFunctorName & functorName() const
Return the functor name.
virtual GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const
virtual bool hasBlocks(SubdomainID) const
Returns whether the functor is defined on this block.
GradientType gradDot(const FaceArg &face, const StateArg &state) const
DotType dot(const FaceArg &face, const StateArg &state) const
std::map< ElemArg, ValueType > _elem_arg_to_value
Map from element arguments to their cached evaluations.
ValueType operator()(const PointArg &point, const StateArg &state) const
ValueType queryQpCache(unsigned int qp, const libMesh::QBase &qrule, std::vector< std::pair< bool, T > > &qp_cache_data, const SpaceArg &space, const StateArg &state) const
check a qp cache and if invalid then evaluate
virtual void residualSetup() override
virtual bool supportsElemSideQpArg() const =0
Whether this functor supports evaluation with ElemSideQpArg.
virtual DotType evaluateDot(const ElemArg &, const StateArg &) const
Evaluate the functor time derivative with a given element.
virtual ValueType evaluate(const NodeArg &node, const StateArg &state) const =0
DotType dot(const PointArg &point, const StateArg &state) const
std::unordered_map< dof_id_type, std::vector< std::pair< bool, ValueType > > > _qp_to_value
Cached element quadrature point functor property evaluations.
GradientType gradDot(const ElemSideQpArg &qp, const StateArg &state) const
virtual GradientType evaluateGradient(const NodeArg &, const StateArg &) const
bool isInternalFace(const FaceInfo &) const
Returns true if the face is an internal face.
virtual DotType evaluateDot(const ElemPointArg &, const StateArg &) const
Evaluate the functor time derivative with a given element and point.
virtual GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const
GradientType gradDot(const ElemQpArg &qp, const StateArg &state) const
virtual ValueType evaluate(const PointArg &, const StateArg &) const
Evaluate the functor at a physical point without any mesh information.
ValueType operator()(const ElemQpArg &qp, const StateArg &state) const
GradientType gradient(const ElemArg &elem, const StateArg &state) const
Same as their evaluateGradient overloads with the same arguments but allows for caching implementatio...
std::map< FaceArg, ValueType > _face_arg_to_value
Map from face arguments to their cached evaluations.
ValueType queryFVArgCache(std::map< SpaceArg, ValueType > &cache_data, const SpaceArg &space) const
check a finite volume spatial argument cache and if invalid then evaluate
virtual ValueType evaluate(const FaceArg &face, const StateArg &state) const =0
DotType dot(const ElemPointArg &elem_point, const StateArg &state) const
virtual void timestepSetup() override
virtual DotType evaluateDot(const NodeArg &, const StateArg &) const
ValueType operator()(const FaceArg &face, const StateArg &state) const
virtual GradientType evaluateGradDot(const FaceArg &, const StateArg &) const
virtual DotType evaluateDot(const ElemQpArg &, const StateArg &) const
FunctorBase(const FunctorBase< T > &, const Moose::Kokkos::FunctorCopy &)
Special constructor used for Kokkos functor copy during parallel dispatch.
GradientType gradient(const ElemQpArg &qp, const StateArg &state) const
virtual ValueType evaluate(const ElemQpArg &qp, const StateArg &state) const =0
virtual GradientType evaluateGradient(const PointArg &, const StateArg &) const
std::vector< std::vector< std::pair< bool, ValueType > > > * _current_side_qp_map_value
Current value for side-qp map cache.
GradientType gradDot(const ElemArg &elem, const StateArg &state) const
Same as their evaluateGradDot overloads with the same arguments but allows for caching implementation...
std::map< NodeArg, ValueType > _node_arg_to_value
Map from nodal arguments to their cached evaluations.
virtual DotType evaluateDot(const PointArg &, const StateArg &) const
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override
std::vector< std::pair< bool, ValueType > > * _current_qp_map_value
Current value for qp map cache.
virtual void customSetup(const ExecFlagType &exec_type) override
DotType dot(const ElemSideQpArg &qp, const StateArg &state) const
std::set< ExecFlagType > _clearance_schedule
How often to clear the material property cache.
FunctorBase(const MooseFunctorName &name, const std::set< ExecFlagType > &clearance_schedule={EXEC_ALWAYS})
MooseFunctorName _functor_name
name of the functor
virtual ValueType evaluate(const ElemPointArg &elem_point, const StateArg &state) const =0
Evaluate the functor with a given element and point.
dof_id_type _current_side_qp_map_key
Current key for side-qp map cache.
virtual ~FunctorBase()=default
ValueType operator()(const ElemPointArg &elem_point, const StateArg &state) const
virtual void jacobianSetup() override
GradientType gradDot(const ElemPointArg &elem_point, const StateArg &state) const
std::unordered_map< dof_id_type, std::vector< std::vector< std::pair< bool, ValueType > > > > _side_qp_to_value
Cached element quadrature point functor property evaluations.
virtual ValueType evaluate(const ElemSideQpArg &side_qp, const StateArg &state) const =0
GradientType gradDot(const PointArg &point, const StateArg &state) const
virtual GradientType evaluateGradient(const FaceArg &, const StateArg &) const
virtual bool isConstant() const
Returns true if this functor is a constant.
virtual GradientType evaluateGradient(const ElemArg &, const StateArg &) const
Evaluate the functor gradient with a given element.
A non-templated base class for functors that allow an owner object to hold different class template i...
virtual bool ownsWrappedFunctor() const =0
virtual ~FunctorEnvelopeBase()=default
virtual bool wrapsNull() const =0
virtual std::string returnType() const =0
virtual bool isConstant() const =0
This is a wrapper that forwards calls to the implementation, which can be switched out at any time wi...
virtual DotType evaluateDot(const FaceArg &face, const StateArg &state) const override
virtual ValueType evaluate(const FaceArg &face, const StateArg &state) const override
virtual bool wrapsNull() const override
virtual GradientType evaluateGradDot(const ElemSideQpArg &qp, const StateArg &state) const override
virtual bool isExtrapolatedBoundaryFace(const FaceInfo &fi, const Elem *const elem, const StateArg &state) const override
Returns whether this (sided) face is an extrapolated boundary face for this functor.
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
virtual ValueType evaluate(const ElemQpArg &qp, const StateArg &state) const override
virtual ValueType evaluate(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor with a given element and point.
virtual GradientType evaluateGradDot(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor gradient-dot with a given element.
virtual DotType evaluateDot(const ElemQpArg &qp, const StateArg &state) const override
virtual GradientType evaluateGradDot(const NodeArg &node, const StateArg &state) const override
virtual ~FunctorEnvelope()=default
virtual GradientType evaluateGradient(const ElemSideQpArg &qp, const StateArg &state) const override
void assign(const FunctorBase< T > &wrapped)
virtual GradientType evaluateGradient(const PointArg &point, const StateArg &state) const override
virtual bool isConstant() const override
Returns true if this functor is a constant.
FunctorEnvelope(FunctorEnvelope &&)=delete
virtual DotType evaluateDot(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor time derivative with a given element and point.
virtual ValueType evaluate(const ElemSideQpArg &qp, const StateArg &state) const override
virtual GradientType evaluateGradDot(const ElemQpArg &qp, const StateArg &state) const override
const FunctorBase< T > * _wrapped
virtual GradientType evaluateGradDot(const PointArg &point, const StateArg &state) const override
virtual bool ownsWrappedFunctor() const override
void assign(std::unique_ptr< FunctorBase< T > > &&wrapped)
virtual GradientType evaluateGradient(const NodeArg &node, const StateArg &state) const override
void assign(FunctorBase< T > &&)=delete
Prevent wrapping of a temporary object.
virtual GradientType evaluateGradDot(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor gradient-dot with a given element and point.
virtual DotType evaluateDot(const NodeArg &node, const StateArg &state) const override
virtual ValueType evaluate(const NodeArg &node, const StateArg &state) const override
virtual bool hasBlocks(const SubdomainID id) const override
Returns whether the functor is defined on this block.
virtual GradientType evaluateGradient(const ElemQpArg &qp, const StateArg &state) const override
FunctorEnvelope(const FunctorEnvelope &)=delete
virtual DotType evaluateDot(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor time derivative with a given element.
virtual ValueType evaluate(const PointArg &point, const StateArg &state) const override
Evaluate the functor at a physical point without any mesh information.
std::unique_ptr< FunctorBase< T > > _owned
Our wrapped object.
virtual GradientType evaluateGradDot(const FaceArg &face, const StateArg &state) const override
virtual GradientType evaluateGradient(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor gradient with a given element.
FunctorEnvelope & operator=(FunctorEnvelope &&)=delete
FunctorEnvelope(FunctorBase< T > &&)=delete
Prevent wrapping of a temporary object.
virtual std::string returnType() const override
virtual DotType evaluateDot(const PointArg &point, const StateArg &state) const override
FunctorEnvelope(const FunctorBase< T > &wrapped)
FunctorEnvelope(std::unique_ptr< FunctorBase< T > > &&wrapped)
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override
virtual ValueType evaluate(const ElemArg &elem, const StateArg &state) const override
Forward calls to wrapped object.
FunctorEnvelope & operator=(const FunctorEnvelope &)=delete
virtual GradientType evaluateGradient(const FaceArg &face, const StateArg &state) const override
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
virtual DotType evaluateDot(const ElemSideQpArg &qp, const StateArg &state) const override
virtual GradientType evaluateGradient(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor gradient with a given element and point.
A functor that serves as a placeholder during the simulation setup phase if a functor consumer reques...
ValueType evaluate(const FaceArg &, const StateArg &) const override
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
ValueType evaluate(const ElemQpArg &, const StateArg &) const override
ValueType evaluate(const PointArg &, const StateArg &) const override
Evaluate the functor at a physical point without any mesh information.
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override
ValueType evaluate(const ElemPointArg &, const StateArg &) const override
Evaluate the functor with a given element and point.
ValueType evaluate(const NodeArg &, const StateArg &) const override
bool hasFaceSide(const FaceInfo &fi, bool) const override
ValueType evaluate(const ElemArg &, const StateArg &) const override
Evaluate the functor with a given element.
static constexpr dof_id_type invalid_id
dof_id_type id() const
unsigned int n_points() const
We need to instantiate the following CompareTypes to tell the compiler that ADReal is a subtype of Ch...
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:65
FunctorEvaluationKind
An enumeration of possible functor evaluation kinds.
StateArg currentState()
std::string demangle(const char *name)
A structure that is used to evaluate Moose functors logically at an element/cell center.
A structure that is used to evaluate Moose functors at an arbitrary physical point contained within a...
Argument for requesting functor evaluation at a quadrature point location in an element.
const libMesh::Elem * elem
The element.
const libMesh::QBase * qrule
The quadrature rule.
unsigned int qp
The quadrature point index.
Argument for requesting functor evaluation at quadrature point locations on an element side.
const libMesh::Elem * elem
The element.
unsigned int qp
The quadrature point index.
unsigned int side
The local side index.
const libMesh::QBase * qrule
The quadrature rule.
A structure defining a "face" evaluation calling argument for Moose functors.
This structure takes an evaluation kind as a template argument and defines a constant expression indi...
FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type type
MetaPhysicL::ReplaceAlgebraicType< T, typenamelibMesh::TensorTools::IncrementRank< typenameMetaPhysicL::ValueType< T >::type >::type >::type type
A structure that defines the return type of a functor based on the type of the functor and the reques...
const std::set< SubdomainID > * subdomain_ids
Indicates what subdomains this argument should be associated with.
A structure that is used to evaluate Moose functors at an arbitrary physical point,...
State argument for evaluating functors.
unsigned int state
The state.