https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MooseObjectWarehouseBase.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12// MOOSE includes
15#include "BlockRestrictable.h"
16#include "TransientInterface.h"
17#include "Coupleable.h"
20#include "SubProblem.h"
21#include "MooseApp.h"
22
23// Forward declarations
25
29template <typename T>
31{
32public:
37
42
48 virtual void addObject(std::shared_ptr<T> object, THREAD_ID tid = 0, bool recurse = true);
49
53 unsigned int size(THREAD_ID tid = 0) const;
54
56
60 const std::vector<std::shared_ptr<T>> & getObjects(THREAD_ID tid = 0) const;
61 const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
62 getBlockObjects(THREAD_ID tid = 0) const;
63 const std::vector<std::shared_ptr<T>> & getBlockObjects(SubdomainID id, THREAD_ID tid = 0) const;
64 const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
66 const std::vector<std::shared_ptr<T>> & getBoundaryObjects(BoundaryID id,
67 THREAD_ID tid = 0) const;
69
71
76 const std::vector<std::shared_ptr<T>> & getActiveObjects(THREAD_ID tid = 0) const;
77 const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
79 const std::vector<std::shared_ptr<T>> & getActiveBlockObjects(SubdomainID id,
80 THREAD_ID tid = 0) const;
81 const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
83 const std::vector<std::shared_ptr<T>> & getActiveBoundaryObjects(BoundaryID id,
84 THREAD_ID tid = 0) const;
86
88
91 bool hasObjects(THREAD_ID tid = 0) const;
92 bool hasActiveObjects(THREAD_ID tid = 0) const;
93 bool hasObjectsForVariable(const VariableName & var_name, THREAD_ID tid) const;
94 bool hasActiveBlockObjects(THREAD_ID tid = 0) const;
98 bool hasBoundaryObjects(THREAD_ID tid = 0) const;
99 bool hasBoundaryObjects(BoundaryID id, THREAD_ID tid = 0) const;
101
108 bool hasObjectsForVariableAndBlocks(const VariableName & var_name,
109 const std::set<SubdomainID> & blocks,
110 std::set<SubdomainID> & blocks_covered,
111 THREAD_ID tid) const;
112
116 std::set<SubdomainID> getActiveBlocks(THREAD_ID tid = 0) const;
117
119
122 bool hasActiveObject(const std::string & name, THREAD_ID tid = 0) const;
123 std::shared_ptr<T> getObject(const std::string & name, THREAD_ID tid = 0) const;
124 std::shared_ptr<T> getActiveObject(const std::string & name, THREAD_ID tid = 0) const;
126
130 const std::vector<std::shared_ptr<T>> & getObjectsForVariable(const VariableName & var_name,
131 THREAD_ID tid) const;
132
136 virtual void updateActive(THREAD_ID tid = 0);
137
141 void sort(THREAD_ID tid = 0);
142
144
147 void updateVariableDependency(std::set<MooseVariableFieldBase *> & needed_moose_vars,
148 THREAD_ID tid = 0) const;
150 std::set<MooseVariableFieldBase *> & needed_moose_vars,
151 THREAD_ID tid = 0) const;
152 void updateBoundaryVariableDependency(std::set<MooseVariableFieldBase *> & needed_moose_vars,
153 THREAD_ID tid = 0) const;
155 std::set<MooseVariableFieldBase *> & needed_moose_vars,
156 THREAD_ID tid = 0) const;
158
160
164 void updateFEVariableCoupledVectorTagDependency(std::set<TagID> & needed_fe_var_vector_tags,
165 THREAD_ID tid = 0) const;
167 std::set<TagID> & needed_fe_var_vector_tags,
168 THREAD_ID tid = 0) const;
170 BoundaryID id, std::set<TagID> & needed_fe_var_vector_tags, THREAD_ID tid = 0) const;
172
174
178 void updateMatPropDependency(std::unordered_set<unsigned int> & needed_mat_props,
179 THREAD_ID tid = 0,
180 const bool producer_only = false) const;
182 std::unordered_set<unsigned int> & needed_mat_props,
183 THREAD_ID tid = 0,
184 const bool producer_only = false) const;
185 void updateBoundaryMatPropDependency(std::unordered_set<unsigned int> & needed_mat_props,
186 THREAD_ID tid = 0,
187 const bool producer_only = false) const;
189 std::unordered_set<unsigned int> & needed_mat_props,
190 THREAD_ID tid = 0,
191 const bool producer_only = false) const;
193
197 void subdomainsCovered(std::set<SubdomainID> & subdomains_covered,
198 std::set<std::string> & unique_variables,
199 THREAD_ID tid = 0) const;
200
205
212 const std::string & prefix = "[DBG]") const;
213
214protected:
217
219 std::vector<std::vector<std::shared_ptr<T>>> _all_objects;
220
222 std::vector<std::vector<std::shared_ptr<T>>> _active_objects;
223
224 // All block restricted objects (THREAD_ID on outer vector)
225 std::vector<std::map<SubdomainID, std::vector<std::shared_ptr<T>>>> _all_block_objects;
226
228 std::vector<std::map<SubdomainID, std::vector<std::shared_ptr<T>>>> _active_block_objects;
229
230 // All boundary restricted objects (THREAD_ID on outer vector)
231 std::vector<std::map<BoundaryID, std::vector<std::shared_ptr<T>>>> _all_boundary_objects;
232
234 std::vector<std::map<BoundaryID, std::vector<std::shared_ptr<T>>>> _active_boundary_objects;
235
237 std::vector<std::map<VariableName, std::vector<std::shared_ptr<T>>>> _all_variable_objects;
238
242 static void updateActiveHelper(std::vector<std::shared_ptr<T>> & active,
243 const std::vector<std::shared_ptr<T>> & all);
244
248 static void sortHelper(std::vector<std::shared_ptr<T>> & objects);
249
253 static void updateVariableDependencyHelper(std::set<MooseVariableFieldBase *> & needed_moose_vars,
254 const std::vector<std::shared_ptr<T>> & objects);
255
259 static void
260 updateFEVariableCoupledVectorTagDependencyHelper(std::set<TagID> & needed_fe_var_vector_tags,
261 const std::vector<std::shared_ptr<T>> & objects);
262
266 virtual void updateMatPropDependencyHelper(std::unordered_set<unsigned int> & needed_mat_props,
267 const std::vector<std::shared_ptr<T>> & objects,
268 const bool producer_only) const;
269
273 void checkThreadID(THREAD_ID tid) const;
274
279 const std::vector<std::map<BoundaryID, std::vector<std::shared_ptr<T>>>> & boundary_objects,
280 const THREAD_ID tid = 0) const;
281
282 friend class MaterialWarehouse;
283};
284
285template <typename T>
297
298template <typename T>
302
303template <typename T>
304unsigned int
306{
307 checkThreadID(tid);
308 return _all_objects[tid].size();
309}
310
311template <typename T>
312void
314 THREAD_ID tid /*= 0*/,
315 bool /* recurse = true */)
316{
317 checkThreadID(tid);
318
319 // Stores object in list of all objects
320 _all_objects[tid].push_back(object);
321
322 // If enabled, store object in a list of all active
323 bool enabled = object->enabled();
324 if (enabled)
325 _active_objects[tid].push_back(object);
326
327 // Perform casts to the Block/BoundaryRestrictable
328 std::shared_ptr<BoundaryRestrictable> bnd =
329 std::dynamic_pointer_cast<BoundaryRestrictable>(object);
330 std::shared_ptr<BlockRestrictable> blk = std::dynamic_pointer_cast<BlockRestrictable>(object);
331
332 // Boundary Restricted
333 if (bnd && bnd->boundaryRestricted())
334 {
335 const std::set<BoundaryID> & ids = bnd->boundaryIDs();
336 for (std::set<BoundaryID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
337 {
338 _all_boundary_objects[tid][*it].push_back(object);
339 if (enabled)
340 _active_boundary_objects[tid][*it].push_back(object);
341 }
342 }
343
344 // Block Restricted
345 else if (blk)
346 {
347 const std::set<SubdomainID> & ids =
348 blk->blockRestricted() ? blk->blockIDs() : blk->meshBlockIDs();
349 for (std::set<SubdomainID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
350 {
351 _all_block_objects[tid][*it].push_back(object);
352 if (enabled)
353 _active_block_objects[tid][*it].push_back(object);
354 }
355
356 // Check variables
357 std::shared_ptr<Coupleable> c_ptr = std::dynamic_pointer_cast<Coupleable>(object);
358 if (c_ptr)
359 for (MooseVariableFieldBase * var : c_ptr->getCoupledMooseVars())
360 blk->checkVariable(*var);
361
362 const InputParameters & parameters = object->parameters();
363
364 SubProblem & problem = *parameters.get<SubProblem *>("_subproblem");
365
366 THREAD_ID tid = parameters.get<THREAD_ID>("_tid");
367
368 if (parameters.isParamValid("variable"))
369 {
370 // Try the scalar version first
371 std::string variable_name = parameters.getMooseType("variable");
372 if (variable_name == "")
373 // When using vector variables, we are only going to use the first one in the list at the
374 // interface level...
375 variable_name = parameters.getVecMooseType("variable")[0];
376
377 blk->checkVariable(problem.getVariable(
379
380 _all_variable_objects[tid][variable_name].push_back(object);
381 }
382 }
383}
384
385template <typename T>
386inline const std::vector<std::shared_ptr<T>> &
388{
389 checkThreadID(tid);
390 return _all_objects[tid];
391}
392
393template <typename T>
394inline const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
400
401template <typename T>
402bool
404{
405 checkThreadID(tid);
406 return _all_boundary_objects[tid].find(id) != _all_boundary_objects[tid].end();
407}
408
409template <typename T>
410const std::vector<std::shared_ptr<T>> &
412{
413 checkThreadID(tid);
414 const auto iter = _all_boundary_objects[tid].find(id);
415 mooseAssert(iter != _all_boundary_objects[tid].end(),
416 "Unable to located active boundary objects for the given id: " << id << ".");
417 return iter->second;
418}
419
420template <typename T>
421inline const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
423{
424 checkThreadID(tid);
425 return _all_block_objects[tid];
426}
427
428template <typename T>
429const std::vector<std::shared_ptr<T>> &
431{
432 checkThreadID(tid);
433 const auto iter = _all_block_objects[tid].find(id);
434 mooseAssert(iter != _all_block_objects[tid].end(),
435 "Unable to located active block objects for the given id: " << id << ".");
436 return iter->second;
437}
438
439template <typename T>
440inline const std::vector<std::shared_ptr<T>> &
442{
443 checkThreadID(tid);
444 return _active_objects[tid];
445}
446
447template <typename T>
448inline const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
454
455template <typename T>
456const std::vector<std::shared_ptr<T>> &
458{
459 checkThreadID(tid);
460 const auto iter = _active_boundary_objects[tid].find(id);
461 mooseAssert(iter != _active_boundary_objects[tid].end(),
462 "Unable to located active boundary objects for the given id: " << id << ".");
463 return iter->second;
464}
465
466template <typename T>
467inline const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
473
474template <typename T>
475const std::vector<std::shared_ptr<T>> &
477{
478 checkThreadID(tid);
479 const auto iter = _active_block_objects[tid].find(id);
480 mooseAssert(iter != _active_block_objects[tid].end(),
481 "Unable to located active block objects for the given id: " << id << ".");
482 return iter->second;
483}
484
485template <typename T>
486bool
488{
489 checkThreadID(tid);
490 return !_all_objects[tid].empty();
491}
492
493template <typename T>
494bool
496{
497 checkThreadID(tid);
498 return !_active_objects[tid].empty();
499}
500
501template <typename T>
502bool
504 THREAD_ID tid) const
505{
506 checkThreadID(tid);
507 return _all_variable_objects[tid].count(var_name);
508}
509
510template <typename T>
511bool
513 const std::set<SubdomainID> & blocks,
514 std::set<SubdomainID> & blocks_covered,
515 THREAD_ID tid /* = 0*/) const
516{
517 checkThreadID(tid);
518 blocks_covered.clear();
519 if (!hasObjectsForVariable(var_name, tid))
520 return false;
521
522 // Check block restriction as a whole
523 for (const auto & object : libmesh_map_find(_all_variable_objects[tid], var_name))
524 {
525 std::shared_ptr<BlockRestrictable> blk = std::dynamic_pointer_cast<BlockRestrictable>(object);
526 if (blk && blk->hasBlocks(blocks))
527 {
528 blocks_covered = blocks;
529 return true;
530 }
531 }
532 // No object has all the blocks, but one might overlap, which could be troublesome.
533 // We'll keep track of which blocks are covered in case several overlap
534 for (const auto & object : libmesh_map_find(_all_variable_objects[tid], var_name))
535 {
536 std::shared_ptr<BlockRestrictable> blk = std::dynamic_pointer_cast<BlockRestrictable>(object);
537 if (blk)
538 for (const auto & block : blocks)
539 if (blk->hasBlocks(block))
540 blocks_covered.insert(block);
541 }
542 // No overlap at all
543 if (blocks_covered.empty())
544 return false;
545
546 return (blocks == blocks_covered);
547}
548
549template <typename T>
550bool
552{
553 checkThreadID(tid);
554 bool has_active_block_objects = false;
555 for (const auto & object_pair : _active_block_objects[tid])
556 has_active_block_objects |= !(object_pair.second.empty());
557 return has_active_block_objects;
558}
559
560template <typename T>
561bool
563{
564 checkThreadID(tid);
565 const auto iter = _active_block_objects[tid].find(id);
566 return iter != _active_block_objects[tid].end();
567}
568
569template <typename T>
570bool
572 const std::vector<std::map<BoundaryID, std::vector<std::shared_ptr<T>>>> & boundary_objects,
573 THREAD_ID tid /* = 0*/) const
574{
575 checkThreadID(tid);
576 bool has_boundary_objects = false;
577 for (const auto & object_pair : boundary_objects[tid])
578 has_boundary_objects |= !(object_pair.second.empty());
579 return has_boundary_objects;
580}
581
582template <typename T>
583bool
588
589template <typename T>
590bool
595
596template <typename T>
597bool
599{
600 checkThreadID(tid);
601 const auto iter = _active_boundary_objects[tid].find(id);
602 return iter != _active_boundary_objects[tid].end();
603}
604
605template <typename T>
606bool
607MooseObjectWarehouseBase<T>::hasActiveObject(const std::string & name, THREAD_ID tid /* = 0*/) const
608{
609 checkThreadID(tid);
610 for (const auto & object : _active_objects[tid])
611 if (object->name() == name)
612 return true;
613 return false;
614}
615
616template <typename T>
617std::shared_ptr<T>
618MooseObjectWarehouseBase<T>::getObject(const std::string & name, THREAD_ID tid /* = 0*/) const
619{
620 checkThreadID(tid);
621 for (const auto & object : _all_objects[tid])
622 if (object->name() == name)
623 return object;
624 mooseError("Unable to locate object: ", name, ".");
625}
626
627template <typename T>
628std::shared_ptr<T>
629MooseObjectWarehouseBase<T>::getActiveObject(const std::string & name, THREAD_ID tid /* = 0*/) const
630{
631 checkThreadID(tid);
632 for (const auto & object : _active_objects[tid])
633 if (object->name() == name)
634 return object;
635 mooseError("Unable to locate active object: ", name, ".");
636}
637
638template <typename T>
639const std::vector<std::shared_ptr<T>> &
641 THREAD_ID tid /* = 0*/) const
642{
643 return libmesh_map_find(_all_variable_objects[tid], var_name);
644}
645
646template <typename T>
647std::set<SubdomainID>
649{
650 checkThreadID(tid);
651 std::set<SubdomainID> ids;
652 for (const auto & object_pair : _active_block_objects[tid])
653 ids.insert(object_pair.first);
654 return ids;
655}
656
657template <typename T>
658void
660{
661 checkThreadID(tid);
662
664
665 for (const auto & object_pair : _all_block_objects[tid])
666 updateActiveHelper(_active_block_objects[tid][object_pair.first], object_pair.second);
667
668 for (const auto & object_pair : _all_boundary_objects[tid])
669 updateActiveHelper(_active_boundary_objects[tid][object_pair.first], object_pair.second);
670}
671
672template <typename T>
673void
674MooseObjectWarehouseBase<T>::updateActiveHelper(std::vector<std::shared_ptr<T>> & active,
675 const std::vector<std::shared_ptr<T>> & all)
676{
677 // Clear the active list
678 active.clear();
679
680 std::copy_if(all.begin(),
681 all.end(),
682 std::back_inserter(active),
683 [](const std::shared_ptr<T> & object) { return object->enabled(); });
684}
685
686template <typename T>
687void
689{
690 checkThreadID(tid);
691
692 for (auto & object_pair : _all_block_objects[tid])
693 sortHelper(object_pair.second);
694
695 for (auto & object_pair : _all_boundary_objects[tid])
696 sortHelper(object_pair.second);
697
699
700 // The active lists now must be update to reflect the order changes
701 updateActive(tid);
702}
703
704template <typename T>
705void
707 std::set<MooseVariableFieldBase *> & needed_moose_vars, THREAD_ID tid /* = 0*/) const
708{
709 if (hasActiveObjects(tid))
710 updateVariableDependencyHelper(needed_moose_vars, _active_objects[tid]);
711}
712
713template <typename T>
714void
716 SubdomainID id,
717 std::set<MooseVariableFieldBase *> & needed_moose_vars,
718 THREAD_ID tid /* = 0*/) const
719{
720 if (hasActiveBlockObjects(id, tid))
721 updateVariableDependencyHelper(needed_moose_vars, getActiveBlockObjects(id, tid));
722}
723
724template <typename T>
725void
727 std::set<MooseVariableFieldBase *> & needed_moose_vars, THREAD_ID tid /* = 0*/) const
728{
730 {
731 typename std::map<BoundaryID, std::vector<std::shared_ptr<T>>>::const_iterator it;
732 for (const auto & object_pair : _active_boundary_objects[tid])
733 updateVariableDependencyHelper(needed_moose_vars, object_pair.second);
734 }
735}
736
737template <typename T>
738void
740 BoundaryID id,
741 std::set<MooseVariableFieldBase *> & needed_moose_vars,
742 THREAD_ID tid /* = 0*/) const
743{
744 if (hasActiveBoundaryObjects(id, tid))
745 updateVariableDependencyHelper(needed_moose_vars, getActiveBoundaryObjects(id, tid));
746}
747
748template <typename T>
749void
751 std::set<MooseVariableFieldBase *> & needed_moose_vars,
752 const std::vector<std::shared_ptr<T>> & objects)
753{
754 for (const auto & object : objects)
755 {
756 auto c = dynamic_cast<const MooseVariableDependencyInterface *>(object.get());
757 if (c)
758 {
759 const auto & mv_deps = c->getMooseVariableDependencies();
760 needed_moose_vars.insert(mv_deps.begin(), mv_deps.end());
761 }
762 }
763}
764
765template <typename T>
766void
768 std::set<TagID> & needed_fe_var_vector_tags, THREAD_ID tid /* = 0*/) const
769{
770 if (hasActiveObjects(tid))
771 updateFEVariableCoupledVectorTagDependencyHelper(needed_fe_var_vector_tags,
772 _active_objects[tid]);
773}
774
775template <typename T>
776void
778 SubdomainID id, std::set<TagID> & needed_fe_var_vector_tags, THREAD_ID tid /* = 0*/) const
779{
780 if (hasActiveBlockObjects(id, tid))
781 updateFEVariableCoupledVectorTagDependencyHelper(needed_fe_var_vector_tags,
782 getActiveBlockObjects(id, tid));
783}
784
785template <typename T>
786void
788 BoundaryID id, std::set<TagID> & needed_fe_var_vector_tags, THREAD_ID tid /* = 0*/) const
789{
790 if (hasActiveBoundaryObjects(id, tid))
791 updateFEVariableCoupledVectorTagDependencyHelper(needed_fe_var_vector_tags,
792 getActiveBoundaryObjects(id, tid));
793}
794
795template <typename T>
796void
798 std::set<TagID> & needed_fe_var_vector_tags, const std::vector<std::shared_ptr<T>> & objects)
799{
800 for (const auto & object : objects)
801 {
802 auto c = dynamic_cast<const Coupleable *>(object.get());
803 if (c)
804 {
805 const auto & tag_deps = c->getFEVariableCoupleableVectorTags();
806 needed_fe_var_vector_tags.insert(tag_deps.begin(), tag_deps.end());
807 }
808 }
809}
810
811template <typename T>
812void
814 std::unordered_set<unsigned int> & needed_mat_props,
815 THREAD_ID tid /* = 0*/,
816 const bool producer_only /* = false*/) const
817{
818 if (hasActiveObjects(tid))
819 updateMatPropDependencyHelper(needed_mat_props, _active_objects[tid], producer_only);
820}
821
822template <typename T>
823void
825 SubdomainID id,
826 std::unordered_set<unsigned int> & needed_mat_props,
827 THREAD_ID tid /* = 0*/,
828 const bool producer_only /* = false*/) const
829{
830 if (hasActiveBlockObjects(id, tid))
831 updateMatPropDependencyHelper(needed_mat_props, getActiveBlockObjects(id, tid), producer_only);
832}
833
834template <typename T>
835void
837 std::unordered_set<unsigned int> & needed_mat_props,
838 THREAD_ID tid /* = 0*/,
839 const bool producer_only /* = false*/) const
840{
842 for (auto & active_bnd_object : _active_boundary_objects[tid])
843 updateMatPropDependencyHelper(needed_mat_props, active_bnd_object.second, producer_only);
844}
845
846template <typename T>
847void
849 BoundaryID id,
850 std::unordered_set<unsigned int> & needed_mat_props,
851 THREAD_ID tid /* = 0*/,
852 const bool producer_only /* = false*/) const
853{
854 if (hasActiveBoundaryObjects(id, tid))
856 needed_mat_props, getActiveBoundaryObjects(id, tid), producer_only);
857}
858
859template <typename T>
860void
862 std::unordered_set<unsigned int> & needed_mat_props,
863 const std::vector<std::shared_ptr<T>> & objects,
864 const bool /* producer_only */) const
865{
866 for (auto & object : objects)
867 {
868 auto c = dynamic_cast<const MaterialPropertyInterface *>(object.get());
869 if (c)
870 {
871 auto & mp_deps = c->getMatPropDependencies();
872 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
873 }
874 }
875}
876
877template <typename T>
878void
879MooseObjectWarehouseBase<T>::subdomainsCovered(std::set<SubdomainID> & subdomains_covered,
880 std::set<std::string> & unique_variables,
881 THREAD_ID tid /*=0*/) const
882{
883 for (const auto & object : _active_objects[tid])
884 {
885 unique_variables.insert(object->variable().name());
886 const auto additional_variables_covered = object->additionalROVariables();
887 unique_variables.insert(additional_variables_covered.begin(),
888 additional_variables_covered.end());
889 }
890
891 for (const auto & object_pair : _active_block_objects[tid])
892 subdomains_covered.insert(object_pair.first);
893}
894
895template <typename T>
896std::string
898 const THREAD_ID tid /*=0*/, const std::string & prefix /*="[DBG]"*/) const
899{
900 std::vector<std::string> output;
901 for (const auto & object : _active_objects[tid])
902 output.push_back(object->name());
903 return ConsoleUtils::formatString(MooseUtils::join(output, " "), prefix);
904}
905
906template <typename T>
907void
908MooseObjectWarehouseBase<T>::sortHelper(std::vector<std::shared_ptr<T>> & objects)
909{
910 // Do nothing if the vector is empty
911 if (objects.empty())
912 return;
913
914 try
915 {
916 // Sort based on dependencies
917 DependencyResolverInterface::sort<std::shared_ptr<T>>(objects);
918 }
919 catch (CyclicDependencyException<std::shared_ptr<T>> & e)
920 {
921 DependencyResolverInterface::cyclicDependencyError<std::shared_ptr<T>>(
922 e, "Cyclic dependency detected in object ordering");
923 }
924}
925
926template <typename T>
927inline void
929{
930 mooseAssert(tid < _num_threads,
931 "Attempting to access a thread id ("
932 << tid << ") greater than the number allowed by the storage item ("
933 << _num_threads << ")");
934}
boundary_id_type BoundaryID
subdomain_id_type SubdomainID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int THREAD_ID
Definition MooseTypes.h:237
char ** blocks
Interface for objects that needs coupling capabilities.
Definition Coupleable.h:53
std::set< TagID > & getFEVariableCoupleableVectorTags()
Definition Coupleable.h:120
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class.
std::vector< std::string > getVecMooseType(const std::string &name) const
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,...
An interface for accessing Materials.
virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
MaterialBase objects are special in that they have additional objects created automatically (see FEPr...
virtual void updateMatPropDependencyHelper(std::unordered_set< unsigned int > &needed_mat_props, const std::vector< std::shared_ptr< MaterialBase > > &objects, const bool producer_only) const override
Helper method for updating material property dependency vector.
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.
A base storage container for MooseObjects.
const std::vector< std::shared_ptr< T > > & getObjectsForVariable(const VariableName &var_name, THREAD_ID tid) const
Getter for objects that have the 'variable' set to a particular variable Note that users should check...
void updateVariableDependency(std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
static void sortHelper(std::vector< std::shared_ptr< T > > &objects)
Helper method for sorting vectors of objects.
bool hasActiveBoundaryObjects(BoundaryID id, THREAD_ID tid=0) const
std::vector< std::vector< std::shared_ptr< T > > > _all_objects
Storage container for the ALL pointers (THREAD_ID on outer vector)
unsigned int size(THREAD_ID tid=0) const
Return how many kernels we store in the current warehouse.
void updateBoundaryMatPropDependency(BoundaryID id, std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
std::string activeObjectsToFormattedString(THREAD_ID tid=0, const std::string &prefix="[DBG]") const
Output the active content of the warehouse to a string, meant to be output to the console.
static void updateVariableDependencyHelper(std::set< MooseVariableFieldBase * > &needed_moose_vars, const std::vector< std::shared_ptr< T > > &objects)
Helper method for updating variable dependency vector.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getBlockObjects(THREAD_ID tid=0) const
const std::vector< std::shared_ptr< T > > & getBoundaryObjects(BoundaryID id, THREAD_ID tid=0) const
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const
bool hasObjectsForVariableAndBlocks(const VariableName &var_name, const std::set< SubdomainID > &blocks, std::set< SubdomainID > &blocks_covered, THREAD_ID tid) const
Whether there are objects for this variable and the set of blocks passed.
virtual ~MooseObjectWarehouseBase()
Destructor.
bool hasBoundaryObjects(THREAD_ID tid=0) const
std::set< SubdomainID > getActiveBlocks(THREAD_ID tid=0) const
Return a set of active SubdomainsIDs.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
std::vector< std::vector< std::shared_ptr< T > > > _active_objects
All active objects (THREAD_ID on outer vector)
const std::vector< std::shared_ptr< T > > & getObjects(THREAD_ID tid=0) const
Retrieve complete vector to the all/block/boundary restricted objects for a given thread.
void updateBoundaryVariableDependency(BoundaryID id, std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
virtual void updateActive(THREAD_ID tid=0)
Updates the active objects storage.
std::vector< std::map< VariableName, std::vector< std::shared_ptr< T > > > > _all_variable_objects
All objects with a certain variable selected, as the 'variable' parameter.
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< T > > > > _all_boundary_objects
bool hasActiveObject(const std::string &name, THREAD_ID tid=0) const
Convenience functions for checking/getting specific objects.
bool hasBoundaryObjectsHelper(const std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< T > > > > &boundary_objects, const THREAD_ID tid=0) const
Helper for determining whether we have boundary objects.
const std::vector< std::shared_ptr< T > > & getActiveBoundaryObjects(BoundaryID id, THREAD_ID tid=0) const
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< T > > > > _active_block_objects
Active block restricted objects (THREAD_ID on outer vector)
void updateFEVariableCoupledVectorTagDependency(std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
Update FE variable coupleable vector tag vector for all objects, block-restricted objects,...
bool hasActiveBlockObjects(SubdomainID id, THREAD_ID tid=0) const
void updateMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
Update material property dependency vector.
MooseObjectWarehouseBase(THREAD_ID num_threads=libMesh::n_threads())
Constructor.
void sort(THREAD_ID tid=0)
Sort the objects using the DependencyResolver.
void updateBoundaryFEVariableCoupledVectorTagDependency(BoundaryID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
void updateBlockMatPropDependency(SubdomainID id, std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< T > > > > _active_boundary_objects
Active boundary restricted objects (THREAD_ID on outer vector)
const THREAD_ID _num_threads
Convenience member storing the number of threads used for storage (1 or libMesh::n_threads)
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
virtual void updateMatPropDependencyHelper(std::unordered_set< unsigned int > &needed_mat_props, const std::vector< std::shared_ptr< T > > &objects, const bool producer_only) const
Helper method for updating material property dependency vector.
void updateBoundaryVariableDependency(std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
void updateBlockVariableDependency(SubdomainID id, std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
bool hasActiveObjects(THREAD_ID tid=0) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
bool hasActiveBlockObjects(THREAD_ID tid=0) const
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< T > > > > _all_block_objects
void updateBoundaryMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
THREAD_ID numThreads() const
Return the number of threads.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
static void updateActiveHelper(std::vector< std::shared_ptr< T > > &active, const std::vector< std::shared_ptr< T > > &all)
Helper method for updating active vectors.
bool hasBoundaryObjects(BoundaryID id, THREAD_ID tid=0) const
bool hasObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread.
std::shared_ptr< T > getObject(const std::string &name, THREAD_ID tid=0) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getBoundaryObjects(THREAD_ID tid=0) const
const std::vector< std::shared_ptr< T > > & getActiveBlockObjects(SubdomainID id, THREAD_ID tid=0) const
bool hasObjectsForVariable(const VariableName &var_name, THREAD_ID tid) const
const std::vector< std::shared_ptr< T > > & getBlockObjects(SubdomainID id, THREAD_ID tid=0) const
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Populates a set of covered subdomains and the associated variable names.
static void updateFEVariableCoupledVectorTagDependencyHelper(std::set< TagID > &needed_fe_var_vector_tags, const std::vector< std::shared_ptr< T > > &objects)
Helper method for updating FE variable coupleable vector tag vector.
void checkThreadID(THREAD_ID tid) const
Calls assert on thread id.
const std::set< MooseVariableFieldBase * > & getMooseVariableDependencies() const
Retrieve the set of MooseVariableFieldBase that this object depends on.
This class provides an interface for common operations on field variables of both FE and FV types wit...
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
std::string formatString(std::string message, const std::string &prefix)
Add new lines and prefixes to a string for pretty display in output NOTE: This makes a copy of the st...
@ VAR_FIELD_ANY
Definition MooseTypes.h:781
@ VAR_ANY
Definition MooseTypes.h:772
unsigned int n_threads()