https://mooseframework.inl.gov
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"
15 #include "MooseFunctorArguments.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 
30 namespace Moose
31 {
37 {
38  Value,
39  Gradient,
40  Dot,
41  GradDot
42 };
43 
48 template <typename, FunctorEvaluationKind>
50 
54 template <typename T>
56 {
57  typedef T type;
58 };
59 
66 template <typename T>
68 {
69  typedef typename MetaPhysicL::ReplaceAlgebraicType<
70  T,
72  typename MetaPhysicL::ValueType<T>::type>::type>::type type;
73 };
74 
78 template <typename T>
80 {
81  typedef T type;
82 };
83 
87 template <typename T>
89 {
91 };
92 
97 template <FunctorEvaluationKind>
99 
103 template <>
105 {
107 };
108 
112 template <>
114 {
116 };
117 
122 {
123 public:
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 
136 template <typename T>
138 {
139 public:
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  {
158  setCacheClearanceSchedule(clearance_schedule);
159  }
160 
165  template <FunctorEvaluationKind FET, typename Space, typename State>
166  typename FunctorReturnType<T, FET>::type genericEvaluate(const Space & r,
167  const State & state) const;
168 
170  const MooseFunctorName & functorName() const { return _functor_name; }
171 
173 
177  ValueType operator()(const ElemArg & elem, const StateArg & state) const;
178  ValueType operator()(const FaceArg & face, const StateArg & state) const;
179  ValueType operator()(const ElemQpArg & qp, const StateArg & state) const;
180  ValueType operator()(const ElemSideQpArg & qp, const StateArg & state) const;
181  ValueType operator()(const ElemPointArg & elem_point, const StateArg & state) const;
182  ValueType operator()(const NodeArg & node, const StateArg & state) const;
184 
186 
190  GradientType gradient(const ElemArg & elem, const StateArg & state) const;
191  GradientType gradient(const FaceArg & face, const StateArg & state) const;
192  GradientType gradient(const ElemQpArg & qp, const StateArg & state) const;
193  GradientType gradient(const ElemSideQpArg & qp, const StateArg & state) const;
194  GradientType gradient(const ElemPointArg & elem_point, const StateArg & state) const;
195  GradientType gradient(const NodeArg & node, const StateArg & state) const;
197 
199 
203  DotType dot(const ElemArg & elem, const StateArg & state) const;
204  DotType dot(const FaceArg & face, const StateArg & state) const;
205  DotType dot(const ElemQpArg & qp, const StateArg & state) const;
206  DotType dot(const ElemSideQpArg & qp, const StateArg & state) const;
207  DotType dot(const ElemPointArg & elem_point, const StateArg & state) const;
208  DotType dot(const NodeArg & node, const StateArg & state) const;
210 
212 
216  GradientType gradDot(const ElemArg & elem, const StateArg & state) const;
217  GradientType gradDot(const FaceArg & face, const StateArg & state) const;
218  GradientType gradDot(const ElemQpArg & qp, const StateArg & state) const;
219  GradientType gradDot(const ElemSideQpArg & qp, const StateArg & state) const;
220  GradientType gradDot(const ElemPointArg & elem_point, const StateArg & state) const;
221  GradientType gradDot(const NodeArg & node, const StateArg & state) const;
223 
224  virtual void residualSetup() override;
225  virtual void jacobianSetup() override;
226  virtual void timestepSetup() override;
227  virtual void customSetup(const ExecFlagType & exec_type) override;
228 
232  void setCacheClearanceSchedule(const std::set<ExecFlagType> & clearance_schedule);
233 
237  virtual bool hasBlocks(SubdomainID /* id */) const
238  {
239  mooseError("Block restriction has not been implemented for functor " + functorName());
240  return false;
241  }
242 
247  virtual bool isExtrapolatedBoundaryFace(const FaceInfo &, const Elem *, const StateArg &) const
248  {
249  mooseError("not implemented");
250  }
251 
255  bool isInternalFace(const FaceInfo &) const;
256 
260  virtual bool isConstant() const { return false; }
261 
262  virtual bool hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const override;
263 
274  void checkFace(const Moose::FaceArg & face) const;
275 
279  virtual bool supportsFaceArg() const = 0;
280 
284  virtual bool supportsElemSideQpArg() const = 0;
285 
286 protected:
292 
297  virtual ValueType evaluate(const ElemArg & elem, const StateArg & state) const = 0;
298 
304  virtual ValueType evaluate(const FaceArg & face, const StateArg & state) const = 0;
305 
311  virtual ValueType evaluate(const ElemQpArg & qp, const StateArg & state) const = 0;
312 
318  virtual ValueType evaluate(const ElemSideQpArg & side_qp, const StateArg & state) const = 0;
319 
324  virtual ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const = 0;
325 
326  virtual ValueType evaluate(const NodeArg & node, const StateArg & state) const = 0;
327 
332  virtual GradientType evaluateGradient(const ElemArg &, const StateArg &) const
333  {
334  mooseError("Element gradient not implemented for functor " + functorName());
335  }
336 
342  virtual GradientType evaluateGradient(const FaceArg &, const StateArg &) const
343  {
344  mooseError("Face gradient not implemented for functor " + functorName());
345  }
346 
352  virtual GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const
353  {
354  mooseError("Element quadrature point gradient not implemented for functor " + functorName());
355  }
356 
362  virtual GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const
363  {
364  mooseError("Element side quadrature point gradient not implemented for functor " +
365  functorName());
366  }
367 
371  virtual GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const
372  {
373  mooseError("Element-point gradient not implemented for functor " + functorName());
374  }
375 
376  virtual GradientType evaluateGradient(const NodeArg &, const StateArg &) const
377  {
378  mooseError("Gradient at node not implemented for functor " + functorName());
379  }
380 
385  virtual DotType evaluateDot(const ElemArg &, const StateArg &) const
386  {
387  mooseError("Element time derivative not implemented for functor " + functorName());
388  }
389 
395  virtual DotType evaluateDot(const FaceArg &, const StateArg &) const
396  {
397  mooseError("Face time derivative not implemented for functor " + functorName());
398  }
399 
405  virtual DotType evaluateDot(const ElemQpArg &, const StateArg &) const
406  {
407  mooseError("Element quadrature point time derivative not implemented for functor " +
408  functorName());
409  }
410 
416  virtual DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const
417  {
418  mooseError("Element side quadrature point time derivative not implemented for functor " +
419  functorName());
420  }
421 
425  virtual DotType evaluateDot(const ElemPointArg &, const StateArg &) const
426  {
427  mooseError("Element-point time derivative not implemented for functor " + functorName());
428  }
429 
430  virtual DotType evaluateDot(const NodeArg &, const StateArg &) const
431  {
432  mooseError("Time derivative at node not implemented for functor " + functorName());
433  }
434 
439  virtual GradientType evaluateGradDot(const ElemArg &, const StateArg &) const
440  {
441  mooseError("Element gradient-dot not implemented for functor " + functorName());
442  }
443 
449  virtual GradientType evaluateGradDot(const FaceArg &, const StateArg &) const
450  {
451  mooseError("Face gradient-dot not implemented for functor " + functorName());
452  }
453 
459  virtual GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const
460  {
461  mooseError("Element quadrature point gradient-dot not implemented for functor " +
462  functorName());
463  }
464 
470  virtual GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const
471  {
472  mooseError("Element side quadrature point gradient-dot not implemented for functor " +
473  functorName());
474  }
475 
479  virtual GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const
480  {
481  mooseError("Element-point gradient-dot not implemented for functor " + functorName());
482  }
483 
484  virtual GradientType evaluateGradDot(const NodeArg &, const StateArg &) const
485  {
486  mooseError("Gradient-dot at node not implemented for functor " + functorName());
487  }
489 
490 private:
494  void clearCacheData();
495 
499  template <typename SpaceArg, typename StateArg>
500  ValueType queryQpCache(unsigned int qp,
501  const libMesh::QBase & qrule,
502  std::vector<std::pair<bool, T>> & qp_cache_data,
503  const SpaceArg & space,
504  const StateArg & state) const;
505 
509  template <typename SpaceArg>
510  ValueType queryFVArgCache(std::map<SpaceArg, ValueType> & cache_data,
511  const SpaceArg & space) const;
512 
514  std::set<ExecFlagType> _clearance_schedule;
515 
518 
519  // Data for traditional element-quadrature point property evaluations which are useful for
520  // caching implementation
521 
524 
526  mutable std::vector<std::pair<bool, ValueType>> * _current_qp_map_value = nullptr;
527 
533  mutable std::unordered_map<dof_id_type, std::vector<std::pair<bool, ValueType>>> _qp_to_value;
534 
535  // Data for traditional element-side-quadrature point property evaluations which are useful for
536  // caching implementation
537 
540 
542  mutable std::vector<std::vector<std::pair<bool, ValueType>>> * _current_side_qp_map_value =
543  nullptr;
544 
551  mutable std::unordered_map<dof_id_type, std::vector<std::vector<std::pair<bool, ValueType>>>>
553 
555  mutable std::map<ElemArg, ValueType> _elem_arg_to_value;
556 
558  mutable std::map<FaceArg, ValueType> _face_arg_to_value;
559 
561  mutable std::map<NodeArg, ValueType> _node_arg_to_value;
562 
564  MooseFunctorName _functor_name;
565 };
566 
567 template <typename T>
568 bool
570 {
571  if (!fi.neighborPtr())
572  return false;
573 
574  return hasBlocks(fi.elem().subdomain_id()) && hasBlocks(fi.neighborPtr()->subdomain_id());
575 }
576 
577 template <typename T>
578 template <typename SpaceArg>
580 FunctorBase<T>::queryFVArgCache(std::map<SpaceArg, ValueType> & cache_data,
581  const SpaceArg & space) const
582 {
583  // We don't want to evaluate if the key already exists, so instead we value initialize
584  auto [it, inserted] = cache_data.try_emplace(space, ValueType());
585  auto & value = it->second;
586 
587  if (inserted)
588  // value not ready to go
589  // this function is only called from functions that assert we are in the current time state
590  value = evaluate(space, currentState());
591 
592  return value;
593 }
594 
595 template <typename T>
597 FunctorBase<T>::operator()(const ElemArg & elem, const StateArg & state) const
598 {
599  if (_always_evaluate)
600  return evaluate(elem, state);
601 
602  mooseAssert(state.state == 0,
603  "Cached evaluations are only currently supported for the current state.");
604 
605  return queryFVArgCache(_elem_arg_to_value, elem);
606 }
607 
608 template <typename T>
610 FunctorBase<T>::operator()(const FaceArg & face_in, const StateArg & state) const
611 {
612  checkFace(face_in);
613 
614  if (_always_evaluate)
615  return evaluate(face_in, state);
616 
617  mooseAssert(state.state == 0,
618  "Cached evaluations are only currently supported for the current state.");
619 
620  return queryFVArgCache(_face_arg_to_value, face_in);
621 }
622 
623 template <typename T>
624 template <typename SpaceArg, typename StateArg>
626 FunctorBase<T>::queryQpCache(const unsigned int qp,
627  const libMesh::QBase & qrule,
628  std::vector<std::pair<bool, ValueType>> & qp_cache_data,
629  const SpaceArg & space,
630  const StateArg & state) const
631 {
632  // Check and see whether we even have sized for this quadrature point. If we haven't then we
633  // must evaluate
634  if (qp >= qp_cache_data.size())
635  {
636  qp_cache_data.resize(qrule.n_points(), std::make_pair(false, ValueType()));
637  auto & pr = qp_cache_data[qp];
638  pr.second = evaluate(space, state);
639  pr.first = true;
640  return pr.second;
641  }
642 
643  // We've already sized for this qp, so let's see whether we have a valid cache value
644  auto & pr = qp_cache_data[qp];
645  if (pr.first)
646  return pr.second;
647 
648  // No valid cache value so evaluate
649  pr.second = evaluate(space, state);
650  pr.first = true;
651  return pr.second;
652 }
653 
654 template <typename T>
656 FunctorBase<T>::operator()(const ElemQpArg & elem_qp, const StateArg & state) const
657 {
658  if (_always_evaluate)
659  return evaluate(elem_qp, state);
660 
661  const auto elem_id = elem_qp.elem->id();
662  if (elem_id != _current_qp_map_key)
663  {
664  _current_qp_map_key = elem_id;
665  _current_qp_map_value = &_qp_to_value[elem_id];
666  }
667  auto & qp_data = *_current_qp_map_value;
668  const auto qp = elem_qp.qp;
669  const auto * const qrule = elem_qp.qrule;
670  mooseAssert(qrule, "qrule must be non-null");
671 
672  return queryQpCache(qp, *qrule, qp_data, elem_qp, state);
673 }
674 
675 template <typename T>
677 FunctorBase<T>::operator()(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
678 {
679  if (_always_evaluate)
680  return evaluate(elem_side_qp, state);
681 
682  const Elem * const elem = elem_side_qp.elem;
683  mooseAssert(elem, "elem must be non-null");
684  const auto elem_id = elem->id();
685  if (elem_id != _current_side_qp_map_key)
686  {
687  _current_side_qp_map_key = elem_id;
688  _current_side_qp_map_value = &_side_qp_to_value[elem_id];
689  }
690  auto & side_qp_data = *_current_side_qp_map_value;
691  const auto side = elem_side_qp.side;
692  const auto qp = elem_side_qp.qp;
693  const auto * const qrule = elem_side_qp.qrule;
694  mooseAssert(qrule, "qrule must be non-null");
695 
696  // Check and see whether we even have sized for this side
697  if (side >= side_qp_data.size())
698  side_qp_data.resize(elem->n_sides());
699 
700  // Ok we were sized enough for our side
701  auto & qp_data = side_qp_data[side];
702  return queryQpCache(qp, *qrule, qp_data, elem_side_qp, state);
703 }
704 
705 template <typename T>
707 FunctorBase<T>::operator()(const ElemPointArg & elem_point, const StateArg & state) const
708 {
709  return evaluate(elem_point, state);
710 }
711 
712 template <typename T>
713 void
714 FunctorBase<T>::setCacheClearanceSchedule(const std::set<ExecFlagType> & clearance_schedule)
715 {
716  if (clearance_schedule.count(EXEC_ALWAYS))
717  _always_evaluate = true;
718 
719  _clearance_schedule = clearance_schedule;
720 }
721 
722 template <typename T>
724 FunctorBase<T>::operator()(const NodeArg & node, const StateArg & state) const
725 {
726  mooseAssert(node.subdomain_ids, "Subdomain IDs must be supplied to the node argument");
727  return evaluate(node, state);
728 }
729 
730 template <typename T>
731 void
733 #if DEBUG
734  face
735 #endif
736 ) const
737 {
738 #if DEBUG
739  const Elem * const elem = face.face_side;
740  const FaceInfo * const fi = face.fi;
741  mooseAssert(fi, "face info should be non-null");
742  bool check_elem_def = false;
743  bool check_neighbor_def = false;
744  // We check if the functor is defined on both sides of the face
745  if (!elem)
746  {
747  if (!hasFaceSide(*fi, true))
748  check_neighbor_def = true;
749  else if (!hasFaceSide(*fi, false))
750  check_elem_def = true;
751  }
752  else if (elem == fi->elemPtr())
753  check_elem_def = true;
754  else
755  {
756  mooseAssert(elem == fi->neighborPtr(), "This has to match something");
757  check_neighbor_def = true;
758  }
759 
760  if (check_elem_def && !hasFaceSide(*fi, true))
761  {
762  std::string additional_message = "It is not defined on the neighbor side either.";
763  if (hasFaceSide(*fi, false))
764  additional_message = "It is however defined on the neighbor side.";
765  additional_message += " Face centroid: " + Moose::stringify(fi->faceCentroid());
766  mooseError(_functor_name,
767  " is not defined on the element side of the face information, but a face argument "
768  "producer "
769  "(e.g. residual object, postprocessor, etc.) has requested evaluation there.\n",
770  additional_message);
771  }
772  if (check_neighbor_def && !hasFaceSide(*fi, false))
773  {
774  std::string additional_message = "It is not defined on the element side either.";
775  if (hasFaceSide(*fi, true))
776  additional_message = "It is however defined on the element side.";
777  additional_message += " Face centroid: " + Moose::stringify(fi->faceCentroid());
778  mooseError(
779  _functor_name,
780  " is not defined on the neighbor side of the face information, but a face argument "
781  "producer (e.g. residual object, postprocessor, etc.) has requested evaluation there.\n",
782  additional_message);
783  }
784 #endif
785 }
786 
787 template <typename T>
788 void
790 {
791  for (auto & map_pr : _qp_to_value)
792  for (auto & pr : map_pr.second)
793  pr.first = false;
794 
795  for (auto & map_pr : _side_qp_to_value)
796  {
797  auto & side_vector = map_pr.second;
798  for (auto & qp_vector : side_vector)
799  for (auto & pr : qp_vector)
800  pr.first = false;
801  }
802 
803  _current_qp_map_key = libMesh::DofObject::invalid_id;
804  _current_qp_map_value = nullptr;
805  _current_side_qp_map_key = libMesh::DofObject::invalid_id;
806  _current_side_qp_map_value = nullptr;
807 
808  _elem_arg_to_value.clear();
809  _face_arg_to_value.clear();
810  _node_arg_to_value.clear();
811 }
812 
813 template <typename T>
814 void
816 {
817  if (_clearance_schedule.count(EXEC_TIMESTEP_BEGIN))
818  clearCacheData();
819 }
820 
821 template <typename T>
822 void
824 {
825  if (_clearance_schedule.count(EXEC_LINEAR))
826  clearCacheData();
827 }
828 
829 template <typename T>
830 void
832 {
833  if (_clearance_schedule.count(EXEC_NONLINEAR))
834  clearCacheData();
835 }
836 
837 template <typename T>
838 void
840 {
841  if (_clearance_schedule.count(exec_type))
842  clearCacheData();
843 }
844 
845 template <typename T>
847 FunctorBase<T>::gradient(const ElemArg & elem, const StateArg & state) const
848 {
849  return evaluateGradient(elem, state);
850 }
851 
852 template <typename T>
854 FunctorBase<T>::gradient(const FaceArg & face, const StateArg & state) const
855 {
856  checkFace(face);
857  return evaluateGradient(face, state);
858 }
859 
860 template <typename T>
862 FunctorBase<T>::gradient(const ElemQpArg & elem_qp, const StateArg & state) const
863 {
864  return evaluateGradient(elem_qp, state);
865 }
866 
867 template <typename T>
869 FunctorBase<T>::gradient(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
870 {
871  return evaluateGradient(elem_side_qp, state);
872 }
873 
874 template <typename T>
876 FunctorBase<T>::gradient(const ElemPointArg & elem_point, const StateArg & state) const
877 {
878  return evaluateGradient(elem_point, state);
879 }
880 
881 template <typename T>
883 FunctorBase<T>::gradient(const NodeArg & node, const StateArg & state) const
884 {
885  return evaluateGradient(node, state);
886 }
887 
888 template <typename T>
890 FunctorBase<T>::dot(const ElemArg & elem, const StateArg & state) const
891 {
892  return evaluateDot(elem, state);
893 }
894 
895 template <typename T>
897 FunctorBase<T>::dot(const FaceArg & face, const StateArg & state) const
898 {
899  checkFace(face);
900  return evaluateDot(face, state);
901 }
902 
903 template <typename T>
905 FunctorBase<T>::dot(const ElemQpArg & elem_qp, const StateArg & state) const
906 {
907  return evaluateDot(elem_qp, state);
908 }
909 
910 template <typename T>
912 FunctorBase<T>::dot(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
913 {
914  return evaluateDot(elem_side_qp, state);
915 }
916 
917 template <typename T>
919 FunctorBase<T>::dot(const ElemPointArg & elem_point, const StateArg & state) const
920 {
921  return evaluateDot(elem_point, state);
922 }
923 
924 template <typename T>
926 FunctorBase<T>::dot(const NodeArg & node, const StateArg & state) const
927 {
928  return evaluateDot(node, state);
929 }
930 
931 template <typename T>
933 FunctorBase<T>::gradDot(const ElemArg & elem, const StateArg & state) const
934 {
935  return evaluateGradDot(elem, state);
936 }
937 
938 template <typename T>
940 FunctorBase<T>::gradDot(const FaceArg & face, const StateArg & state) const
941 {
942  checkFace(face);
943  return evaluateGradDot(face, state);
944 }
945 
946 template <typename T>
948 FunctorBase<T>::gradDot(const ElemQpArg & elem_qp, const StateArg & state) const
949 {
950  return evaluateGradDot(elem_qp, state);
951 }
952 
953 template <typename T>
955 FunctorBase<T>::gradDot(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
956 {
957  return evaluateGradDot(elem_side_qp, state);
958 }
959 
960 template <typename T>
962 FunctorBase<T>::gradDot(const ElemPointArg & elem_point, const StateArg & state) const
963 {
964  return evaluateGradDot(elem_point, state);
965 }
966 
967 template <typename T>
969 FunctorBase<T>::gradDot(const NodeArg & node, const StateArg & state) const
970 {
971  return evaluateGradDot(node, state);
972 }
973 
974 template <typename T>
975 bool
976 FunctorBase<T>::hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const
977 {
978  if (fi_elem_side)
979  return hasBlocks(fi.elem().subdomain_id());
980  else
981  return fi.neighborPtr() && hasBlocks(fi.neighbor().subdomain_id());
982 }
983 
984 template <typename T>
985 template <FunctorEvaluationKind FET, typename Space, typename State>
987 FunctorBase<T>::genericEvaluate(const Space & r, const State & state) const
988 {
989  if constexpr (FET == FunctorEvaluationKind::Value)
990  return (*this)(r, state);
991  else if constexpr (FET == FunctorEvaluationKind::Gradient)
992  return gradient(r, state);
993  else if constexpr (FET == FunctorEvaluationKind::Dot)
994  return dot(r, state);
995  else
996  return gradDot(r, state);
997 }
998 
1004 {
1005 public:
1006  FunctorEnvelopeBase() = default;
1007  virtual ~FunctorEnvelopeBase() = default;
1008 
1012  virtual bool wrapsNull() const = 0;
1013 
1017  virtual std::string returnType() const = 0;
1018 
1022  virtual bool isConstant() const = 0;
1023 
1031  virtual bool ownsWrappedFunctor() const = 0;
1032 };
1033 
1039 template <typename T>
1040 class FunctorEnvelope final : public FunctorBase<T>, public FunctorEnvelopeBase
1041 {
1042 public:
1043  using typename Moose::FunctorBase<T>::ValueType;
1044  using typename Moose::FunctorBase<T>::GradientType;
1045  using typename Moose::FunctorBase<T>::DotType;
1046 
1051  : FunctorBase<T>("wraps_" + wrapped.functorName()), FunctorEnvelopeBase(), _wrapped(&wrapped)
1052  {
1053  }
1054 
1060  FunctorEnvelope(std::unique_ptr<FunctorBase<T>> && wrapped)
1061  : FunctorBase<T>("wraps_" + wrapped->functorName()),
1063  _owned(std::move(wrapped)),
1064  _wrapped(_owned.get())
1065  {
1066  }
1067 
1072  FunctorEnvelope(FunctorBase<T> &&) = delete;
1073 
1078  void assign(const FunctorBase<T> & wrapped)
1079  {
1080  _owned.reset();
1081  _wrapped = &wrapped;
1082  }
1083 
1088  void assign(std::unique_ptr<FunctorBase<T>> && wrapped)
1089  {
1090  _owned = std::move(wrapped);
1091  _wrapped = _owned.get();
1092  }
1093 
1098  void assign(FunctorBase<T> &&) = delete;
1099 
1100  FunctorEnvelope(const FunctorEnvelope &) = delete;
1101  FunctorEnvelope(FunctorEnvelope &&) = delete;
1102  FunctorEnvelope & operator=(const FunctorEnvelope &) = delete;
1103  FunctorEnvelope & operator=(FunctorEnvelope &&) = delete;
1104 
1105  virtual ~FunctorEnvelope() = default;
1106 
1110  virtual bool wrapsNull() const override { return wrapsType<NullFunctor<T>>(); }
1111 
1115  virtual std::string returnType() const override { return libMesh::demangle(typeid(T).name()); }
1116 
1117  virtual bool ownsWrappedFunctor() const override { return _owned.get(); }
1118 
1122  template <typename T2>
1123  bool wrapsType() const
1124  {
1125  return dynamic_cast<const T2 *>(_wrapped);
1126  }
1127 
1128  virtual bool isExtrapolatedBoundaryFace(const FaceInfo & fi,
1129  const Elem * const elem,
1130  const StateArg & state) const override
1131  {
1132  return _wrapped->isExtrapolatedBoundaryFace(fi, elem, state);
1133  }
1134  virtual bool isConstant() const override { return _wrapped->isConstant(); }
1135  virtual bool hasBlocks(const SubdomainID id) const override { return _wrapped->hasBlocks(id); }
1136  virtual bool hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const override
1137  {
1138  return _wrapped->hasFaceSide(fi, fi_elem_side);
1139  }
1140 
1141  bool supportsFaceArg() const override final { return true; }
1142  bool supportsElemSideQpArg() const override final { return true; }
1143 
1144 protected:
1146 
1149  virtual ValueType evaluate(const ElemArg & elem, const StateArg & state) const override
1150  {
1151  return _wrapped->operator()(elem, state);
1152  }
1153  virtual ValueType evaluate(const FaceArg & face, const StateArg & state) const override
1154  {
1155  return _wrapped->operator()(face, state);
1156  }
1157  virtual ValueType evaluate(const ElemQpArg & qp, const StateArg & state) const override
1158  {
1159  return _wrapped->operator()(qp, state);
1160  }
1161  virtual ValueType evaluate(const ElemSideQpArg & qp, const StateArg & state) const override
1162  {
1163  return _wrapped->operator()(qp, state);
1164  }
1165  virtual ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const override
1166  {
1167  return _wrapped->operator()(elem_point, state);
1168  }
1169  virtual ValueType evaluate(const NodeArg & node, const StateArg & state) const override
1170  {
1171  return _wrapped->operator()(node, state);
1172  }
1173 
1174  virtual GradientType evaluateGradient(const ElemArg & elem, const StateArg & state) const override
1175  {
1176  return _wrapped->gradient(elem, state);
1177  }
1178  virtual GradientType evaluateGradient(const FaceArg & face, const StateArg & state) const override
1179  {
1180  return _wrapped->gradient(face, state);
1181  }
1182  virtual GradientType evaluateGradient(const ElemQpArg & qp, const StateArg & state) const override
1183  {
1184  return _wrapped->gradient(qp, state);
1185  }
1187  const StateArg & state) const override
1188  {
1189  return _wrapped->gradient(qp, state);
1190  }
1191  virtual GradientType evaluateGradient(const ElemPointArg & elem_point,
1192  const StateArg & state) const override
1193  {
1194  return _wrapped->gradient(elem_point, state);
1195  }
1196  virtual GradientType evaluateGradient(const NodeArg & node, const StateArg & state) const override
1197  {
1198  return _wrapped->gradient(node, state);
1199  }
1200 
1201  virtual DotType evaluateDot(const ElemArg & elem, const StateArg & state) const override
1202  {
1203  return _wrapped->dot(elem, state);
1204  }
1205  virtual DotType evaluateDot(const FaceArg & face, const StateArg & state) const override
1206  {
1207  return _wrapped->dot(face, state);
1208  }
1209  virtual DotType evaluateDot(const ElemQpArg & qp, const StateArg & state) const override
1210  {
1211  return _wrapped->dot(qp, state);
1212  }
1213  virtual DotType evaluateDot(const ElemSideQpArg & qp, const StateArg & state) const override
1214  {
1215  return _wrapped->dot(qp, state);
1216  }
1217  virtual DotType evaluateDot(const ElemPointArg & elem_point,
1218  const StateArg & state) const override
1219  {
1220  return _wrapped->dot(elem_point, state);
1221  }
1222  virtual DotType evaluateDot(const NodeArg & node, const StateArg & state) const override
1223  {
1224  return _wrapped->dot(node, state);
1225  }
1226 
1227  virtual GradientType evaluateGradDot(const ElemArg & elem, const StateArg & state) const override
1228  {
1229  return _wrapped->gradDot(elem, state);
1230  }
1231  virtual GradientType evaluateGradDot(const FaceArg & face, const StateArg & state) const override
1232  {
1233  return _wrapped->gradDot(face, state);
1234  }
1235  virtual GradientType evaluateGradDot(const ElemQpArg & qp, const StateArg & state) const override
1236  {
1237  return _wrapped->gradDot(qp, state);
1238  }
1240  const StateArg & state) const override
1241  {
1242  return _wrapped->gradDot(qp, state);
1243  }
1244  virtual GradientType evaluateGradDot(const ElemPointArg & elem_point,
1245  const StateArg & state) const override
1246  {
1247  return _wrapped->gradDot(elem_point, state);
1248  }
1249  virtual GradientType evaluateGradDot(const NodeArg & node, const StateArg & state) const override
1250  {
1251  return _wrapped->gradDot(node, state);
1252  }
1254 
1255 private:
1257  std::unique_ptr<FunctorBase<T>> _owned;
1259 
1260  friend class ::SubProblem;
1261 };
1262 
1266 template <typename T>
1267 class ConstantFunctor final : public FunctorBase<T>
1268 {
1269 public:
1270  using typename FunctorBase<T>::FunctorType;
1271  using typename FunctorBase<T>::ValueType;
1272  using typename FunctorBase<T>::GradientType;
1273  using typename FunctorBase<T>::DotType;
1274 
1276  : FunctorBase<T>("constant_" + std::to_string(value)), _value(value)
1277  {
1278  }
1280  : FunctorBase<T>("constant_" + std::to_string(MetaPhysicL::raw_value(value))), _value(value)
1281  {
1282  }
1283 
1284  virtual bool isConstant() const override { return true; }
1285 
1286  bool hasBlocks(SubdomainID /* id */) const override { return true; }
1287 
1288  bool supportsFaceArg() const override final { return true; }
1289  bool supportsElemSideQpArg() const override final { return true; }
1290 
1291 private:
1292  ValueType evaluate(const ElemArg &, const StateArg &) const override { return _value; }
1293  ValueType evaluate(const FaceArg &, const StateArg &) const override { return _value; }
1294  ValueType evaluate(const ElemQpArg &, const StateArg &) const override { return _value; }
1295  ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override { return _value; }
1296  ValueType evaluate(const ElemPointArg &, const StateArg &) const override { return _value; }
1297  ValueType evaluate(const NodeArg &, const StateArg &) const override { return _value; }
1298 
1299  GradientType evaluateGradient(const ElemArg &, const StateArg &) const override { return 0; }
1300  GradientType evaluateGradient(const FaceArg &, const StateArg &) const override { return 0; }
1301  GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const override { return 0; }
1302  GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const override
1303  {
1304  return 0;
1305  }
1306  GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const override { return 0; }
1307  GradientType evaluateGradient(const NodeArg &, const StateArg &) const override { return 0; }
1308 
1309  DotType evaluateDot(const ElemArg &, const StateArg &) const override { return 0; }
1310  DotType evaluateDot(const FaceArg &, const StateArg &) const override { return 0; }
1311  DotType evaluateDot(const ElemQpArg &, const StateArg &) const override { return 0; }
1312  DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const override { return 0; }
1313  DotType evaluateDot(const ElemPointArg &, const StateArg &) const override { return 0; }
1314  DotType evaluateDot(const NodeArg &, const StateArg &) const override { return 0; }
1315 
1316  GradientType evaluateGradDot(const ElemArg &, const StateArg &) const override { return 0; }
1317  GradientType evaluateGradDot(const FaceArg &, const StateArg &) const override { return 0; }
1318  GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const override { return 0; }
1319  GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const override { return 0; }
1320  GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const override { return 0; }
1321  GradientType evaluateGradDot(const NodeArg &, const StateArg &) const override { return 0; }
1322 
1323 private:
1325 };
1326 
1331 template <typename T>
1332 class NullFunctor final : public FunctorBase<T>
1333 {
1334 public:
1335  using typename FunctorBase<T>::FunctorType;
1336  using typename FunctorBase<T>::ValueType;
1337  using typename FunctorBase<T>::GradientType;
1338  using typename FunctorBase<T>::DotType;
1339 
1340  NullFunctor() : FunctorBase<T>("null") {}
1341 
1342  // For backwards compatiblity of unit testing
1343  bool hasFaceSide(const FaceInfo & fi, bool) const override;
1344 
1345  bool supportsFaceArg() const override final { return false; }
1346  bool supportsElemSideQpArg() const override final { return false; }
1347 
1348 private:
1349  ValueType evaluate(const ElemArg &, const StateArg &) const override
1350  {
1351  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1352  "they've written broken code");
1353  }
1354  ValueType evaluate(const FaceArg &, const StateArg &) const override
1355  {
1356  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1357  "they've written broken code");
1358  }
1359  ValueType evaluate(const ElemQpArg &, const StateArg &) const override
1360  {
1361  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1362  "they've written broken code");
1363  }
1364  ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override
1365  {
1366  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1367  "they've written broken code");
1368  }
1369  ValueType evaluate(const ElemPointArg &, const StateArg &) const override
1370  {
1371  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1372  "they've written broken code");
1373  }
1374  ValueType evaluate(const NodeArg &, const StateArg &) const override
1375  {
1376  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1377  "they've written broken code");
1378  }
1379 };
1380 
1381 template <typename T>
1382 bool
1383 NullFunctor<T>::hasFaceSide(const FaceInfo &, const bool) const
1384 {
1385  // For backwards compatiblity of unit testing
1386  return true;
1387 }
1388 }
std::string name(const ElemQuality q)
virtual DotType evaluateDot(const FaceArg &face, const StateArg &state) const override
ValueType evaluate(const NodeArg &, const StateArg &) const override
virtual bool wrapsNull() const override
GradientType evaluateGradDot(const ElemArg &, const StateArg &) const override
Evaluate the functor gradient-dot with a given element.
virtual bool hasBlocks(SubdomainID) const
Returns whether the functor is defined on this block.
Definition: MooseFunctor.h:237
unsigned int side
The local side index.
virtual GradientType evaluateGradient(const NodeArg &, const StateArg &) const
Definition: MooseFunctor.h:376
void assign(std::unique_ptr< FunctorBase< T >> &&wrapped)
const libMesh::QBase * qrule
The quadrature rule.
virtual ValueType evaluate(const ElemQpArg &qp, const StateArg &state) const override
virtual GradientType evaluateGradient(const NodeArg &node, const StateArg &state) const override
void setCacheClearanceSchedule(const std::set< ExecFlagType > &clearance_schedule)
Set how often to clear the functor evaluation cache.
Definition: MooseFunctor.h:714
ValueType evaluate(const ElemQpArg &, const StateArg &) const override
Base class template for functor objects.
Definition: MooseFunctor.h:137
virtual GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const
Definition: MooseFunctor.h:362
ConstantFunctor(ValueType &&value)
FunctorEnvelope(std::unique_ptr< FunctorBase< T >> &&wrapped)
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
dof_id_type _current_qp_map_key
Current key for qp map cache.
Definition: MooseFunctor.h:523
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
DotType evaluateDot(const ElemQpArg &, const StateArg &) const override
ValueType evaluate(const ElemArg &, const StateArg &) const override
Evaluate the functor with a given element.
virtual GradientType evaluateGradDot(const ElemSideQpArg &qp, const StateArg &state) const override
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
virtual std::string returnType() const override
GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const override
virtual DotType evaluateDot(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor time derivative with a given element.
ValueType evaluate(const FaceArg &, const StateArg &) const override
virtual ~FunctorEnvelope()=default
const Elem & elem() const
Definition: FaceInfo.h:81
GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const override
virtual void customSetup(const ExecFlagType &exec_type)=0
virtual GradientType evaluateGradDot(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor gradient-dot with a given element and point.
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
virtual GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const
Evaluate the functor gradient-dot with a given element and point.
Definition: MooseFunctor.h:479
virtual bool isConstant() const =0
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
virtual void timestepSetup()=0
virtual ValueType evaluate(const NodeArg &node, const StateArg &state) const override
virtual std::string returnType() const =0
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition: FaceInfo.h:71
This is a wrapper that forwards calls to the implementation, which can be switched out at any time wi...
virtual bool isExtrapolatedBoundaryFace(const FaceInfo &, const Elem *, const StateArg &) const
Returns whether this (sided) face is an extrapolated boundary face for this functor.
Definition: MooseFunctor.h:247
virtual GradientType evaluateGradient(const ElemSideQpArg &qp, const StateArg &state) const override
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const override
Evaluate the functor gradient-dot with a given element and point.
std::map< FaceArg, ValueType > _face_arg_to_value
Map from face arguments to their cached evaluations.
Definition: MooseFunctor.h:558
DotType evaluateDot(const ElemArg &, const StateArg &) const override
Evaluate the functor time derivative with a given element.
We need to instantiate the following CompareTypes to tell the compiler that ADReal is a subtype of Ch...
virtual bool isConstant() const override
Returns true if this functor is a constant.
A structure that is used to evaluate Moose functors at an arbitrary physical point contained within a...
virtual DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const
Definition: MooseFunctor.h:416
virtual DotType evaluateDot(const ElemPointArg &, const StateArg &) const
Evaluate the functor time derivative with a given element and point.
Definition: MooseFunctor.h:425
const ExecFlagType EXEC_ALWAYS
Definition: Moose.C:47
A non-templated base class for functors that allow an owner object to hold different class template i...
GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const override
virtual GradientType evaluateGradient(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor gradient with a given element.
virtual DotType evaluateDot(const ElemQpArg &, const StateArg &) const
Definition: MooseFunctor.h:405
GradientType evaluateGradient(const ElemArg &, const StateArg &) const override
Evaluate the functor gradient with a given element.
virtual ~FunctorEnvelopeBase()=default
typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector...
Definition: MooseFunctor.h:149
ValueType evaluate(const FaceArg &, const StateArg &) const override
std::vector< std::pair< bool, ValueType > > * _current_qp_map_value
Current value for qp map cache.
Definition: MooseFunctor.h:526
virtual DotType evaluateDot(const ElemArg &, const StateArg &) const
Evaluate the functor time derivative with a given element.
Definition: MooseFunctor.h:385
bool hasBlocks(SubdomainID) const override
Returns whether the functor is defined on this block.
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
Abstract base class that can be used to hold collections of functors.
Definition: MooseFunctor.h:121
GradientType gradDot(const ElemArg &elem, const StateArg &state) const
Same as their evaluateGradDot overloads with the same arguments but allows for caching implementation...
Definition: MooseFunctor.h:933
GradientType evaluateGradient(const NodeArg &, const StateArg &) const override
DotType evaluateDot(const ElemPointArg &, const StateArg &) const override
Evaluate the functor time derivative with a given element and point.
virtual void customSetup(const ExecFlagType &exec_type) override
Definition: MooseFunctor.h:839
GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const override
Evaluate the functor gradient with a given element and point.
FunctorEvaluationKind
An enumeration of possible functor evaluation kinds.
Definition: MooseFunctor.h:36
MetaPhysicL::ReplaceAlgebraicType< T, typename libMesh::TensorTools::IncrementRank< typename MetaPhysicL::ValueType< T >::type >::type >::type type
Definition: MooseFunctor.h:72
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.
Definition: MooseFunctor.h:552
bool isInternalFace(const FaceInfo &) const
Returns true if the face is an internal face.
Definition: MooseFunctor.h:569
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:36
virtual bool supportsElemSideQpArg() const =0
Whether this functor supports evaluation with ElemSideQpArg.
virtual GradientType evaluateGradient(const ElemQpArg &qp, const StateArg &state) const override
const std::set< SubdomainID > * subdomain_ids
Indicates what subdomains this argument should be associated with.
const Elem * neighborPtr() const
Definition: FaceInfo.h:84
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.
virtual void jacobianSetup()=0
virtual GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const
Definition: MooseFunctor.h:352
MooseFunctorName _functor_name
name of the functor
Definition: MooseFunctor.h:564
dof_id_type id() const
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
virtual bool hasBlocks(const SubdomainID id) const override
Returns whether the functor is defined on this block.
A structure defining a "face" evaluation calling argument for Moose functors.
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
Definition: MooseFunctor.h:626
unsigned int qp
The quadrature point index.
virtual GradientType evaluateGradient(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor gradient with a given element and point.
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition: Moose.C:35
virtual bool ownsWrappedFunctor() const =0
virtual GradientType evaluateGradDot(const FaceArg &, const StateArg &) const
Definition: MooseFunctor.h:449
void checkFace(const Moose::FaceArg &face) const
Examines the incoming face argument.
Definition: MooseFunctor.h:732
virtual GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const
Definition: MooseFunctor.h:459
virtual GradientType evaluateGradDot(const NodeArg &node, const StateArg &state) const override
ValueType queryFVArgCache(std::map< SpaceArg, ValueType > &cache_data, const SpaceArg &space) const
check a finite volume spatial argument cache and if invalid then evaluate
Definition: MooseFunctor.h:580
const libMesh::QBase * qrule
The quadrature rule.
ValueType evaluate(const ElemPointArg &, const StateArg &) const override
Evaluate the functor with a given element and point.
virtual DotType evaluateDot(const NodeArg &, const StateArg &) const
Definition: MooseFunctor.h:430
virtual GradientType evaluateGradient(const ElemArg &, const StateArg &) const
Evaluate the functor gradient with a given element.
Definition: MooseFunctor.h:332
const Elem & neighbor() const
Definition: FaceInfo.h:216
static const dof_id_type invalid_id
ValueType evaluate(const ElemArg &, const StateArg &) const override
Evaluate the functor with a given element.
virtual ValueType evaluate(const FaceArg &face, const StateArg &state) const override
virtual bool wrapsNull() const =0
A structure that is used to evaluate Moose functors logically at an element/cell center.
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
unsigned int n_points() const
ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override
virtual GradientType evaluateGradDot(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor gradient-dot with a given element.
Argument for requesting functor evaluation at a quadrature point location in an element.
virtual void jacobianSetup() override
Definition: MooseFunctor.h:831
T evaluate(Real, const Point &)
The general evaluation method is not defined.
const libMesh::Elem * elem
The element.
virtual void timestepSetup() override
Definition: MooseFunctor.h:815
virtual GradientType evaluateGradDot(const ElemArg &, const StateArg &) const
Evaluate the functor gradient-dot with a given element.
Definition: MooseFunctor.h:439
const ExecFlagType EXEC_LINEAR
Definition: Moose.C:29
virtual GradientType evaluateGradient(const FaceArg &, const StateArg &) const
Definition: MooseFunctor.h:342
virtual ValueType evaluate(const ElemArg &elem, const StateArg &state) const =0
Evaluate the functor with a given element.
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
std::string demangle(const char *name)
virtual DotType evaluateDot(const FaceArg &, const StateArg &) const
Definition: MooseFunctor.h:395
std::map< ElemArg, ValueType > _elem_arg_to_value
Map from element arguments to their cached evaluations.
Definition: MooseFunctor.h:555
const MooseFunctorName & functorName() const
Return the functor name.
Definition: MooseFunctor.h:170
FunctorEnvelope(const FunctorBase< T > &wrapped)
ValueType evaluate(const NodeArg &, const StateArg &) const override
dof_id_type _current_side_qp_map_key
Current key for side-qp map cache.
Definition: MooseFunctor.h:539
const Elem * elemPtr() const
Definition: FaceInfo.h:82
This structure takes an evaluation kind as a template argument and defines a constant expression indi...
Definition: MooseFunctor.h:98
virtual void residualSetup()=0
const ExecFlagType EXEC_NONLINEAR
Definition: Moose.C:31
virtual GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const
Definition: MooseFunctor.h:470
virtual GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const
Evaluate the functor gradient with a given element and point.
Definition: MooseFunctor.h:371
virtual ~FunctorBase()=default
ConstantFunctor(const ValueType &value)
ValueType operator()(const ElemArg &elem, const StateArg &state) const
Same as their evaluate overloads with the same arguments but allows for caching implementation.
Definition: MooseFunctor.h:597
virtual bool supportsFaceArg() const =0
Whether this functor supports evaluation with FaceArg.
DotType dot(const ElemArg &elem, const StateArg &state) const
Same as their evaluateDot overloads with the same arguments but allows for caching implementation...
Definition: MooseFunctor.h:890
Class template for creating constant functors.
virtual ValueType evaluate(const ElemSideQpArg &qp, const StateArg &state) const override
std::unique_ptr< FunctorBase< T > > _owned
Our wrapped object.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type type
Definition: MooseFunctor.h:90
GradientType evaluateGradDot(const NodeArg &, const StateArg &) const override
DotType evaluateDot(const NodeArg &, const StateArg &) const override
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
GradientType evaluateGradDot(const FaceArg &, const StateArg &) const override
bool hasFaceSide(const FaceInfo &fi, bool) const override
GradientType gradient(const ElemArg &elem, const StateArg &state) const
Same as their evaluateGradient overloads with the same arguments but allows for caching implementatio...
Definition: MooseFunctor.h:847
std::vector< std::vector< std::pair< bool, ValueType > > > * _current_side_qp_map_value
Current value for side-qp map cache.
Definition: MooseFunctor.h:542
bool _always_evaluate
Boolean to check if we always need evaluation.
Definition: MooseFunctor.h:517
GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const override
virtual DotType evaluateDot(const NodeArg &node, const StateArg &state) const override
ValueType evaluate(const ElemQpArg &, const StateArg &) const override
State argument for evaluating functors.
void clearCacheData()
clear cache data
Definition: MooseFunctor.h:789
FunctorBase(const MooseFunctorName &name, const std::set< ExecFlagType > &clearance_schedule={EXEC_ALWAYS})
Definition: MooseFunctor.h:153
virtual void residualSetup() override
Definition: MooseFunctor.h:823
void assign(const FunctorBase< T > &wrapped)
unsigned int qp
The quadrature point index.
virtual GradientType evaluateGradient(const FaceArg &face, const StateArg &state) const override
FunctorEnvelope & operator=(const 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.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override
DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const override
virtual bool isConstant() const
Returns true if this functor is a constant.
Definition: MooseFunctor.h:260
const libMesh::Elem * elem
The element.
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override
GradientType evaluateGradient(const FaceArg &, const StateArg &) const override
A structure that defines the return type of a functor based on the type of the functor and the reques...
Definition: MooseFunctor.h:49
virtual DotType evaluateDot(const ElemSideQpArg &qp, const StateArg &state) const override
virtual GradientType evaluateGradDot(const NodeArg &, const StateArg &) const
Definition: MooseFunctor.h:484
DotType evaluateDot(const FaceArg &, const StateArg &) const override
const FunctorBase< T > * _wrapped
A base class interface for both producers and consumers of functor face arguments, e.g.
StateArg currentState()
virtual DotType evaluateDot(const ElemQpArg &qp, const StateArg &state) const override
A functor that serves as a placeholder during the simulation setup phase if a functor consumer reques...
virtual GradientType evaluateGradDot(const FaceArg &face, const StateArg &state) const override
Argument for requesting functor evaluation at quadrature point locations on an element side...
std::unordered_map< dof_id_type, std::vector< std::pair< bool, ValueType > > > _qp_to_value
Cached element quadrature point functor property evaluations.
Definition: MooseFunctor.h:533
virtual GradientType evaluateGradDot(const ElemQpArg &qp, const StateArg &state) const override
unsigned int state
The state.
virtual ValueType evaluate(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor 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...
Definition: MooseFunctor.h:987
uint8_t dof_id_type
std::map< NodeArg, ValueType > _node_arg_to_value
Map from nodal arguments to their cached evaluations.
Definition: MooseFunctor.h:561
std::set< ExecFlagType > _clearance_schedule
How often to clear the material property cache.
Definition: MooseFunctor.h:514
virtual bool ownsWrappedFunctor() const override
ValueType evaluate(const ElemPointArg &, const StateArg &) const override
Evaluate the functor with a given element and point.
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override
Definition: MooseFunctor.h:976
virtual ValueType evaluate(const ElemArg &elem, const StateArg &state) const override
Forward calls to wrapped object.
virtual bool isConstant() const override
Returns true if this functor is a constant.