https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComputeMaterialsObjectThread.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
12#include "NonlinearSystem.h"
13#include "Problem.h"
14#include "FEProblem.h"
16#include "MaterialData.h"
17#include "Assembly.h"
18#include "AuxKernel.h"
19#include "Material.h"
20
21#include "libmesh/threads.h"
22#include "libmesh/quadrature.h"
23
25 FEProblemBase & fe_problem,
26 MaterialPropertyStorage & material_props,
27 MaterialPropertyStorage & bnd_material_props,
28 MaterialPropertyStorage & neighbor_material_props,
29 std::vector<std::vector<std::unique_ptr<Assembly>>> & assembly)
30 : ThreadedElementLoop<ConstElemRange>(fe_problem),
31 _fe_problem(fe_problem),
32 _material_props(material_props),
33 _bnd_material_props(bnd_material_props),
34 _neighbor_material_props(neighbor_material_props),
35 _materials(_fe_problem.getRegularMaterialsWarehouse()),
36 _interface_materials(_fe_problem.getInterfaceMaterialsWarehouse()),
37 _discrete_materials(_fe_problem.getDiscreteMaterialWarehouse()),
38 _assembly(assembly),
39 _need_internal_side_material(false),
40 _has_stateful_props(_material_props.hasStatefulProperties()),
41 _has_bnd_stateful_props(_bnd_material_props.hasStatefulProperties()),
42 _has_neighbor_stateful_props(_neighbor_material_props.hasStatefulProperties())
43{
44}
45
46// Splitting Constructor
48 Threads::split split)
49 : ThreadedElementLoop<ConstElemRange>(x, split),
50 _fe_problem(x._fe_problem),
51 _material_props(x._material_props),
52 _bnd_material_props(x._bnd_material_props),
53 _neighbor_material_props(x._neighbor_material_props),
54 _materials(x._materials),
55 _interface_materials(x._interface_materials),
56 _discrete_materials(x._discrete_materials),
57 _assembly(x._assembly),
58 _need_internal_side_material(x._need_internal_side_material),
59 _has_stateful_props(_material_props.hasStatefulProperties()),
60 _has_bnd_stateful_props(_bnd_material_props.hasStatefulProperties()),
61 _has_neighbor_stateful_props(_neighbor_material_props.hasStatefulProperties())
62{
63}
64
65void
67{
70
71 std::set<MooseVariableFEBase *> needed_moose_vars;
72 _materials.updateVariableDependency(needed_moose_vars, _tid);
75
76 std::set<TagID> needed_fe_var_vector_tags;
78 _subdomain, needed_fe_var_vector_tags, _tid);
80 _subdomain, needed_fe_var_vector_tags, _tid);
82
83 // Note that we do not know here which materials will be active on this subdomain because we don't
84 // have the various warehouses (kernels, ...) to gather the needed material properties like in
85 // NonlinearThread
86}
87
88void
113
114void
116 unsigned int side,
117 BoundaryID bnd_id,
118 const Elem * /*lower_d_elem = nullptr*/)
119{
121 {
122 _fe_problem.reinitElemFace(elem, side, _tid);
123 const auto face_n_points = _assembly[_tid][/*system_index*/ 0]->qRuleFace()->n_points();
124
126
128 {
129 // Face Materials
132 _tid,
134 face_n_points,
135 *elem,
136 side);
137 if (_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
139 _tid,
140 _materials[Moose::FACE_MATERIAL_DATA].getActiveBlockObjects(_subdomain, _tid),
141 face_n_points,
142 *elem,
143 side);
144
145 // Boundary Materials
148 _tid, _materials.getActiveBoundaryObjects(bnd_id, _tid), face_n_points, *elem, side);
151 _tid, _materials.getActiveBoundaryObjects(bnd_id, _tid), face_n_points, *elem, side);
152 }
153 }
154}
155
156void
157ComputeMaterialsObjectThread::onInternalSide(const Elem * elem, unsigned int side)
158{
160 {
161 const Elem * neighbor = elem->neighbor_ptr(side);
162
164 unsigned int face_n_points = _assembly[_tid][0]->qRuleFace()->n_points();
167
169 {
172 _tid,
174 face_n_points,
175 *elem,
176 side);
177 if (_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
179 _tid,
180 _materials[Moose::FACE_MATERIAL_DATA].getActiveBlockObjects(_subdomain, _tid),
181 face_n_points,
182 *elem,
183 side);
184 }
185
186 unsigned int neighbor_side = neighbor->which_neighbor_am_i(_assembly[_tid][0]->elem());
187
189 {
190 // Neighbor Materials
191 if (_discrete_materials[Moose::NEIGHBOR_MATERIAL_DATA].hasActiveBlockObjects(
192 neighbor->subdomain_id(), _tid))
194 _tid,
196 neighbor->subdomain_id(), _tid),
197 face_n_points,
198 *elem,
199 side);
200 if (_materials[Moose::NEIGHBOR_MATERIAL_DATA].hasActiveBlockObjects(neighbor->subdomain_id(),
201 _tid))
203 _tid,
204 _materials[Moose::NEIGHBOR_MATERIAL_DATA].getActiveBlockObjects(
205 neighbor->subdomain_id(), _tid),
206 face_n_points,
207 *neighbor,
208 neighbor_side);
209 }
210 }
211}
212
213void
214ComputeMaterialsObjectThread::onInterface(const Elem * elem, unsigned int side, BoundaryID bnd_id)
215{
217 return;
218
219 _fe_problem.reinitElemFace(elem, side, _tid);
220 unsigned int face_n_points = _assembly[_tid][0]->qRuleFace()->n_points();
221
224
226 {
227 // Face Materials
230 _tid,
232 face_n_points,
233 *elem,
234 side);
235
236 if (_materials[Moose::FACE_MATERIAL_DATA].hasActiveBlockObjects(_subdomain, _tid))
238 _tid,
239 _materials[Moose::FACE_MATERIAL_DATA].getActiveBlockObjects(_subdomain, _tid),
240 face_n_points,
241 *elem,
242 side);
243
244 // Boundary Materials
247 _tid, _materials.getActiveBoundaryObjects(bnd_id, _tid), face_n_points, *elem, side);
248
251 _tid, _materials.getActiveBoundaryObjects(bnd_id, _tid), face_n_points, *elem, side);
252 }
253
254 const Elem * neighbor = elem->neighbor_ptr(side);
255 unsigned int neighbor_side = neighbor->which_neighbor_am_i(_assembly[_tid][0]->elem());
256
257 // Do we have neighbor stateful properties or do we have stateful interface material properties?
258 // If either then we need to reinit the neighbor, so at least at a minimum _neighbor_elem isn't
259 // NULL!
260 if (neighbor->active() &&
263 _fe_problem.reinitNeighbor(elem, side, _tid);
264
265 if (_has_neighbor_stateful_props && neighbor->active())
266 {
267 // Neighbor Materials
268 if (_discrete_materials[Moose::NEIGHBOR_MATERIAL_DATA].hasActiveBlockObjects(
269 neighbor->subdomain_id(), _tid))
271 _tid,
273 neighbor->subdomain_id(), _tid),
274 face_n_points,
275 *elem,
276 side);
277
278 if (_materials[Moose::NEIGHBOR_MATERIAL_DATA].hasActiveBlockObjects(neighbor->subdomain_id(),
279 _tid))
281 _tid,
282 _materials[Moose::NEIGHBOR_MATERIAL_DATA].getActiveBlockObjects(neighbor->subdomain_id(),
283 _tid),
284 face_n_points,
285 *neighbor,
286 neighbor_side);
287 }
288
289 // Interface Materials. Make sure we do these after neighbors
292 _tid,
294 face_n_points,
295 *elem,
296 side);
297}
298
299void
303
304void
boundary_id_type BoundaryID
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
MaterialPropertyStorage & _material_props
std::vector< std::vector< std::unique_ptr< Assembly > > > & _assembly
const MaterialWarehouse & _interface_materials
This is populated using _fe_problem.getResidualInterfaceMaterialsWarehouse because it has the union o...
MaterialPropertyStorage & _neighbor_material_props
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
const MaterialWarehouse & _materials
This is populated using _fe_problem.getResidualMaterialsWarehouse because it has the union of traditi...
virtual void post() override
Called after the element range loop.
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
Called when doing boundary assembling.
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
ComputeMaterialsObjectThread(FEProblemBase &fe_problem, MaterialPropertyStorage &material_props, MaterialPropertyStorage &bnd_material_props, MaterialPropertyStorage &neighbor_material_props, std::vector< std::vector< std::unique_ptr< Assembly > > > &assembly)
virtual void onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing interface assembling.
void join(const ComputeMaterialsObjectThread &)
const MaterialWarehouse & _discrete_materials
MaterialPropertyStorage & _bnd_material_props
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
bool needInternalNeighborSideMaterial(SubdomainID subdomain_id, const THREAD_ID tid)
bool needInterfaceMaterialOnSide(BoundaryID bnd_id, const THREAD_ID tid)
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
virtual void reinitElemNeighborAndLowerD(const Elem *elem, unsigned int side, const THREAD_ID tid) override
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.
void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFEBase * > &moose_vars, const THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid) override
bool needBoundaryMaterialOnSide(BoundaryID bnd_id, const THREAD_ID tid)
These methods are used to determine whether stateful material properties need to be stored on interna...
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid) override
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Stores the stateful material properties computed by materials.
void initStatefulProps(const THREAD_ID tid, const std::vector< std::shared_ptr< MaterialBase > > &mats, const unsigned int n_qpoints, const Elem &elem, const unsigned int side=0)
Initialize stateful material properties.
const MaterialData & getMaterialData(const THREAD_ID tid) const
void updateVariableDependency(std::set< MooseVariableFieldBase * > &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, 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
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
SubdomainID _subdomain
The subdomain for the current element.
Base class for assembly-like calculations.
@ NEIGHBOR_MATERIAL_DATA
Definition MooseTypes.h:750
@ FACE_MATERIAL_DATA
Definition MooseTypes.h:749