www.mooseframework.org
SubProblem.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "Problem.h"
13 #include "DiracKernelInfo.h"
14 #include "GeometricSearchData.h"
15 #include "MooseTypes.h"
16 #include "VectorTag.h"
17 #include "MooseError.h"
19 #include "RawValueFunctor.h"
20 #include "ADWrapperFunctor.h"
21 
22 #include "libmesh/coupling_matrix.h"
23 #include "libmesh/parameters.h"
24 
25 #include <memory>
26 #include <unordered_map>
27 #include <map>
28 #include <vector>
29 
30 namespace libMesh
31 {
32 template <typename>
33 class VectorValue;
35 class GhostingFunctor;
36 }
37 
38 class MooseMesh;
39 class Factory;
40 class Assembly;
43 template <typename>
49 class SystemBase;
50 class LineSearch;
51 class FaceInfo;
52 class MooseObjectName;
53 namespace Moose
54 {
55 class FunctorEnvelopeBase;
56 }
57 
58 // libMesh forward declarations
59 namespace libMesh
60 {
61 class EquationSystems;
62 class DofMap;
63 class CouplingMatrix;
64 template <typename T>
65 class SparseMatrix;
66 template <typename T>
67 class NumericVector;
68 class System;
69 } // namespace libMesh
70 
75 class SubProblem : public Problem
76 {
77 public:
79 
81  virtual ~SubProblem();
82 
83  virtual EquationSystems & es() = 0;
84  virtual MooseMesh & mesh() = 0;
85  virtual const MooseMesh & mesh() const = 0;
86  virtual const MooseMesh & mesh(bool use_displaced) const = 0;
87 
89 
93  virtual bool nlConverged(const unsigned int nl_sys_num) { return converged(nl_sys_num); }
94 
101  virtual bool converged(const unsigned int nl_sys_num) { return nlConverged(nl_sys_num); }
102 
106  virtual unsigned int nlSysNum(const NonlinearSystemName & nl_sys_name) const = 0;
107 
111  virtual unsigned int linearSysNum(const LinearSystemName & linear_sys_name) const = 0;
112 
116  virtual unsigned int solverSysNum(const SolverSystemName & solver_sys_name) const = 0;
117 
118  virtual void onTimestepBegin() = 0;
119  virtual void onTimestepEnd() = 0;
120 
121  virtual bool isTransient() const = 0;
122 
124  virtual void needFV() = 0;
125 
127  virtual bool haveFV() const = 0;
128 
133 
144  virtual TagID addVectorTag(const TagName & tag_name,
146 
150  virtual const VectorTag & getVectorTag(const TagID tag_id) const;
151  std::vector<VectorTag> getVectorTags(const std::set<TagID> & tag_ids) const;
152 
156  virtual TagID getVectorTagID(const TagName & tag_name) const;
157 
161  virtual TagName vectorTagName(const TagID tag) const;
162 
167  virtual const std::vector<VectorTag> &
169 
173  virtual bool vectorTagExists(const TagID tag_id) const { return tag_id < _vector_tags.size(); }
174 
178  virtual bool vectorTagExists(const TagName & tag_name) const;
179 
183  virtual unsigned int numVectorTags(const Moose::VectorTagType type = Moose::VECTOR_TAG_ANY) const;
184 
185  virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const;
186 
195  virtual TagID addMatrixTag(TagName tag_name);
196 
200  virtual TagID getMatrixTagID(const TagName & tag_name) const;
201 
205  virtual TagName matrixTagName(TagID tag);
206 
210  virtual bool matrixTagExists(const TagName & tag_name) const;
211 
215  virtual bool matrixTagExists(TagID tag_id) const;
216 
220  virtual unsigned int numMatrixTags() const { return _matrix_tag_name_to_tag_id.size(); }
221 
225  virtual std::map<TagName, TagID> & getMatrixTags() { return _matrix_tag_name_to_tag_id; }
226 
228  virtual bool hasVariable(const std::string & var_name) const = 0;
229 
239  virtual const MooseVariableFieldBase & getVariable(
240  const THREAD_ID tid,
241  const std::string & var_name,
243  Moose::VarFieldType expected_var_field_type = Moose::VarFieldType::VAR_FIELD_ANY) const = 0;
244  virtual MooseVariableFieldBase &
246  const std::string & var_name,
249  {
250  return const_cast<MooseVariableFieldBase &>(const_cast<const SubProblem *>(this)->getVariable(
251  tid, var_name, expected_var_type, expected_var_field_type));
252  }
253 
255  virtual MooseVariable & getStandardVariable(const THREAD_ID tid,
256  const std::string & var_name) = 0;
257 
260  const std::string & var_name) = 0;
261 
263  virtual VectorMooseVariable & getVectorVariable(const THREAD_ID tid,
264  const std::string & var_name) = 0;
265 
267  virtual ArrayMooseVariable & getArrayVariable(const THREAD_ID tid,
268  const std::string & var_name) = 0;
269 
271  static std::string arrayVariableComponent(const std::string & var_name, unsigned int i)
272  {
273  return var_name + "_" + std::to_string(i);
274  }
275 
277  virtual bool hasScalarVariable(const std::string & var_name) const = 0;
278 
280  virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid,
281  const std::string & var_name) = 0;
282 
284  virtual System & getSystem(const std::string & var_name) = 0;
285 
292  virtual void
293  setActiveElementalMooseVariables(const std::set<MooseVariableFieldBase *> & moose_vars,
294  const THREAD_ID tid);
295 
301  virtual const std::set<MooseVariableFieldBase *> &
303 
309  virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const;
310 
318  virtual void clearActiveElementalMooseVariables(const THREAD_ID tid);
319 
320  virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) = 0;
321  virtual const Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) const = 0;
322 
326  virtual const SystemBase & systemBaseNonlinear(const unsigned int sys_num) const = 0;
327  virtual SystemBase & systemBaseNonlinear(const unsigned int sys_num) = 0;
331  virtual const SystemBase & systemBaseLinear(const unsigned int sys_num) const = 0;
332  virtual SystemBase & systemBaseLinear(const unsigned int sys_num) = 0;
336  virtual const SystemBase & systemBaseAuxiliary() const = 0;
337  virtual SystemBase & systemBaseAuxiliary() = 0;
338 
339  virtual void prepareShapes(unsigned int var, const THREAD_ID tid) = 0;
340  virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid) = 0;
341  virtual void prepareNeighborShapes(unsigned int var, const THREAD_ID tid) = 0;
343 
348  unsigned int getAxisymmetricRadialCoord() const;
349 
350  virtual DiracKernelInfo & diracKernelInfo();
351  virtual Real finalNonlinearResidual(const unsigned int nl_sys_num) const;
352  virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const;
353  virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const;
354 
355  virtual void addResidual(const THREAD_ID tid) = 0;
356  virtual void addResidualNeighbor(const THREAD_ID tid) = 0;
357  virtual void addResidualLower(const THREAD_ID tid) = 0;
358 
359  virtual void cacheResidual(const THREAD_ID tid);
360  virtual void cacheResidualNeighbor(const THREAD_ID tid);
361  virtual void addCachedResidual(const THREAD_ID tid);
362 
363  virtual void setResidual(NumericVector<Number> & residual, const THREAD_ID tid) = 0;
364  virtual void setResidualNeighbor(NumericVector<Number> & residual, const THREAD_ID tid) = 0;
365 
366  virtual void addJacobian(const THREAD_ID tid) = 0;
367  virtual void addJacobianNeighbor(const THREAD_ID tid) = 0;
368  virtual void addJacobianNeighborLowerD(const THREAD_ID tid) = 0;
369  virtual void addJacobianLowerD(const THREAD_ID tid) = 0;
370  virtual void addJacobianNeighbor(SparseMatrix<Number> & jacobian,
371  unsigned int ivar,
372  unsigned int jvar,
373  const DofMap & dof_map,
374  std::vector<dof_id_type> & dof_indices,
375  std::vector<dof_id_type> & neighbor_dof_indices,
376  const std::set<TagID> & tags,
377  const THREAD_ID tid) = 0;
378 
379  virtual void cacheJacobian(const THREAD_ID tid);
380  virtual void cacheJacobianNeighbor(const THREAD_ID tid);
381  virtual void addCachedJacobian(const THREAD_ID tid);
382 
383  virtual void prepare(const Elem * elem, const THREAD_ID tid) = 0;
384  virtual void prepareFace(const Elem * elem, const THREAD_ID tid) = 0;
385  virtual void prepare(const Elem * elem,
386  unsigned int ivar,
387  unsigned int jvar,
388  const std::vector<dof_id_type> & dof_indices,
389  const THREAD_ID tid) = 0;
390  virtual void setCurrentSubdomainID(const Elem * elem, const THREAD_ID tid) = 0;
391  virtual void
392  setNeighborSubdomainID(const Elem * elem, unsigned int side, const THREAD_ID tid) = 0;
393  virtual void prepareAssembly(const THREAD_ID tid) = 0;
394 
395  virtual void reinitElem(const Elem * elem, const THREAD_ID tid) = 0;
396  virtual void reinitElemPhys(const Elem * elem,
397  const std::vector<Point> & phys_points_in_elem,
398  const THREAD_ID tid) = 0;
399  virtual void
400  reinitElemFace(const Elem * elem, unsigned int side, BoundaryID bnd_id, const THREAD_ID tid) = 0;
401  virtual void reinitLowerDElem(const Elem * lower_d_elem,
402  const THREAD_ID tid,
403  const std::vector<Point> * const pts = nullptr,
404  const std::vector<Real> * const weights = nullptr);
405  virtual void reinitNode(const Node * node, const THREAD_ID tid) = 0;
406  virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, const THREAD_ID tid) = 0;
407  virtual void reinitNodes(const std::vector<dof_id_type> & nodes, const THREAD_ID tid) = 0;
408  virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, const THREAD_ID tid) = 0;
409  virtual void reinitNeighbor(const Elem * elem, unsigned int side, const THREAD_ID tid) = 0;
410  virtual void reinitNeighborPhys(const Elem * neighbor,
411  unsigned int neighbor_side,
412  const std::vector<Point> & physical_points,
413  const THREAD_ID tid) = 0;
414  virtual void reinitNeighborPhys(const Elem * neighbor,
415  const std::vector<Point> & physical_points,
416  const THREAD_ID tid) = 0;
417  virtual void
418  reinitElemNeighborAndLowerD(const Elem * elem, unsigned int side, const THREAD_ID tid) = 0;
425  virtual void reinitScalars(const THREAD_ID tid,
426  bool reinit_for_derivative_reordering = false) = 0;
427  virtual void reinitOffDiagScalars(const THREAD_ID tid) = 0;
428 
430  virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid);
431 
438  virtual void reinitElemFaceRef(const Elem * elem,
439  unsigned int side,
440  BoundaryID bnd_id,
441  Real tolerance,
442  const std::vector<Point> * const pts,
443  const std::vector<Real> * const weights = nullptr,
444  const THREAD_ID tid = 0);
445 
452  virtual void reinitNeighborFaceRef(const Elem * neighbor_elem,
453  unsigned int neighbor_side,
454  BoundaryID bnd_id,
455  Real tolerance,
456  const std::vector<Point> * const pts,
457  const std::vector<Real> * const weights = nullptr,
458  const THREAD_ID tid = 0);
459 
463  void reinitNeighborLowerDElem(const Elem * elem, const THREAD_ID tid = 0);
464 
468  void reinitMortarElem(const Elem * elem, const THREAD_ID tid = 0);
469 
473  virtual bool reinitDirac(const Elem * elem, const THREAD_ID tid) = 0;
477  virtual void getDiracElements(std::set<const Elem *> & elems) = 0;
482  virtual void clearDiracInfo() = 0;
483 
484  // Geom Search
485  virtual void
487 
488  virtual GeometricSearchData & geomSearchData() = 0;
489 
490  virtual void meshChanged();
491 
500  virtual void storeSubdomainMatPropName(SubdomainID block_id, const std::string & name);
501 
510  virtual void storeBoundaryMatPropName(BoundaryID boundary_id, const std::string & name);
511 
520  virtual void storeSubdomainZeroMatProp(SubdomainID block_id, const MaterialPropertyName & name);
521 
530  virtual void storeBoundaryZeroMatProp(BoundaryID boundary_id, const MaterialPropertyName & name);
531 
538  virtual void storeSubdomainDelayedCheckMatProp(const std::string & requestor,
539  SubdomainID block_id,
540  const std::string & name);
541 
549  virtual void storeBoundaryDelayedCheckMatProp(const std::string & requestor,
550  BoundaryID boundary_id,
551  const std::string & name);
552 
558  virtual void checkBlockMatProps();
559 
565  virtual void checkBoundaryMatProps();
566 
570  virtual void markMatPropRequested(const std::string &);
571 
575  virtual bool isMatPropRequested(const std::string & prop_name) const;
576 
580  void addConsumedPropertyName(const MooseObjectName & obj_name, const std::string & prop_name);
581 
585  const std::map<MooseObjectName, std::set<std::string>> & getConsumedPropertyMap() const;
586 
590  virtual void addGhostedElem(dof_id_type elem_id) = 0;
591 
595  virtual void addGhostedBoundary(BoundaryID boundary_id) = 0;
596 
600  virtual void ghostGhostedBoundaries() = 0;
601 
605  virtual std::set<SubdomainID> getMaterialPropertyBlocks(const std::string & prop_name);
606 
610  virtual std::vector<SubdomainName> getMaterialPropertyBlockNames(const std::string & prop_name);
611 
615  virtual bool hasBlockMaterialProperty(SubdomainID block_id, const std::string & prop_name);
616 
620  virtual std::set<BoundaryID> getMaterialPropertyBoundaryIDs(const std::string & prop_name);
621 
625  virtual std::vector<BoundaryName> getMaterialPropertyBoundaryNames(const std::string & prop_name);
626 
630  virtual bool hasBoundaryMaterialProperty(BoundaryID boundary_id, const std::string & prop_name);
631 
636  virtual bool computingInitialResidual(const unsigned int nl_sys_num) const = 0;
637 
642  virtual std::set<dof_id_type> & ghostedElems() { return _ghosted_elems; }
643 
644  std::map<std::string, std::vector<dof_id_type>> _var_dof_map;
645 
649  const CouplingMatrix & nonlocalCouplingMatrix(const unsigned i) const { return _nonlocal_cm[i]; }
650 
655 
659  void setCurrentlyComputingJacobian(const bool currently_computing_jacobian)
660  {
661  _currently_computing_jacobian = currently_computing_jacobian;
662  }
663 
667  const bool & currentlyComputingResidualAndJacobian() const;
668 
672  void setCurrentlyComputingResidualAndJacobian(bool currently_computing_residual_and_jacobian);
673 
678 
682  virtual void computingNonlinearResid(const bool computing_nonlinear_residual)
683  {
684  _computing_nonlinear_residual = computing_nonlinear_residual;
685  }
686 
691 
695  virtual void setCurrentlyComputingResidual(const bool currently_computing_residual)
696  {
697  _currently_computing_residual = currently_computing_residual;
698  }
699 
702 
704  virtual bool safeAccessTaggedVectors() const { return _safe_access_tagged_vectors; }
705 
707 
709 
710  virtual void setActiveFEVariableCoupleableVectorTags(std::set<TagID> & vtags,
711  const THREAD_ID tid);
712 
713  virtual void setActiveFEVariableCoupleableMatrixTags(std::set<TagID> & mtags,
714  const THREAD_ID tid);
715 
717 
719 
720  virtual void setActiveScalarVariableCoupleableVectorTags(std::set<TagID> & vtags,
721  const THREAD_ID tid);
722 
723  virtual void setActiveScalarVariableCoupleableMatrixTags(std::set<TagID> & mtags,
724  const THREAD_ID tid);
725 
726  const std::set<TagID> & getActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) const;
727 
728  const std::set<TagID> & getActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) const;
729 
730  const std::set<TagID> & getActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) const;
731 
732  const std::set<TagID> & getActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) const;
733 
737  virtual void haveADObjects(bool have_ad_objects) { _have_ad_objects = have_ad_objects; }
741  bool haveADObjects() const { return _have_ad_objects; }
742 
743  virtual LineSearch * getLineSearch() = 0;
744 
748  virtual const CouplingMatrix * couplingMatrix(const unsigned int nl_sys_num) const = 0;
749 
750 private:
760  void cloneAlgebraicGhostingFunctor(GhostingFunctor & algebraic_gf, bool to_mesh = true);
761 
771  void cloneCouplingGhostingFunctor(GhostingFunctor & coupling_gf, bool to_mesh = true);
772 
773 public:
777  void addAlgebraicGhostingFunctor(GhostingFunctor & algebraic_gf, bool to_mesh = true);
778 
782  void addCouplingGhostingFunctor(GhostingFunctor & coupling_gf, bool to_mesh = true);
783 
787  void removeAlgebraicGhostingFunctor(GhostingFunctor & algebraic_gf);
788 
792  void removeCouplingGhostingFunctor(GhostingFunctor & coupling_gf);
793 
798  virtual void automaticScaling(bool automatic_scaling);
799 
804  bool automaticScaling() const;
805 
810  void hasScalingVector(const unsigned int nl_sys_num);
811 
815  virtual bool haveDisplaced() const = 0;
816 
820  virtual bool computingScalingJacobian() const = 0;
821 
825  virtual bool computingScalingResidual() const = 0;
826 
830  void clearAllDofIndices();
831 
841  template <typename T>
842  const Moose::Functor<T> & getFunctor(const std::string & name,
843  const THREAD_ID tid,
844  const std::string & requestor_name,
845  bool requestor_is_ad);
846 
850  bool hasFunctor(const std::string & name, const THREAD_ID tid) const;
851 
855  template <typename T>
856  bool hasFunctorWithType(const std::string & name, const THREAD_ID tid) const;
857 
861  template <typename T>
862  void
863  addFunctor(const std::string & name, const Moose::FunctorBase<T> & functor, const THREAD_ID tid);
864 
878  template <typename T, typename PolymorphicLambda>
879  const Moose::FunctorBase<T> &
880  addPiecewiseByBlockLambdaFunctor(const std::string & name,
881  PolymorphicLambda my_lammy,
882  const std::set<ExecFlagType> & clearance_schedule,
883  const MooseMesh & mesh,
884  const std::set<SubdomainID> & block_ids,
885  const THREAD_ID tid);
886 
887  virtual void initialSetup();
888  virtual void timestepSetup();
889  virtual void customSetup(const ExecFlagType & exec_type);
890  virtual void residualSetup();
891  virtual void jacobianSetup();
892 
894  void setFunctorOutput(bool set_output) { _output_functors = set_output; }
895 
899  virtual std::size_t numNonlinearSystems() const = 0;
900 
904  virtual unsigned int currentNlSysNum() const = 0;
905 
909  virtual std::size_t numLinearSystems() const = 0;
910 
914  virtual std::size_t numSolverSystems() const = 0;
915 
919  virtual unsigned int currentLinearSysNum() const = 0;
920 
924  template <typename T>
925  void registerUnfilledFunctorRequest(T * functor_interface,
926  const std::string & functor_name,
927  const THREAD_ID tid);
928 
932  virtual const std::vector<VectorTag> & currentResidualVectorTags() const = 0;
933 
940  static void selectVectorTagsFromSystem(const SystemBase & system,
941  const std::vector<VectorTag> & input_vector_tags,
942  std::set<TagID> & selected_tags);
943 
950  static void selectMatrixTagsFromSystem(const SystemBase & system,
951  const std::map<TagName, TagID> & input_matrix_tags,
952  std::set<TagID> & selected_tags);
953 
957  void reinitFVFace(const THREAD_ID tid, const FaceInfo & fi);
958 
962  virtual bool hasNonlocalCoupling() const = 0;
963 
969  virtual void doingPRefinement(bool doing_p_refinement,
970  const MultiMooseEnum & disable_p_refinement_for_families);
971 
975  [[nodiscard]] bool doingPRefinement() const;
976 
980  [[nodiscard]] bool havePRefinement() const { return _have_p_refinement; }
981 
985  virtual void setCurrentLowerDElem(const Elem * const lower_d_elem, const THREAD_ID tid);
986 
987 protected:
992  template <typename T>
994  const std::string & var_name,
995  Moose::VarKindType expected_var_type,
996  Moose::VarFieldType expected_var_field_type,
997  const std::vector<T> & nls,
998  const SystemBase & aux) const;
999 
1003  bool verifyVectorTags() const;
1004 
1006  std::map<TagName, TagID> _matrix_tag_name_to_tag_id;
1007 
1009  std::map<TagID, TagName> _matrix_tag_id_to_tag_name;
1010 
1013 
1014  std::vector<CouplingMatrix> _nonlocal_cm;
1015 
1017 
1019  std::map<SubdomainID, std::set<std::string>> _map_block_material_props;
1020 
1022  std::map<BoundaryID, std::set<std::string>> _map_boundary_material_props;
1023 
1025  std::map<SubdomainID, std::set<MaterialPropertyName>> _zero_block_material_props;
1026  std::map<BoundaryID, std::set<MaterialPropertyName>> _zero_boundary_material_props;
1027 
1029  std::set<std::string> _material_property_requested;
1030 
1032 
1037  std::map<SubdomainID, std::multimap<std::string, std::string>> _map_block_material_props_check;
1038  std::map<BoundaryID, std::multimap<std::string, std::string>> _map_boundary_material_props_check;
1040 
1042  std::vector<std::set<MooseVariableFieldBase *>> _active_elemental_moose_variables;
1043 
1045  /* This needs to remain <unsigned int> for threading purposes */
1046  std::vector<unsigned int> _has_active_elemental_moose_variables;
1047 
1048  std::vector<std::set<TagID>> _active_fe_var_coupleable_matrix_tags;
1049 
1050  std::vector<std::set<TagID>> _active_fe_var_coupleable_vector_tags;
1051 
1052  std::vector<std::set<TagID>> _active_sc_var_coupleable_matrix_tags;
1053 
1054  std::vector<std::set<TagID>> _active_sc_var_coupleable_vector_tags;
1055 
1058 
1061 
1063  std::set<dof_id_type> _ghosted_elems;
1064 
1067 
1070 
1073 
1076 
1079 
1082 
1085 
1086 private:
1093  virtual std::pair<bool, unsigned int>
1094  determineSolverSystem(const std::string & var_name, bool error_if_not_found = false) const = 0;
1095 
1096  enum class TrueFunctorIs
1097  {
1098  UNSET,
1099  NONAD,
1100  AD
1101  };
1102 
1107  std::vector<std::multimap<std::string,
1108  std::tuple<TrueFunctorIs,
1109  std::unique_ptr<Moose::FunctorEnvelopeBase>,
1110  std::unique_ptr<Moose::FunctorEnvelopeBase>>>>
1112 
1114  std::vector<std::map<std::string, std::unique_ptr<Moose::FunctorAbstract>>> _pbblf_functors;
1115 
1117  void showFunctors() const;
1118 
1120  void showFunctorRequestors() const;
1121 
1124  std::map<std::string, std::set<std::string>> _functor_to_requestors;
1125 
1128  std::vector<std::multimap<std::string, std::pair<bool, bool>>> _functor_to_request_info;
1129 
1132 
1134  std::vector<VectorTag> _vector_tags;
1135 
1141  std::vector<std::vector<VectorTag>> _typed_vector_tags;
1142 
1144  std::map<TagName, TagID> _vector_tags_name_map;
1145 
1147  std::string restrictionSubdomainCheckName(SubdomainID check_id);
1148  std::string restrictionBoundaryCheckName(BoundaryID check_id);
1150 
1151  // Contains properties consumed by objects, see addConsumedPropertyName
1152  std::map<MooseObjectName, std::set<std::string>> _consumed_material_properties;
1153 
1157  std::unordered_map<GhostingFunctor *, std::vector<std::shared_ptr<GhostingFunctor>>>
1159 
1163  std::unordered_map<GhostingFunctor *, std::vector<std::shared_ptr<GhostingFunctor>>>
1165 
1168 
1169  friend class Restartable;
1170 };
1171 
1172 template <typename T>
1173 const Moose::Functor<T> &
1174 SubProblem::getFunctor(const std::string & name,
1175  const THREAD_ID tid,
1176  const std::string & requestor_name,
1177  const bool requestor_is_ad)
1178 {
1179  mooseAssert(tid < _functors.size(), "Too large a thread ID");
1180 
1181  // Log the requestor
1182  _functor_to_requestors["wraps_" + name].insert(requestor_name);
1183 
1184  constexpr bool requested_functor_is_ad =
1185  !std::is_same<T, typename MetaPhysicL::RawType<T>::value_type>::value;
1186 
1187  auto & functor_to_request_info = _functor_to_request_info[tid];
1188 
1189  // Get the requested functor if we already have it
1190  auto & functors = _functors[tid];
1191  if (auto find_ret = functors.find("wraps_" + name); find_ret != functors.end())
1192  {
1193  if (functors.count("wraps_" + name) > 1)
1194  mooseError("Attempted to get a functor with the name '",
1195  name,
1196  "' but multiple functors match. Make sure that you do not have functor material "
1197  "properties, functions, postprocessors or variables with the same names");
1198 
1199  auto & [true_functor_is, non_ad_functor, ad_functor] = find_ret->second;
1200  auto & functor_wrapper = requested_functor_is_ad ? *ad_functor : *non_ad_functor;
1201 
1202  auto * const functor = dynamic_cast<Moose::Functor<T> *>(&functor_wrapper);
1203  if (!functor)
1204  mooseError("A call to SubProblem::getFunctor requested a functor named '",
1205  name,
1206  "' that returns the type: '",
1207  libMesh::demangle(typeid(T).name()),
1208  "'. However, that functor already exists and returns a different type: '",
1209  functor_wrapper.returnType(),
1210  "'");
1211 
1212  if (functor->template wrapsType<Moose::NullFunctor<T>>())
1213  // Store for future checking when the actual functor gets added
1214  functor_to_request_info.emplace(name,
1215  std::make_pair(requested_functor_is_ad, requestor_is_ad));
1216  else
1217  {
1218  // We already have the actual functor
1219  if (true_functor_is == SubProblem::TrueFunctorIs::UNSET)
1220  mooseError("We already have the functor; it should not be unset");
1221 
1222  // Check for whether this is a valid request
1223  if (!requested_functor_is_ad && requestor_is_ad &&
1224  true_functor_is == SubProblem::TrueFunctorIs::AD)
1225  mooseError("We are requesting a non-AD functor from an AD object, but the true functor is "
1226  "AD. This "
1227  "means we could be dropping important derivatives. We will not allow this");
1228  }
1229 
1230  return *functor;
1231  }
1232 
1233  // We don't have the functor yet but we could have it in the future. We'll create null functors
1234  // for now
1235  functor_to_request_info.emplace(name, std::make_pair(requested_functor_is_ad, requestor_is_ad));
1236  if constexpr (requested_functor_is_ad)
1237  {
1238  typedef typename MetaPhysicL::RawType<T>::value_type NonADType;
1239  typedef T ADType;
1240 
1241  auto emplace_ret =
1242  functors.emplace("wraps_" + name,
1243  std::make_tuple(SubProblem::TrueFunctorIs::UNSET,
1244  std::make_unique<Moose::Functor<NonADType>>(
1245  std::make_unique<Moose::NullFunctor<NonADType>>()),
1246  std::make_unique<Moose::Functor<ADType>>(
1247  std::make_unique<Moose::NullFunctor<ADType>>())));
1248 
1249  return static_cast<Moose::Functor<T> &>(*(requested_functor_is_ad
1250  ? std::get<2>(emplace_ret->second)
1251  : std::get<1>(emplace_ret->second)));
1252  }
1253  else
1254  {
1255  typedef T NonADType;
1256  typedef typename Moose::ADType<T>::type ADType;
1257 
1258  auto emplace_ret =
1259  functors.emplace("wraps_" + name,
1260  std::make_tuple(SubProblem::TrueFunctorIs::UNSET,
1261  std::make_unique<Moose::Functor<NonADType>>(
1262  std::make_unique<Moose::NullFunctor<NonADType>>()),
1263  std::make_unique<Moose::Functor<ADType>>(
1264  std::make_unique<Moose::NullFunctor<ADType>>())));
1265 
1266  return static_cast<Moose::Functor<T> &>(*(requested_functor_is_ad
1267  ? std::get<2>(emplace_ret->second)
1268  : std::get<1>(emplace_ret->second)));
1269  }
1270 }
1271 
1272 template <typename T>
1273 bool
1274 SubProblem::hasFunctorWithType(const std::string & name, const THREAD_ID tid) const
1275 {
1276  mooseAssert(tid < _functors.size(), "Too large a thread ID");
1277  auto & functors = _functors[tid];
1278 
1279  const auto & it = functors.find("wraps_" + name);
1280  constexpr bool requested_functor_is_ad =
1281  !std::is_same<T, typename MetaPhysicL::RawType<T>::value_type>::value;
1282 
1283  if (it == functors.end())
1284  return false;
1285  else
1286  return dynamic_cast<Moose::Functor<T> *>(
1287  requested_functor_is_ad ? std::get<2>(it->second).get() : std::get<1>(it->second).get());
1288 }
1289 
1290 template <typename T, typename PolymorphicLambda>
1291 const Moose::FunctorBase<T> &
1293  PolymorphicLambda my_lammy,
1294  const std::set<ExecFlagType> & clearance_schedule,
1295  const MooseMesh & mesh,
1296  const std::set<SubdomainID> & block_ids,
1297  const THREAD_ID tid)
1298 {
1299  auto & pbblf_functors = _pbblf_functors[tid];
1300 
1301  auto [it, first_time_added] =
1302  pbblf_functors.emplace(name,
1303  std::make_unique<PiecewiseByBlockLambdaFunctor<T>>(
1304  name, my_lammy, clearance_schedule, mesh, block_ids));
1305 
1306  auto * functor = dynamic_cast<PiecewiseByBlockLambdaFunctor<T> *>(it->second.get());
1307  if (!functor)
1308  {
1309  if (first_time_added)
1310  mooseError("This should be impossible. If this was the first time we added the functor, then "
1311  "the dynamic cast absolutely should have succeeded");
1312  else
1313  mooseError("Attempted to add a lambda functor with the name '",
1314  name,
1315  "' but another lambda functor of that name returns a different type");
1316  }
1317 
1318  if (first_time_added)
1319  addFunctor(name, *functor, tid);
1320  else
1321  // The functor already exists
1322  functor->setFunctor(mesh, block_ids, my_lammy);
1323 
1324  return *functor;
1325 }
1326 
1327 template <typename T>
1328 void
1329 SubProblem::addFunctor(const std::string & name,
1330  const Moose::FunctorBase<T> & functor,
1331  const THREAD_ID tid)
1332 {
1333  constexpr bool added_functor_is_ad =
1334  !std::is_same<T, typename MetaPhysicL::RawType<T>::value_type>::value;
1335 
1336  mooseAssert(tid < _functors.size(), "Too large a thread ID");
1337 
1338  auto & functor_to_request_info = _functor_to_request_info[tid];
1339  auto & functors = _functors[tid];
1340  auto it = functors.find("wraps_" + name);
1341  if (it != functors.end())
1342  {
1343  // We have this functor already. If it's a null functor, we want to replace it with the valid
1344  // functor we have now. If it's not then we'll add a new entry into the multimap and then we'll
1345  // error later if a user requests a functor because their request is ambiguous. This is the
1346  // reason that the functors container is a multimap: for nice error messages
1347  auto * const existing_wrapper_base =
1348  added_functor_is_ad ? std::get<2>(it->second).get() : std::get<1>(it->second).get();
1349  auto * const existing_wrapper = dynamic_cast<Moose::Functor<T> *>(existing_wrapper_base);
1350  if (existing_wrapper && existing_wrapper->template wrapsType<Moose::NullFunctor<T>>())
1351  {
1352  // Sanity check
1353  auto [request_info_it, request_info_end_it] = functor_to_request_info.equal_range(name);
1354  if (request_info_it == request_info_end_it)
1355  mooseError("We are wrapping a NullFunctor but we don't have any unfilled functor request "
1356  "info. This doesn't make sense.");
1357 
1358  // Check for valid requests
1359  while (request_info_it != request_info_end_it)
1360  {
1361  auto & [requested_functor_is_ad, requestor_is_ad] = request_info_it->second;
1362  if (!requested_functor_is_ad && requestor_is_ad && added_functor_is_ad)
1363  mooseError("We are requesting a non-AD functor from an AD object, but the true functor "
1364  "is AD. This means we could be dropping important derivatives. We will not "
1365  "allow this");
1366  // We're going to eventually check whether we've fulfilled all functor requests and our
1367  // check will be that the multimap is empty. This request is fulfilled, so erase it from the
1368  // map now
1369  request_info_it = functor_to_request_info.erase(request_info_it);
1370  }
1371 
1372  // Ok we didn't have the functor before, so we will add it now
1373  std::get<0>(it->second) =
1375  existing_wrapper->assign(functor);
1376  // Finally we create the non-AD or AD complement of the just added functor
1377  if constexpr (added_functor_is_ad)
1378  {
1379  typedef typename MetaPhysicL::RawType<T>::value_type NonADType;
1380  auto * const existing_non_ad_wrapper_base = std::get<1>(it->second).get();
1381  auto * const existing_non_ad_wrapper =
1382  dynamic_cast<Moose::Functor<NonADType> *>(existing_non_ad_wrapper_base);
1383  mooseAssert(existing_non_ad_wrapper->template wrapsType<Moose::NullFunctor<NonADType>>(),
1384  "Both members of pair should have been wrapping a NullFunctor");
1385  existing_non_ad_wrapper->assign(
1386  std::make_unique<Moose::RawValueFunctor<NonADType>>(functor));
1387  }
1388  else
1389  {
1390  typedef typename Moose::ADType<T>::type ADType;
1391  auto * const existing_ad_wrapper_base = std::get<2>(it->second).get();
1392  auto * const existing_ad_wrapper =
1393  dynamic_cast<Moose::Functor<ADType> *>(existing_ad_wrapper_base);
1394  mooseAssert(existing_ad_wrapper->template wrapsType<Moose::NullFunctor<ADType>>(),
1395  "Both members of pair should have been wrapping a NullFunctor");
1396  existing_ad_wrapper->assign(std::make_unique<Moose::ADWrapperFunctor<ADType>>(functor));
1397  }
1398  return;
1399  }
1400  }
1401 
1402  // We are a new functor, create the opposite ADType one and store it with other functors
1403  if constexpr (added_functor_is_ad)
1404  {
1405  typedef typename MetaPhysicL::RawType<T>::value_type NonADType;
1406  auto new_non_ad_wrapper = std::make_unique<Moose::Functor<NonADType>>(
1407  std::make_unique<Moose::RawValueFunctor<NonADType>>(functor));
1408  auto new_ad_wrapper = std::make_unique<Moose::Functor<T>>(functor);
1409  _functors[tid].emplace("wraps_" + name,
1410  std::make_tuple(SubProblem::TrueFunctorIs::AD,
1411  std::move(new_non_ad_wrapper),
1412  std::move(new_ad_wrapper)));
1413  }
1414  else
1415  {
1416  typedef typename Moose::ADType<T>::type ADType;
1417  auto new_non_ad_wrapper = std::make_unique<Moose::Functor<T>>((functor));
1418  auto new_ad_wrapper = std::make_unique<Moose::Functor<ADType>>(
1419  std::make_unique<Moose::ADWrapperFunctor<ADType>>(functor));
1420  _functors[tid].emplace("wraps_" + name,
1421  std::make_tuple(SubProblem::TrueFunctorIs::NONAD,
1422  std::move(new_non_ad_wrapper),
1423  std::move(new_ad_wrapper)));
1424  }
1425 }
1426 
1427 inline const bool &
1429 {
1431 }
1432 
1433 inline void
1435  const bool currently_computing_residual_and_jacobian)
1436 {
1437  _currently_computing_residual_and_jacobian = currently_computing_residual_and_jacobian;
1438 }
1439 
1440 namespace Moose
1441 {
1442 void initial_condition(EquationSystems & es, const std::string & system_name);
1443 } // namespace Moose
virtual void prepareShapes(unsigned int var, const THREAD_ID tid)=0
virtual void getDiracElements(std::set< const Elem *> &elems)=0
Fills "elems" with the elements that should be looped over for Dirac Kernels.
virtual MooseMesh & mesh()=0
virtual void addCachedResidual(const THREAD_ID tid)
Definition: SubProblem.C:1262
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual bool computingScalingResidual() const =0
Getter for whether we&#39;re computing the scaling residual.
VarFieldType
Definition: MooseTypes.h:634
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
Definition: SubProblem.C:772
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition: SubProblem.C:181
void reinitNeighborLowerDElem(const Elem *elem, const THREAD_ID tid=0)
reinitialize a neighboring lower dimensional element
Definition: SubProblem.C:950
virtual void setResidualNeighbor(NumericVector< Number > &residual, const THREAD_ID tid)=0
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the scalar variable reference from whichever system contains it.
std::map< TagName, TagID > _matrix_tag_name_to_tag_id
The currently declared tags.
Definition: SubProblem.h:1006
A material property that is evaluated on-the-fly via calls to various overloads of operator() ...
virtual void clearActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid)
Definition: SubProblem.C:362
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const
Definition: SubProblem.C:730
virtual void clearActiveFEVariableCoupleableVectorTags(const THREAD_ID tid)
Definition: SubProblem.C:356
bool _requires_nonlocal_coupling
nonlocal coupling requirement flag
Definition: SubProblem.h:1057
virtual bool hasBoundaryMaterialProperty(BoundaryID boundary_id, const std::string &prop_name)
Check if a material property is defined on a block.
Definition: SubProblem.C:548
bool _have_ad_objects
AD flag indicating whether any AD objects have been added.
Definition: SubProblem.h:1084
virtual void setActiveScalarVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition: SubProblem.C:380
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false)=0
fills the VariableValue arrays for scalar variables from the solution vector
MooseVariableFieldBase & getVariableHelper(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type, Moose::VarFieldType expected_var_field_type, const std::vector< T > &nls, const SystemBase &aux) const
Helper function called by getVariable that handles the logic for checking whether Variables of the re...
std::map< BoundaryID, std::multimap< std::string, std::string > > _map_boundary_material_props_check
Definition: SubProblem.h:1038
A class for creating restricted objects.
Definition: Restartable.h:28
The DiracKernelInfo object is a place where all the Dirac points added by different DiracKernels are ...
Factory & _factory
The Factory for building objects.
Definition: SubProblem.h:1012
virtual VectorMooseVariable & getVectorVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested VectorMooseVariable which may be in any system...
const std::set< TagID > & getActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition: SubProblem.C:415
void initial_condition(EquationSystems &es, const std::string &system_name)
virtual std::set< BoundaryID > getMaterialPropertyBoundaryIDs(const std::string &prop_name)
Get a vector containing the block ids the material property is defined on.
Definition: SubProblem.C:503
virtual void haveADObjects(bool have_ad_objects)
Method for setting whether we have any ad objects.
Definition: SubProblem.h:737
virtual void addJacobianNeighborLowerD(const THREAD_ID tid)=0
const Moose::Functor< T > & getFunctor(const std::string &name, const THREAD_ID tid, const std::string &requestor_name, bool requestor_is_ad)
Definition: SubProblem.h:1174
virtual void addResidual(const THREAD_ID tid)=0
Base class template for functor objects.
Definition: MooseFunctor.h:137
virtual void reinitLowerDElem(const Elem *lower_d_elem, const THREAD_ID tid, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Definition: SubProblem.C:920
virtual MooseVariableFieldBase & getActualFieldVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested MooseVariableField which may be in any system...
virtual bool converged(const unsigned int nl_sys_num)
Eventually we want to convert this virtual over to taking a nonlinear system number argument...
Definition: SubProblem.h:101
Keeps track of stuff related to assembling.
Definition: Assembly.h:93
Class for stuff related to variables.
Definition: Adaptivity.h:31
virtual void reinitOffDiagScalars(const THREAD_ID tid)=0
virtual void setCurrentlyComputingResidual(const bool currently_computing_residual)
Set whether or not the problem is in the process of computing the residual.
Definition: SubProblem.h:695
virtual void reinitElem(const Elem *elem, const THREAD_ID tid)=0
unsigned int TagID
Definition: MooseTypes.h:199
virtual void onTimestepEnd()=0
virtual void storeSubdomainZeroMatProp(SubdomainID block_id, const MaterialPropertyName &name)
Adds to a map based on block ids of material properties for which a zero value can be returned...
Definition: SubProblem.C:573
virtual const std::vector< VectorTag > & currentResidualVectorTags() const =0
Return the residual vector tags we are currently computing.
virtual bool hasBlockMaterialProperty(SubdomainID block_id, const std::string &prop_name)
Check if a material property is defined on a block.
Definition: SubProblem.C:489
const std::set< TagID > & getActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition: SubProblem.C:368
std::string restrictionBoundaryCheckName(BoundaryID check_id)
Definition: SubProblem.C:759
Generic factory class for build all sorts of objects.
Definition: Factory.h:28
virtual bool computingScalingJacobian() const =0
Getter for whether we&#39;re computing the scaling jacobian.
MooseVariableFE< RealVectorValue > VectorMooseVariable
Definition: SubProblem.h:46
VectorValue< Real > RealVectorValue
Definition: SubProblem.h:33
virtual const SystemBase & systemBaseNonlinear(const unsigned int sys_num) const =0
Return the nonlinear system object as a base class reference given the system number.
const std::set< TagID > & getActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition: SubProblem.C:374
virtual unsigned int currentNlSysNum() const =0
virtual bool safeAccessTaggedVectors() const
Is it safe to access the tagged vectors.
Definition: SubProblem.h:704
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)=0
void addConsumedPropertyName(const MooseObjectName &obj_name, const std::string &prop_name)
Helper for tracking the object that is consuming a property for MaterialPropertyDebugOutput.
Definition: SubProblem.C:706
bool _currently_computing_jacobian
Flag to determine whether the problem is currently computing Jacobian.
Definition: SubProblem.h:1066
std::map< std::string, std::set< std::string > > _functor_to_requestors
The requestors of functors where the key is the prop name and the value is a set of names of requesto...
Definition: SubProblem.h:1124
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFieldBase *> &moose_vars, const THREAD_ID tid)
Set the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:421
virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid)
sets the current boundary ID in assembly
Definition: SubProblem.C:765
virtual void storeSubdomainDelayedCheckMatProp(const std::string &requestor, SubdomainID block_id, const std::string &name)
Adds to a map based on block ids of material properties to validate.
Definition: SubProblem.C:585
virtual void setCurrentLowerDElem(const Elem *const lower_d_elem, const THREAD_ID tid)
Set the current lower dimensional element.
Definition: SubProblem.C:1330
virtual ~SubProblem()
Definition: SubProblem.C:79
virtual void prepareNeighborShapes(unsigned int var, const THREAD_ID tid)=0
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:82
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:432
virtual void addCachedJacobian(const THREAD_ID tid)
Definition: SubProblem.C:1283
virtual void residualSetup()
Definition: SubProblem.C:1158
virtual void storeBoundaryZeroMatProp(BoundaryID boundary_id, const MaterialPropertyName &name)
Adds to a map based on boundary ids of material properties for which a zero value can be returned...
Definition: SubProblem.C:579
This is a wrapper that forwards calls to the implementation, which can be switched out at any time wi...
Class that hold the whole problem being solved.
Definition: Problem.h:19
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
add a functor to the problem functor container
Definition: SubProblem.h:1329
Wraps non-AD functors such that they can be used in objects that have requested the functor as AD...
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid)=0
std::unordered_map< GhostingFunctor *, std::vector< std::shared_ptr< GhostingFunctor > > > _root_alg_gf_to_sys_clones
A map from a root algebraic ghosting functor, e.g.
Definition: SubProblem.h:1158
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void storeBoundaryDelayedCheckMatProp(const std::string &requestor, BoundaryID boundary_id, const std::string &name)
Adds to a map based on boundary ids of material properties to validate.
Definition: SubProblem.C:593
virtual void addJacobianNeighbor(const THREAD_ID tid)=0
void reinitFVFace(const THREAD_ID tid, const FaceInfo &fi)
reinitialize the finite volume assembly data for the provided face and thread
Definition: SubProblem.C:1241
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid)=0
static void selectVectorTagsFromSystem(const SystemBase &system, const std::vector< VectorTag > &input_vector_tags, std::set< TagID > &selected_tags)
Select the vector tags which belong to a specific system.
Definition: SubProblem.C:267
bool _output_functors
Whether to output a list of the functors used and requested (currently only at initialSetup) ...
Definition: SubProblem.h:1131
void addAlgebraicGhostingFunctor(GhostingFunctor &algebraic_gf, bool to_mesh=true)
Add an algebraic ghosting functor to this problem&#39;s DofMaps.
Definition: SubProblem.C:986
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual void jacobianSetup()
Definition: SubProblem.C:1166
virtual bool computingInitialResidual(const unsigned int nl_sys_num) const =0
Returns true if the problem is in the process of computing it&#39;s initial residual. ...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void setCurrentlyComputingResidualAndJacobian(bool currently_computing_residual_and_jacobian)
Set whether or not the problem is in the process of computing the Jacobian.
Definition: SubProblem.h:1434
void showFunctors() const
Lists all functors in the problem.
Definition: SubProblem.C:1204
Base class for a system (of equations)
Definition: SystemBase.h:85
const bool & currentlyComputingResidualAndJacobian() const
Returns true if the problem is in the process of computing the residual and the Jacobian.
Definition: SubProblem.h:1428
bool computingNonlinearResid() const
Returns true if the problem is in the process of computing the nonlinear residual.
Definition: SubProblem.h:677
std::vector< VectorTag > _vector_tags
The declared vector tags.
Definition: SubProblem.h:1134
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid)
Clear the active elemental MooseVariableFieldBase.
Definition: SubProblem.C:444
std::set< dof_id_type > _ghosted_elems
Elements that should have Dofs ghosted to the local processor.
Definition: SubProblem.h:1063
std::vector< CouplingMatrix > _nonlocal_cm
Definition: SubProblem.h:1014
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
virtual void markMatPropRequested(const std::string &)
Helper method for adding a material property name to the _material_property_requested set...
Definition: SubProblem.C:694
void clearAllDofIndices()
Clear dof indices from variables in nl and aux systems.
Definition: SubProblem.C:1134
virtual void addResidualLower(const THREAD_ID tid)=0
virtual bool nlConverged(const unsigned int nl_sys_num)
Definition: SubProblem.h:93
std::vector< std::set< TagID > > _active_sc_var_coupleable_vector_tags
Definition: SubProblem.h:1054
std::map< BoundaryID, std::set< MaterialPropertyName > > _zero_boundary_material_props
Definition: SubProblem.h:1026
virtual void addJacobian(const THREAD_ID tid)=0
const bool & currentlyComputingResidual() const
Returns true if the problem is in the process of computing the residual.
Definition: SubProblem.h:690
virtual EquationSystems & es()=0
bool verifyVectorTags() const
Verify the integrity of _vector_tags and _typed_vector_tags.
Definition: SubProblem.C:219
void setCurrentlyComputingJacobian(const bool currently_computing_jacobian)
Set whether or not the problem is in the process of computing the Jacobian.
Definition: SubProblem.h:659
const std::set< TagID > & getActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition: SubProblem.C:409
bool _computing_nonlinear_residual
Whether the non-linear residual is being evaluated.
Definition: SubProblem.h:1072
std::map< BoundaryID, std::set< std::string > > _map_boundary_material_props
Map for boundary material properties (boundary_id -> list of properties)
Definition: SubProblem.h:1022
virtual Real finalNonlinearResidual(const unsigned int nl_sys_num) const
Definition: SubProblem.C:724
virtual void customSetup(const ExecFlagType &exec_type)
Definition: SubProblem.C:1150
std::map< std::string, std::vector< dof_id_type > > _var_dof_map
Definition: SubProblem.h:644
virtual void checkBoundaryMatProps()
Checks boundary material properties integrity.
Definition: SubProblem.C:643
virtual void ghostGhostedBoundaries()=0
Causes the boundaries added using addGhostedBoundary to actually be ghosted.
virtual void setActiveScalarVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition: SubProblem.C:387
bool automaticScaling() const
Automatic scaling getter.
Definition: SubProblem.C:1119
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:35
virtual void reinitNeighborFaceRef(const Elem *neighbor_elem, unsigned int neighbor_side, BoundaryID bnd_id, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr, const THREAD_ID tid=0)
reinitialize FE objects on a given neighbor element on a given side at a given set of reference point...
Definition: SubProblem.C:883
virtual void reinitNode(const Node *node, const THREAD_ID tid)=0
virtual LineSearch * getLineSearch()=0
void removeCouplingGhostingFunctor(GhostingFunctor &coupling_gf)
Remove a coupling ghosting functor from this problem&#39;s DofMaps.
Definition: SubProblem.C:1070
bool havePRefinement() const
Query whether p-refinement has been requested at any point during the simulation. ...
Definition: SubProblem.h:980
virtual bool isMatPropRequested(const std::string &prop_name) const
Find out if a material property has been requested by any object.
Definition: SubProblem.C:700
std::map< MooseObjectName, std::set< std::string > > _consumed_material_properties
Definition: SubProblem.h:1152
void removeAlgebraicGhostingFunctor(GhostingFunctor &algebraic_gf)
Remove an algebraic ghosting functor from this problem&#39;s DofMaps.
Definition: SubProblem.C:1030
virtual void clearDiracInfo()=0
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in...
std::map< TagID, TagName > _matrix_tag_id_to_tag_name
Reverse map.
Definition: SubProblem.h:1009
virtual bool hasNonlocalCoupling() const =0
Whether the simulation has nonlocal coupling which should be accounted for in the Jacobian...
virtual DiracKernelInfo & diracKernelInfo()
Definition: SubProblem.C:718
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition: SubProblem.C:347
virtual TagID getMatrixTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition: SubProblem.C:320
virtual const SystemBase & systemBaseAuxiliary() const =0
Return the auxiliary system object as a base class reference.
virtual void clearActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid)
Definition: SubProblem.C:397
bool _safe_access_tagged_vectors
Is it safe to retrieve data from tagged vectors.
Definition: SubProblem.h:1081
bool hasFunctorWithType(const std::string &name, const THREAD_ID tid) const
checks whether we have a functor of type T corresponding to name on the thread id tid ...
Definition: SubProblem.h:1274
std::vector< std::multimap< std::string, std::pair< bool, bool > > > _functor_to_request_info
A multimap (for each thread) from unfilled functor requests to whether the requests were for AD funct...
Definition: SubProblem.h:1128
virtual void setResidual(NumericVector< Number > &residual, const THREAD_ID tid)=0
boundary_id_type BoundaryID
virtual const CouplingMatrix * couplingMatrix(const unsigned int nl_sys_num) const =0
The coupling matrix defining what blocks exist in the preconditioning matrix.
virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const
Definition: SubProblem.C:736
void hasScalingVector(const unsigned int nl_sys_num)
Tells this problem that the assembly associated with the given nonlinear system number involves a sca...
Definition: SubProblem.C:1127
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:627
virtual std::size_t numSolverSystems() const =0
virtual void storeBoundaryMatPropName(BoundaryID boundary_id, const std::string &name)
Adds the given material property to a storage map based on boundary ids.
Definition: SubProblem.C:567
SubProblem(const InputParameters &parameters)
Definition: SubProblem.C:49
virtual bool isTransient() const =0
virtual TagID addMatrixTag(TagName tag_name)
Create a Tag.
Definition: SubProblem.C:289
std::string restrictionSubdomainCheckName(SubdomainID check_id)
Helper functions for checking MaterialProperties.
Definition: SubProblem.C:748
virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const
Definition: SubProblem.C:209
virtual void onTimestepBegin()=0
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
virtual bool hasScalarVariable(const std::string &var_name) const =0
Returns a Boolean indicating whether any system contains a variable with the name provided...
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
virtual void checkBlockMatProps()
Checks block material properties integrity.
Definition: SubProblem.C:601
virtual bool checkNonlocalCouplingRequirement()
Definition: SubProblem.h:88
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition: SubProblem.C:150
virtual MooseVariable & getStandardVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested MooseVariable which may be in any system.
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition: SubProblem.h:642
virtual ArrayMooseVariable & getArrayVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested ArrayMooseVariable which may be in any system...
virtual void addJacobianLowerD(const THREAD_ID tid)=0
virtual void reinitElemFaceRef(const Elem *elem, unsigned int side, BoundaryID bnd_id, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr, const THREAD_ID tid=0)
reinitialize FE objects on a given element on a given side at a given set of reference points and the...
Definition: SubProblem.C:843
virtual std::vector< SubdomainName > getMaterialPropertyBlockNames(const std::string &prop_name)
Get a vector of block id equivalences that the material property is defined on.
Definition: SubProblem.C:467
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
subdomain_id_type SubdomainID
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
virtual GeometricSearchData & geomSearchData()=0
std::string demangle(const char *name)
void cloneCouplingGhostingFunctor(GhostingFunctor &coupling_gf, bool to_mesh=true)
Creates (n_sys - 1) clones of the provided coupling ghosting functor (corresponding to the nonlinear ...
Definition: SubProblem.C:998
virtual void prepare(const Elem *elem, const THREAD_ID tid)=0
virtual bool hasVariable(const std::string &var_name) const =0
Whether or not this problem has the variable.
bool haveADObjects() const
Method for reading wehther we have any ad objects.
Definition: SubProblem.h:741
virtual void clearActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid)
Definition: SubProblem.C:403
virtual std::map< TagName, TagID > & getMatrixTags()
Return all matrix tags in the system, where a tag is represented by a map from name to ID...
Definition: SubProblem.h:225
void showFunctorRequestors() const
Lists all functors and all the objects that requested them.
Definition: SubProblem.C:1216
GeometricSearchType
Used to select groups of geometric search objects to update.
bool doingPRefinement() const
Definition: SubProblem.C:1324
VectorTagType
Definition: MooseTypes.h:891
virtual void cacheJacobianNeighbor(const THREAD_ID tid)
Definition: SubProblem.C:1277
void cloneAlgebraicGhostingFunctor(GhostingFunctor &algebraic_gf, bool to_mesh=true)
Creates (n_sys - 1) clones of the provided algebraic ghosting functor (corresponding to the nonlinear...
Definition: SubProblem.C:964
std::vector< std::map< std::string, std::unique_ptr< Moose::FunctorAbstract > > > _pbblf_functors
Container to hold PiecewiseByBlockLambdaFunctors.
Definition: SubProblem.h:1114
std::vector< std::set< TagID > > _active_fe_var_coupleable_vector_tags
Definition: SubProblem.h:1050
virtual void prepareFace(const Elem *elem, const THREAD_ID tid)=0
virtual void cacheResidual(const THREAD_ID tid)
Definition: SubProblem.C:1248
virtual void timestepSetup()
Definition: SubProblem.C:1142
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:220
virtual unsigned int currentLinearSysNum() const =0
virtual void addResidualNeighbor(const THREAD_ID tid)=0
std::unordered_map< GhostingFunctor *, std::vector< std::shared_ptr< GhostingFunctor > > > _root_coupling_gf_to_sys_clones
A map from a root coupling ghosting functor, e.g.
Definition: SubProblem.h:1164
virtual bool reinitDirac(const Elem *elem, const THREAD_ID tid)=0
Returns true if the Problem has Dirac kernels it needs to compute on elem.
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid)=0
static std::string arrayVariableComponent(const std::string &var_name, unsigned int i)
Returns the variable name of a component of an array variable.
Definition: SubProblem.h:271
void registerUnfilledFunctorRequest(T *functor_interface, const std::string &functor_name, const THREAD_ID tid)
Register an unfulfilled functor request.
std::vector< std::set< MooseVariableFieldBase * > > _active_elemental_moose_variables
This is the set of MooseVariableFieldBase that will actually get reinited by a call to reinit(elem) ...
Definition: SubProblem.h:1042
virtual void reinitElemNeighborAndLowerD(const Elem *elem, unsigned int side, const THREAD_ID tid)=0
bool _default_ghosting
Whether or not to use default libMesh coupling.
Definition: SubProblem.h:1060
virtual std::set< SubdomainID > getMaterialPropertyBlocks(const std::string &prop_name)
Get a vector containing the block ids the material property is defined on.
Definition: SubProblem.C:451
virtual void initialSetup()
Definition: SubProblem.C:1174
bool _have_p_refinement
Whether p-refinement has been requested at any point during the simulation.
Definition: SubProblem.h:1167
virtual System & getSystem(const std::string &var_name)=0
Returns the equation system containing the variable provided.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
virtual void needFV()=0
marks this problem as including/needing finite volume functionality.
std::map< SubdomainID, std::set< MaterialPropertyName > > _zero_block_material_props
Set of properties returned as zero properties.
Definition: SubProblem.h:1025
CoordinateSystemType
Definition: MooseTypes.h:722
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
virtual std::vector< BoundaryName > getMaterialPropertyBoundaryNames(const std::string &prop_name)
Get a vector of block id equivalences that the material property is defined on.
Definition: SubProblem.C:519
virtual MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY)
Definition: SubProblem.h:245
std::map< TagName, TagID > _vector_tags_name_map
Map of vector tag TagName to TagID.
Definition: SubProblem.h:1144
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL)=0
std::vector< unsigned int > _has_active_elemental_moose_variables
Whether or not there is currently a list of active elemental moose variables.
Definition: SubProblem.h:1046
virtual void addGhostedBoundary(BoundaryID boundary_id)=0
Will make sure that all necessary elements from boundary_id are ghosted to this processor.
std::vector< std::vector< VectorTag > > _typed_vector_tags
The vector tags associated with each VectorTagType This is kept separate from _vector_tags for quick ...
Definition: SubProblem.h:1141
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid)=0
virtual void addGhostedElem(dof_id_type elem_id)=0
Will make sure that all dofs connected to elem_id are ghosted to this processor.
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
void addCouplingGhostingFunctor(GhostingFunctor &coupling_gf, bool to_mesh=true)
Add a coupling functor to this problem&#39;s DofMaps.
Definition: SubProblem.C:1019
static void selectMatrixTagsFromSystem(const SystemBase &system, const std::map< TagName, TagID > &input_matrix_tags, std::set< TagID > &selected_tags)
Select the matrix tags which belong to a specific system.
Definition: SubProblem.C:278
virtual std::pair< bool, unsigned int > determineSolverSystem(const std::string &var_name, bool error_if_not_found=false) const =0
Class for scalar variables (they are different).
virtual void prepareAssembly(const THREAD_ID tid)=0
const Moose::FunctorBase< T > & addPiecewiseByBlockLambdaFunctor(const std::string &name, PolymorphicLambda my_lammy, const std::set< ExecFlagType > &clearance_schedule, const MooseMesh &mesh, const std::set< SubdomainID > &block_ids, const THREAD_ID tid)
Add a functor that has block-wise lambda definitions, e.g.
Definition: SubProblem.h:1292
MooseVariableFE< RealEigenVector > ArrayMooseVariable
Definition: SubProblem.h:47
std::set< std::string > _material_property_requested
set containing all material property names that have been requested by getMaterialProperty* ...
Definition: SubProblem.h:1029
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
The total number of tags, which can be limited to the tag type.
Definition: SubProblem.C:173
virtual void setActiveFEVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition: SubProblem.C:341
virtual unsigned int linearSysNum(const LinearSystemName &linear_sys_name) const =0
const InputParameters & parameters() const
Get the parameters of the object.
std::vector< std::multimap< std::string, std::tuple< TrueFunctorIs, std::unique_ptr< Moose::FunctorEnvelopeBase >, std::unique_ptr< Moose::FunctorEnvelopeBase > > > > _functors
A container holding pointers to all the functors in our problem.
Definition: SubProblem.h:1111
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
Definition: SubProblem.C:1235
virtual void cacheResidualNeighbor(const THREAD_ID tid)
Definition: SubProblem.C:1255
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:199
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition: SubProblem.C:438
static InputParameters validParams()
Definition: SubProblem.C:34
bool _currently_computing_residual
Whether the residual is being evaluated.
Definition: SubProblem.h:1075
std::map< SubdomainID, std::multimap< std::string, std::string > > _map_block_material_props_check
Data structures of the requested material properties.
Definition: SubProblem.h:1037
void setFunctorOutput(bool set_output)
Setter for debug functor output.
Definition: SubProblem.h:894
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual bool haveDisplaced() const =0
Whether we have a displaced problem in our simulation.
const bool & currentlyComputingJacobian() const
Returns true if the problem is in the process of computing the Jacobian.
Definition: SubProblem.h:654
virtual void computingNonlinearResid(const bool computing_nonlinear_residual)
Set whether or not the problem is in the process of computing the nonlinear residual.
Definition: SubProblem.h:682
virtual bool safeAccessTaggedMatrices() const
Is it safe to access the tagged matrices.
Definition: SubProblem.h:701
virtual std::size_t numNonlinearSystems() const =0
virtual bool haveFV() const =0
returns true if this problem includes/needs finite volume functionality.
bool hasFunctor(const std::string &name, const THREAD_ID tid) const
checks whether we have a functor corresponding to name on the thread id tid
Definition: SubProblem.C:1227
const std::map< MooseObjectName, std::set< std::string > > & getConsumedPropertyMap() const
Return the map that tracks the object with consumed material properties.
Definition: SubProblem.C:712
Storage for all of the information pretaining to a vector tag.
Definition: VectorTag.h:15
bool _safe_access_tagged_matrices
Is it safe to retrieve data from tagged matrices.
Definition: SubProblem.h:1078
MooseVariableFE< Real > MooseVariable
Definition: SubProblem.h:44
DiracKernelInfo _dirac_kernel_info
nonlocal coupling matrix;
Definition: SubProblem.h:1016
virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid)=0
std::map< SubdomainID, std::set< std::string > > _map_block_material_props
Map of material properties (block_id -> list of properties)
Definition: SubProblem.h:1019
A class for storing the names of MooseObject by tag and object name.
const CouplingMatrix & nonlocalCouplingMatrix(const unsigned i) const
Definition: SubProblem.h:649
bool defaultGhosting()
Whether or not the user has requested default ghosting ot be on.
Definition: SubProblem.h:132
virtual const SystemBase & systemBaseLinear(const unsigned int sys_num) const =0
Return the linear system object as a base class reference given the system number.
std::vector< std::set< TagID > > _active_fe_var_coupleable_matrix_tags
Definition: SubProblem.h:1048
virtual const VectorTag & getVectorTag(const TagID tag_id) const
Get a VectorTag from a TagID.
Definition: SubProblem.C:139
std::vector< std::set< TagID > > _active_sc_var_coupleable_matrix_tags
Definition: SubProblem.h:1052
virtual void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, const THREAD_ID tid)=0
A functor that serves as a placeholder during the simulation setup phase if a functor consumer reques...
virtual void storeSubdomainMatPropName(SubdomainID block_id, const std::string &name)
Adds the given material property to a storage map based on block ids.
Definition: SubProblem.C:561
virtual void cacheJacobian(const THREAD_ID tid)
Definition: SubProblem.C:1269
virtual void meshChanged()
Definition: SubProblem.C:742
Abstract definition of a RestartableData value.
void reinitMortarElem(const Elem *elem, const THREAD_ID tid=0)
Reinit a mortar element to obtain a valid JxW.
Definition: SubProblem.C:957
virtual std::size_t numLinearSystems() const =0
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:335
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid)=0
virtual unsigned int solverSysNum(const SolverSystemName &solver_sys_name) const =0
unsigned int THREAD_ID
Definition: MooseTypes.h:198
uint8_t dof_id_type
bool _currently_computing_residual_and_jacobian
Flag to determine whether the problem is currently computing the residual and Jacobian.
Definition: SubProblem.h:1069
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)=0
virtual unsigned int nlSysNum(const NonlinearSystemName &nl_sys_name) const =0