https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SubProblem.C
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#include "SubProblem.h"
11#include "Factory.h"
12#include "MooseMesh.h"
13#include "Conversion.h"
14#include "Function.h"
15#include "MooseApp.h"
16#include "MooseVariableFE.h"
17#include "MooseArray.h"
18#include "Assembly.h"
19#include "MooseObjectName.h"
20#include "RelationshipManager.h"
21#include "MooseUtils.h"
22#include "DisplacedSystem.h"
23#include "NonlinearSystemBase.h"
24#include "LinearSystem.h"
25
26#include "libmesh/equation_systems.h"
27#include "libmesh/system.h"
28#include "libmesh/dof_map.h"
29#include "libmesh/string_to_enum.h"
30
31#include <regex>
32
35{
37
38 params.addParam<bool>(
39 "default_ghosting",
40 false,
41 "Whether or not to use libMesh's default amount of algebraic and geometric ghosting");
42
43 params.addParamNamesToGroup("default_ghosting", "Advanced");
44
45 return params;
46}
47
48const std::unordered_set<FEFamily> SubProblem::_default_families_without_p_refinement = {
56
57// SubProblem /////
59 : Problem(parameters),
60 _factory(_app.getFactory()),
61 _default_ghosting(getParam<bool>("default_ghosting")),
62 _currently_computing_jacobian(false),
63 _currently_computing_residual_and_jacobian(false),
64 _computing_nonlinear_residual(false),
65 _currently_computing_residual(false),
66 _safe_access_tagged_matrices(false),
67 _safe_access_tagged_vectors(false),
68 _have_ad_objects(false),
69 _show_functors(false),
70 _show_chain_control_data(false),
71 _typed_vector_tags(2),
72 _have_p_refinement(false)
73{
74 unsigned int n_threads = libMesh::n_threads();
75 _active_elemental_moose_variables.resize(n_threads);
77
82
83 _functors.resize(n_threads);
84 _pbblf_functors.resize(n_threads);
85 _functor_to_request_info.resize(n_threads);
86}
87
89
91SubProblem::addVectorTag(const TagName & tag_name,
92 const Moose::VectorTagType type /* = Moose::VECTOR_TAG_RESIDUAL */)
93{
95 mooseError("Vector tag type cannot be VECTOR_TAG_ANY");
96
97 const auto tag_name_upper = MooseUtils::toUpper(tag_name);
98
99 // First, see if the tag exists already
100 for (const auto & vector_tag : _vector_tags)
101 {
102 mooseAssert(_vector_tags[vector_tag._id] == vector_tag, "Vector tags index mismatch");
103 if (vector_tag._name == tag_name_upper)
104 {
105 if (vector_tag._type != type)
106 mooseError("While attempting to add vector tag with name '",
107 tag_name_upper,
108 "' and type ",
109 type,
110 ",\na tag with the same name but type ",
111 vector_tag._type,
112 " was found.\n\nA tag can only exist with one type.");
113
114 return vector_tag._id;
115 }
116 }
117
118 // Doesn't exist - create it
119 const TagID new_tag_id = _vector_tags.size();
120 const TagTypeID new_tag_type_id = _typed_vector_tags[type].size();
121 // Primary storage for all tags where the index in the vector == the tag ID
122 _vector_tags.emplace_back(new_tag_id, new_tag_type_id, tag_name_upper, type);
123 // Secondary storage for each type so that we can have quick access to all tags of a type
124 _typed_vector_tags[type].emplace_back(new_tag_id, new_tag_type_id, tag_name_upper, type);
125 // Name map storage for quick name access
126 _vector_tags_name_map.emplace(tag_name_upper, new_tag_id);
127
128 // Make sure that _vector_tags, _typed_vector_tags, and _vector_tags_name_map are sane
130
131 return new_tag_id;
132}
133
134bool
135SubProblem::vectorTagExists(const TagName & tag_name) const
136{
137 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
138
139 const auto tag_name_upper = MooseUtils::toUpper(tag_name);
140 for (const auto & vector_tag : _vector_tags)
141 if (vector_tag._name == tag_name_upper)
142 return true;
143
144 return false;
145}
146
147void
152
153bool
155{
156 return _not_zeroed_tagged_vectors.count(tag);
157}
158
159const VectorTag &
161{
162 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
163
164 if (!vectorTagExists(tag_id))
165 mooseError("Vector tag with ID ", tag_id, " does not exist");
166
167 return _vector_tags[tag_id];
168}
169
170std::vector<VectorTag>
171SubProblem::getVectorTags(const std::set<TagID> & tag_ids) const
172{
173 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
174
175 std::vector<VectorTag> tags;
176 tags.reserve(tag_ids.size());
177 for (const auto & tag_id : tag_ids)
178 tags.push_back(getVectorTag(tag_id));
179 return tags;
180}
181
182const std::vector<VectorTag> &
183SubProblem::getVectorTags(const Moose::VectorTagType type /* = Moose::VECTOR_TAG_ANY */) const
184{
185 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
186
188 return _vector_tags;
189 else
190 return _typed_vector_tags[type];
191}
192
193unsigned int
194SubProblem::numVectorTags(const Moose::VectorTagType type /* = Moose::VECTOR_TAG_ANY */) const
195{
196 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
197
198 return getVectorTags(type).size();
199}
200
201TagID
202SubProblem::getVectorTagID(const TagName & tag_name) const
203{
204 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
205
206 const auto tag_name_upper = MooseUtils::toUpper(tag_name);
207 const auto search = _vector_tags_name_map.find(tag_name_upper);
208 if (search != _vector_tags_name_map.end())
209 return search->second;
210
211 std::string message =
212 tag_name_upper == "TIME"
213 ? ".\n\nThis may occur if "
214 "you have a TimeKernel in your problem but did not specify a transient executioner."
215 : "";
216 mooseError("Vector tag '", tag_name_upper, "' does not exist", message);
217}
218
219TagName
221{
222 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
223 if (!vectorTagExists(tag_id))
224 mooseError("Vector tag with ID ", tag_id, " does not exist");
225
226 return _vector_tags[tag_id]._name;
227}
228
231{
232 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
233 if (!vectorTagExists(tag_id))
234 mooseError("Vector tag with ID ", tag_id, " does not exist");
235
236 return _vector_tags[tag_id]._type;
237}
238
239bool
241{
242 for (TagID tag_id = 0; tag_id < _vector_tags.size(); ++tag_id)
243 {
244 const auto & vector_tag = _vector_tags[tag_id];
245
246 if (vector_tag._id != tag_id)
247 mooseError("Vector tag ", vector_tag._id, " id mismatch in _vector_tags");
248 if (vector_tag._type == Moose::VECTOR_TAG_ANY)
249 mooseError("Vector tag '", vector_tag._name, "' has type VECTOR_TAG_ANY");
250
251 const auto search = _vector_tags_name_map.find(vector_tag._name);
252 if (search == _vector_tags_name_map.end())
253 mooseError("Vector tag ", vector_tag._id, " is not in _vector_tags_name_map");
254 else if (search->second != tag_id)
255 mooseError("Vector tag ", vector_tag._id, " has incorrect id in _vector_tags_name_map");
256
257 unsigned int found_in_type = 0;
258 for (TagTypeID tag_type_id = 0; tag_type_id < _typed_vector_tags[vector_tag._type].size();
259 ++tag_type_id)
260 {
261 const auto & vector_tag_type = _typed_vector_tags[vector_tag._type][tag_type_id];
262 if (vector_tag_type == vector_tag)
263 {
264 ++found_in_type;
265 if (vector_tag_type._type_id != tag_type_id)
266 mooseError("Type ID for Vector tag ", tag_id, " is incorrect");
267 }
268 }
269
270 if (found_in_type == 0)
271 mooseError("Vector tag ", tag_id, " not found in _typed_vector_tags");
272 if (found_in_type > 1)
273 mooseError("Vector tag ", tag_id, " found multiple times in _typed_vector_tags");
274 }
275
276 unsigned int num_typed_vector_tags = 0;
277 for (const auto & typed_vector_tags : _typed_vector_tags)
278 num_typed_vector_tags += typed_vector_tags.size();
279 if (num_typed_vector_tags != _vector_tags.size())
280 mooseError("Size mismatch between _vector_tags and _typed_vector_tags");
281 if (_vector_tags_name_map.size() != _vector_tags.size())
282 mooseError("Size mismatch between _vector_tags and _vector_tags_name_map");
283
284 return true;
285}
286
287void
289 const std::vector<VectorTag> & input_vector_tags,
290 std::set<TagID> & selected_tags)
291{
292 selected_tags.clear();
293 for (const auto & vector_tag : input_vector_tags)
294 if (system.hasVector(vector_tag._id))
295 selected_tags.insert(vector_tag._id);
296}
297
298void
300 const std::map<TagName, TagID> & input_matrix_tags,
301 std::set<TagID> & selected_tags)
302{
303 selected_tags.clear();
304 for (const auto & matrix_tag_pair : input_matrix_tags)
305 if (system.hasMatrix(matrix_tag_pair.second))
306 selected_tags.insert(matrix_tag_pair.second);
307}
308
309TagID
311{
312 auto tag_name_upper = MooseUtils::toUpper(tag_name);
313 auto existing_tag = _matrix_tag_name_to_tag_id.find(tag_name_upper);
314 if (existing_tag == _matrix_tag_name_to_tag_id.end())
315 {
316 auto tag_id = _matrix_tag_name_to_tag_id.size();
317
318 _matrix_tag_name_to_tag_id[tag_name_upper] = tag_id;
319
320 _matrix_tag_id_to_tag_name[tag_id] = tag_name_upper;
321 }
322
323 return _matrix_tag_name_to_tag_id.at(tag_name_upper);
324}
325
326bool
327SubProblem::matrixTagExists(const TagName & tag_name) const
328{
329 auto tag_name_upper = MooseUtils::toUpper(tag_name);
330
331 return _matrix_tag_name_to_tag_id.find(tag_name_upper) != _matrix_tag_name_to_tag_id.end();
332}
333
334bool
336{
337 return _matrix_tag_id_to_tag_name.find(tag_id) != _matrix_tag_id_to_tag_name.end();
338}
339
340TagID
341SubProblem::getMatrixTagID(const TagName & tag_name) const
342{
343 auto tag_name_upper = MooseUtils::toUpper(tag_name);
344
345 if (!matrixTagExists(tag_name))
346 mooseError("Matrix tag: ",
347 tag_name,
348 " does not exist. ",
349 "If this is a TimeKernel then this may have happened because you didn't "
350 "specify a Transient Executioner.");
351
352 return _matrix_tag_name_to_tag_id.at(tag_name_upper);
353}
354
355TagName
360
361void
366
367void
369{
371 for (const auto sys_num : make_range(numSolverSystems()))
374}
375
376void
381
382void
387
388const std::set<TagID> &
393
394const std::set<TagID> &
399
400void
402 const THREAD_ID tid)
403{
405}
406
407void
409 const THREAD_ID tid)
410{
412 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
415}
416
417void
422
423void
428
429const std::set<TagID> &
434
435const std::set<TagID> &
440
441void
442SubProblem::setActiveElementalMooseVariables(const std::set<MooseVariableFEBase *> & moose_vars,
443 const THREAD_ID tid)
444{
445 if (!moose_vars.empty())
446 {
448 _active_elemental_moose_variables[tid] = moose_vars;
449 }
450}
451
452const std::set<MooseVariableFEBase *> &
457
458bool
463
464void
470
471std::set<SubdomainID>
472SubProblem::getMaterialPropertyBlocks(const std::string & prop_name)
473{
474 std::set<SubdomainID> blocks;
475
476 for (const auto & it : _map_block_material_props)
477 {
478 const std::set<std::string> & prop_names = it.second;
479 std::set<std::string>::iterator name_it = prop_names.find(prop_name);
480 if (name_it != prop_names.end())
481 blocks.insert(it.first);
482 }
483
484 return blocks;
485}
486
487std::vector<SubdomainName>
488SubProblem::getMaterialPropertyBlockNames(const std::string & prop_name)
489{
490 std::set<SubdomainID> blocks = getMaterialPropertyBlocks(prop_name);
491 std::vector<SubdomainName> block_names;
492 block_names.reserve(blocks.size());
493 for (const auto & block_id : blocks)
494 {
495 SubdomainName name;
496 name = mesh().getMesh().subdomain_name(block_id);
497 if (name.empty())
498 {
499 std::ostringstream oss;
500 oss << block_id;
501 name = oss.str();
502 }
503 block_names.push_back(name);
504 }
505
506 return block_names;
507}
508
509bool
510SubProblem::hasBlockMaterialProperty(SubdomainID bid, const std::string & prop_name)
511{
512 auto it = _map_block_material_props.find(bid);
513 if (it == _map_block_material_props.end())
514 return false;
515
516 if (it->second.count(prop_name) > 0)
517 return true;
518 else
519 return false;
520}
521
522// TODO: remove code duplication by templating
523std::set<BoundaryID>
524SubProblem::getMaterialPropertyBoundaryIDs(const std::string & prop_name)
525{
526 std::set<BoundaryID> boundaries;
527
528 for (const auto & it : _map_boundary_material_props)
529 {
530 const std::set<std::string> & prop_names = it.second;
531 std::set<std::string>::iterator name_it = prop_names.find(prop_name);
532 if (name_it != prop_names.end())
533 boundaries.insert(it.first);
534 }
535
536 return boundaries;
537}
538
539std::vector<BoundaryName>
541{
542 std::set<BoundaryID> boundaries = getMaterialPropertyBoundaryIDs(prop_name);
543 std::vector<BoundaryName> boundary_names;
544 boundary_names.reserve(boundaries.size());
545 const BoundaryInfo & boundary_info = mesh().getMesh().get_boundary_info();
546
547 for (const auto & bnd_id : boundaries)
548 {
549 BoundaryName name;
550 if (bnd_id == Moose::ANY_BOUNDARY_ID)
551 name = "ANY_BOUNDARY_ID";
552 else
553 {
554 name = boundary_info.get_sideset_name(bnd_id);
555 if (name.empty())
556 {
557 std::ostringstream oss;
558 oss << bnd_id;
559 name = oss.str();
560 }
561 }
562 boundary_names.push_back(name);
563 }
564
565 return boundary_names;
566}
567
568bool
569SubProblem::hasBoundaryMaterialProperty(BoundaryID bid, const std::string & prop_name)
570{
571 auto it = _map_boundary_material_props.find(bid);
572 if (it == _map_boundary_material_props.end())
573 return false;
574
575 if (it->second.count(prop_name) > 0)
576 return true;
577 else
578 return false;
579}
580
581void
582SubProblem::storeSubdomainMatPropName(SubdomainID block_id, const std::string & name)
583{
584 _map_block_material_props[block_id].insert(name);
585}
586
587void
588SubProblem::storeBoundaryMatPropName(BoundaryID boundary_id, const std::string & name)
589{
590 _map_boundary_material_props[boundary_id].insert(name);
591}
592
593void
594SubProblem::storeSubdomainZeroMatProp(SubdomainID block_id, const MaterialPropertyName & name)
595{
596 _zero_block_material_props[block_id].insert(name);
597}
598
599void
600SubProblem::storeBoundaryZeroMatProp(BoundaryID boundary_id, const MaterialPropertyName & name)
601{
602 _zero_boundary_material_props[boundary_id].insert(name);
603}
604
605void
607 SubdomainID block_id,
608 const std::string & name)
609{
610 _map_block_material_props_check[block_id].insert(std::make_pair(requestor, name));
611}
612
613void
615 BoundaryID boundary_id,
616 const std::string & name)
617{
618 _map_boundary_material_props_check[boundary_id].insert(std::make_pair(requestor, name));
619}
620
621void
623{
624 // Variable for storing all available blocks/boundaries from the mesh
625 std::set<SubdomainID> all_ids(mesh().meshSubdomains());
626
627 std::stringstream errors;
628
629 // Loop through the properties to check
630 for (const auto & check_it : _map_block_material_props_check)
631 {
632 // The current id for the property being checked (BoundaryID || BlockID)
633 SubdomainID check_id = check_it.first;
634
635 std::set<SubdomainID> check_ids = {check_id};
636
637 // Loop through all the block/boundary ids
638 for (const auto & id : check_ids)
639 {
640 // Loop through all the stored properties
641 for (const auto & prop_it : check_it.second)
642 {
643 // Produce an error if the material property is not defined on the current block/boundary
644 // and any block/boundary
645 // and not is not a zero material property.
646 if (_map_block_material_props[id].count(prop_it.second) == 0 &&
647 _zero_block_material_props[id].count(prop_it.second) == 0)
648 {
649 std::string check_name = restrictionSubdomainCheckName(id);
650 if (check_name.empty())
651 check_name = std::to_string(id);
652 errors << "Material property '" << prop_it.second << "', requested by '" << prop_it.first
653 << "' is not defined on block " << check_name << "\n";
654 }
655 }
656 }
657 }
658
659 if (!errors.str().empty())
660 mooseError(errors.str());
661}
662
663void
665{
666 // Variable for storing the value for ANY_BOUNDARY_ID
668
669 // Variable for storing all available blocks/boundaries from the mesh
670 std::set<BoundaryID> all_ids(mesh().getBoundaryIDs());
671
672 std::stringstream errors;
673
674 // Loop through the properties to check
675 for (const auto & check_it : _map_boundary_material_props_check)
676 {
677 // The current id for the property being checked (BoundaryID || BlockID)
678 BoundaryID check_id = check_it.first;
679
680 // In the case when the material being checked has an ID is set to ANY, then loop through all
681 // the possible ids and verify that the material property is defined.
682 std::set<BoundaryID> check_ids{check_id};
683 if (check_id == any_id)
684 check_ids = all_ids;
685
686 // Loop through all the block/boundary ids
687 for (const auto & id : check_ids)
688 {
689 // Loop through all the stored properties
690 for (const auto & prop_it : check_it.second)
691 {
692 // Produce an error if the material property is not defined on the current block/boundary
693 // and any block/boundary
694 // and not is not a zero material property.
695 if (_map_boundary_material_props[id].count(prop_it.second) == 0 &&
696 _map_boundary_material_props[any_id].count(prop_it.second) == 0 &&
697 _zero_boundary_material_props[id].count(prop_it.second) == 0 &&
698 _zero_boundary_material_props[any_id].count(prop_it.second) == 0)
699 {
700 std::string check_name = restrictionBoundaryCheckName(id);
701 if (check_name.empty())
702 check_name = std::to_string(id);
703 errors << "Material property '" << prop_it.second << "', requested by '" << prop_it.first
704 << "' is not defined on boundary " << check_name << "\n";
705 }
706 }
707 }
708 }
709
710 if (!errors.str().empty())
711 mooseError(errors.str());
712}
713
714bool
715SubProblem::nlConverged(const unsigned int nl_sys_num)
716{
717 mooseAssert(nl_sys_num < numNonlinearSystems(),
718 "The nonlinear system number is higher than the number of systems we have!");
719 return solverSystemConverged(nl_sys_num);
720}
721
722void
723SubProblem::markMatPropRequested(const std::string & prop_name)
724{
725 _material_property_requested.insert(prop_name);
726}
727
728bool
729SubProblem::isMatPropRequested(const std::string & prop_name) const
730{
731 return _material_property_requested.find(prop_name) != _material_property_requested.end();
732}
733
734void
735SubProblem::addConsumedPropertyName(const MooseObjectName & obj_name, const std::string & prop_name)
736{
737 _consumed_material_properties[obj_name].insert(prop_name);
738}
739
740const std::map<MooseObjectName, std::set<std::string>> &
745
751
752Real
754{
755 return 0;
756}
757
758unsigned int
760{
761 return 0;
762}
763
764unsigned int
766{
767 return 0;
768}
769
770std::string
772{
773 // TODO: Put a better a interface in MOOSE
774 std::map<subdomain_id_type, std::string> & name_map = mesh().getMesh().set_subdomain_name_map();
775 std::map<subdomain_id_type, std::string>::const_iterator pos = name_map.find(check_id);
776 if (pos != name_map.end())
777 return pos->second;
778 return "";
779}
780
781std::string
783{
784 return mesh().getMesh().get_boundary_info().sideset_name(check_id);
785}
786
787void
789{
790 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
791 assembly(tid, nl_sys_num).setCurrentBoundaryID(bid);
792}
793
794unsigned int
799
800bool
801SubProblem::hasLinearVariable(const std::string & var_name) const
802{
803 for (const auto i : make_range(numLinearSystems()))
804 if (systemBaseLinear(i).hasVariable(var_name))
805 return true;
806 return false;
807}
808
809bool
810SubProblem::hasAuxiliaryVariable(const std::string & var_name) const
811{
812 return systemBaseAuxiliary().hasVariable(var_name);
813}
814
815template <typename T>
818 const std::string & var_name,
819 Moose::VarKindType expected_var_type,
820 Moose::VarFieldType expected_var_field_type,
821 const std::vector<T> & systems,
822 const SystemBase & aux) const
823{
824 // Eventual return value
825 MooseVariableFEBase * var = nullptr;
826
827 const auto [var_in_sys, sys_num] = determineSolverSystem(var_name);
828
829 // First check that the variable is found on the expected system.
830 if (expected_var_type == Moose::VarKindType::VAR_ANY)
831 {
832 if (var_in_sys)
833 var = &(systems[sys_num]->getVariable(tid, var_name));
834 else if (aux.hasVariable(var_name))
835 var = &(aux.getVariable(tid, var_name));
836 else
837 mooseError("Unknown variable " + var_name);
838 }
839 else if (expected_var_type == Moose::VarKindType::VAR_SOLVER && var_in_sys &&
840 systems[sys_num]->hasVariable(var_name))
841 var = &(systems[sys_num]->getVariable(tid, var_name));
842 else if (expected_var_type == Moose::VarKindType::VAR_AUXILIARY && aux.hasVariable(var_name))
843 var = &(aux.getVariable(tid, var_name));
844 else
845 {
846 std::string expected_var_type_string =
847 (expected_var_type == Moose::VarKindType::VAR_SOLVER ? "nonlinear" : "auxiliary");
848 mooseError("No ",
849 expected_var_type_string,
850 " variable named ",
851 var_name,
852 " found. "
853 "Did you specify an auxiliary variable when you meant to specify a nonlinear "
854 "variable (or vice-versa)?");
855 }
856
857 // Now make sure the var found has the expected field type.
858 if ((expected_var_field_type == Moose::VarFieldType::VAR_FIELD_ANY) ||
859 (expected_var_field_type == var->fieldType()))
860 return *var;
861 else
862 {
863 std::string expected_var_field_type_string =
864 MooseUtils::toLower(Moose::stringify(expected_var_field_type));
865 std::string var_field_type_string = MooseUtils::toLower(Moose::stringify(var->fieldType()));
866
867 mooseError("No ",
868 expected_var_field_type_string,
869 " variable named ",
870 var_name,
871 " found. "
872 "Did you specify a ",
873 var_field_type_string,
874 " variable when you meant to specify a ",
875 expected_var_field_type_string,
876 " variable?");
877 }
878}
879
880void
882 unsigned int side,
883 Real tolerance,
884 const std::vector<Point> * const pts,
885 const std::vector<Real> * const weights,
886 const THREAD_ID tid)
887{
888 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
889 {
890 // - Set our _current_elem for proper dof index getting in the moose variables
891 // - Reinitialize all of our FE objects so we have current phi, dphi, etc. data
892 // Note that our number of shape functions will reflect the number of shapes associated with the
893 // interior element while the number of quadrature points will be determined by the passed pts
894 // parameter (which presumably will have a number of pts reflective of a facial quadrature rule)
895 assembly(tid, nl_sys_num).reinitElemFaceRef(elem, side, tolerance, pts, weights);
896
897 auto & nl = systemBaseNonlinear(nl_sys_num);
898
899 // Actually get the dof indices in the moose variables
900 nl.prepare(tid);
901
902 // Let's finally compute our variable values!
903 nl.reinitElemFace(elem, side, tid);
904 }
905
906 // do same for aux as for nl
908 systemBaseAuxiliary().reinitElemFace(elem, side, tid);
909
910 // With the dof indices set in the moose variables, now let's properly size
911 // our local residuals/Jacobians
912 auto & current_assembly = assembly(tid, currentNlSysNum());
914 current_assembly.prepareJacobianBlock();
916 current_assembly.prepareResidual();
917}
918
919void
920SubProblem::reinitNeighborFaceRef(const Elem * neighbor_elem,
921 unsigned int neighbor_side,
922 Real tolerance,
923 const std::vector<Point> * const pts,
924 const std::vector<Real> * const weights,
925 const THREAD_ID tid)
926{
927 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
928 {
929 // - Set our _current_neighbor_elem for proper dof index getting in the moose variables
930 // - Reinitialize all of our FE objects so we have current phi, dphi, etc. data
931 // Note that our number of shape functions will reflect the number of shapes associated with the
932 // interior element while the number of quadrature points will be determined by the passed pts
933 // parameter (which presumably will have a number of pts reflective of a facial quadrature rule)
934 assembly(tid, nl_sys_num)
935 .reinitNeighborFaceRef(neighbor_elem, neighbor_side, tolerance, pts, weights);
936
937 auto & nl = systemBaseNonlinear(nl_sys_num);
938
939 // Actually get the dof indices in the moose variables
940 nl.prepareNeighbor(tid);
941
942 // Let's finally compute our variable values!
943 nl.reinitNeighborFace(neighbor_elem, neighbor_side, tid);
944 }
945
946 // do same for aux as for nl
948 systemBaseAuxiliary().reinitNeighborFace(neighbor_elem, neighbor_side, tid);
949
950 // With the dof indices set in the moose variables, now let's properly size
951 // our local residuals/Jacobians
953}
954
955void
957 const THREAD_ID tid,
958 const std::vector<Point> * const pts,
959 const std::vector<Real> * const weights)
960{
961 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
962 {
963 // - Set our _current_lower_d_elem for proper dof index getting in the moose variables
964 // - Reinitialize all of our lower-d FE objects so we have current phi, dphi, etc. data
965 assembly(tid, nl_sys_num).reinitLowerDElem(elem, pts, weights);
966
967 auto & nl = systemBaseNonlinear(nl_sys_num);
968
969 // Actually get the dof indices in the moose variables
970 nl.prepareLowerD(tid);
971
972 // With the dof indices set in the moose variables, now let's properly size
973 // our local residuals/Jacobians
974 assembly(tid, nl_sys_num).prepareLowerD();
975
976 // Let's finally compute our variable values!
977 nl.reinitLowerD(tid);
978 }
979
980 // do same for aux as for nl
983}
984
985void
986SubProblem::reinitNodes(const std::vector<dof_id_type> & nodes, const THREAD_ID tid)
987{
988 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
989 systemBaseNonlinear(nl_sys_num).reinitNodes(nodes, tid);
990 systemBaseAuxiliary().reinitNodes(nodes, tid);
991}
992
993void
994SubProblem::reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, const THREAD_ID tid)
995{
996 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
997 systemBaseNonlinear(nl_sys_num).reinitNodesNeighbor(nodes, tid);
999}
1000
1001void
1003{
1004 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1005 assembly(tid, nl_sys_num).reinitNeighborLowerDElem(elem);
1006}
1007
1008void
1009SubProblem::reinitMortarElem(const Elem * elem, const THREAD_ID tid)
1010{
1011 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1012 assembly(tid, nl_sys_num).reinitMortarElem(elem);
1013}
1014
1015void
1017{
1018 EquationSystems & eq = es();
1019 const auto n_sys = eq.n_systems();
1020
1021 auto pr = _root_alg_gf_to_sys_clones.emplace(
1022 &algebraic_gf, std::vector<std::shared_ptr<libMesh::GhostingFunctor>>(n_sys - 1));
1023 mooseAssert(pr.second, "We are adding a duplicate algebraic ghosting functor");
1024 auto & clones_vec = pr.first->second;
1025
1026 for (MooseIndex(n_sys) i = 1; i < n_sys; ++i)
1027 {
1028 DofMap & dof_map = eq.get_system(i).get_dof_map();
1029 std::shared_ptr<libMesh::GhostingFunctor> clone_alg_gf = algebraic_gf.clone();
1030 std::dynamic_pointer_cast<RelationshipManager>(clone_alg_gf)
1031 ->init(mesh(), *algebraic_gf.get_mesh(), &dof_map);
1032 dof_map.add_algebraic_ghosting_functor(clone_alg_gf, to_mesh);
1033 clones_vec[i - 1] = clone_alg_gf;
1034 }
1035}
1036
1037void
1039{
1040 EquationSystems & eq = es();
1041 const auto n_sys = eq.n_systems();
1042 if (!n_sys)
1043 return;
1044
1045 eq.get_system(0).get_dof_map().add_algebraic_ghosting_functor(algebraic_gf, to_mesh);
1046 cloneAlgebraicGhostingFunctor(algebraic_gf, to_mesh);
1047}
1048
1049void
1051{
1052 const std::size_t num_nl_sys = numNonlinearSystems();
1053
1054 auto pr = _root_coupling_gf_to_sys_clones.emplace(
1055 &coupling_gf, std::vector<std::shared_ptr<libMesh::GhostingFunctor>>(num_nl_sys - 1));
1056 mooseAssert(pr.second, "We are adding a duplicate coupling functor");
1057 auto & clones_vec = pr.first->second;
1058
1059 for (const auto i : make_range(std::size_t(1), num_nl_sys))
1060 {
1061 DofMap & dof_map = systemBaseNonlinear(i).system().get_dof_map();
1062 std::shared_ptr<libMesh::GhostingFunctor> clone_coupling_gf = coupling_gf.clone();
1063 std::dynamic_pointer_cast<RelationshipManager>(clone_coupling_gf)
1064 ->init(mesh(), *coupling_gf.get_mesh(), &dof_map);
1065 dof_map.add_coupling_functor(clone_coupling_gf, to_mesh);
1066 clones_vec[i - 1] = clone_coupling_gf;
1067 }
1068}
1069
1070void
1072{
1073 const auto num_nl_sys = numNonlinearSystems();
1074 if (!num_nl_sys)
1075 return;
1076
1077 systemBaseNonlinear(0).system().get_dof_map().add_coupling_functor(coupling_gf, to_mesh);
1078 cloneCouplingGhostingFunctor(coupling_gf, to_mesh);
1079}
1080
1081void
1083{
1084 EquationSystems & eq = es();
1085 const auto n_sys = eq.n_systems();
1086 DofMap & nl_dof_map = eq.get_system(0).get_dof_map();
1087
1088 const bool found_in_root_sys =
1089 std::find(nl_dof_map.algebraic_ghosting_functors_begin(),
1090 nl_dof_map.algebraic_ghosting_functors_end(),
1091 &algebraic_gf) != nl_dof_map.algebraic_ghosting_functors_end();
1092
1093#ifndef NDEBUG
1094 const bool found_in_our_map =
1095 _root_alg_gf_to_sys_clones.find(&algebraic_gf) != _root_alg_gf_to_sys_clones.end();
1096 mooseAssert(found_in_root_sys == found_in_our_map,
1097 "If the ghosting functor exists in the root DofMap, then we need to have a key for "
1098 "it in our gf to clones map");
1099#endif
1100
1101 if (found_in_root_sys) // libMesh yells if we try to remove
1102 // something that's not there
1103 nl_dof_map.remove_algebraic_ghosting_functor(algebraic_gf);
1104
1105 auto it = _root_alg_gf_to_sys_clones.find(&algebraic_gf);
1106 if (it == _root_alg_gf_to_sys_clones.end())
1107 return;
1108
1109 auto & clones_vec = it->second;
1110 mooseAssert((n_sys - 1) == clones_vec.size(),
1111 "The size of the gf clones vector doesn't match the number of systems minus one");
1112 if (clones_vec.empty())
1113 {
1114 mooseAssert(n_sys == 1, "The clones vector should only be empty if there is only one system");
1115 return;
1116 }
1117
1118 for (const auto i : make_range(n_sys))
1119 eq.get_system(i + 1).get_dof_map().remove_algebraic_ghosting_functor(*clones_vec[i]);
1120
1121 _root_alg_gf_to_sys_clones.erase(it->first);
1122}
1123
1124void
1126{
1127 EquationSystems & eq = es();
1128 const auto num_nl_sys = numNonlinearSystems();
1129 if (!num_nl_sys)
1130 return;
1131
1132 DofMap & nl_dof_map = eq.get_system(0).get_dof_map();
1133 const bool found_in_root_sys = std::find(nl_dof_map.coupling_functors_begin(),
1134 nl_dof_map.coupling_functors_end(),
1135 &coupling_gf) != nl_dof_map.coupling_functors_end();
1136
1137#ifndef NDEBUG
1138 const bool found_in_our_map =
1140 mooseAssert(found_in_root_sys == found_in_our_map,
1141 "If the ghosting functor exists in the root DofMap, then we need to have a key for "
1142 "it in our gf to clones map");
1143#endif
1144
1145 if (found_in_root_sys) // libMesh yells if we try to remove
1146 // something that's not there
1147 nl_dof_map.remove_coupling_functor(coupling_gf);
1148
1149 auto it = _root_coupling_gf_to_sys_clones.find(&coupling_gf);
1150 if (it == _root_coupling_gf_to_sys_clones.end())
1151 return;
1152
1153 auto & clones_vec = it->second;
1154 mooseAssert((num_nl_sys - 1) == clones_vec.size(),
1155 "The size of the gf clones vector doesn't match the number of systems minus one");
1156 if (clones_vec.empty())
1157 {
1158 mooseAssert(num_nl_sys == 1,
1159 "The clones vector should only be empty if there is only one nonlinear system");
1160 return;
1161 }
1162
1163 for (const auto i : make_range(num_nl_sys))
1164 eq.get_system(i + 1).get_dof_map().remove_coupling_functor(*clones_vec[i]);
1165
1166 _root_coupling_gf_to_sys_clones.erase(it->first);
1167}
1168
1169void
1170SubProblem::automaticScaling(bool automatic_scaling)
1171{
1172 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1173 systemBaseNonlinear(nl_sys_num).automaticScaling(automatic_scaling);
1174}
1175
1176bool
1178{
1179 // Currently going to assume that we are applying or not applying automatic scaling consistently
1180 // across nonlinear systems
1182}
1183
1184void
1185SubProblem::hasScalingVector(const unsigned int nl_sys_num)
1186{
1187 for (const THREAD_ID tid : make_range(libMesh::n_threads()))
1188 assembly(tid, nl_sys_num).hasScalingVector();
1189}
1190
1191void
1193{
1194 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1197}
1198
1199void
1201{
1202 for (auto & map : _pbblf_functors)
1203 for (auto & pr : map)
1204 pr.second->timestepSetup();
1207}
1208
1209void
1211{
1212 for (auto & map : _pbblf_functors)
1213 for (auto & pr : map)
1214 pr.second->customSetup(exec_type);
1215}
1216
1217void
1219{
1220 for (auto & map : _pbblf_functors)
1221 for (auto & pr : map)
1222 pr.second->residualSetup();
1223}
1224
1225void
1227{
1228 for (auto & map : _pbblf_functors)
1229 for (auto & pr : map)
1230 pr.second->jacobianSetup();
1231}
1232
1233void
1235{
1236 if (_show_functors)
1237 {
1238 showFunctors();
1240 }
1243
1244 for (const auto & functors : _functors)
1245 for (const auto & [functor_wrapper_name, functor_wrapper] : functors)
1246 {
1247 const auto & [true_functor_type, non_ad_functor, ad_functor] = functor_wrapper;
1248 mooseAssert(non_ad_functor->wrapsNull() == ad_functor->wrapsNull(), "These must agree");
1249 const auto functor_name = removeSubstring(functor_wrapper_name, "wraps_");
1250 if (non_ad_functor->wrapsNull())
1251 mooseError(
1252 "No functor ever provided with name '",
1253 functor_name,
1254 "', which was requested by '",
1255 MooseUtils::join(libmesh_map_find(_functor_to_requestors, functor_wrapper_name), ","),
1256 "'.");
1257 if (true_functor_type == TrueFunctorIs::NONAD ? non_ad_functor->ownsWrappedFunctor()
1258 : ad_functor->ownsWrappedFunctor())
1259 mooseError("Functor envelopes should not own the functors they wrap, but '",
1260 functor_name,
1261 "' is owned by the wrapper. Please open a MOOSE issue for help resolving this.");
1262 }
1263}
1264
1265void
1267{
1268 _console << "[DBG] Wrapped functors found in Subproblem" << std::endl;
1269 std::string functor_names = "[DBG] ";
1270 for (const auto & functor_pair : _functors[0])
1271 functor_names += std::regex_replace(functor_pair.first, std::regex("wraps_"), "") + " ";
1272 if (functor_names.size())
1273 functor_names.pop_back();
1274 _console << functor_names << std::endl;
1275}
1276
1277void
1279{
1280 for (const auto & [functor, requestors] : _functor_to_requestors)
1281 {
1282 _console << "[DBG] Requestors for wrapped functor "
1283 << std::regex_replace(functor, std::regex("wraps_"), "") << std::endl;
1284 _console << "[DBG] " << MooseUtils::join(requestors, " ") << std::endl;
1285 }
1286}
1287
1288bool
1289SubProblem::hasFunctor(const std::string & name, const THREAD_ID tid) const
1290{
1291 mooseAssert(tid < _functors.size(), "Too large a thread ID");
1292 auto & functors = _functors[tid];
1293 return (functors.find("wraps_" + name) != functors.end());
1294}
1295
1298{
1299 return mesh().getCoordSystem(sid);
1300}
1301
1302void
1304{
1305 for (const auto nl : make_range(numNonlinearSystems()))
1306 assembly(tid, nl).reinitFVFace(fi);
1307}
1308
1309void
1315
1316void
1322
1323void
1329
1330void
1337
1338void
1343
1344void
1349
1350void
1352{
1353 std::unordered_set<FEFamily> disable_families;
1354 for (const auto & [family, flag] : _family_for_p_refinement)
1355 if (flag)
1356 disable_families.insert(family);
1357
1358 for (const auto tid : make_range(libMesh::n_threads()))
1359 for (const auto s : make_range(numNonlinearSystems()))
1360 assembly(tid, s).havePRefinement(disable_families);
1361
1362 auto & eq = es();
1363 for (const auto family : disable_families)
1364 for (const auto i : make_range(eq.n_systems()))
1365 {
1366 auto & system = eq.get_system(i);
1367 auto & dof_map = system.get_dof_map();
1368 for (const auto vg : make_range(system.n_variable_groups()))
1369 {
1370 const auto & var_group = system.variable_group(vg);
1371 if (var_group.type().family == family)
1372 dof_map.should_p_refine(vg, false);
1373 }
1374 }
1375
1376 _have_p_refinement = true;
1377}
1378
1379bool
1381{
1382 return mesh().doingPRefinement();
1383}
1384
1385void
1387{
1388 auto family = Utility::string_to_enum<FEFamily>(params.get<MooseEnum>("family"));
1389 bool flag = _default_families_without_p_refinement.count(family);
1390 if (params.isParamValid("disable_p_refinement"))
1391 flag = params.get<bool>("disable_p_refinement");
1392
1393 auto [it, inserted] = _family_for_p_refinement.emplace(family, flag);
1394 if (!inserted && flag != it->second)
1395 mooseError("'disable_p_refinement' not set consistently for variables in ", family);
1396}
1397
1398void
1399SubProblem::setCurrentLowerDElem(const Elem * const lower_d_elem, const THREAD_ID tid)
1400{
1401 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1402 assembly(tid, nl_sys_num).setCurrentLowerDElem(lower_d_elem);
1403}
1404
1405template MooseVariableFEBase &
1407 const std::string & var_name,
1408 Moose::VarKindType expected_var_type,
1409 Moose::VarFieldType expected_var_field_type,
1410 const std::vector<std::shared_ptr<SolverSystem>> & nls,
1411 const SystemBase & aux) const;
1412template MooseVariableFEBase &
1414 const std::string & var_name,
1415 Moose::VarKindType expected_var_type,
1416 Moose::VarFieldType expected_var_field_type,
1417 const std::vector<std::unique_ptr<DisplacedSystem>> & nls,
1418 const SystemBase & aux) const;
1419
1420void
boundary_id_type BoundaryID
subdomain_id_type SubdomainID
unsigned int TagID
Definition MooseTypes.h:238
unsigned int THREAD_ID
Definition MooseTypes.h:237
unsigned int TagTypeID
Definition MooseTypes.h:239
void removeSubstring(std::string &main, const std::string &sub)
unsigned int count
Definition MortarUtils.C:53
char ** blocks
Key structure for APIs manipulating global vectors/matrices.
Definition Assembly.h:836
void cacheJacobianNonlocal(GlobalDataKey)
Takes the values that are currently in _sub_Keg and appends them to the cached values.
Definition Assembly.C:4073
void prepareLowerD()
Prepare the Jacobians and residuals for a lower dimensional element.
Definition Assembly.C:2848
void reinitFVFace(const FaceInfo &fi)
Definition Assembly.C:1857
void cacheResidualNeighbor(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Rn of all field variables and appends them to the cached ...
Definition Assembly.C:3440
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)
Reinitialize FE data for the given neighbor_element on the given side with a given set of reference p...
Definition Assembly.C:2194
void prepareNeighbor()
Definition Assembly.C:2810
void cacheJacobianNeighbor(GlobalDataKey)
Takes the values that are currently in the neighbor Dense Matrices and appends them to the cached val...
Definition Assembly.C:4095
void reinitLowerDElem(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for a lower dimenesional element with a given set of reference points.
Definition Assembly.C:2290
void cacheJacobian(GlobalDataKey)
Takes the values that are currently in _sub_Kee and appends them to the cached values.
Definition Assembly.C:4043
void setCurrentBoundaryID(BoundaryID i)
set the current boundary ID
Definition Assembly.h:425
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition Assembly.C:3798
void cacheResidual(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Re of all field variables and appends them to the cached ...
Definition Assembly.C:3390
void reinitElemFaceRef(const Elem *elem, unsigned int elem_side, Real tolerance, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for the given element on the given side, optionally with a given set of referenc...
Definition Assembly.C:2019
void havePRefinement(const std::unordered_set< FEFamily > &disable_p_refinement_for_families)
Indicate that we have p-refinement.
Definition Assembly.C:4842
void setCurrentLowerDElem(const Elem *const lower_d_elem)
Set the current lower dimensional element.
Definition Assembly.h:3219
void reinitNeighborLowerDElem(const Elem *elem)
reinitialize a neighboring lower dimensional element
Definition Assembly.C:2383
void reinitMortarElem(const Elem *elem)
reinitialize a mortar segment mesh element in order to get a proper JxW
Definition Assembly.C:2404
void hasScalingVector()
signals this object that a vector containing variable scaling factors should be used when doing resid...
Definition Assembly.C:4557
void addCachedResiduals(GlobalDataKey, const std::vector< VectorTag > &tags)
Pushes all cached residuals to the global residual vectors associated with each tag.
Definition Assembly.C:3468
std::string outputChainControlMap() const
Output the chain control map to a string.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
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
void reinit()
Completely redo all geometric search objects.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...
ChainControlDataSystem & getChainControlDataSystem()
Gets the system that manages the ChainControls.
Definition MooseApp.h:891
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.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
Definition MooseMesh.C:4423
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3557
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
Get the coordinate system type, e.g.
Definition MooseMesh.C:4304
void doingPRefinement(bool doing_p_refinement)
Indicate whether the kind of adaptivity we're doing includes p-refinement.
Definition MooseMesh.h:1502
A class for storing the names of MooseObject by tag and object name.
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual Moose::VarFieldType fieldType() const =0
Field type of this variable.
Class that hold the whole problem being solved.
Definition Problem.h:20
static InputParameters validParams()
Definition Problem.C:15
const std::map< MooseObjectName, std::set< std::string > > & getConsumedPropertyMap() const
Return the map that tracks the object with consumed material properties.
Definition SubProblem.C:741
std::vector< std::map< std::string, std::unique_ptr< Moose::FunctorAbstract > > > _pbblf_functors
Container to hold PiecewiseByBlockLambdaFunctors.
virtual void clearActiveFEVariableCoupleableVectorTags(const THREAD_ID tid)
Definition SubProblem.C:377
void showFunctorRequestors() const
Lists all functors and all the objects that requested them.
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:735
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:582
void reinitFVFace(const THREAD_ID tid, const FaceInfo &fi)
reinitialize the finite volume assembly data for the provided face and thread
void showFunctors() const
Lists all functors in the problem.
virtual MooseMesh & mesh()=0
virtual unsigned int currentNlSysNum() const =0
virtual void checkBoundaryMatProps()
Checks boundary material properties integrity.
Definition SubProblem.C:664
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:614
virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const
Definition SubProblem.C:765
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition SubProblem.C:220
std::string restrictionBoundaryCheckName(BoundaryID check_id)
Definition SubProblem.C:782
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
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
Definition SubProblem.C:795
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:723
const bool & currentlyComputingJacobian() const
Returns true if the problem is in the process of computing the Jacobian.
Definition SubProblem.h:692
virtual bool hasBoundaryMaterialProperty(BoundaryID boundary_id, const std::string &prop_name)
Check if a material property is defined on a block.
Definition SubProblem.C:569
virtual void checkBlockMatProps()
Checks block material properties integrity.
Definition SubProblem.C:622
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition SubProblem.C:202
std::vector< std::set< TagID > > _active_fe_var_coupleable_vector_tags
virtual void clearActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid)
Definition SubProblem.C:383
virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const
Definition SubProblem.C:230
virtual std::size_t numNonlinearSystems() const =0
virtual bool hasLinearVariable(const std::string &var_name) const
Whether or not this problem has this linear variable.
Definition SubProblem.C:801
void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)
Definition SubProblem.C:994
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:881
virtual const VectorTag & getVectorTag(const TagID tag_id) const
Get a VectorTag from a TagID.
Definition SubProblem.C:160
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition SubProblem.C:453
void hasScalingVector(const unsigned int nl_sys_num)
Tells this problem that the assembly associated with the given nonlinear system number involves a sca...
std::map< TagID, TagName > _matrix_tag_id_to_tag_name
Reverse map.
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:788
virtual void cacheResidual(const THREAD_ID tid)
virtual void jacobianSetup()
virtual void initialSetup()
virtual void cacheJacobian(const THREAD_ID tid)
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition SubProblem.C:171
bool doingPRefinement() const
std::map< MooseObjectName, std::set< std::string > > _consumed_material_properties
virtual DiracKernelInfo & diracKernelInfo()
Definition SubProblem.C:747
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const
Definition SubProblem.C:759
void preparePRefinement()
Prepare DofMap and Assembly classes with our p-refinement information.
static InputParameters validParams()
Definition SubProblem.C:34
virtual TagID getMatrixTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition SubProblem.C:341
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
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:588
void removeCouplingGhostingFunctor(libMesh::GhostingFunctor &coupling_gf)
Remove a coupling ghosting functor from this problem's DofMaps.
virtual void setActiveScalarVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition SubProblem.C:401
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:472
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:920
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.
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)
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:194
void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)
Definition SubProblem.C:986
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:356
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:148
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
void markFamilyPRefinement(const InputParameters &params)
Mark a variable family for either disabling or enabling p-refinement with valid parameters of a varia...
std::vector< std::set< TagID > > _active_sc_var_coupleable_matrix_tags
DiracKernelInfo _dirac_kernel_info
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition SubProblem.C:459
virtual std::size_t numLinearSystems() const =0
bool _show_chain_control_data
Whether to output a list of all the chain control data.
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:753
void reinitMortarElem(const Elem *elem, const THREAD_ID tid=0)
Reinit a mortar element to obtain a valid JxW.
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:594
virtual void setActiveFEVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition SubProblem.C:362
virtual bool solverSystemConverged(const unsigned int sys_num)
Definition SubProblem.h:100
bool verifyVectorTags() const
Verify the integrity of _vector_tags and _typed_vector_tags.
Definition SubProblem.C:240
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition SubProblem.C:91
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.
void addAlgebraicGhostingFunctor(libMesh::GhostingFunctor &algebraic_gf, bool to_mesh=true)
Add an algebraic ghosting functor to this problem's DofMaps.
virtual bool hasBlockMaterialProperty(SubdomainID block_id, const std::string &prop_name)
Check if a material property is defined on a block.
Definition SubProblem.C:510
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:288
virtual void setActiveScalarVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition SubProblem.C:408
const std::set< TagID > & getActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition SubProblem.C:430
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:418
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.
const std::set< TagID > & getActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition SubProblem.C:389
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition SubProblem.C:368
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid)
Clear the active elemental MooseVariableFieldBase.
Definition SubProblem.C:465
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...
std::unordered_map< FEFamily, bool > _family_for_p_refinement
Indicate whether a family is disabled for p-refinement.
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:299
bool _have_p_refinement
Whether p-refinement has been requested at any point during the simulation.
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:771
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:154
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:424
virtual void setCurrentLowerDElem(const Elem *const lower_d_elem, const THREAD_ID tid)
Set the current lower dimensional element.
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition SubProblem.C:327
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:524
std::map< BoundaryID, std::set< std::string > > _map_boundary_material_props
Map for boundary material properties (boundary_id -> list of properties)
virtual void addCachedResidual(const THREAD_ID tid)
static const std::unordered_set< FEFamily > _default_families_without_p_refinement
The set of variable families by default disable p-refinement.
Definition SubProblem.h:48
virtual void addCachedJacobian(const THREAD_ID tid)
virtual TagID addMatrixTag(TagName tag_name)
Create a Tag.
Definition SubProblem.C:310
SubProblem(const InputParameters &parameters)
Definition SubProblem.C:58
std::map< SubdomainID, std::set< std::string > > _map_block_material_props
Map of material properties (block_id -> list of properties)
virtual libMesh::EquationSystems & es()=0
std::set< std::string > _material_property_requested
set containing all material property names that have been requested by getMaterialProperty*
bool _show_functors
Whether to output a list of the functors used and requested (currently only at initialSetup)
virtual bool hasAuxiliaryVariable(const std::string &var_name) const
Whether or not this problem has this auxiliary variable.
Definition SubProblem.C:810
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:540
std::map< BoundaryID, std::set< MaterialPropertyName > > _zero_boundary_material_props
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:442
virtual void timestepSetup()
virtual bool hasVariable(const std::string &var_name) const =0
Whether or not this problem has the variable.
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 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 bool nlConverged(const unsigned int nl_sys_num)
Definition SubProblem.C:715
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition SubProblem.h:201
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:606
const std::set< TagID > & getActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition SubProblem.C:395
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:488
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:729
const std::set< TagID > & getActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition SubProblem.C:436
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 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:600
void reinitGeomSearch()
reinitialize this object's geometric search data, e.g.
bool automaticScaling() const
Automatic scaling getter.
virtual ~SubProblem()
Definition SubProblem.C:88
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:956
Base class for a system (of equations)
Definition SystemBase.h:87
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:323
bool automaticScaling() const
Getter for whether we are performing automatic scaling.
Definition SystemBase.h:123
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
Definition SystemBase.C:421
virtual void reinitNeighborFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition SystemBase.C:373
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition SystemBase.C:923
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition SystemBase.C:89
void setActiveScalarVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the scalar variables.
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of neighbor nodes.
Definition SystemBase.C:432
virtual void reinitLowerD(THREAD_ID tid)
Compute the values of the variables on the lower dimensional element.
Definition SystemBase.C:389
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:255
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Reinit assembly info for a side of an element.
Definition SystemBase.C:365
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition SystemBase.C:850
void clearAllDofIndices()
Clear all dof indices from moose variables.
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition SystemBase.h:388
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
Definition SystemBase.C:331
Storage for all of the information pretaining to a vector tag.
Definition VectorTag.h:18
void add_coupling_functor(GhostingFunctor &coupling_functor, bool to_mesh=true)
unsigned int n_systems() const
const T_sys & get_system(std::string_view name) const
virtual std::unique_ptr< GhostingFunctor > clone() const=0
const MeshBase * get_mesh() const
const DofMap & get_dof_map() const
std::string toUpper(std::string name)
Convert supplied string to upper case.
std::string toLower(std::string name)
Convert supplied string to lower case.
@ VAR_FIELD_ANY
Definition MooseTypes.h:781
@ VECTOR_TAG_ANY
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:64
CoordinateSystemType
Definition MooseTypes.h:864
VarKindType
Framework-wide stuff.
Definition MooseTypes.h:769
@ VAR_ANY
Definition MooseTypes.h:772
@ VAR_AUXILIARY
Definition MooseTypes.h:771
@ VAR_SOLVER
Definition MooseTypes.h:770
const BoundaryID ANY_BOUNDARY_ID
Definition MooseTypes.C:21
RATIONAL_BERNSTEIN
unsigned int n_threads()