https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MaterialWarehouse.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// MOOSE includes
11#include "MaterialWarehouse.h"
12#include "MaterialBase.h"
13
14// Defined out-of-line so the MooseObjectWarehouse<MaterialBase> base is instantiated here, where
15// MaterialBase is complete (it is only forward-declared in the header).
20
21void
22MaterialWarehouse::addObjects(std::shared_ptr<MaterialBase> block,
23 std::shared_ptr<MaterialBase> neighbor,
24 std::shared_ptr<MaterialBase> face,
25 THREAD_ID tid /*=0*/)
26{
28 _neighbor_materials.addObject(neighbor, tid);
29 _face_materials.addObject(face, tid);
30}
31
34{
35 switch (data_type)
36 {
39
41 return _face_materials;
42
43 default:
44 return *this;
45 }
46}
47
48void
55
56void
63
64void
70
71void
76
77void
83
84void
89
90void
97
98void
105
106void
113
114void
115MaterialWarehouse::sort(THREAD_ID tid /*=0*/, bool sort_all_objects /*=false*/)
116{
117 checkThreadID(tid);
118
119 for (auto & object_pair : _all_block_objects[tid])
120 sortHelper(object_pair.second);
121 for (auto & object_pair : _all_boundary_objects[tid])
122 sortHelper(object_pair.second);
123
124 for (auto & object_pair : _neighbor_materials._all_block_objects[tid])
125 sortHelper(object_pair.second);
126 for (auto & object_pair : _neighbor_materials._all_boundary_objects[tid])
127 sortHelper(object_pair.second);
128
129 for (auto & object_pair : _face_materials._all_block_objects[tid])
130 sortHelper(object_pair.second);
131 for (auto & object_pair : _face_materials._all_boundary_objects[tid])
132 sortHelper(object_pair.second);
133
134 if (sort_all_objects)
135 {
139 }
140
141 updateActive(tid);
142}
143
144void
146 std::unordered_set<unsigned int> & needed_mat_props,
147 const std::vector<std::shared_ptr<MaterialBase>> & materials,
148 const bool producer_only) const
149{
150 if (producer_only)
151 {
152 std::unordered_set<unsigned int> consumer_needed_mat_props;
153
154 do
155 {
156 consumer_needed_mat_props = needed_mat_props;
157
158 for (auto & material : materials)
159 for (const auto prop : consumer_needed_mat_props)
160 if (material->getSuppliedPropIDs().count(prop))
161 {
162 auto & mp_deps = material->getMatPropDependencies();
163 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
164 }
165
166 } while (consumer_needed_mat_props.size() != needed_mat_props.size());
167 }
168 else
170 needed_mat_props, materials, producer_only);
171}
subdomain_id_type SubdomainID
unsigned int THREAD_ID
Definition MooseTypes.h:237
MaterialBases compute MaterialProperties.
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 jacobianSetup(THREAD_ID tid=0) const override
void addObjects(std::shared_ptr< MaterialBase > block, std::shared_ptr< MaterialBase > neighbor, std::shared_ptr< MaterialBase > face, THREAD_ID tid=0)
A special method unique to this class for adding Block, Neighbor, and Face material objects.
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.
void sort(THREAD_ID tid=0, bool sort_all_objects=false)
By default, this method only sorts block and boundary-wise object storages that are used by the MOOSE...
virtual void subdomainSetup(THREAD_ID tid=0) const override
virtual void neighborSubdomainSetup(THREAD_ID tid=0) const
MooseObjectWarehouse< MaterialBase > _neighbor_materials
Storage for neighbor material objects (Block are stored in the base class)
const MooseObjectWarehouse< MaterialBase > & operator[](Moose::MaterialDataType data_type) const
MooseObjectWarehouse< MaterialBase > _face_materials
Storage for face material objects (Block are stored in the base class)
virtual void residualSetup(THREAD_ID tid=0) const override
virtual void timestepSetup(THREAD_ID tid=0) const override
virtual void initialSetup(THREAD_ID tid=0) const override
Convenience methods for calling object setup methods that handle the extra neighbor and face objects.
static void sortHelper(std::vector< std::shared_ptr< T > > &objects)
Helper method for sorting vectors of objects.
std::vector< std::vector< std::shared_ptr< T > > > _all_objects
Storage container for the ALL pointers (THREAD_ID on outer vector)
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< T > > > > _all_boundary_objects
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.
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< T > > > > _all_block_objects
void checkThreadID(THREAD_ID tid) const
Calls assert on thread id.
A storage container for MooseObjects that inherit from SetupInterface.
virtual void timestepSetup(THREAD_ID tid=0) const
virtual void subdomainSetup(THREAD_ID tid=0) const
virtual void initialSetup(THREAD_ID tid=0) const
Convenience methods for calling object setup methods.
virtual void residualSetup(THREAD_ID tid=0) const
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.
virtual void jacobianSetup(THREAD_ID tid=0) const
MaterialDataType
MaterialData types.
Definition MooseTypes.h:746
@ NEIGHBOR_MATERIAL_DATA
Definition MooseTypes.h:750
@ FACE_MATERIAL_DATA
Definition MooseTypes.h:749