https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SubProblem.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 "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
30namespace libMesh
31{
32template <typename>
33class VectorValue;
34typedef VectorValue<Real> RealVectorValue;
35class GhostingFunctor;
36}
37
38class MooseMesh;
39class Factory;
40class Assembly;
43template <typename>
44class MooseVariableFE;
49class SystemBase;
50class LineSearch;
51class FaceInfo;
52class MooseObjectName;
53namespace Moose
54{
55class FunctorEnvelopeBase;
56}
57
58// libMesh forward declarations
59namespace libMesh
60{
61class EquationSystems;
62class DofMap;
63class CouplingMatrix;
64template <typename T>
65class SparseMatrix;
66template <typename T>
67class NumericVector;
68class System;
69} // namespace libMesh
70
73
78class SubProblem : public Problem
79{
80public:
82
84 virtual ~SubProblem();
85
87 virtual MooseMesh & mesh() = 0;
88 virtual const MooseMesh & mesh() const = 0;
89 virtual const MooseMesh & mesh(bool use_displaced) const = 0;
90
92 THREAD_ID numThreads() const;
93
98 virtual bool checkNonlocalCouplingRequirement() const = 0;
99
103 virtual bool solverSystemConverged(const unsigned int sys_num) { return converged(sys_num); }
104
108 virtual bool nlConverged(const unsigned int nl_sys_num);
109
116 virtual bool converged(const unsigned int sys_num) { return solverSystemConverged(sys_num); }
117
121 virtual unsigned int nlSysNum(const NonlinearSystemName & nl_sys_name) const = 0;
122
126 virtual unsigned int linearSysNum(const LinearSystemName & linear_sys_name) const = 0;
127
131 virtual unsigned int solverSysNum(const SolverSystemName & solver_sys_name) const = 0;
132
133 virtual void onTimestepBegin() = 0;
134 virtual void onTimestepEnd() = 0;
135
136 virtual bool isTransient() const = 0;
137
139 virtual void needFV() = 0;
140
142 virtual bool haveFV() const = 0;
143
148
159 virtual TagID addVectorTag(const TagName & tag_name,
161
167 void addNotZeroedVectorTag(const TagID tag);
168
176 bool vectorTagNotZeroed(const TagID tag) const;
177
181 virtual const VectorTag & getVectorTag(const TagID tag_id) const;
182 std::vector<VectorTag> getVectorTags(const std::set<TagID> & tag_ids) const;
183
187 virtual TagID getVectorTagID(const TagName & tag_name) const;
188
192 virtual TagName vectorTagName(const TagID tag) const;
193
198 virtual const std::vector<VectorTag> &
200
204 virtual bool vectorTagExists(const TagID tag_id) const { return tag_id < _vector_tags.size(); }
205
209 virtual bool vectorTagExists(const TagName & tag_name) const;
210
214 virtual unsigned int numVectorTags(const Moose::VectorTagType type = Moose::VECTOR_TAG_ANY) const;
215
216 virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const;
217
226 virtual TagID addMatrixTag(TagName tag_name);
227
231 virtual TagID getMatrixTagID(const TagName & tag_name) const;
232
236 virtual TagName matrixTagName(TagID tag);
237
241 virtual bool matrixTagExists(const TagName & tag_name) const;
242
246 virtual bool matrixTagExists(TagID tag_id) const;
247
251 virtual unsigned int numMatrixTags() const { return _matrix_tag_name_to_tag_id.size(); }
252
256 virtual std::map<TagName, TagID> & getMatrixTags() { return _matrix_tag_name_to_tag_id; }
257
259 virtual bool hasVariable(const std::string & var_name) const = 0;
260
262 virtual bool hasLinearVariable(const std::string & var_name) const;
263
265 virtual bool hasAuxiliaryVariable(const std::string & var_name) const;
266
277 const THREAD_ID tid,
278 const std::string & var_name,
280 Moose::VarFieldType expected_var_field_type = Moose::VarFieldType::VAR_FIELD_ANY) const = 0;
281 virtual MooseVariableFieldBase &
283 const std::string & var_name,
286 {
287 return const_cast<MooseVariableFieldBase &>(const_cast<const SubProblem *>(this)->getVariable(
288 tid, var_name, expected_var_type, expected_var_field_type));
289 }
290
293 const std::string & var_name) = 0;
294
297 const std::string & var_name) = 0;
298
301 const std::string & var_name) = 0;
302
305 const std::string & var_name) = 0;
306
308 virtual bool hasScalarVariable(const std::string & var_name) const = 0;
309
312 const std::string & var_name) = 0;
313
315 virtual libMesh::System & getSystem(const std::string & var_name) = 0;
316
323 virtual void
324 setActiveElementalMooseVariables(const std::set<MooseVariableFieldBase *> & moose_vars,
325 const THREAD_ID tid);
326
332 virtual const std::set<MooseVariableFieldBase *> &
334
340 virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const;
341
349 virtual void clearActiveElementalMooseVariables(const THREAD_ID tid);
350
351 virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) = 0;
352 virtual const Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) const = 0;
353
357 virtual const SystemBase & systemBaseNonlinear(const unsigned int sys_num) const = 0;
358 virtual SystemBase & systemBaseNonlinear(const unsigned int sys_num) = 0;
362 virtual const SystemBase & systemBaseLinear(const unsigned int sys_num) const = 0;
363 virtual SystemBase & systemBaseLinear(const unsigned int sys_num) = 0;
367 virtual const SystemBase & systemBaseSolver(const unsigned int sys_num) const = 0;
368 virtual SystemBase & systemBaseSolver(const unsigned int sys_num) = 0;
372 virtual const SystemBase & systemBaseAuxiliary() const = 0;
374
375 virtual void prepareShapes(unsigned int var, const THREAD_ID tid) = 0;
376 virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid) = 0;
377 virtual void prepareNeighborShapes(unsigned int var, const THREAD_ID tid) = 0;
379
384 unsigned int getAxisymmetricRadialCoord() const;
385
387 virtual Real finalNonlinearResidual(const unsigned int nl_sys_num) const;
388 virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const;
389 virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const;
390
391 virtual void addResidual(const THREAD_ID tid) = 0;
392 virtual void addResidualNeighbor(const THREAD_ID tid) = 0;
393 virtual void addResidualLower(const THREAD_ID tid) = 0;
394
395 virtual void cacheResidual(const THREAD_ID tid);
396 virtual void cacheResidualNeighbor(const THREAD_ID tid);
397 virtual void addCachedResidual(const THREAD_ID tid);
398
400 const THREAD_ID tid) = 0;
402 const THREAD_ID tid) = 0;
403
404 virtual void addJacobian(const THREAD_ID tid) = 0;
405 virtual void addJacobianNeighbor(const THREAD_ID tid) = 0;
406 virtual void addJacobianNeighborLowerD(const THREAD_ID tid) = 0;
407 virtual void addJacobianLowerD(const THREAD_ID tid) = 0;
409 unsigned int ivar,
410 unsigned int jvar,
411 const libMesh::DofMap & dof_map,
412 std::vector<dof_id_type> & dof_indices,
413 std::vector<dof_id_type> & neighbor_dof_indices,
414 const std::set<TagID> & tags,
415 const THREAD_ID tid) = 0;
416
417 virtual void cacheJacobian(const THREAD_ID tid);
418 virtual void cacheJacobianNeighbor(const THREAD_ID tid);
419 virtual void addCachedJacobian(const THREAD_ID tid);
420
421 virtual void prepare(const Elem * elem, const THREAD_ID tid) = 0;
422 virtual void prepareFace(const Elem * elem, const THREAD_ID tid) = 0;
423 virtual void prepare(const Elem * elem,
424 unsigned int ivar,
425 unsigned int jvar,
426 const std::vector<dof_id_type> & dof_indices,
427 const THREAD_ID tid) = 0;
428 virtual void setCurrentSubdomainID(const Elem * elem, const THREAD_ID tid) = 0;
429 virtual void
430 setNeighborSubdomainID(const Elem * elem, unsigned int side, const THREAD_ID tid) = 0;
431 virtual void prepareAssembly(const THREAD_ID tid) = 0;
432
433 virtual void reinitElem(const Elem * elem, const THREAD_ID tid) = 0;
434 virtual void reinitElemPhys(const Elem * elem,
435 const std::vector<Point> & phys_points_in_elem,
436 const THREAD_ID tid) = 0;
437 virtual void reinitElemFace(const Elem * elem, unsigned int side, const THREAD_ID tid) = 0;
438 virtual void reinitLowerDElem(const Elem * lower_d_elem,
439 const THREAD_ID tid,
440 const std::vector<Point> * const pts = nullptr,
441 const std::vector<Real> * const weights = nullptr);
442 virtual void reinitNode(const Node * node, const THREAD_ID tid) = 0;
443 virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, const THREAD_ID tid) = 0;
444 void reinitNodes(const std::vector<dof_id_type> & nodes, const THREAD_ID tid);
445 void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, const THREAD_ID tid);
446 virtual void reinitNeighbor(const Elem * elem, unsigned int side, const THREAD_ID tid) = 0;
447 virtual void reinitNeighborPhys(const Elem * neighbor,
448 unsigned int neighbor_side,
449 const std::vector<Point> & physical_points,
450 const THREAD_ID tid) = 0;
451 virtual void reinitNeighborPhys(const Elem * neighbor,
452 const std::vector<Point> & physical_points,
453 const THREAD_ID tid) = 0;
454 virtual void
455 reinitElemNeighborAndLowerD(const Elem * elem, unsigned int side, const THREAD_ID tid) = 0;
462 virtual void reinitScalars(const THREAD_ID tid,
463 bool reinit_for_derivative_reordering = false) = 0;
464 virtual void reinitOffDiagScalars(const THREAD_ID tid) = 0;
465
467 virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid);
468
475 virtual void reinitElemFaceRef(const Elem * elem,
476 unsigned int side,
477 Real tolerance,
478 const std::vector<Point> * const pts,
479 const std::vector<Real> * const weights = nullptr,
480 const THREAD_ID tid = 0);
481
488 virtual void reinitNeighborFaceRef(const Elem * neighbor_elem,
489 unsigned int neighbor_side,
490 Real tolerance,
491 const std::vector<Point> * const pts,
492 const std::vector<Real> * const weights = nullptr,
493 const THREAD_ID tid = 0);
494
498 void reinitNeighborLowerDElem(const Elem * elem, const THREAD_ID tid = 0);
499
503 void reinitMortarElem(const Elem * elem, const THREAD_ID tid = 0);
504
508 virtual bool reinitDirac(const Elem * elem, const THREAD_ID tid) = 0;
512 virtual void getDiracElements(std::set<const Elem *> & elems) = 0;
517 virtual void clearDiracInfo() = 0;
518
522 virtual void
524
529 void reinitGeomSearch();
530
532
541 virtual void storeSubdomainMatPropName(SubdomainID block_id, const std::string & name);
542
551 virtual void storeBoundaryMatPropName(BoundaryID boundary_id, const std::string & name);
552
561 virtual void storeSubdomainZeroMatProp(SubdomainID block_id, const MaterialPropertyName & name);
562
571 virtual void storeBoundaryZeroMatProp(BoundaryID boundary_id, const MaterialPropertyName & name);
572
579 virtual void storeSubdomainDelayedCheckMatProp(const std::string & requestor,
580 SubdomainID block_id,
581 const std::string & name);
582
590 virtual void storeBoundaryDelayedCheckMatProp(const std::string & requestor,
591 BoundaryID boundary_id,
592 const std::string & name);
593
599 virtual void checkBlockMatProps();
600
606 virtual void checkBoundaryMatProps();
607
611 virtual void markMatPropRequested(const std::string &);
612
616 virtual bool isMatPropRequested(const std::string & prop_name) const;
617
621 void addConsumedPropertyName(const MooseObjectName & obj_name, const std::string & prop_name);
622
626 const std::map<MooseObjectName, std::set<std::string>> & getConsumedPropertyMap() const;
627
631 virtual void addGhostedElem(dof_id_type elem_id) = 0;
632
636 virtual void addGhostedBoundary(BoundaryID boundary_id) = 0;
637
641 virtual void ghostGhostedBoundaries() = 0;
642
646 virtual std::set<SubdomainID> getMaterialPropertyBlocks(const std::string & prop_name);
647
651 virtual std::vector<SubdomainName> getMaterialPropertyBlockNames(const std::string & prop_name);
652
656 virtual bool hasBlockMaterialProperty(SubdomainID block_id, const std::string & prop_name);
657
661 virtual std::set<BoundaryID> getMaterialPropertyBoundaryIDs(const std::string & prop_name);
662
666 virtual std::vector<BoundaryName> getMaterialPropertyBoundaryNames(const std::string & prop_name);
667
671 virtual bool hasBoundaryMaterialProperty(BoundaryID boundary_id, const std::string & prop_name);
672
677 virtual bool computingPreSMOResidual(const unsigned int nl_sys_num) const = 0;
678
683 virtual std::set<dof_id_type> & ghostedElems() { return _ghosted_elems; }
684
685 std::map<std::string, std::vector<dof_id_type>> _var_dof_map;
686
690 virtual const libMesh::CouplingMatrix & nonlocalCouplingMatrix(const unsigned i) const = 0;
691
696
700 void setCurrentlyComputingJacobian(const bool currently_computing_jacobian)
701 {
702 _currently_computing_jacobian = currently_computing_jacobian;
703 }
704
708 const bool & currentlyComputingResidualAndJacobian() const;
709
713 void setCurrentlyComputingResidualAndJacobian(bool currently_computing_residual_and_jacobian);
714
719
723 virtual void computingNonlinearResid(const bool computing_nonlinear_residual)
724 {
725 _computing_nonlinear_residual = computing_nonlinear_residual;
726 }
727
732
736 virtual void setCurrentlyComputingResidual(const bool currently_computing_residual)
737 {
738 _currently_computing_residual = currently_computing_residual;
739 }
740
743
746
748
750
751 virtual void setActiveFEVariableCoupleableVectorTags(std::set<TagID> & vtags,
752 const THREAD_ID tid);
753
754 virtual void setActiveFEVariableCoupleableMatrixTags(std::set<TagID> & mtags,
755 const THREAD_ID tid);
756
758
760
761 virtual void setActiveScalarVariableCoupleableVectorTags(std::set<TagID> & vtags,
762 const THREAD_ID tid);
763
764 virtual void setActiveScalarVariableCoupleableMatrixTags(std::set<TagID> & mtags,
765 const THREAD_ID tid);
766
767 const std::set<TagID> & getActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) const;
768
769 const std::set<TagID> & getActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) const;
770
771 const std::set<TagID> & getActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) const;
772
773 const std::set<TagID> & getActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) const;
774
778 virtual void haveADObjects(bool have_ad_objects) { _have_ad_objects = have_ad_objects; }
782 bool haveADObjects() const { return _have_ad_objects; }
783
784 virtual LineSearch * getLineSearch() = 0;
785
789 virtual const libMesh::CouplingMatrix * couplingMatrix(const unsigned int nl_sys_num) const = 0;
790
791private:
801 void cloneAlgebraicGhostingFunctor(libMesh::GhostingFunctor & algebraic_gf, bool to_mesh = true);
802
812 void cloneCouplingGhostingFunctor(libMesh::GhostingFunctor & coupling_gf, bool to_mesh = true);
813
814public:
818 void addAlgebraicGhostingFunctor(libMesh::GhostingFunctor & algebraic_gf, bool to_mesh = true);
819
823 void addCouplingGhostingFunctor(libMesh::GhostingFunctor & coupling_gf, bool to_mesh = true);
824
829
834
839 virtual void automaticScaling(bool automatic_scaling);
840
845 bool automaticScaling() const;
846
850 virtual bool haveDisplaced() const = 0;
851
855 virtual bool computingScalingJacobian() const = 0;
856
860 virtual bool computingScalingResidual() const = 0;
861
865 void clearAllDofIndices();
866
876 template <typename T>
877 const Moose::Functor<T> & getFunctor(const std::string & name,
878 const THREAD_ID tid,
879 const std::string & requestor_name,
880 bool requestor_is_ad);
881
885 bool hasFunctor(const std::string & name, const THREAD_ID tid) const;
886
890 template <typename T>
891 bool hasFunctorWithType(const std::string & name, const THREAD_ID tid) const;
892
896 template <typename T>
897 void
898 addFunctor(const std::string & name, const Moose::FunctorBase<T> & functor, const THREAD_ID tid);
899
913 template <typename T, typename PolymorphicLambda>
915 addPiecewiseByBlockLambdaFunctor(const std::string & name,
916 PolymorphicLambda my_lammy,
917 const std::set<ExecFlagType> & clearance_schedule,
918 const MooseMesh & mesh,
919 const std::set<SubdomainID> & block_ids,
920 const THREAD_ID tid);
921
922 virtual void initialSetup();
923 virtual void timestepSetup();
924 virtual void customSetup(const ExecFlagType & exec_type);
925 virtual void residualSetup();
926 virtual void jacobianSetup();
927
929 void setFunctorOutput(bool set_output) { _show_functors = set_output; }
931 void setChainControlDataOutput(bool set_output) { _show_chain_control_data = set_output; }
932
933#ifndef NDEBUG
935 virtual bool checkResidualForNans() const = 0;
936#endif
937
941 virtual std::size_t numNonlinearSystems() const = 0;
942
946 virtual unsigned int currentNlSysNum() const = 0;
947
951 virtual std::size_t numLinearSystems() const = 0;
952
956 virtual std::size_t numSolverSystems() const = 0;
957
961 virtual unsigned int currentLinearSysNum() const = 0;
962
966 template <typename T>
967 void registerUnfilledFunctorRequest(T * functor_interface,
968 const std::string & functor_name,
969 const THREAD_ID tid);
970
974 virtual const std::vector<VectorTag> & currentResidualVectorTags() const = 0;
975
982 static void selectVectorTagsFromSystem(const SystemBase & system,
983 const std::vector<VectorTag> & input_vector_tags,
984 std::set<TagID> & selected_tags);
985
992 static void selectMatrixTagsFromSystem(const SystemBase & system,
993 const std::map<TagName, TagID> & input_matrix_tags,
994 std::set<TagID> & selected_tags);
995
999 void reinitFVFace(const THREAD_ID tid, const FaceInfo & fi);
1000
1006 virtual bool hasNonlocalCoupling() const = 0;
1007
1011 void preparePRefinement();
1012
1016 [[nodiscard]] bool doingPRefinement() const;
1017
1021 virtual void setCurrentLowerDElem(const Elem * const lower_d_elem, const THREAD_ID tid);
1022
1023protected:
1028 template <typename T>
1030 const std::string & var_name,
1031 Moose::VarKindType expected_var_type,
1032 Moose::VarFieldType expected_var_field_type,
1033 const std::vector<T> & nls,
1034 const SystemBase & aux) const;
1035
1039 bool verifyVectorTags() const;
1040
1042 std::map<TagName, TagID> _matrix_tag_name_to_tag_id;
1043
1045 std::map<TagID, TagName> _matrix_tag_id_to_tag_name;
1046
1049
1051
1053 std::map<SubdomainID, std::set<std::string>> _map_block_material_props;
1054
1056 std::map<BoundaryID, std::set<std::string>> _map_boundary_material_props;
1057
1059 std::map<SubdomainID, std::set<MaterialPropertyName>> _zero_block_material_props;
1060 std::map<BoundaryID, std::set<MaterialPropertyName>> _zero_boundary_material_props;
1061
1063 std::set<std::string> _material_property_requested;
1064
1066
1071 std::map<SubdomainID, std::multimap<std::string, std::string>> _map_block_material_props_check;
1072 std::map<BoundaryID, std::multimap<std::string, std::string>> _map_boundary_material_props_check;
1074
1076 std::vector<std::set<MooseVariableFieldBase *>> _active_elemental_moose_variables;
1077
1079 /* This needs to remain <unsigned int> for threading purposes */
1080 std::vector<unsigned int> _has_active_elemental_moose_variables;
1081
1082 std::vector<std::set<TagID>> _active_fe_var_coupleable_matrix_tags;
1083
1084 std::vector<std::set<TagID>> _active_fe_var_coupleable_vector_tags;
1085
1086 std::vector<std::set<TagID>> _active_sc_var_coupleable_matrix_tags;
1087
1088 std::vector<std::set<TagID>> _active_sc_var_coupleable_vector_tags;
1089
1092
1094 std::set<dof_id_type> _ghosted_elems;
1095
1098
1101
1104
1107
1110
1113
1116
1118 std::unordered_set<TagID> _not_zeroed_tagged_vectors;
1119
1120private:
1127 virtual std::pair<bool, unsigned int>
1128 determineSolverSystem(const std::string & var_name, bool error_if_not_found = false) const = 0;
1129
1130 enum class TrueFunctorIs
1131 {
1132 UNSET,
1133 NONAD,
1134 AD
1135 };
1136
1141 std::vector<std::multimap<std::string,
1142 std::tuple<TrueFunctorIs,
1143 std::unique_ptr<Moose::FunctorEnvelopeBase>,
1144 std::unique_ptr<Moose::FunctorEnvelopeBase>>>>
1146
1148 std::vector<std::map<std::string, std::unique_ptr<Moose::FunctorAbstract>>> _pbblf_functors;
1149
1151 void showFunctors() const;
1152
1154 void showFunctorRequestors() const;
1155
1158 std::map<std::string, std::set<std::string>> _functor_to_requestors;
1159
1162 std::vector<std::multimap<std::string, std::pair<bool, bool>>> _functor_to_request_info;
1163
1166
1169
1171 std::vector<VectorTag> _vector_tags;
1172
1178 std::vector<std::vector<VectorTag>> _typed_vector_tags;
1179
1181 std::map<TagName, TagID> _vector_tags_name_map;
1182
1184 std::string restrictionSubdomainCheckName(SubdomainID check_id);
1185 std::string restrictionBoundaryCheckName(BoundaryID check_id);
1187
1188 // Contains properties consumed by objects, see addConsumedPropertyName
1189 std::map<MooseObjectName, std::set<std::string>> _consumed_material_properties;
1190
1194 std::unordered_map<libMesh::GhostingFunctor *,
1195 std::vector<std::shared_ptr<libMesh::GhostingFunctor>>>
1197
1201 std::unordered_map<libMesh::GhostingFunctor *,
1202 std::vector<std::shared_ptr<libMesh::GhostingFunctor>>>
1204
1205 friend class Restartable;
1206};
1207
1208template <typename T>
1209const Moose::Functor<T> &
1210SubProblem::getFunctor(const std::string & name,
1211 const THREAD_ID tid,
1212 const std::string & requestor_name,
1213 const bool requestor_is_ad)
1214{
1215 mooseAssert(tid < _functors.size(), "Too large a thread ID");
1216
1217 // Log the requestor
1218 _functor_to_requestors["wraps_" + name].insert(requestor_name);
1219
1220 constexpr bool requested_functor_is_ad =
1221 !std::is_same<T, typename MetaPhysicL::RawType<T>::value_type>::value;
1222
1223 auto & functor_to_request_info = _functor_to_request_info[tid];
1224
1225 // Get the requested functor if we already have it
1226 auto & functors = _functors[tid];
1227 if (auto find_ret = functors.find("wraps_" + name); find_ret != functors.end())
1228 {
1229 if (functors.count("wraps_" + name) > 1)
1230 mooseError("Attempted to get a functor with the name '",
1231 name,
1232 "' but multiple (" + std::to_string(functors.count("wraps_" + name)) +
1233 ") functors match. Make sure that you do not have functor material "
1234 "properties, functions, postprocessors or variables with the same names.");
1235
1236 auto & [true_functor_is, non_ad_functor, ad_functor] = find_ret->second;
1237 auto & functor_wrapper = requested_functor_is_ad ? *ad_functor : *non_ad_functor;
1238
1239 auto * const functor = dynamic_cast<Moose::Functor<T> *>(&functor_wrapper);
1240 if (!functor)
1241 mooseError("A call to SubProblem::getFunctor requested a functor named '",
1242 name,
1243 "' that returns the type: '",
1244 libMesh::demangle(typeid(T).name()),
1245 "'. However, that functor already exists and returns a different type: '",
1246 functor_wrapper.returnType(),
1247 "'");
1248
1249 if (functor->template wrapsType<Moose::NullFunctor<T>>())
1250 // Store for future checking when the actual functor gets added
1251 functor_to_request_info.emplace(name,
1252 std::make_pair(requested_functor_is_ad, requestor_is_ad));
1253 else
1254 {
1255 // We already have the actual functor
1256 if (true_functor_is == SubProblem::TrueFunctorIs::UNSET)
1257 mooseError("We already have the functor; it should not be unset");
1258
1259 // Check for whether this is a valid request
1260 // We allow auxiliary variables and linear variables to be retrieved as non AD
1261 if (!requested_functor_is_ad && requestor_is_ad &&
1262 true_functor_is == SubProblem::TrueFunctorIs::AD &&
1264 mooseError("The AD object '",
1265 requestor_name,
1266 "' is requesting the functor '",
1267 name,
1268 "' as a non-AD functor even though it is truly an AD functor, which is not "
1269 "allowed, since this may unintentionally drop derivatives.");
1270 }
1271
1272 return *functor;
1273 }
1274
1275 // We don't have the functor yet but we could have it in the future. We'll create null functors
1276 // for now
1277 functor_to_request_info.emplace(name, std::make_pair(requested_functor_is_ad, requestor_is_ad));
1278 if constexpr (requested_functor_is_ad)
1279 {
1280 typedef typename MetaPhysicL::RawType<T>::value_type NonADType;
1281 typedef T ADType;
1282
1283 auto emplace_ret =
1284 functors.emplace("wraps_" + name,
1285 std::make_tuple(SubProblem::TrueFunctorIs::UNSET,
1286 std::make_unique<Moose::Functor<NonADType>>(
1287 std::make_unique<Moose::NullFunctor<NonADType>>()),
1288 std::make_unique<Moose::Functor<ADType>>(
1289 std::make_unique<Moose::NullFunctor<ADType>>())));
1290
1291 return cast_ref<Moose::Functor<T> &>(*(requested_functor_is_ad
1292 ? std::get<2>(emplace_ret->second)
1293 : std::get<1>(emplace_ret->second)));
1294 }
1295 else
1296 {
1297 typedef T NonADType;
1298 typedef typename Moose::ADType<T>::type ADType;
1299
1300 auto emplace_ret =
1301 functors.emplace("wraps_" + name,
1302 std::make_tuple(SubProblem::TrueFunctorIs::UNSET,
1303 std::make_unique<Moose::Functor<NonADType>>(
1304 std::make_unique<Moose::NullFunctor<NonADType>>()),
1305 std::make_unique<Moose::Functor<ADType>>(
1306 std::make_unique<Moose::NullFunctor<ADType>>())));
1307
1308 return cast_ref<Moose::Functor<T> &>(*(requested_functor_is_ad
1309 ? std::get<2>(emplace_ret->second)
1310 : std::get<1>(emplace_ret->second)));
1311 }
1312}
1313
1314template <typename T>
1315bool
1316SubProblem::hasFunctorWithType(const std::string & name, const THREAD_ID tid) const
1317{
1318 mooseAssert(tid < _functors.size(), "Too large a thread ID");
1319 auto & functors = _functors[tid];
1320
1321 const auto & it = functors.find("wraps_" + name);
1322 constexpr bool requested_functor_is_ad =
1323 !std::is_same<T, typename MetaPhysicL::RawType<T>::value_type>::value;
1324
1325 if (it == functors.end())
1326 return false;
1327 else
1328 return dynamic_cast<Moose::Functor<T> *>(
1329 requested_functor_is_ad ? std::get<2>(it->second).get() : std::get<1>(it->second).get());
1330}
1331
1332template <typename T, typename PolymorphicLambda>
1335 PolymorphicLambda my_lammy,
1336 const std::set<ExecFlagType> & clearance_schedule,
1337 const MooseMesh & mesh,
1338 const std::set<SubdomainID> & block_ids,
1339 const THREAD_ID tid)
1340{
1341 auto & pbblf_functors = _pbblf_functors[tid];
1342
1343 auto [it, first_time_added] =
1344 pbblf_functors.emplace(name,
1345 std::make_unique<PiecewiseByBlockLambdaFunctor<T>>(
1346 name, my_lammy, clearance_schedule, mesh, block_ids));
1347
1348 auto * functor = dynamic_cast<PiecewiseByBlockLambdaFunctor<T> *>(it->second.get());
1349 if (!functor)
1350 {
1351 if (first_time_added)
1352 mooseError("This should be impossible. If this was the first time we added the functor, then "
1353 "the dynamic cast absolutely should have succeeded");
1354 else
1355 mooseError("Attempted to add a lambda functor with the name '",
1356 name,
1357 "' but another lambda functor of that name returns a different type");
1358 }
1359
1360 if (first_time_added)
1361 addFunctor(name, *functor, tid);
1362 else
1363 // The functor already exists
1364 functor->setFunctor(mesh, block_ids, my_lammy);
1365
1366 return *functor;
1367}
1368
1369template <typename T>
1370void
1371SubProblem::addFunctor(const std::string & name,
1372 const Moose::FunctorBase<T> & functor,
1373 const THREAD_ID tid)
1374{
1375 constexpr bool added_functor_is_ad =
1376 !std::is_same<T, typename MetaPhysicL::RawType<T>::value_type>::value;
1377
1378 mooseAssert(tid < _functors.size(), "Too large a thread ID");
1379
1380 auto & functor_to_request_info = _functor_to_request_info[tid];
1381 auto & functors = _functors[tid];
1382 auto it = functors.find("wraps_" + name);
1383 if (it != functors.end())
1384 {
1385 // We have this functor already. If it's a null functor, we want to replace it with the valid
1386 // functor we have now. If it's not then we'll add a new entry into the multimap and then we'll
1387 // error later if a user requests a functor because their request is ambiguous. This is the
1388 // reason that the functors container is a multimap: for nice error messages
1389 auto * const existing_wrapper_base =
1390 added_functor_is_ad ? std::get<2>(it->second).get() : std::get<1>(it->second).get();
1391 auto * const existing_wrapper = dynamic_cast<Moose::Functor<T> *>(existing_wrapper_base);
1392 if (existing_wrapper && existing_wrapper->template wrapsType<Moose::NullFunctor<T>>())
1393 {
1394 // Sanity check
1395 auto [request_info_it, request_info_end_it] = functor_to_request_info.equal_range(name);
1396 if (request_info_it == request_info_end_it)
1397 mooseError("We are wrapping a NullFunctor but we don't have any unfilled functor request "
1398 "info. This doesn't make sense.");
1399
1400 // Check for valid requests
1401 while (request_info_it != request_info_end_it)
1402 {
1403 auto & [requested_functor_is_ad, requestor_is_ad] = request_info_it->second;
1404 if (!requested_functor_is_ad && requestor_is_ad && added_functor_is_ad)
1405 mooseError("We are requesting a non-AD functor '" + name +
1406 "' from an AD object, but the true functor is AD. This means we could be "
1407 "dropping important derivatives. We will not allow this");
1408 // We're going to eventually check whether we've fulfilled all functor requests and our
1409 // check will be that the multimap is empty. This request is fulfilled, so erase it from the
1410 // map now
1411 request_info_it = functor_to_request_info.erase(request_info_it);
1412 }
1413
1414 // Ok we didn't have the functor before, so we will add it now
1415 std::get<0>(it->second) =
1417 existing_wrapper->assign(functor);
1418 // Finally we create the non-AD or AD complement of the just added functor
1419 if constexpr (added_functor_is_ad)
1420 {
1421 typedef typename MetaPhysicL::RawType<T>::value_type NonADType;
1422 auto * const existing_non_ad_wrapper_base = std::get<1>(it->second).get();
1423 auto * const existing_non_ad_wrapper =
1424 dynamic_cast<Moose::Functor<NonADType> *>(existing_non_ad_wrapper_base);
1425 mooseAssert(existing_non_ad_wrapper->template wrapsType<Moose::NullFunctor<NonADType>>(),
1426 "Both members of pair should have been wrapping a NullFunctor");
1427 existing_non_ad_wrapper->assign(
1428 std::make_unique<Moose::RawValueFunctor<NonADType>>(functor));
1429 }
1430 else
1431 {
1432 typedef typename Moose::ADType<T>::type ADType;
1433 auto * const existing_ad_wrapper_base = std::get<2>(it->second).get();
1434 auto * const existing_ad_wrapper =
1435 dynamic_cast<Moose::Functor<ADType> *>(existing_ad_wrapper_base);
1436 mooseAssert(existing_ad_wrapper->template wrapsType<Moose::NullFunctor<ADType>>(),
1437 "Both members of pair should have been wrapping a NullFunctor");
1438 existing_ad_wrapper->assign(std::make_unique<Moose::ADWrapperFunctor<ADType>>(functor));
1439 }
1440 return;
1441 }
1442 else if (!existing_wrapper)
1443 {
1444 // Functor was emplaced but the cast failed. This could be a double definition with
1445 // different types, or it could be a request with one type then a definition with another
1446 // type. Either way it is going to error later, but it is cleaner to catch it now
1447 mooseError("Functor '",
1448 name,
1449 "' is being added with return type '",
1450 MooseUtils::prettyCppType<T>(),
1451 "' but it has already been defined or requested with return type '",
1452 existing_wrapper_base->returnType(),
1453 "'.");
1454 }
1455 }
1456
1457 // We are a new functor, create the opposite ADType one and store it with other functors
1458 if constexpr (added_functor_is_ad)
1459 {
1460 typedef typename MetaPhysicL::RawType<T>::value_type NonADType;
1461 auto new_non_ad_wrapper = std::make_unique<Moose::Functor<NonADType>>(
1462 std::make_unique<Moose::RawValueFunctor<NonADType>>(functor));
1463 auto new_ad_wrapper = std::make_unique<Moose::Functor<T>>(functor);
1464 _functors[tid].emplace("wraps_" + name,
1465 std::make_tuple(SubProblem::TrueFunctorIs::AD,
1466 std::move(new_non_ad_wrapper),
1467 std::move(new_ad_wrapper)));
1468 }
1469 else
1470 {
1471 typedef typename Moose::ADType<T>::type ADType;
1472 auto new_non_ad_wrapper = std::make_unique<Moose::Functor<T>>((functor));
1473 auto new_ad_wrapper = std::make_unique<Moose::Functor<ADType>>(
1474 std::make_unique<Moose::ADWrapperFunctor<ADType>>(functor));
1475 _functors[tid].emplace("wraps_" + name,
1476 std::make_tuple(SubProblem::TrueFunctorIs::NONAD,
1477 std::move(new_non_ad_wrapper),
1478 std::move(new_ad_wrapper)));
1479 }
1480}
1481
1482inline const bool &
1487
1488inline void
1490 const bool currently_computing_residual_and_jacobian)
1491{
1492 _currently_computing_residual_and_jacobian = currently_computing_residual_and_jacobian;
1493}
1494
1495namespace Moose
1496{
1497void initial_condition(libMesh::EquationSystems & es, const std::string & system_name);
1498} // namespace Moose
boundary_id_type BoundaryID
subdomain_id_type SubdomainID
unsigned int TagID
Definition MooseTypes.h:238
unsigned int THREAD_ID
Definition MooseTypes.h:237
MooseVariableFE< Real > MooseVariable
Definition SubProblem.h:45
MooseVariableFE< RealEigenVector > ArrayMooseVariable
Definition SubProblem.h:47
MooseVariableFE< RealVectorValue > VectorMooseVariable
Definition SubProblem.h:46
Keeps track of stuff related to assembling.
Definition Assembly.h:102
The DiracKernelInfo object is a place where all the Dirac points added by different DiracKernels are ...
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
Generic factory class for build all sorts of objects.
Definition Factory.h:29
GeometricSearchType
Used to select groups of geometric search objects to update.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
Class for containing MooseEnum item information.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
A class for storing the names of MooseObject by tag and object name.
Class for stuff related to variables.
This class provides an interface for common operations on field variables of both FE and FV types wit...
Class for scalar variables (they are different).
Wraps non-AD functors such that they can be used in objects that have requested the functor as AD.
Base class template for functor objects.
This is a wrapper that forwards calls to the implementation, which can be switched out at any time wi...
A functor that serves as a placeholder during the simulation setup phase if a functor consumer reques...
A material property that is evaluated on-the-fly via calls to various overloads of operator()
Class that hold the whole problem being solved.
Definition Problem.h:20
Abstract definition of a RestartableData value.
A class for creating restricted objects.
Definition Restartable.h:29
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
const std::map< MooseObjectName, std::set< std::string > > & getConsumedPropertyMap() const
Return the map that tracks the object with consumed material properties.
Definition SubProblem.C:734
std::vector< std::map< std::string, std::unique_ptr< Moose::FunctorAbstract > > > _pbblf_functors
Container to hold PiecewiseByBlockLambdaFunctors.
bool _safe_access_tagged_vectors
Is it safe to retrieve data from tagged vectors.
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid)=0
virtual void addResidualNeighbor(const THREAD_ID tid)=0
virtual void clearActiveFEVariableCoupleableVectorTags(const THREAD_ID tid)
Definition SubProblem.C:370
void showFunctorRequestors() const
Lists all functors and all the objects that requested them.
virtual void prepareFace(const Elem *elem, 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:728
virtual void addJacobianNeighbor(const THREAD_ID tid)=0
THREAD_ID numThreads() const
Definition SubProblem.C:81
std::vector< VectorTag > _vector_tags
The declared vector tags.
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:575
void reinitFVFace(const THREAD_ID tid, const FaceInfo &fi)
reinitialize the finite volume assembly data for the provided face and thread
const Moose::Functor< T > & getFunctor(const std::string &name, const THREAD_ID tid, const std::string &requestor_name, bool requestor_is_ad)
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:736
void showFunctors() const
Lists all functors in the problem.
virtual MooseMesh & mesh()=0
virtual bool computingScalingResidual() const =0
Getter for whether we're computing the scaling residual.
virtual unsigned int currentNlSysNum() const =0
virtual void checkBoundaryMatProps()
Checks boundary material properties integrity.
Definition SubProblem.C:657
virtual void cacheJacobianNeighbor(const THREAD_ID tid)
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:607
virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const
Definition SubProblem.C:758
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition SubProblem.C:213
std::string restrictionBoundaryCheckName(BoundaryID check_id)
Definition SubProblem.C:775
void removeAlgebraicGhostingFunctor(libMesh::GhostingFunctor &algebraic_gf)
Remove an algebraic ghosting functor from this problem's DofMaps.
std::map< BoundaryID, std::multimap< std::string, std::string > > _map_boundary_material_props_check
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 bool checkResidualForNans() const =0
Whether to check residual for NaN/Inf values.
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid)=0
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
Definition SubProblem.C:788
std::vector< std::vector< VectorTag > > _typed_vector_tags
The vector tags associated with each VectorTagType This is kept separate from _vector_tags for quick ...
virtual void markMatPropRequested(const std::string &)
Helper method for adding a material property name to the _material_property_requested set.
Definition SubProblem.C:716
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.
virtual bool computingScalingJacobian() const =0
Getter for whether we're computing the scaling jacobian.
const bool & currentlyComputingJacobian() const
Returns true if the problem is in the process of computing the Jacobian.
Definition SubProblem.h:695
virtual bool hasBoundaryMaterialProperty(BoundaryID boundary_id, const std::string &prop_name)
Check if a material property is defined on a block.
Definition SubProblem.C:562
virtual void checkBlockMatProps()
Checks block material properties integrity.
Definition SubProblem.C:615
void registerUnfilledFunctorRequest(T *functor_interface, const std::string &functor_name, const THREAD_ID tid)
Register an unfulfilled functor request.
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition SubProblem.C:195
std::vector< std::set< TagID > > _active_fe_var_coupleable_vector_tags
virtual void clearActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid)
Definition SubProblem.C:376
virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const
Definition SubProblem.C:223
virtual std::size_t numNonlinearSystems() const =0
bool _currently_computing_residual
Whether the residual is being evaluated.
virtual bool hasLinearVariable(const std::string &var_name) const
Whether or not this problem has this linear variable.
Definition SubProblem.C:794
void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)
Definition SubProblem.C:987
bool _computing_nonlinear_residual
Whether the non-linear residual is being evaluated.
void clearAllDofIndices()
Clear dof indices from variables in nl and aux systems.
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
virtual void reinitElemFaceRef(const Elem *elem, unsigned int side, 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:874
virtual const VectorTag & getVectorTag(const TagID tag_id) const
Get a VectorTag from a TagID.
Definition SubProblem.C:153
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition SubProblem.C:446
virtual SystemBase & systemBaseNonlinear(const unsigned int sys_num)=0
virtual void needFV()=0
marks this problem as including/needing finite volume functionality.
std::map< TagID, TagName > _matrix_tag_id_to_tag_name
Reverse map.
virtual bool safeAccessTaggedMatrices() const
Is it safe to access the tagged matrices.
Definition SubProblem.h:742
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.
std::map< std::string, std::vector< dof_id_type > > _var_dof_map
Definition SubProblem.h:685
virtual void customSetup(const ExecFlagType &exec_type)
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.
virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid)
sets the current boundary ID in assembly
Definition SubProblem.C:781
virtual void cacheResidual(const THREAD_ID tid)
virtual void jacobianSetup()
virtual void initialSetup()
virtual void cacheJacobian(const THREAD_ID tid)
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition SubProblem.h:683
Factory & _factory
The Factory for building objects.
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid)=0
virtual void reinitNode(const Node *node, const THREAD_ID tid)=0
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition SubProblem.C:164
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition SubProblem.h:251
virtual SystemBase & systemBaseSolver(const unsigned int sys_num)=0
bool doingPRefinement() const
std::map< MooseObjectName, std::set< std::string > > _consumed_material_properties
void setCurrentlyComputingJacobian(const bool currently_computing_jacobian)
Set whether or not the problem is in the process of computing the Jacobian.
Definition SubProblem.h:700
virtual DiracKernelInfo & diracKernelInfo()
Definition SubProblem.C:740
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const
Definition SubProblem.C:752
void preparePRefinement()
Prepare DofMap and Assembly classes with our p-refinement information.
virtual unsigned int currentLinearSysNum() const =0
static InputParameters validParams()
Definition SubProblem.C:34
virtual LineSearch * getLineSearch()=0
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid)=0
virtual TagID getMatrixTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition SubProblem.C:334
virtual void addGhostedBoundary(BoundaryID boundary_id)=0
Will make sure that all necessary elements from boundary_id are ghosted to this processor.
std::unordered_map< libMesh::GhostingFunctor *, std::vector< std::shared_ptr< libMesh::GhostingFunctor > > > _root_coupling_gf_to_sys_clones
A map from a root coupling ghosting functor, e.g.
void reinitNeighborLowerDElem(const Elem *elem, const THREAD_ID tid=0)
reinitialize a neighboring lower dimensional element
Definition SubProblem.C:995
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:581
void removeCouplingGhostingFunctor(libMesh::GhostingFunctor &coupling_gf)
Remove a coupling ghosting functor from this problem's DofMaps.
virtual SystemBase & systemBaseLinear(const unsigned int sys_num)=0
virtual void setActiveScalarVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition SubProblem.C:394
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:465
std::map< TagName, TagID > _vector_tags_name_map
Map of vector tag TagName to TagID.
virtual void reinitNeighborFaceRef(const Elem *neighbor_elem, unsigned int neighbor_side, 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:913
virtual void ghostGhostedBoundaries()=0
Causes the boundaries added using addGhostedBoundary to actually be ghosted.
std::map< SubdomainID, std::set< MaterialPropertyName > > _zero_block_material_props
Set of properties returned as zero properties.
virtual bool hasNonlocalCoupling() const =0
Whether the simulation has active nonlocal coupling which should be accounted for in the Jacobian.
virtual void reinitElemFace(const Elem *elem, unsigned int side, const THREAD_ID tid)=0
std::vector< std::set< TagID > > _active_sc_var_coupleable_vector_tags
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)
void setFunctorOutput(bool set_output)
Setter for debug functor output.
Definition SubProblem.h:929
bool defaultGhosting()
Whether or not the user has requested default ghosting ot be on.
Definition SubProblem.h:147
virtual void addJacobianNeighborLowerD(const THREAD_ID tid)=0
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:187
void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)
Definition SubProblem.C:979
void cloneCouplingGhostingFunctor(libMesh::GhostingFunctor &coupling_gf, bool to_mesh=true)
Creates (n_sys - 1) clones of the provided coupling ghosting functor (corresponding to the nonlinear ...
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...
virtual std::size_t numSolverSystems() const =0
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition SubProblem.C:349
virtual const MooseMesh & mesh() const =0
void addNotZeroedVectorTag(const TagID tag)
Adds a vector tag to the list of vectors that will not be zeroed when other tagged vectors are.
Definition SubProblem.C:141
virtual void haveADObjects(bool have_ad_objects)
Method for setting whether we have any ad objects.
Definition SubProblem.h:778
virtual void addResidual(const THREAD_ID tid)=0
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
std::vector< std::set< TagID > > _active_sc_var_coupleable_matrix_tags
virtual void addGhostedElem(dof_id_type elem_id)=0
Will make sure that all dofs connected to elem_id are ghosted to this processor.
DiracKernelInfo _dirac_kernel_info
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:723
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition SubProblem.C:452
virtual std::size_t numLinearSystems() const =0
bool _show_chain_control_data
Whether to output a list of all the chain control data.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid)=0
virtual unsigned int nlSysNum(const NonlinearSystemName &nl_sys_name) const =0
virtual std::pair< bool, unsigned int > determineSolverSystem(const std::string &var_name, bool error_if_not_found=false) const =0
virtual Real finalNonlinearResidual(const unsigned int nl_sys_num) const
Definition SubProblem.C:746
virtual SystemBase & systemBaseAuxiliary()=0
void reinitMortarElem(const Elem *elem, const THREAD_ID tid=0)
Reinit a mortar element to obtain a valid JxW.
virtual void setResidual(libMesh::NumericVector< libMesh::Number > &residual, const THREAD_ID tid)=0
bool _safe_access_tagged_matrices
Is it safe to retrieve data from tagged matrices.
virtual void prepareNeighborShapes(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 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 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:587
virtual void setActiveFEVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition SubProblem.C:355
virtual bool solverSystemConverged(const unsigned int sys_num)
Definition SubProblem.h:103
bool verifyVectorTags() const
Verify the integrity of _vector_tags and _typed_vector_tags.
Definition SubProblem.C:233
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition SubProblem.C:84
std::unordered_set< TagID > _not_zeroed_tagged_vectors
the list of vector tags that will not be zeroed when all other tags are
void addCouplingGhostingFunctor(libMesh::GhostingFunctor &coupling_gf, bool to_mesh=true)
Add a coupling functor to this problem's DofMaps.
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.
virtual const libMesh::CouplingMatrix & nonlocalCouplingMatrix(const unsigned i) const =0
void addAlgebraicGhostingFunctor(libMesh::GhostingFunctor &algebraic_gf, bool to_mesh=true)
Add an algebraic ghosting functor to this problem's DofMaps.
bool _default_ghosting
Whether or not to use default libMesh coupling.
virtual bool hasBlockMaterialProperty(SubdomainID block_id, const std::string &prop_name)
Check if a material property is defined on a block.
Definition SubProblem.C:503
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:281
virtual void setActiveScalarVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition SubProblem.C:401
virtual bool checkNonlocalCouplingRequirement() const =0
const std::set< TagID > & getActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition SubProblem.C:423
std::map< SubdomainID, std::multimap< std::string, std::string > > _map_block_material_props_check
Data structures of the requested material properties.
virtual void clearActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid)
Definition SubProblem.C:411
std::set< dof_id_type > _ghosted_elems
Elements that should have Dofs ghosted to the local processor.
std::unordered_map< libMesh::GhostingFunctor *, std::vector< std::shared_ptr< libMesh::GhostingFunctor > > > _root_alg_gf_to_sys_clones
A map from a root algebraic ghosting functor, e.g.
virtual void prepare(const Elem *elem, const THREAD_ID tid)=0
bool computingNonlinearResid() const
Returns true if the problem is in the process of computing the nonlinear residual.
Definition SubProblem.h:718
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL)=0
update geometric search data
const std::set< TagID > & getActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition SubProblem.C:382
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition SubProblem.C:361
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid)
Clear the active elemental MooseVariableFieldBase.
Definition SubProblem.C:458
void cloneAlgebraicGhostingFunctor(libMesh::GhostingFunctor &algebraic_gf, bool to_mesh=true)
Creates (n_sys - 1) clones of the provided algebraic ghosting functor (corresponding to the nonlinear...
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:292
virtual bool converged(const unsigned int sys_num)
Eventually we want to convert this virtual over to taking a solver system number argument.
Definition SubProblem.h:116
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.
std::string restrictionSubdomainCheckName(SubdomainID check_id)
Helper functions for checking MaterialProperties.
Definition SubProblem.C:764
bool haveADObjects() const
Method for reading wehther we have any ad objects.
Definition SubProblem.h:782
bool vectorTagNotZeroed(const TagID tag) const
Checks if a vector tag is in the list of vectors that will not be zeroed when other tagged vectors ar...
Definition SubProblem.C:147
virtual libMesh::System & getSystem(const std::string &var_name)=0
Returns the equation system containing the variable provided.
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual const SystemBase & systemBaseAuxiliary() const =0
Return the auxiliary system object as a base class reference.
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
virtual void clearActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid)
Definition SubProblem.C:417
virtual void prepareShapes(unsigned int var, const THREAD_ID tid)=0
virtual void onTimestepBegin()=0
virtual void setCurrentLowerDElem(const Elem *const lower_d_elem, const THREAD_ID tid)
Set the current lower dimensional element.
virtual unsigned int linearSysNum(const LinearSystemName &linear_sys_name) const =0
virtual unsigned int solverSysNum(const SolverSystemName &solver_sys_name) const =0
void setCurrentlyComputingResidualAndJacobian(bool currently_computing_residual_and_jacobian)
Set whether or not the problem is in the process of computing the Jacobian.
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
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition SubProblem.C:320
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...
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:517
std::map< BoundaryID, std::set< std::string > > _map_boundary_material_props
Map for boundary material properties (boundary_id -> list of properties)
void setChainControlDataOutput(bool set_output)
Setter for debug chain control data output.
Definition SubProblem.h:931
const bool & currentlyComputingResidual() const
Returns true if the problem is in the process of computing the residual.
Definition SubProblem.h:731
virtual bool hasScalarVariable(const std::string &var_name) const =0
Returns a Boolean indicating whether any system contains a variable with the name provided.
virtual void addCachedResidual(const THREAD_ID tid)
virtual bool safeAccessTaggedVectors() const
Is it safe to access the tagged vectors.
Definition SubProblem.h:745
virtual void reinitOffDiagScalars(const THREAD_ID tid)=0
virtual bool haveFV() const =0
returns true if this problem includes/needs finite volume functionality.
virtual void addCachedJacobian(const THREAD_ID tid)
virtual TagID addMatrixTag(TagName tag_name)
Create a Tag.
Definition SubProblem.C:303
bool _currently_computing_jacobian
Flag to determine whether the problem is currently computing Jacobian.
virtual bool computingPreSMOResidual(const unsigned int nl_sys_num) const =0
Returns true if the problem is in the process of computing it's initial residual.
std::map< SubdomainID, std::set< std::string > > _map_block_material_props
Map of material properties (block_id -> list of properties)
virtual void addJacobianNeighbor(libMesh::SparseMatrix< libMesh::Number > &jacobian, unsigned int ivar, unsigned int jvar, const libMesh::DofMap &dof_map, std::vector< dof_id_type > &dof_indices, std::vector< dof_id_type > &neighbor_dof_indices, const std::set< TagID > &tags, const THREAD_ID tid)=0
virtual libMesh::EquationSystems & es()=0
virtual void onTimestepEnd()=0
std::set< std::string > _material_property_requested
set containing all material property names that have been requested by getMaterialProperty*
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 setResidualNeighbor(libMesh::NumericVector< libMesh::Number > &residual, const THREAD_ID tid)=0
bool _show_functors
Whether to output a list of the functors used and requested (currently only at initialSetup)
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:256
virtual bool hasAuxiliaryVariable(const std::string &var_name) const
Whether or not this problem has this auxiliary variable.
Definition SubProblem.C:803
std::vector< std::set< TagID > > _active_fe_var_coupleable_matrix_tags
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:533
std::map< BoundaryID, std::set< MaterialPropertyName > > _zero_boundary_material_props
virtual void addJacobianLowerD(const THREAD_ID tid)=0
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:435
virtual void timestepSetup()
virtual const libMesh::CouplingMatrix * couplingMatrix(const unsigned int nl_sys_num) const =0
The coupling matrix defining what blocks exist in the preconditioning matrix.
virtual void prepareAssembly(const THREAD_ID tid)=0
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 hasVariable(const std::string &var_name) const =0
Whether or not this problem has the variable.
virtual void reinitNeighborPhys(const Elem *neighbor, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual void addJacobian(const THREAD_ID tid)=0
virtual const std::vector< VectorTag > & currentResidualVectorTags() const =0
Return the residual vector tags we are currently computing.
std::map< TagName, TagID > _matrix_tag_name_to_tag_id
The currently declared tags.
virtual bool isTransient() const =0
virtual const SystemBase & systemBaseSolver(const unsigned int sys_num) const =0
Return the solver system object as a base class reference given the system number.
virtual void clearDiracInfo()=0
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in.
virtual bool nlConverged(const unsigned int nl_sys_num)
Definition SubProblem.C:708
virtual void reinitElem(const Elem *elem, const THREAD_ID tid)=0
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition SubProblem.h:204
virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid)=0
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
virtual void addResidualLower(const THREAD_ID tid)=0
virtual void cacheResidualNeighbor(const THREAD_ID tid)
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:599
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
add a functor to the problem functor container
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.
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the scalar variable reference from whichever system contains it.
const std::set< TagID > & getActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition SubProblem.C:388
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:481
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...
virtual void residualSetup()
virtual bool isMatPropRequested(const std::string &prop_name) const
Find out if a material property has been requested by any object.
Definition SubProblem.C:722
virtual void prepare(const Elem *elem, unsigned int ivar, unsigned int jvar, const std::vector< dof_id_type > &dof_indices, const THREAD_ID tid)=0
virtual bool haveDisplaced() const =0
Whether we have a displaced problem in our simulation.
const std::set< TagID > & getActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition SubProblem.C:429
const bool & currentlyComputingResidualAndJacobian() const
Returns true if the problem is in the process of computing the residual and the Jacobian.
std::vector< unsigned int > _has_active_elemental_moose_variables
Whether or not there is currently a list of active elemental moose variables.
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:282
virtual GeometricSearchData & geomSearchData()=0
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:593
bool _currently_computing_residual_and_jacobian
Flag to determine whether the problem is currently computing the residual and Jacobian.
virtual const MooseMesh & mesh(bool use_displaced) const =0
bool _have_ad_objects
AD flag indicating whether any AD objects have been added.
virtual const Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) const =0
void reinitGeomSearch()
reinitialize this object's geometric search data, e.g.
virtual void reinitElemNeighborAndLowerD(const Elem *elem, unsigned int side, const THREAD_ID tid)=0
bool automaticScaling() const
Automatic scaling getter.
virtual ~SubProblem()
Definition SubProblem.C:78
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:949
Base class for a system (of equations)
Definition SystemBase.h:87
Storage for all of the information pretaining to a vector tag.
Definition VectorTag.h:18
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
@ VAR_FIELD_ANY
Definition MooseTypes.h:781
@ VECTOR_TAG_ANY
@ VECTOR_TAG_RESIDUAL
CoordinateSystemType
Definition MooseTypes.h:864
VarKindType
Framework-wide stuff.
Definition MooseTypes.h:769
@ VAR_ANY
Definition MooseTypes.h:772
void initial_condition(libMesh::EquationSystems &es, const std::string &system_name)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::string demangle(const char *name)
VectorValue< Real > RealVectorValue
Definition SubProblem.h:34