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  setCacheClearanceSchedule(clearance_schedule);
158  }
159 
160 #ifdef MOOSE_KOKKOS_ENABLED
161 
165 #endif
166 
171  template <FunctorEvaluationKind FET, typename Space, typename State>
172  typename FunctorReturnType<T, FET>::type genericEvaluate(const Space & r,
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;
190 
192 
196  GradientType gradient(const ElemArg & elem, const StateArg & state) const;
197  GradientType gradient(const FaceArg & face, const StateArg & state) const;
198  GradientType gradient(const ElemQpArg & qp, const StateArg & state) const;
199  GradientType gradient(const ElemSideQpArg & qp, const StateArg & state) const;
200  GradientType gradient(const ElemPointArg & elem_point, const StateArg & state) const;
201  GradientType gradient(const NodeArg & node, const StateArg & state) const;
203 
205 
209  DotType dot(const ElemArg & elem, const StateArg & state) const;
210  DotType dot(const FaceArg & face, const StateArg & state) const;
211  DotType dot(const ElemQpArg & qp, const StateArg & state) const;
212  DotType dot(const ElemSideQpArg & qp, const StateArg & state) const;
213  DotType dot(const ElemPointArg & elem_point, const StateArg & state) const;
214  DotType dot(const NodeArg & node, const StateArg & state) const;
216 
218 
222  GradientType gradDot(const ElemArg & elem, const StateArg & state) const;
223  GradientType gradDot(const FaceArg & face, const StateArg & state) const;
224  GradientType gradDot(const ElemQpArg & qp, const StateArg & state) const;
225  GradientType gradDot(const ElemSideQpArg & qp, const StateArg & state) const;
226  GradientType gradDot(const ElemPointArg & elem_point, const StateArg & state) const;
227  GradientType gradDot(const NodeArg & node, const StateArg & state) const;
229 
230  virtual void residualSetup() override;
231  virtual void jacobianSetup() override;
232  virtual void timestepSetup() override;
233  virtual void customSetup(const ExecFlagType & exec_type) override;
234 
238  void setCacheClearanceSchedule(const std::set<ExecFlagType> & clearance_schedule);
239 
243  virtual bool hasBlocks(SubdomainID /* id */) const
244  {
245  mooseError("Block restriction has not been implemented for functor " + functorName());
246  return false;
247  }
248 
253  virtual bool isExtrapolatedBoundaryFace(const FaceInfo &, const Elem *, const StateArg &) const
254  {
255  mooseError("not implemented");
256  }
257 
261  bool isInternalFace(const FaceInfo &) const;
262 
266  virtual bool isConstant() const { return false; }
267 
268  virtual bool hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const override;
269 
280  void checkFace(const Moose::FaceArg & face) const;
281 
285  virtual bool supportsFaceArg() const = 0;
286 
290  virtual bool supportsElemSideQpArg() const = 0;
291 
292 protected:
298 
303  virtual ValueType evaluate(const ElemArg & elem, const StateArg & state) const = 0;
304 
310  virtual ValueType evaluate(const FaceArg & face, const StateArg & state) const = 0;
311 
317  virtual ValueType evaluate(const ElemQpArg & qp, const StateArg & state) const = 0;
318 
324  virtual ValueType evaluate(const ElemSideQpArg & side_qp, const StateArg & state) const = 0;
325 
330  virtual ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const = 0;
331 
332  virtual ValueType evaluate(const NodeArg & node, const StateArg & state) const = 0;
333 
338  virtual GradientType evaluateGradient(const ElemArg &, const StateArg &) const
339  {
340  mooseError("Element gradient not implemented for functor " + functorName());
341  }
342 
348  virtual GradientType evaluateGradient(const FaceArg &, const StateArg &) const
349  {
350  mooseError("Face gradient not implemented for functor " + functorName());
351  }
352 
358  virtual GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const
359  {
360  mooseError("Element quadrature point gradient not implemented for functor " + functorName());
361  }
362 
368  virtual GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const
369  {
370  mooseError("Element side quadrature point gradient not implemented for functor " +
371  functorName());
372  }
373 
377  virtual GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const
378  {
379  mooseError("Element-point gradient not implemented for functor " + functorName());
380  }
381 
382  virtual GradientType evaluateGradient(const NodeArg &, const StateArg &) const
383  {
384  mooseError("Gradient at node not implemented for functor " + functorName());
385  }
386 
391  virtual DotType evaluateDot(const ElemArg &, const StateArg &) const
392  {
393  mooseError("Element time derivative not implemented for functor " + functorName());
394  }
395 
401  virtual DotType evaluateDot(const FaceArg &, const StateArg &) const
402  {
403  mooseError("Face time derivative not implemented for functor " + functorName());
404  }
405 
411  virtual DotType evaluateDot(const ElemQpArg &, const StateArg &) const
412  {
413  mooseError("Element quadrature point time derivative not implemented for functor " +
414  functorName());
415  }
416 
422  virtual DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const
423  {
424  mooseError("Element side quadrature point time derivative not implemented for functor " +
425  functorName());
426  }
427 
431  virtual DotType evaluateDot(const ElemPointArg &, const StateArg &) const
432  {
433  mooseError("Element-point time derivative not implemented for functor " + functorName());
434  }
435 
436  virtual DotType evaluateDot(const NodeArg &, const StateArg &) const
437  {
438  mooseError("Time derivative at node not implemented for functor " + functorName());
439  }
440 
445  virtual GradientType evaluateGradDot(const ElemArg &, const StateArg &) const
446  {
447  mooseError("Element gradient-dot not implemented for functor " + functorName());
448  }
449 
455  virtual GradientType evaluateGradDot(const FaceArg &, const StateArg &) const
456  {
457  mooseError("Face gradient-dot not implemented for functor " + functorName());
458  }
459 
465  virtual GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const
466  {
467  mooseError("Element quadrature point gradient-dot not implemented for functor " +
468  functorName());
469  }
470 
476  virtual GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const
477  {
478  mooseError("Element side quadrature point gradient-dot not implemented for functor " +
479  functorName());
480  }
481 
485  virtual GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const
486  {
487  mooseError("Element-point gradient-dot not implemented for functor " + functorName());
488  }
489 
490  virtual GradientType evaluateGradDot(const NodeArg &, const StateArg &) const
491  {
492  mooseError("Gradient-dot at node not implemented for functor " + functorName());
493  }
495 
496 private:
500  void clearCacheData();
501 
505  template <typename SpaceArg, typename StateArg>
506  ValueType queryQpCache(unsigned int qp,
507  const libMesh::QBase & qrule,
508  std::vector<std::pair<bool, T>> & qp_cache_data,
509  const SpaceArg & space,
510  const StateArg & state) const;
511 
515  template <typename SpaceArg>
516  ValueType queryFVArgCache(std::map<SpaceArg, ValueType> & cache_data,
517  const SpaceArg & space) const;
518 
520  std::set<ExecFlagType> _clearance_schedule;
521 
524 
525  // Data for traditional element-quadrature point property evaluations which are useful for
526  // caching implementation
527 
530 
532  mutable std::vector<std::pair<bool, ValueType>> * _current_qp_map_value = nullptr;
533 
539  mutable std::unordered_map<dof_id_type, std::vector<std::pair<bool, ValueType>>> _qp_to_value;
540 
541  // Data for traditional element-side-quadrature point property evaluations which are useful for
542  // caching implementation
543 
546 
548  mutable std::vector<std::vector<std::pair<bool, ValueType>>> * _current_side_qp_map_value =
549  nullptr;
550 
557  mutable std::unordered_map<dof_id_type, std::vector<std::vector<std::pair<bool, ValueType>>>>
559 
561  mutable std::map<ElemArg, ValueType> _elem_arg_to_value;
562 
564  mutable std::map<FaceArg, ValueType> _face_arg_to_value;
565 
567  mutable std::map<NodeArg, ValueType> _node_arg_to_value;
568 
570  MooseFunctorName _functor_name;
571 };
572 
573 template <typename T>
574 bool
576 {
577  if (!fi.neighborPtr())
578  return false;
579 
580  return hasBlocks(fi.elem().subdomain_id()) && hasBlocks(fi.neighborPtr()->subdomain_id());
581 }
582 
583 template <typename T>
584 template <typename SpaceArg>
586 FunctorBase<T>::queryFVArgCache(std::map<SpaceArg, ValueType> & cache_data,
587  const SpaceArg & space) const
588 {
589  // We don't want to evaluate if the key already exists, so instead we value initialize
590  auto [it, inserted] = cache_data.try_emplace(space, ValueType());
591  auto & value = it->second;
592 
593  if (inserted)
594  // value not ready to go
595  // this function is only called from functions that assert we are in the current time state
596  value = evaluate(space, currentState());
597 
598  return value;
599 }
600 
601 template <typename T>
603 FunctorBase<T>::operator()(const ElemArg & elem, const StateArg & state) const
604 {
605  if (_always_evaluate)
606  return evaluate(elem, state);
607 
608  mooseAssert(state.state == 0,
609  "Cached evaluations are only currently supported for the current state.");
610 
611  return queryFVArgCache(_elem_arg_to_value, elem);
612 }
613 
614 template <typename T>
616 FunctorBase<T>::operator()(const FaceArg & face_in, const StateArg & state) const
617 {
618  checkFace(face_in);
619 
620  if (_always_evaluate)
621  return evaluate(face_in, state);
622 
623  mooseAssert(state.state == 0,
624  "Cached evaluations are only currently supported for the current state.");
625 
626  return queryFVArgCache(_face_arg_to_value, face_in);
627 }
628 
629 template <typename T>
630 template <typename SpaceArg, typename StateArg>
632 FunctorBase<T>::queryQpCache(const unsigned int qp,
633  const libMesh::QBase & qrule,
634  std::vector<std::pair<bool, ValueType>> & qp_cache_data,
635  const SpaceArg & space,
636  const StateArg & state) const
637 {
638  // Check and see whether we even have sized for this quadrature point. If we haven't then we
639  // must evaluate
640  if (qp >= qp_cache_data.size())
641  {
642  qp_cache_data.resize(qrule.n_points(), std::make_pair(false, ValueType()));
643  auto & pr = qp_cache_data[qp];
644  pr.second = evaluate(space, state);
645  pr.first = true;
646  return pr.second;
647  }
648 
649  // We've already sized for this qp, so let's see whether we have a valid cache value
650  auto & pr = qp_cache_data[qp];
651  if (pr.first)
652  return pr.second;
653 
654  // No valid cache value so evaluate
655  pr.second = evaluate(space, state);
656  pr.first = true;
657  return pr.second;
658 }
659 
660 template <typename T>
662 FunctorBase<T>::operator()(const ElemQpArg & elem_qp, const StateArg & state) const
663 {
664  if (_always_evaluate)
665  return evaluate(elem_qp, state);
666 
667  const auto elem_id = elem_qp.elem->id();
668  if (elem_id != _current_qp_map_key)
669  {
670  _current_qp_map_key = elem_id;
671  _current_qp_map_value = &_qp_to_value[elem_id];
672  }
673  auto & qp_data = *_current_qp_map_value;
674  const auto qp = elem_qp.qp;
675  const auto * const qrule = elem_qp.qrule;
676  mooseAssert(qrule, "qrule must be non-null");
677 
678  return queryQpCache(qp, *qrule, qp_data, elem_qp, state);
679 }
680 
681 template <typename T>
683 FunctorBase<T>::operator()(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
684 {
685  if (_always_evaluate)
686  return evaluate(elem_side_qp, state);
687 
688  const Elem * const elem = elem_side_qp.elem;
689  mooseAssert(elem, "elem must be non-null");
690  const auto elem_id = elem->id();
691  if (elem_id != _current_side_qp_map_key)
692  {
693  _current_side_qp_map_key = elem_id;
694  _current_side_qp_map_value = &_side_qp_to_value[elem_id];
695  }
696  auto & side_qp_data = *_current_side_qp_map_value;
697  const auto side = elem_side_qp.side;
698  const auto qp = elem_side_qp.qp;
699  const auto * const qrule = elem_side_qp.qrule;
700  mooseAssert(qrule, "qrule must be non-null");
701 
702  // Check and see whether we even have sized for this side
703  if (side >= side_qp_data.size())
704  side_qp_data.resize(elem->n_sides());
705 
706  // Ok we were sized enough for our side
707  auto & qp_data = side_qp_data[side];
708  return queryQpCache(qp, *qrule, qp_data, elem_side_qp, state);
709 }
710 
711 template <typename T>
713 FunctorBase<T>::operator()(const ElemPointArg & elem_point, const StateArg & state) const
714 {
715  return evaluate(elem_point, state);
716 }
717 
718 template <typename T>
719 void
720 FunctorBase<T>::setCacheClearanceSchedule(const std::set<ExecFlagType> & clearance_schedule)
721 {
722  if (clearance_schedule.count(EXEC_ALWAYS))
723  _always_evaluate = true;
724 
725  _clearance_schedule = clearance_schedule;
726 }
727 
728 template <typename T>
730 FunctorBase<T>::operator()(const NodeArg & node, const StateArg & state) const
731 {
732  mooseAssert(node.subdomain_ids, "Subdomain IDs must be supplied to the node argument");
733  return evaluate(node, state);
734 }
735 
736 template <typename T>
737 void
739 #if DEBUG
740  face
741 #endif
742 ) const
743 {
744 #if DEBUG
745  const Elem * const elem = face.face_side;
746  const FaceInfo * const fi = face.fi;
747  mooseAssert(fi, "face info should be non-null");
748  bool check_elem_def = false;
749  bool check_neighbor_def = false;
750  // We check if the functor is defined on both sides of the face
751  if (!elem)
752  {
753  if (!hasFaceSide(*fi, true))
754  check_neighbor_def = true;
755  else if (!hasFaceSide(*fi, false))
756  check_elem_def = true;
757  }
758  else if (elem == fi->elemPtr())
759  check_elem_def = true;
760  else
761  {
762  mooseAssert(elem == fi->neighborPtr(), "This has to match something");
763  check_neighbor_def = true;
764  }
765 
766  if (check_elem_def && !hasFaceSide(*fi, true))
767  {
768  std::string additional_message = "It is not defined on the neighbor side either.";
769  if (hasFaceSide(*fi, false))
770  additional_message = "It is however defined on the neighbor side.";
771  additional_message += " Face centroid: " + Moose::stringify(fi->faceCentroid());
772  mooseError(_functor_name,
773  " is not defined on the element side of the face information, but a face argument "
774  "producer "
775  "(e.g. residual object, postprocessor, etc.) has requested evaluation there.\n",
776  additional_message);
777  }
778  if (check_neighbor_def && !hasFaceSide(*fi, false))
779  {
780  std::string additional_message = "It is not defined on the element side either.";
781  if (hasFaceSide(*fi, true))
782  additional_message = "It is however defined on the element side.";
783  additional_message += " Face centroid: " + Moose::stringify(fi->faceCentroid());
784  mooseError(
785  _functor_name,
786  " is not defined on the neighbor side of the face information, but a face argument "
787  "producer (e.g. residual object, postprocessor, etc.) has requested evaluation there.\n",
788  additional_message);
789  }
790 #endif
791 }
792 
793 template <typename T>
794 void
796 {
797  for (auto & map_pr : _qp_to_value)
798  for (auto & pr : map_pr.second)
799  pr.first = false;
800 
801  for (auto & map_pr : _side_qp_to_value)
802  {
803  auto & side_vector = map_pr.second;
804  for (auto & qp_vector : side_vector)
805  for (auto & pr : qp_vector)
806  pr.first = false;
807  }
808 
809  _current_qp_map_key = libMesh::DofObject::invalid_id;
810  _current_qp_map_value = nullptr;
811  _current_side_qp_map_key = libMesh::DofObject::invalid_id;
812  _current_side_qp_map_value = nullptr;
813 
814  _elem_arg_to_value.clear();
815  _face_arg_to_value.clear();
816  _node_arg_to_value.clear();
817 }
818 
819 template <typename T>
820 void
822 {
823  if (_clearance_schedule.count(EXEC_TIMESTEP_BEGIN))
824  clearCacheData();
825 }
826 
827 template <typename T>
828 void
830 {
831  if (_clearance_schedule.count(EXEC_LINEAR))
832  clearCacheData();
833 }
834 
835 template <typename T>
836 void
838 {
839  if (_clearance_schedule.count(EXEC_NONLINEAR))
840  clearCacheData();
841 }
842 
843 template <typename T>
844 void
846 {
847  if (_clearance_schedule.count(exec_type))
848  clearCacheData();
849 }
850 
851 template <typename T>
853 FunctorBase<T>::gradient(const ElemArg & elem, const StateArg & state) const
854 {
855  return evaluateGradient(elem, state);
856 }
857 
858 template <typename T>
860 FunctorBase<T>::gradient(const FaceArg & face, const StateArg & state) const
861 {
862  checkFace(face);
863  return evaluateGradient(face, state);
864 }
865 
866 template <typename T>
868 FunctorBase<T>::gradient(const ElemQpArg & elem_qp, const StateArg & state) const
869 {
870  return evaluateGradient(elem_qp, state);
871 }
872 
873 template <typename T>
875 FunctorBase<T>::gradient(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
876 {
877  return evaluateGradient(elem_side_qp, state);
878 }
879 
880 template <typename T>
882 FunctorBase<T>::gradient(const ElemPointArg & elem_point, const StateArg & state) const
883 {
884  return evaluateGradient(elem_point, state);
885 }
886 
887 template <typename T>
889 FunctorBase<T>::gradient(const NodeArg & node, const StateArg & state) const
890 {
891  return evaluateGradient(node, state);
892 }
893 
894 template <typename T>
896 FunctorBase<T>::dot(const ElemArg & elem, const StateArg & state) const
897 {
898  return evaluateDot(elem, state);
899 }
900 
901 template <typename T>
903 FunctorBase<T>::dot(const FaceArg & face, const StateArg & state) const
904 {
905  checkFace(face);
906  return evaluateDot(face, state);
907 }
908 
909 template <typename T>
911 FunctorBase<T>::dot(const ElemQpArg & elem_qp, const StateArg & state) const
912 {
913  return evaluateDot(elem_qp, state);
914 }
915 
916 template <typename T>
918 FunctorBase<T>::dot(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
919 {
920  return evaluateDot(elem_side_qp, state);
921 }
922 
923 template <typename T>
925 FunctorBase<T>::dot(const ElemPointArg & elem_point, const StateArg & state) const
926 {
927  return evaluateDot(elem_point, state);
928 }
929 
930 template <typename T>
932 FunctorBase<T>::dot(const NodeArg & node, const StateArg & state) const
933 {
934  return evaluateDot(node, state);
935 }
936 
937 template <typename T>
939 FunctorBase<T>::gradDot(const ElemArg & elem, const StateArg & state) const
940 {
941  return evaluateGradDot(elem, state);
942 }
943 
944 template <typename T>
946 FunctorBase<T>::gradDot(const FaceArg & face, const StateArg & state) const
947 {
948  checkFace(face);
949  return evaluateGradDot(face, state);
950 }
951 
952 template <typename T>
954 FunctorBase<T>::gradDot(const ElemQpArg & elem_qp, const StateArg & state) const
955 {
956  return evaluateGradDot(elem_qp, state);
957 }
958 
959 template <typename T>
961 FunctorBase<T>::gradDot(const ElemSideQpArg & elem_side_qp, const StateArg & state) const
962 {
963  return evaluateGradDot(elem_side_qp, state);
964 }
965 
966 template <typename T>
968 FunctorBase<T>::gradDot(const ElemPointArg & elem_point, const StateArg & state) const
969 {
970  return evaluateGradDot(elem_point, state);
971 }
972 
973 template <typename T>
975 FunctorBase<T>::gradDot(const NodeArg & node, const StateArg & state) const
976 {
977  return evaluateGradDot(node, state);
978 }
979 
980 template <typename T>
981 bool
982 FunctorBase<T>::hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const
983 {
984  if (fi_elem_side)
985  return hasBlocks(fi.elem().subdomain_id());
986  else
987  return fi.neighborPtr() && hasBlocks(fi.neighbor().subdomain_id());
988 }
989 
990 template <typename T>
991 template <FunctorEvaluationKind FET, typename Space, typename State>
993 FunctorBase<T>::genericEvaluate(const Space & r, const State & state) const
994 {
995  if constexpr (FET == FunctorEvaluationKind::Value)
996  return (*this)(r, state);
997  else if constexpr (FET == FunctorEvaluationKind::Gradient)
998  return gradient(r, state);
999  else if constexpr (FET == FunctorEvaluationKind::Dot)
1000  return dot(r, state);
1001  else
1002  return gradDot(r, state);
1003 }
1004 
1010 {
1011 public:
1012  FunctorEnvelopeBase() = default;
1013  virtual ~FunctorEnvelopeBase() = default;
1014 
1018  virtual bool wrapsNull() const = 0;
1019 
1023  virtual std::string returnType() const = 0;
1024 
1028  virtual bool isConstant() const = 0;
1029 
1037  virtual bool ownsWrappedFunctor() const = 0;
1038 };
1039 
1045 template <typename T>
1046 class FunctorEnvelope final : public FunctorBase<T>, public FunctorEnvelopeBase
1047 {
1048 public:
1049  using typename Moose::FunctorBase<T>::ValueType;
1050  using typename Moose::FunctorBase<T>::GradientType;
1051  using typename Moose::FunctorBase<T>::DotType;
1052 
1057  : FunctorBase<T>("wraps_" + wrapped.functorName()), FunctorEnvelopeBase(), _wrapped(&wrapped)
1058  {
1059  }
1060 
1066  FunctorEnvelope(std::unique_ptr<FunctorBase<T>> && wrapped)
1067  : FunctorBase<T>("wraps_" + wrapped->functorName()),
1069  _owned(std::move(wrapped)),
1070  _wrapped(_owned.get())
1071  {
1072  }
1073 
1078  FunctorEnvelope(FunctorBase<T> &&) = delete;
1079 
1084  void assign(const FunctorBase<T> & wrapped)
1085  {
1086  _owned.reset();
1087  _wrapped = &wrapped;
1088  }
1089 
1094  void assign(std::unique_ptr<FunctorBase<T>> && wrapped)
1095  {
1096  _owned = std::move(wrapped);
1097  _wrapped = _owned.get();
1098  }
1099 
1104  void assign(FunctorBase<T> &&) = delete;
1105 
1106  FunctorEnvelope(const FunctorEnvelope &) = delete;
1107  FunctorEnvelope(FunctorEnvelope &&) = delete;
1108  FunctorEnvelope & operator=(const FunctorEnvelope &) = delete;
1109  FunctorEnvelope & operator=(FunctorEnvelope &&) = delete;
1110 
1111  virtual ~FunctorEnvelope() = default;
1112 
1116  virtual bool wrapsNull() const override { return wrapsType<NullFunctor<T>>(); }
1117 
1121  virtual std::string returnType() const override { return libMesh::demangle(typeid(T).name()); }
1122 
1123  virtual bool ownsWrappedFunctor() const override { return _owned.get(); }
1124 
1128  template <typename T2>
1129  bool wrapsType() const
1130  {
1131  return dynamic_cast<const T2 *>(_wrapped);
1132  }
1133 
1134  virtual bool isExtrapolatedBoundaryFace(const FaceInfo & fi,
1135  const Elem * const elem,
1136  const StateArg & state) const override
1137  {
1138  return _wrapped->isExtrapolatedBoundaryFace(fi, elem, state);
1139  }
1140  virtual bool isConstant() const override { return _wrapped->isConstant(); }
1141  virtual bool hasBlocks(const SubdomainID id) const override { return _wrapped->hasBlocks(id); }
1142  virtual bool hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const override
1143  {
1144  return _wrapped->hasFaceSide(fi, fi_elem_side);
1145  }
1146 
1147  bool supportsFaceArg() const override final { return true; }
1148  bool supportsElemSideQpArg() const override final { return true; }
1149 
1150 protected:
1152 
1155  virtual ValueType evaluate(const ElemArg & elem, const StateArg & state) const override
1156  {
1157  return _wrapped->operator()(elem, state);
1158  }
1159  virtual ValueType evaluate(const FaceArg & face, const StateArg & state) const override
1160  {
1161  return _wrapped->operator()(face, state);
1162  }
1163  virtual ValueType evaluate(const ElemQpArg & qp, const StateArg & state) const override
1164  {
1165  return _wrapped->operator()(qp, state);
1166  }
1167  virtual ValueType evaluate(const ElemSideQpArg & qp, const StateArg & state) const override
1168  {
1169  return _wrapped->operator()(qp, state);
1170  }
1171  virtual ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const override
1172  {
1173  return _wrapped->operator()(elem_point, state);
1174  }
1175  virtual ValueType evaluate(const NodeArg & node, const StateArg & state) const override
1176  {
1177  return _wrapped->operator()(node, state);
1178  }
1179 
1180  virtual GradientType evaluateGradient(const ElemArg & elem, const StateArg & state) const override
1181  {
1182  return _wrapped->gradient(elem, state);
1183  }
1184  virtual GradientType evaluateGradient(const FaceArg & face, const StateArg & state) const override
1185  {
1186  return _wrapped->gradient(face, state);
1187  }
1188  virtual GradientType evaluateGradient(const ElemQpArg & qp, const StateArg & state) const override
1189  {
1190  return _wrapped->gradient(qp, state);
1191  }
1193  const StateArg & state) const override
1194  {
1195  return _wrapped->gradient(qp, state);
1196  }
1197  virtual GradientType evaluateGradient(const ElemPointArg & elem_point,
1198  const StateArg & state) const override
1199  {
1200  return _wrapped->gradient(elem_point, state);
1201  }
1202  virtual GradientType evaluateGradient(const NodeArg & node, const StateArg & state) const override
1203  {
1204  return _wrapped->gradient(node, state);
1205  }
1206 
1207  virtual DotType evaluateDot(const ElemArg & elem, const StateArg & state) const override
1208  {
1209  return _wrapped->dot(elem, state);
1210  }
1211  virtual DotType evaluateDot(const FaceArg & face, const StateArg & state) const override
1212  {
1213  return _wrapped->dot(face, state);
1214  }
1215  virtual DotType evaluateDot(const ElemQpArg & qp, const StateArg & state) const override
1216  {
1217  return _wrapped->dot(qp, state);
1218  }
1219  virtual DotType evaluateDot(const ElemSideQpArg & qp, const StateArg & state) const override
1220  {
1221  return _wrapped->dot(qp, state);
1222  }
1223  virtual DotType evaluateDot(const ElemPointArg & elem_point,
1224  const StateArg & state) const override
1225  {
1226  return _wrapped->dot(elem_point, state);
1227  }
1228  virtual DotType evaluateDot(const NodeArg & node, const StateArg & state) const override
1229  {
1230  return _wrapped->dot(node, state);
1231  }
1232 
1233  virtual GradientType evaluateGradDot(const ElemArg & elem, const StateArg & state) const override
1234  {
1235  return _wrapped->gradDot(elem, state);
1236  }
1237  virtual GradientType evaluateGradDot(const FaceArg & face, const StateArg & state) const override
1238  {
1239  return _wrapped->gradDot(face, state);
1240  }
1241  virtual GradientType evaluateGradDot(const ElemQpArg & qp, const StateArg & state) const override
1242  {
1243  return _wrapped->gradDot(qp, state);
1244  }
1246  const StateArg & state) const override
1247  {
1248  return _wrapped->gradDot(qp, state);
1249  }
1250  virtual GradientType evaluateGradDot(const ElemPointArg & elem_point,
1251  const StateArg & state) const override
1252  {
1253  return _wrapped->gradDot(elem_point, state);
1254  }
1255  virtual GradientType evaluateGradDot(const NodeArg & node, const StateArg & state) const override
1256  {
1257  return _wrapped->gradDot(node, state);
1258  }
1260 
1261 private:
1263  std::unique_ptr<FunctorBase<T>> _owned;
1265 
1266  friend class ::SubProblem;
1267 };
1268 
1272 template <typename T>
1273 class ConstantFunctor final : public FunctorBase<T>
1274 {
1275 public:
1276  using typename FunctorBase<T>::FunctorType;
1277  using typename FunctorBase<T>::ValueType;
1278  using typename FunctorBase<T>::GradientType;
1279  using typename FunctorBase<T>::DotType;
1280 
1282  : FunctorBase<T>("constant_" + std::to_string(value)), _value(value)
1283  {
1284  }
1286  : FunctorBase<T>("constant_" + std::to_string(MetaPhysicL::raw_value(value))), _value(value)
1287  {
1288  }
1289 
1290  virtual bool isConstant() const override { return true; }
1291 
1292  bool hasBlocks(SubdomainID /* id */) const override { return true; }
1293 
1294  bool supportsFaceArg() const override final { return true; }
1295  bool supportsElemSideQpArg() const override final { return true; }
1296 
1297 private:
1298  ValueType evaluate(const ElemArg &, const StateArg &) const override { return _value; }
1299  ValueType evaluate(const FaceArg &, const StateArg &) const override { return _value; }
1300  ValueType evaluate(const ElemQpArg &, const StateArg &) const override { return _value; }
1301  ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override { return _value; }
1302  ValueType evaluate(const ElemPointArg &, const StateArg &) const override { return _value; }
1303  ValueType evaluate(const NodeArg &, const StateArg &) const override { return _value; }
1304 
1305  GradientType evaluateGradient(const ElemArg &, const StateArg &) const override { return 0; }
1306  GradientType evaluateGradient(const FaceArg &, const StateArg &) const override { return 0; }
1307  GradientType evaluateGradient(const ElemQpArg &, const StateArg &) const override { return 0; }
1308  GradientType evaluateGradient(const ElemSideQpArg &, const StateArg &) const override
1309  {
1310  return 0;
1311  }
1312  GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const override { return 0; }
1313  GradientType evaluateGradient(const NodeArg &, const StateArg &) const override { return 0; }
1314 
1315  DotType evaluateDot(const ElemArg &, const StateArg &) const override { return 0; }
1316  DotType evaluateDot(const FaceArg &, const StateArg &) const override { return 0; }
1317  DotType evaluateDot(const ElemQpArg &, const StateArg &) const override { return 0; }
1318  DotType evaluateDot(const ElemSideQpArg &, const StateArg &) const override { return 0; }
1319  DotType evaluateDot(const ElemPointArg &, const StateArg &) const override { return 0; }
1320  DotType evaluateDot(const NodeArg &, const StateArg &) const override { return 0; }
1321 
1322  GradientType evaluateGradDot(const ElemArg &, const StateArg &) const override { return 0; }
1323  GradientType evaluateGradDot(const FaceArg &, const StateArg &) const override { return 0; }
1324  GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const override { return 0; }
1325  GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const override { return 0; }
1326  GradientType evaluateGradDot(const ElemPointArg &, const StateArg &) const override { return 0; }
1327  GradientType evaluateGradDot(const NodeArg &, const StateArg &) const override { return 0; }
1328 
1329 private:
1331 };
1332 
1337 template <typename T>
1338 class NullFunctor final : public FunctorBase<T>
1339 {
1340 public:
1341  using typename FunctorBase<T>::FunctorType;
1342  using typename FunctorBase<T>::ValueType;
1343  using typename FunctorBase<T>::GradientType;
1344  using typename FunctorBase<T>::DotType;
1345 
1346  NullFunctor() : FunctorBase<T>("null") {}
1347 
1348  // For backwards compatiblity of unit testing
1349  bool hasFaceSide(const FaceInfo & fi, bool) const override;
1350 
1351  bool supportsFaceArg() const override final { return false; }
1352  bool supportsElemSideQpArg() const override final { return false; }
1353 
1354 private:
1355  ValueType evaluate(const ElemArg &, const StateArg &) const override
1356  {
1357  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1358  "they've written broken code");
1359  }
1360  ValueType evaluate(const FaceArg &, const StateArg &) const override
1361  {
1362  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1363  "they've written broken code");
1364  }
1365  ValueType evaluate(const ElemQpArg &, const StateArg &) const override
1366  {
1367  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1368  "they've written broken code");
1369  }
1370  ValueType evaluate(const ElemSideQpArg &, const StateArg &) const override
1371  {
1372  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1373  "they've written broken code");
1374  }
1375  ValueType evaluate(const ElemPointArg &, const StateArg &) const override
1376  {
1377  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1378  "they've written broken code");
1379  }
1380  ValueType evaluate(const NodeArg &, const StateArg &) const override
1381  {
1382  mooseError("We should never get here. If you have, contact a MOOSE developer and tell them "
1383  "they've written broken code");
1384  }
1385 };
1386 
1387 template <typename T>
1388 bool
1389 NullFunctor<T>::hasFaceSide(const FaceInfo &, const bool) const
1390 {
1391  // For backwards compatiblity of unit testing
1392  return true;
1393 }
1394 }
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:243
unsigned int side
The local side index.
virtual GradientType evaluateGradient(const NodeArg &, const StateArg &) const
Definition: MooseFunctor.h:382
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:720
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:368
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:529
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:311
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:85
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:485
virtual bool isConstant() const =0
virtual void timestepSetup()=0
virtual ValueType evaluate(const NodeArg &node, const StateArg &state) const override
virtual std::string returnType() const =0
FunctorBase(const FunctorBase< T > &, const Moose::Kokkos::FunctorCopy &)
Special constructor used for Kokkos functor copy during parallel dispatch.
Definition: MooseFunctor.h:164
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition: FaceInfo.h:75
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:253
virtual GradientType evaluateGradient(const ElemSideQpArg &qp, const StateArg &state) const override
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:100
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:564
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:422
virtual DotType evaluateDot(const ElemPointArg &, const StateArg &) const
Evaluate the functor time derivative with a given element and point.
Definition: MooseFunctor.h:431
const ExecFlagType EXEC_ALWAYS
Definition: Moose.C:51
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:411
GradientType evaluateGradient(const ElemArg &, const StateArg &) const override
Evaluate the functor gradient with a given element.
virtual ~FunctorEnvelopeBase()=default
typename FunctorReturnType< libMesh::VectorValue, 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:532
virtual DotType evaluateDot(const ElemArg &, const StateArg &) const
Evaluate the functor time derivative with a given element.
Definition: MooseFunctor.h:391
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:939
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:845
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:558
bool isInternalFace(const FaceInfo &) const
Returns true if the face is an internal face.
Definition: MooseFunctor.h:575
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:37
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:88
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:358
MooseFunctorName _functor_name
name of the functor
Definition: MooseFunctor.h:570
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.
static constexpr dof_id_type invalid_id
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:632
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:37
virtual bool ownsWrappedFunctor() const =0
virtual GradientType evaluateGradDot(const FaceArg &, const StateArg &) const
Definition: MooseFunctor.h:455
void checkFace(const Moose::FaceArg &face) const
Examines the incoming face argument.
Definition: MooseFunctor.h:738
virtual GradientType evaluateGradDot(const ElemQpArg &, const StateArg &) const
Definition: MooseFunctor.h:465
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:586
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:436
virtual GradientType evaluateGradient(const ElemArg &, const StateArg &) const
Evaluate the functor gradient with a given element.
Definition: MooseFunctor.h:338
const Elem & neighbor() const
Definition: FaceInfo.h:220
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:837
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:821
virtual GradientType evaluateGradDot(const ElemArg &, const StateArg &) const
Evaluate the functor gradient-dot with a given element.
Definition: MooseFunctor.h:445
const ExecFlagType EXEC_LINEAR
Definition: Moose.C:31
virtual GradientType evaluateGradient(const FaceArg &, const StateArg &) const
Definition: MooseFunctor.h:348
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:401
std::map< ElemArg, ValueType > _elem_arg_to_value
Map from element arguments to their cached evaluations.
Definition: MooseFunctor.h:561
const MooseFunctorName & functorName() const
Return the functor name.
Definition: MooseFunctor.h:176
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:545
const Elem * elemPtr() const
Definition: FaceInfo.h:86
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:33
virtual GradientType evaluateGradDot(const ElemSideQpArg &, const StateArg &) const
Definition: MooseFunctor.h:476
virtual GradientType evaluateGradient(const ElemPointArg &, const StateArg &) const
Evaluate the functor gradient with a given element and point.
Definition: MooseFunctor.h:377
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:603
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:896
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:853
std::vector< std::vector< std::pair< bool, ValueType > > > * _current_side_qp_map_value
Current value for side-qp map cache.
Definition: MooseFunctor.h:548
bool _always_evaluate
Boolean to check if we always need evaluation.
Definition: MooseFunctor.h:523
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:795
FunctorBase(const MooseFunctorName &name, const std::set< ExecFlagType > &clearance_schedule={EXEC_ALWAYS})
Definition: MooseFunctor.h:153
virtual void residualSetup() override
Definition: MooseFunctor.h:829
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:266
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:490
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...
const Elem & get(const ElemType type_in)
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:539
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:993
uint8_t dof_id_type
std::map< NodeArg, ValueType > _node_arg_to_value
Map from nodal arguments to their cached evaluations.
Definition: MooseFunctor.h:567
std::set< ExecFlagType > _clearance_schedule
How often to clear the material property cache.
Definition: MooseFunctor.h:520
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:982
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.