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
48// SubProblem /////
50 : Problem(parameters),
51 _factory(_app.getFactory()),
52 _default_ghosting(getParam<bool>("default_ghosting")),
53 _currently_computing_jacobian(false),
54 _currently_computing_residual_and_jacobian(false),
55 _computing_nonlinear_residual(false),
56 _currently_computing_residual(false),
57 _safe_access_tagged_matrices(false),
58 _safe_access_tagged_vectors(false),
59 _have_ad_objects(false),
60 _show_functors(false),
61 _show_chain_control_data(false),
62 _typed_vector_tags(2)
63{
64 unsigned int n_threads = libMesh::n_threads();
65 _active_elemental_moose_variables.resize(n_threads);
67
72
73 _functors.resize(n_threads);
74 _pbblf_functors.resize(n_threads);
75 _functor_to_request_info.resize(n_threads);
76}
77
79
81SubProblem::addVectorTag(const TagName & tag_name,
82 const Moose::VectorTagType type /* = Moose::VECTOR_TAG_RESIDUAL */)
83{
85 mooseError("Vector tag type cannot be VECTOR_TAG_ANY");
86
87 const auto tag_name_upper = MooseUtils::toUpper(tag_name);
88
89 // First, see if the tag exists already
90 for (const auto & vector_tag : _vector_tags)
91 {
92 mooseAssert(_vector_tags[vector_tag._id] == vector_tag, "Vector tags index mismatch");
93 if (vector_tag._name == tag_name_upper)
94 {
95 if (vector_tag._type != type)
96 mooseError("While attempting to add vector tag with name '",
97 tag_name_upper,
98 "' and type ",
99 type,
100 ",\na tag with the same name but type ",
101 vector_tag._type,
102 " was found.\n\nA tag can only exist with one type.");
103
104 return vector_tag._id;
105 }
106 }
107
108 // Doesn't exist - create it
109 const TagID new_tag_id = _vector_tags.size();
110 const TagTypeID new_tag_type_id = _typed_vector_tags[type].size();
111 // Primary storage for all tags where the index in the vector == the tag ID
112 _vector_tags.emplace_back(new_tag_id, new_tag_type_id, tag_name_upper, type);
113 // Secondary storage for each type so that we can have quick access to all tags of a type
114 _typed_vector_tags[type].emplace_back(new_tag_id, new_tag_type_id, tag_name_upper, type);
115 // Name map storage for quick name access
116 _vector_tags_name_map.emplace(tag_name_upper, new_tag_id);
117
118 // Make sure that _vector_tags, _typed_vector_tags, and _vector_tags_name_map are sane
120
121 return new_tag_id;
122}
123
124bool
125SubProblem::vectorTagExists(const TagName & tag_name) const
126{
127 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
128
129 const auto tag_name_upper = MooseUtils::toUpper(tag_name);
130 for (const auto & vector_tag : _vector_tags)
131 if (vector_tag._name == tag_name_upper)
132 return true;
133
134 return false;
135}
136
137void
142
143bool
145{
146 return _not_zeroed_tagged_vectors.count(tag);
147}
148
149const VectorTag &
151{
152 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
153
154 if (!vectorTagExists(tag_id))
155 mooseError("Vector tag with ID ", tag_id, " does not exist");
156
157 return _vector_tags[tag_id];
158}
159
160std::vector<VectorTag>
161SubProblem::getVectorTags(const std::set<TagID> & tag_ids) const
162{
163 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
164
165 std::vector<VectorTag> tags;
166 tags.reserve(tag_ids.size());
167 for (const auto & tag_id : tag_ids)
168 tags.push_back(getVectorTag(tag_id));
169 return tags;
170}
171
172const std::vector<VectorTag> &
173SubProblem::getVectorTags(const Moose::VectorTagType type /* = Moose::VECTOR_TAG_ANY */) const
174{
175 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
176
178 return _vector_tags;
179 else
180 return _typed_vector_tags[type];
181}
182
183unsigned int
184SubProblem::numVectorTags(const Moose::VectorTagType type /* = Moose::VECTOR_TAG_ANY */) const
185{
186 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
187
188 return getVectorTags(type).size();
189}
190
191TagID
192SubProblem::getVectorTagID(const TagName & tag_name) const
193{
194 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
195
196 const auto tag_name_upper = MooseUtils::toUpper(tag_name);
197 const auto search = _vector_tags_name_map.find(tag_name_upper);
198 if (search != _vector_tags_name_map.end())
199 return search->second;
200
201 std::string message =
202 tag_name_upper == "TIME"
203 ? ".\n\nThis may occur if "
204 "you have a TimeKernel in your problem but did not specify a transient executioner."
205 : "";
206 mooseError("Vector tag '", tag_name_upper, "' does not exist", message);
207}
208
209TagName
211{
212 mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
213 if (!vectorTagExists(tag_id))
214 mooseError("Vector tag with ID ", tag_id, " does not exist");
215
216 return _vector_tags[tag_id]._name;
217}
218
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]._type;
227}
228
229bool
231{
232 for (TagID tag_id = 0; tag_id < _vector_tags.size(); ++tag_id)
233 {
234 const auto & vector_tag = _vector_tags[tag_id];
235
236 if (vector_tag._id != tag_id)
237 mooseError("Vector tag ", vector_tag._id, " id mismatch in _vector_tags");
238 if (vector_tag._type == Moose::VECTOR_TAG_ANY)
239 mooseError("Vector tag '", vector_tag._name, "' has type VECTOR_TAG_ANY");
240
241 const auto search = _vector_tags_name_map.find(vector_tag._name);
242 if (search == _vector_tags_name_map.end())
243 mooseError("Vector tag ", vector_tag._id, " is not in _vector_tags_name_map");
244 else if (search->second != tag_id)
245 mooseError("Vector tag ", vector_tag._id, " has incorrect id in _vector_tags_name_map");
246
247 unsigned int found_in_type = 0;
248 for (TagTypeID tag_type_id = 0; tag_type_id < _typed_vector_tags[vector_tag._type].size();
249 ++tag_type_id)
250 {
251 const auto & vector_tag_type = _typed_vector_tags[vector_tag._type][tag_type_id];
252 if (vector_tag_type == vector_tag)
253 {
254 ++found_in_type;
255 if (vector_tag_type._type_id != tag_type_id)
256 mooseError("Type ID for Vector tag ", tag_id, " is incorrect");
257 }
258 }
259
260 if (found_in_type == 0)
261 mooseError("Vector tag ", tag_id, " not found in _typed_vector_tags");
262 if (found_in_type > 1)
263 mooseError("Vector tag ", tag_id, " found multiple times in _typed_vector_tags");
264 }
265
266 unsigned int num_typed_vector_tags = 0;
267 for (const auto & typed_vector_tags : _typed_vector_tags)
268 num_typed_vector_tags += typed_vector_tags.size();
269 if (num_typed_vector_tags != _vector_tags.size())
270 mooseError("Size mismatch between _vector_tags and _typed_vector_tags");
271 if (_vector_tags_name_map.size() != _vector_tags.size())
272 mooseError("Size mismatch between _vector_tags and _vector_tags_name_map");
273
274 return true;
275}
276
277void
279 const std::vector<VectorTag> & input_vector_tags,
280 std::set<TagID> & selected_tags)
281{
282 selected_tags.clear();
283 for (const auto & vector_tag : input_vector_tags)
284 if (system.hasVector(vector_tag._id))
285 selected_tags.insert(vector_tag._id);
286}
287
288void
290 const std::map<TagName, TagID> & input_matrix_tags,
291 std::set<TagID> & selected_tags)
292{
293 selected_tags.clear();
294 for (const auto & matrix_tag_pair : input_matrix_tags)
295 if (system.hasMatrix(matrix_tag_pair.second))
296 selected_tags.insert(matrix_tag_pair.second);
297}
298
299TagID
301{
302 auto tag_name_upper = MooseUtils::toUpper(tag_name);
303 auto existing_tag = _matrix_tag_name_to_tag_id.find(tag_name_upper);
304 if (existing_tag == _matrix_tag_name_to_tag_id.end())
305 {
306 auto tag_id = _matrix_tag_name_to_tag_id.size();
307
308 _matrix_tag_name_to_tag_id[tag_name_upper] = tag_id;
309
310 _matrix_tag_id_to_tag_name[tag_id] = tag_name_upper;
311 }
312
313 return _matrix_tag_name_to_tag_id.at(tag_name_upper);
314}
315
316bool
317SubProblem::matrixTagExists(const TagName & tag_name) const
318{
319 auto tag_name_upper = MooseUtils::toUpper(tag_name);
320
321 return _matrix_tag_name_to_tag_id.find(tag_name_upper) != _matrix_tag_name_to_tag_id.end();
322}
323
324bool
326{
327 return _matrix_tag_id_to_tag_name.find(tag_id) != _matrix_tag_id_to_tag_name.end();
328}
329
330TagID
331SubProblem::getMatrixTagID(const TagName & tag_name) const
332{
333 auto tag_name_upper = MooseUtils::toUpper(tag_name);
334
335 if (!matrixTagExists(tag_name))
336 mooseError("Matrix tag: ",
337 tag_name,
338 " does not exist. ",
339 "If this is a TimeKernel then this may have happened because you didn't "
340 "specify a Transient Executioner.");
341
342 return _matrix_tag_name_to_tag_id.at(tag_name_upper);
343}
344
345TagName
350
351void
356
357void
359{
361 for (const auto sys_num : make_range(numSolverSystems()))
364}
365
366void
371
372void
377
378const std::set<TagID> &
383
384const std::set<TagID> &
389
390void
392 const THREAD_ID tid)
393{
395}
396
397void
399 const THREAD_ID tid)
400{
402 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
405}
406
407void
412
413void
418
419const std::set<TagID> &
424
425const std::set<TagID> &
430
431void
432SubProblem::setActiveElementalMooseVariables(const std::set<MooseVariableFEBase *> & moose_vars,
433 const THREAD_ID tid)
434{
435 if (!moose_vars.empty())
436 {
438 _active_elemental_moose_variables[tid] = moose_vars;
439 }
440}
441
442const std::set<MooseVariableFEBase *> &
447
448bool
453
454void
460
461std::set<SubdomainID>
462SubProblem::getMaterialPropertyBlocks(const std::string & prop_name)
463{
464 std::set<SubdomainID> blocks;
465
466 for (const auto & it : _map_block_material_props)
467 {
468 const std::set<std::string> & prop_names = it.second;
469 std::set<std::string>::iterator name_it = prop_names.find(prop_name);
470 if (name_it != prop_names.end())
471 blocks.insert(it.first);
472 }
473
474 return blocks;
475}
476
477std::vector<SubdomainName>
478SubProblem::getMaterialPropertyBlockNames(const std::string & prop_name)
479{
480 std::set<SubdomainID> blocks = getMaterialPropertyBlocks(prop_name);
481 std::vector<SubdomainName> block_names;
482 block_names.reserve(blocks.size());
483 for (const auto & block_id : blocks)
484 {
485 SubdomainName name;
486 name = mesh().getMesh().subdomain_name(block_id);
487 if (name.empty())
488 {
489 std::ostringstream oss;
490 oss << block_id;
491 name = oss.str();
492 }
493 block_names.push_back(name);
494 }
495
496 return block_names;
497}
498
499bool
500SubProblem::hasBlockMaterialProperty(SubdomainID bid, const std::string & prop_name)
501{
502 auto it = _map_block_material_props.find(bid);
503 if (it == _map_block_material_props.end())
504 return false;
505
506 if (it->second.count(prop_name) > 0)
507 return true;
508 else
509 return false;
510}
511
512// TODO: remove code duplication by templating
513std::set<BoundaryID>
514SubProblem::getMaterialPropertyBoundaryIDs(const std::string & prop_name)
515{
516 std::set<BoundaryID> boundaries;
517
518 for (const auto & it : _map_boundary_material_props)
519 {
520 const std::set<std::string> & prop_names = it.second;
521 std::set<std::string>::iterator name_it = prop_names.find(prop_name);
522 if (name_it != prop_names.end())
523 boundaries.insert(it.first);
524 }
525
526 return boundaries;
527}
528
529std::vector<BoundaryName>
531{
532 std::set<BoundaryID> boundaries = getMaterialPropertyBoundaryIDs(prop_name);
533 std::vector<BoundaryName> boundary_names;
534 boundary_names.reserve(boundaries.size());
535 const BoundaryInfo & boundary_info = mesh().getMesh().get_boundary_info();
536
537 for (const auto & bnd_id : boundaries)
538 {
539 BoundaryName name;
540 if (bnd_id == Moose::ANY_BOUNDARY_ID)
541 name = "ANY_BOUNDARY_ID";
542 else
543 {
544 name = boundary_info.get_sideset_name(bnd_id);
545 if (name.empty())
546 {
547 std::ostringstream oss;
548 oss << bnd_id;
549 name = oss.str();
550 }
551 }
552 boundary_names.push_back(name);
553 }
554
555 return boundary_names;
556}
557
558bool
559SubProblem::hasBoundaryMaterialProperty(BoundaryID bid, const std::string & prop_name)
560{
561 auto it = _map_boundary_material_props.find(bid);
562 if (it == _map_boundary_material_props.end())
563 return false;
564
565 if (it->second.count(prop_name) > 0)
566 return true;
567 else
568 return false;
569}
570
571void
572SubProblem::storeSubdomainMatPropName(SubdomainID block_id, const std::string & name)
573{
574 _map_block_material_props[block_id].insert(name);
575}
576
577void
578SubProblem::storeBoundaryMatPropName(BoundaryID boundary_id, const std::string & name)
579{
580 _map_boundary_material_props[boundary_id].insert(name);
581}
582
583void
584SubProblem::storeSubdomainZeroMatProp(SubdomainID block_id, const MaterialPropertyName & name)
585{
586 _zero_block_material_props[block_id].insert(name);
587}
588
589void
590SubProblem::storeBoundaryZeroMatProp(BoundaryID boundary_id, const MaterialPropertyName & name)
591{
592 _zero_boundary_material_props[boundary_id].insert(name);
593}
594
595void
597 SubdomainID block_id,
598 const std::string & name)
599{
600 _map_block_material_props_check[block_id].insert(std::make_pair(requestor, name));
601}
602
603void
605 BoundaryID boundary_id,
606 const std::string & name)
607{
608 _map_boundary_material_props_check[boundary_id].insert(std::make_pair(requestor, name));
609}
610
611void
613{
614 // Variable for storing all available blocks/boundaries from the mesh
615 std::set<SubdomainID> all_ids(mesh().meshSubdomains());
616
617 std::stringstream errors;
618
619 // Loop through the properties to check
620 for (const auto & check_it : _map_block_material_props_check)
621 {
622 // The current id for the property being checked (BoundaryID || BlockID)
623 SubdomainID check_id = check_it.first;
624
625 std::set<SubdomainID> check_ids = {check_id};
626
627 // Loop through all the block/boundary ids
628 for (const auto & id : check_ids)
629 {
630 // Loop through all the stored properties
631 for (const auto & prop_it : check_it.second)
632 {
633 // Produce an error if the material property is not defined on the current block/boundary
634 // and any block/boundary
635 // and not is not a zero material property.
636 if (_map_block_material_props[id].count(prop_it.second) == 0 &&
637 _zero_block_material_props[id].count(prop_it.second) == 0)
638 {
639 std::string check_name = restrictionSubdomainCheckName(id);
640 if (check_name.empty())
641 check_name = std::to_string(id);
642 errors << "Material property '" << prop_it.second << "', requested by '" << prop_it.first
643 << "' is not defined on block " << check_name << "\n";
644 }
645 }
646 }
647 }
648
649 if (!errors.str().empty())
650 mooseError(errors.str());
651}
652
653void
655{
656 // Variable for storing the value for ANY_BOUNDARY_ID
658
659 // Variable for storing all available blocks/boundaries from the mesh
660 std::set<BoundaryID> all_ids(mesh().getBoundaryIDs());
661
662 std::stringstream errors;
663
664 // Loop through the properties to check
665 for (const auto & check_it : _map_boundary_material_props_check)
666 {
667 // The current id for the property being checked (BoundaryID || BlockID)
668 BoundaryID check_id = check_it.first;
669
670 // In the case when the material being checked has an ID is set to ANY, then loop through all
671 // the possible ids and verify that the material property is defined.
672 std::set<BoundaryID> check_ids{check_id};
673 if (check_id == any_id)
674 check_ids = all_ids;
675
676 // Loop through all the block/boundary ids
677 for (const auto & id : check_ids)
678 {
679 // Loop through all the stored properties
680 for (const auto & prop_it : check_it.second)
681 {
682 // Produce an error if the material property is not defined on the current block/boundary
683 // and any block/boundary
684 // and not is not a zero material property.
685 if (_map_boundary_material_props[id].count(prop_it.second) == 0 &&
686 _map_boundary_material_props[any_id].count(prop_it.second) == 0 &&
687 _zero_boundary_material_props[id].count(prop_it.second) == 0 &&
688 _zero_boundary_material_props[any_id].count(prop_it.second) == 0)
689 {
690 std::string check_name = restrictionBoundaryCheckName(id);
691 if (check_name.empty())
692 check_name = std::to_string(id);
693 errors << "Material property '" << prop_it.second << "', requested by '" << prop_it.first
694 << "' is not defined on boundary " << check_name << "\n";
695 }
696 }
697 }
698 }
699
700 if (!errors.str().empty())
701 mooseError(errors.str());
702}
703
704bool
705SubProblem::nlConverged(const unsigned int nl_sys_num)
706{
707 mooseAssert(nl_sys_num < numNonlinearSystems(),
708 "The nonlinear system number is higher than the number of systems we have!");
709 return solverSystemConverged(nl_sys_num);
710}
711
712void
713SubProblem::markMatPropRequested(const std::string & prop_name)
714{
715 _material_property_requested.insert(prop_name);
716}
717
718bool
719SubProblem::isMatPropRequested(const std::string & prop_name) const
720{
721 return _material_property_requested.find(prop_name) != _material_property_requested.end();
722}
723
724void
725SubProblem::addConsumedPropertyName(const MooseObjectName & obj_name, const std::string & prop_name)
726{
727 _consumed_material_properties[obj_name].insert(prop_name);
728}
729
730const std::map<MooseObjectName, std::set<std::string>> &
735
741
742Real
744{
745 return 0;
746}
747
748unsigned int
750{
751 return 0;
752}
753
754unsigned int
756{
757 return 0;
758}
759
760std::string
762{
763 // TODO: Put a better a interface in MOOSE
764 std::map<subdomain_id_type, std::string> & name_map = mesh().getMesh().set_subdomain_name_map();
765 std::map<subdomain_id_type, std::string>::const_iterator pos = name_map.find(check_id);
766 if (pos != name_map.end())
767 return pos->second;
768 return "";
769}
770
771std::string
773{
774 return mesh().getMesh().get_boundary_info().sideset_name(check_id);
775}
776
777void
779{
780 for (const auto sys_num : make_range(numSolverSystems()))
781 assembly(tid, sys_num).setCurrentBoundaryID(bid);
782}
783
784unsigned int
789
790bool
791SubProblem::hasLinearVariable(const std::string & var_name) const
792{
793 for (const auto i : make_range(numLinearSystems()))
794 if (systemBaseLinear(i).hasVariable(var_name))
795 return true;
796 return false;
797}
798
799bool
800SubProblem::hasAuxiliaryVariable(const std::string & var_name) const
801{
802 return systemBaseAuxiliary().hasVariable(var_name);
803}
804
805template <typename T>
808 const std::string & var_name,
809 Moose::VarKindType expected_var_type,
810 Moose::VarFieldType expected_var_field_type,
811 const std::vector<T> & systems,
812 const SystemBase & aux) const
813{
814 // Eventual return value
815 MooseVariableFEBase * var = nullptr;
816
817 const auto [var_in_sys, sys_num] = determineSolverSystem(var_name);
818
819 // First check that the variable is found on the expected system.
820 if (expected_var_type == Moose::VarKindType::VAR_ANY)
821 {
822 if (var_in_sys)
823 var = &(systems[sys_num]->getVariable(tid, var_name));
824 else if (aux.hasVariable(var_name))
825 var = &(aux.getVariable(tid, var_name));
826 else
827 mooseError("Unknown variable " + var_name);
828 }
829 else if (expected_var_type == Moose::VarKindType::VAR_SOLVER && var_in_sys &&
830 systems[sys_num]->hasVariable(var_name))
831 var = &(systems[sys_num]->getVariable(tid, var_name));
832 else if (expected_var_type == Moose::VarKindType::VAR_AUXILIARY && aux.hasVariable(var_name))
833 var = &(aux.getVariable(tid, var_name));
834 else
835 {
836 std::string expected_var_type_string =
837 (expected_var_type == Moose::VarKindType::VAR_SOLVER ? "nonlinear" : "auxiliary");
838 mooseError("No ",
839 expected_var_type_string,
840 " variable named ",
841 var_name,
842 " found. "
843 "Did you specify an auxiliary variable when you meant to specify a nonlinear "
844 "variable (or vice-versa)?");
845 }
846
847 // Now make sure the var found has the expected field type.
848 if ((expected_var_field_type == Moose::VarFieldType::VAR_FIELD_ANY) ||
849 (expected_var_field_type == var->fieldType()))
850 return *var;
851 else
852 {
853 std::string expected_var_field_type_string =
854 MooseUtils::toLower(Moose::stringify(expected_var_field_type));
855 std::string var_field_type_string = MooseUtils::toLower(Moose::stringify(var->fieldType()));
856
857 mooseError("No ",
858 expected_var_field_type_string,
859 " variable named ",
860 var_name,
861 " found. "
862 "Did you specify a ",
863 var_field_type_string,
864 " variable when you meant to specify a ",
865 expected_var_field_type_string,
866 " variable?");
867 }
868}
869
870void
872 unsigned int side,
873 Real tolerance,
874 const std::vector<Point> * const pts,
875 const std::vector<Real> * const weights,
876 const THREAD_ID tid)
877{
878 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
879 {
880 // - Set our _current_elem for proper dof index getting in the moose variables
881 // - Reinitialize all of our FE objects so we have current phi, dphi, etc. data
882 // Note that our number of shape functions will reflect the number of shapes associated with the
883 // interior element while the number of quadrature points will be determined by the passed pts
884 // parameter (which presumably will have a number of pts reflective of a facial quadrature rule)
885 assembly(tid, nl_sys_num).reinitElemFaceRef(elem, side, tolerance, pts, weights);
886
887 auto & nl = systemBaseNonlinear(nl_sys_num);
888
889 // Actually get the dof indices in the moose variables
890 nl.prepare(tid);
891
892 // Let's finally compute our variable values!
893 nl.reinitElemFace(elem, side, tid);
894 }
895
896 // do same for aux as for nl
898 systemBaseAuxiliary().reinitElemFace(elem, side, tid);
899
900 // With the dof indices set in the moose variables, now let's properly size
901 // our local residuals/Jacobians
902 auto & current_assembly = assembly(tid, currentNlSysNum());
904 current_assembly.prepareJacobianBlock();
906 current_assembly.prepareResidual();
907}
908
909void
910SubProblem::reinitNeighborFaceRef(const Elem * neighbor_elem,
911 unsigned int neighbor_side,
912 Real tolerance,
913 const std::vector<Point> * const pts,
914 const std::vector<Real> * const weights,
915 const THREAD_ID tid)
916{
917 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
918 {
919 // - Set our _current_neighbor_elem for proper dof index getting in the moose variables
920 // - Reinitialize all of our FE objects so we have current phi, dphi, etc. data
921 // Note that our number of shape functions will reflect the number of shapes associated with the
922 // interior element while the number of quadrature points will be determined by the passed pts
923 // parameter (which presumably will have a number of pts reflective of a facial quadrature rule)
924 assembly(tid, nl_sys_num)
925 .reinitNeighborFaceRef(neighbor_elem, neighbor_side, tolerance, pts, weights);
926
927 auto & nl = systemBaseNonlinear(nl_sys_num);
928
929 // Actually get the dof indices in the moose variables
930 nl.prepareNeighbor(tid);
931
932 // Let's finally compute our variable values!
933 nl.reinitNeighborFace(neighbor_elem, neighbor_side, tid);
934 }
935
936 // do same for aux as for nl
938 systemBaseAuxiliary().reinitNeighborFace(neighbor_elem, neighbor_side, tid);
939
940 // With the dof indices set in the moose variables, now let's properly size
941 // our local residuals/Jacobians
943}
944
945void
947 const THREAD_ID tid,
948 const std::vector<Point> * const pts,
949 const std::vector<Real> * const weights)
950{
951 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
952 {
953 // - Set our _current_lower_d_elem for proper dof index getting in the moose variables
954 // - Reinitialize all of our lower-d FE objects so we have current phi, dphi, etc. data
955 assembly(tid, nl_sys_num).reinitLowerDElem(elem, pts, weights);
956
957 auto & nl = systemBaseNonlinear(nl_sys_num);
958
959 // Actually get the dof indices in the moose variables
960 nl.prepareLowerD(tid);
961
962 // With the dof indices set in the moose variables, now let's properly size
963 // our local residuals/Jacobians
964 assembly(tid, nl_sys_num).prepareLowerD();
965
966 // Let's finally compute our variable values!
967 nl.reinitLowerD(tid);
968 }
969
970 // do same for aux as for nl
973}
974
975void
976SubProblem::reinitNodes(const std::vector<dof_id_type> & nodes, const THREAD_ID tid)
977{
978 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
979 systemBaseNonlinear(nl_sys_num).reinitNodes(nodes, tid);
980 systemBaseAuxiliary().reinitNodes(nodes, tid);
981}
982
983void
984SubProblem::reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, const THREAD_ID tid)
985{
986 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
987 systemBaseNonlinear(nl_sys_num).reinitNodesNeighbor(nodes, tid);
989}
990
991void
993{
994 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
995 assembly(tid, nl_sys_num).reinitNeighborLowerDElem(elem);
996}
997
998void
999SubProblem::reinitMortarElem(const Elem * elem, const THREAD_ID tid)
1000{
1001 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1002 assembly(tid, nl_sys_num).reinitMortarElem(elem);
1003}
1004
1005void
1007{
1008 EquationSystems & eq = es();
1009 const auto n_sys = eq.n_systems();
1010
1011 auto pr = _root_alg_gf_to_sys_clones.emplace(
1012 &algebraic_gf, std::vector<std::shared_ptr<libMesh::GhostingFunctor>>(n_sys - 1));
1013 mooseAssert(pr.second, "We are adding a duplicate algebraic ghosting functor");
1014 auto & clones_vec = pr.first->second;
1015
1016 for (MooseIndex(n_sys) i = 1; i < n_sys; ++i)
1017 {
1018 DofMap & dof_map = eq.get_system(i).get_dof_map();
1019 std::shared_ptr<libMesh::GhostingFunctor> clone_alg_gf = algebraic_gf.clone();
1020 std::dynamic_pointer_cast<RelationshipManager>(clone_alg_gf)
1021 ->init(mesh(), *algebraic_gf.get_mesh(), &dof_map);
1022 dof_map.add_algebraic_ghosting_functor(clone_alg_gf, to_mesh);
1023 clones_vec[i - 1] = clone_alg_gf;
1024 }
1025}
1026
1027void
1029{
1030 EquationSystems & eq = es();
1031 const auto n_sys = eq.n_systems();
1032 if (!n_sys)
1033 return;
1034
1035 eq.get_system(0).get_dof_map().add_algebraic_ghosting_functor(algebraic_gf, to_mesh);
1036 cloneAlgebraicGhostingFunctor(algebraic_gf, to_mesh);
1037}
1038
1039void
1041{
1042 const std::size_t num_nl_sys = numNonlinearSystems();
1043
1044 auto pr = _root_coupling_gf_to_sys_clones.emplace(
1045 &coupling_gf, std::vector<std::shared_ptr<libMesh::GhostingFunctor>>(num_nl_sys - 1));
1046 mooseAssert(pr.second, "We are adding a duplicate coupling functor");
1047 auto & clones_vec = pr.first->second;
1048
1049 for (const auto i : make_range(std::size_t(1), num_nl_sys))
1050 {
1051 DofMap & dof_map = systemBaseNonlinear(i).system().get_dof_map();
1052 std::shared_ptr<libMesh::GhostingFunctor> clone_coupling_gf = coupling_gf.clone();
1053 std::dynamic_pointer_cast<RelationshipManager>(clone_coupling_gf)
1054 ->init(mesh(), *coupling_gf.get_mesh(), &dof_map);
1055 dof_map.add_coupling_functor(clone_coupling_gf, to_mesh);
1056 clones_vec[i - 1] = clone_coupling_gf;
1057 }
1058}
1059
1060void
1062{
1063 const auto num_nl_sys = numNonlinearSystems();
1064 if (!num_nl_sys)
1065 return;
1066
1067 systemBaseNonlinear(0).system().get_dof_map().add_coupling_functor(coupling_gf, to_mesh);
1068 cloneCouplingGhostingFunctor(coupling_gf, to_mesh);
1069}
1070
1071void
1073{
1074 EquationSystems & eq = es();
1075 const auto n_sys = eq.n_systems();
1076 DofMap & nl_dof_map = eq.get_system(0).get_dof_map();
1077
1078 const bool found_in_root_sys =
1079 std::find(nl_dof_map.algebraic_ghosting_functors_begin(),
1080 nl_dof_map.algebraic_ghosting_functors_end(),
1081 &algebraic_gf) != nl_dof_map.algebraic_ghosting_functors_end();
1082
1083#ifndef NDEBUG
1084 const bool found_in_our_map =
1085 _root_alg_gf_to_sys_clones.find(&algebraic_gf) != _root_alg_gf_to_sys_clones.end();
1086 mooseAssert(found_in_root_sys == found_in_our_map,
1087 "If the ghosting functor exists in the root DofMap, then we need to have a key for "
1088 "it in our gf to clones map");
1089#endif
1090
1091 if (found_in_root_sys) // libMesh yells if we try to remove
1092 // something that's not there
1093 nl_dof_map.remove_algebraic_ghosting_functor(algebraic_gf);
1094
1095 auto it = _root_alg_gf_to_sys_clones.find(&algebraic_gf);
1096 if (it == _root_alg_gf_to_sys_clones.end())
1097 return;
1098
1099 auto & clones_vec = it->second;
1100 mooseAssert((n_sys - 1) == clones_vec.size(),
1101 "The size of the gf clones vector doesn't match the number of systems minus one");
1102 if (clones_vec.empty())
1103 {
1104 mooseAssert(n_sys == 1, "The clones vector should only be empty if there is only one system");
1105 return;
1106 }
1107
1108 for (const auto i : make_range(n_sys))
1109 eq.get_system(i + 1).get_dof_map().remove_algebraic_ghosting_functor(*clones_vec[i]);
1110
1111 _root_alg_gf_to_sys_clones.erase(it->first);
1112}
1113
1114void
1116{
1117 EquationSystems & eq = es();
1118 const auto num_nl_sys = numNonlinearSystems();
1119 if (!num_nl_sys)
1120 return;
1121
1122 DofMap & nl_dof_map = eq.get_system(0).get_dof_map();
1123 const bool found_in_root_sys = std::find(nl_dof_map.coupling_functors_begin(),
1124 nl_dof_map.coupling_functors_end(),
1125 &coupling_gf) != nl_dof_map.coupling_functors_end();
1126
1127#ifndef NDEBUG
1128 const bool found_in_our_map =
1130 mooseAssert(found_in_root_sys == found_in_our_map,
1131 "If the ghosting functor exists in the root DofMap, then we need to have a key for "
1132 "it in our gf to clones map");
1133#endif
1134
1135 if (found_in_root_sys) // libMesh yells if we try to remove
1136 // something that's not there
1137 nl_dof_map.remove_coupling_functor(coupling_gf);
1138
1139 auto it = _root_coupling_gf_to_sys_clones.find(&coupling_gf);
1140 if (it == _root_coupling_gf_to_sys_clones.end())
1141 return;
1142
1143 auto & clones_vec = it->second;
1144 mooseAssert((num_nl_sys - 1) == clones_vec.size(),
1145 "The size of the gf clones vector doesn't match the number of systems minus one");
1146 if (clones_vec.empty())
1147 {
1148 mooseAssert(num_nl_sys == 1,
1149 "The clones vector should only be empty if there is only one nonlinear system");
1150 return;
1151 }
1152
1153 for (const auto i : make_range(num_nl_sys))
1154 eq.get_system(i + 1).get_dof_map().remove_coupling_functor(*clones_vec[i]);
1155
1156 _root_coupling_gf_to_sys_clones.erase(it->first);
1157}
1158
1159void
1160SubProblem::automaticScaling(bool automatic_scaling)
1161{
1162 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1163 systemBaseNonlinear(nl_sys_num).automaticScaling(automatic_scaling);
1164}
1165
1166bool
1168{
1169 // Currently going to assume that we are applying or not applying automatic scaling consistently
1170 // across nonlinear systems
1172}
1173
1174void
1175SubProblem::hasScalingVector(const unsigned int nl_sys_num)
1176{
1177 for (const THREAD_ID tid : make_range(libMesh::n_threads()))
1178 assembly(tid, nl_sys_num).hasScalingVector();
1179}
1180
1181void
1183{
1184 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1187}
1188
1189void
1191{
1192 for (auto & map : _pbblf_functors)
1193 for (auto & pr : map)
1194 pr.second->timestepSetup();
1197}
1198
1199void
1201{
1202 for (auto & map : _pbblf_functors)
1203 for (auto & pr : map)
1204 pr.second->customSetup(exec_type);
1205}
1206
1207void
1209{
1210 for (auto & map : _pbblf_functors)
1211 for (auto & pr : map)
1212 pr.second->residualSetup();
1213}
1214
1215void
1217{
1218 for (auto & map : _pbblf_functors)
1219 for (auto & pr : map)
1220 pr.second->jacobianSetup();
1221}
1222
1223void
1225{
1226 if (_show_functors)
1227 {
1228 showFunctors();
1230 }
1233
1234 for (const auto & functors : _functors)
1235 for (const auto & [functor_wrapper_name, functor_wrapper] : functors)
1236 {
1237 const auto & [true_functor_type, non_ad_functor, ad_functor] = functor_wrapper;
1238 mooseAssert(non_ad_functor->wrapsNull() == ad_functor->wrapsNull(), "These must agree");
1239 const auto functor_name = removeSubstring(functor_wrapper_name, "wraps_");
1240 if (non_ad_functor->wrapsNull())
1241 mooseError(
1242 "No functor ever provided with name '",
1243 functor_name,
1244 "', which was requested by '",
1245 MooseUtils::join(libmesh_map_find(_functor_to_requestors, functor_wrapper_name), ","),
1246 "'.");
1247 if (true_functor_type == TrueFunctorIs::NONAD ? non_ad_functor->ownsWrappedFunctor()
1248 : ad_functor->ownsWrappedFunctor())
1249 mooseError("Functor envelopes should not own the functors they wrap, but '",
1250 functor_name,
1251 "' is owned by the wrapper. Please open a MOOSE issue for help resolving this.");
1252 }
1253}
1254
1255void
1257{
1258 _console << "[DBG] Wrapped functors found in Subproblem" << std::endl;
1259 std::string functor_names = "[DBG] ";
1260 for (const auto & functor_pair : _functors[0])
1261 functor_names += std::regex_replace(functor_pair.first, std::regex("wraps_"), "") + " ";
1262 if (functor_names.size())
1263 functor_names.pop_back();
1264 _console << functor_names << std::endl;
1265}
1266
1267void
1269{
1270 for (const auto & [functor, requestors] : _functor_to_requestors)
1271 {
1272 _console << "[DBG] Requestors for wrapped functor "
1273 << std::regex_replace(functor, std::regex("wraps_"), "") << std::endl;
1274 _console << "[DBG] " << MooseUtils::join(requestors, " ") << std::endl;
1275 }
1276}
1277
1278bool
1279SubProblem::hasFunctor(const std::string & name, const THREAD_ID tid) const
1280{
1281 mooseAssert(tid < _functors.size(), "Too large a thread ID");
1282 auto & functors = _functors[tid];
1283 return (functors.find("wraps_" + name) != functors.end());
1284}
1285
1288{
1289 return mesh().getCoordSystem(sid);
1290}
1291
1292void
1294{
1295 for (const auto nl : make_range(numNonlinearSystems()))
1296 assembly(tid, nl).reinitFVFace(fi);
1297}
1298
1299void
1305
1306void
1312
1313void
1319
1320void
1327
1328void
1333
1334void
1339
1340void
1342{
1343 for (const auto tid : make_range(libMesh::n_threads()))
1344 for (const auto s : make_range(numNonlinearSystems()))
1345 assembly(tid, s).preparePRefinement();
1346}
1347
1348bool
1350{
1351 return mesh().doingPRefinement();
1352}
1353
1354void
1355SubProblem::setCurrentLowerDElem(const Elem * const lower_d_elem, const THREAD_ID tid)
1356{
1357 for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1358 assembly(tid, nl_sys_num).setCurrentLowerDElem(lower_d_elem);
1359}
1360
1361template MooseVariableFEBase &
1363 const std::string & var_name,
1364 Moose::VarKindType expected_var_type,
1365 Moose::VarFieldType expected_var_field_type,
1366 const std::vector<std::shared_ptr<SolverSystem>> & nls,
1367 const SystemBase & aux) const;
1368template MooseVariableFEBase &
1370 const std::string & var_name,
1371 Moose::VarKindType expected_var_type,
1372 Moose::VarFieldType expected_var_field_type,
1373 const std::vector<std::unique_ptr<DisplacedSystem>> & nls,
1374 const SystemBase & aux) const;
1375
1376void
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:4110
void prepareLowerD()
Prepare the Jacobians and residuals for a lower dimensional element.
Definition Assembly.C:2885
void reinitFVFace(const FaceInfo &fi)
Definition Assembly.C:1894
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:3477
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:2231
void prepareNeighbor()
Definition Assembly.C:2847
void cacheJacobianNeighbor(GlobalDataKey)
Takes the values that are currently in the neighbor Dense Matrices and appends them to the cached val...
Definition Assembly.C:4132
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:2327
void cacheJacobian(GlobalDataKey)
Takes the values that are currently in _sub_Kee and appends them to the cached values.
Definition Assembly.C:4080
void setCurrentBoundaryID(BoundaryID i)
set the current boundary ID
Definition Assembly.h:425
void preparePRefinement()
Prepare helper FEs for p-refinement.
Definition Assembly.C:4876
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition Assembly.C:3835
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:3427
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:2056
void setCurrentLowerDElem(const Elem *const lower_d_elem)
Set the current lower dimensional element.
Definition Assembly.h:3214
void reinitNeighborLowerDElem(const Elem *elem)
reinitialize a neighboring lower dimensional element
Definition Assembly.C:2420
void reinitMortarElem(const Elem *elem)
reinitialize a mortar segment mesh element in order to get a proper JxW
Definition Assembly.C:2441
void hasScalingVector()
signals this object that a vector containing variable scaling factors should be used when doing resid...
Definition Assembly.C:4593
void addCachedResiduals(GlobalDataKey, const std::vector< VectorTag > &tags)
Pushes all cached residuals to the global residual vectors associated with each tag.
Definition Assembly.C:3505
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.
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.
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
Definition MooseMesh.C:4378
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3512
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
Get the coordinate system type, e.g.
Definition MooseMesh.C:4259
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:731
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:367
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:725
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:572
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:654
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:604
virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const
Definition SubProblem.C:755
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition SubProblem.C:210
std::string restrictionBoundaryCheckName(BoundaryID check_id)
Definition SubProblem.C:772
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:785
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:713
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:559
virtual void checkBlockMatProps()
Checks block material properties integrity.
Definition SubProblem.C:612
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition SubProblem.C:192
std::vector< std::set< TagID > > _active_fe_var_coupleable_vector_tags
virtual void clearActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid)
Definition SubProblem.C:373
virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const
Definition SubProblem.C:220
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:791
void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)
Definition SubProblem.C:984
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:871
virtual const VectorTag & getVectorTag(const TagID tag_id) const
Get a VectorTag from a TagID.
Definition SubProblem.C:150
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition SubProblem.C:443
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:778
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:161
bool doingPRefinement() const
std::map< MooseObjectName, std::set< std::string > > _consumed_material_properties
virtual DiracKernelInfo & diracKernelInfo()
Definition SubProblem.C:737
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const
Definition SubProblem.C:749
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:331
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:992
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:578
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:391
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:462
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:910
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:184
void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid)
Definition SubProblem.C:976
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:346
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:138
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
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:449
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:743
void reinitMortarElem(const Elem *elem, const THREAD_ID tid=0)
Reinit a mortar element to obtain a valid JxW.
Definition SubProblem.C:999
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:584
virtual void setActiveFEVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition SubProblem.C:352
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:230
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition SubProblem.C:81
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:500
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:278
virtual void setActiveScalarVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition SubProblem.C:398
const std::set< TagID > & getActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition SubProblem.C:420
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:408
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:379
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition SubProblem.C:358
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid)
Clear the active elemental MooseVariableFieldBase.
Definition SubProblem.C:455
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:289
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:761
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:144
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:414
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:317
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:514
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)
virtual void addCachedJacobian(const THREAD_ID tid)
virtual TagID addMatrixTag(TagName tag_name)
Create a Tag.
Definition SubProblem.C:300
SubProblem(const InputParameters &parameters)
Definition SubProblem.C:49
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:800
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:530
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:432
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:705
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:596
const std::set< TagID > & getActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition SubProblem.C:385
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:478
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:719
const std::set< TagID > & getActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition SubProblem.C:426
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:590
void reinitGeomSearch()
reinitialize this object's geometric search data, e.g.
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:946
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:921
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:848
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:65
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
unsigned int n_threads()