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).
17 : MooseObjectWarehouse<MaterialBase>(num_threads),
18 _neighbor_materials(num_threads),
19 _face_materials(num_threads)
20{
21}
22
23void
24MaterialWarehouse::addObjects(std::shared_ptr<MaterialBase> block,
25 std::shared_ptr<MaterialBase> neighbor,
26 std::shared_ptr<MaterialBase> face,
27 THREAD_ID tid /*=0*/)
28{
30 _neighbor_materials.addObject(neighbor, tid);
31 _face_materials.addObject(face, tid);
32}
33
36{
37 switch (data_type)
38 {
41
43 return _face_materials;
44
45 default:
46 return *this;
47 }
48}
49
50void
57
58void
65
66void
72
73void
78
79void
85
86void
91
92void
99
100void
107
108void
115
116void
117MaterialWarehouse::sort(THREAD_ID tid /*=0*/, bool sort_all_objects /*=false*/)
118{
119 checkThreadID(tid);
120
121 for (auto & object_pair : _all_block_objects[tid])
122 sortHelper(object_pair.second);
123 for (auto & object_pair : _all_boundary_objects[tid])
124 sortHelper(object_pair.second);
125
126 for (auto & object_pair : _neighbor_materials._all_block_objects[tid])
127 sortHelper(object_pair.second);
128 for (auto & object_pair : _neighbor_materials._all_boundary_objects[tid])
129 sortHelper(object_pair.second);
130
131 for (auto & object_pair : _face_materials._all_block_objects[tid])
132 sortHelper(object_pair.second);
133 for (auto & object_pair : _face_materials._all_boundary_objects[tid])
134 sortHelper(object_pair.second);
135
136 if (sort_all_objects)
137 {
141 }
142
143 updateActive(tid);
144}
145
146void
148 std::unordered_set<unsigned int> & needed_mat_props,
149 const std::vector<std::shared_ptr<MaterialBase>> & materials,
150 const bool producer_only) const
151{
152 if (producer_only)
153 {
154 std::unordered_set<unsigned int> consumer_needed_mat_props;
155
156 do
157 {
158 consumer_needed_mat_props = needed_mat_props;
159
160 for (auto & material : materials)
161 for (const auto prop : consumer_needed_mat_props)
162 if (material->getSuppliedPropIDs().count(prop))
163 {
164 auto & mp_deps = material->getMatPropDependencies();
165 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
166 }
167
168 } while (consumer_needed_mat_props.size() != needed_mat_props.size());
169 }
170 else
172 needed_mat_props, materials, producer_only);
173}
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:750
@ NEIGHBOR_MATERIAL_DATA
Definition MooseTypes.h:754
@ FACE_MATERIAL_DATA
Definition MooseTypes.h:753