https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ComputeUserObjectsThread Class Reference

Class for threaded computation of UserObjects. More...

#include <ComputeUserObjectsThread.h>

Inheritance diagram for ComputeUserObjectsThread:
[legend]

Classes

struct  BoundaryMaterialReinitCache
 
struct  InterfaceMaterialReinitCache
 
struct  InternalSideMaterialReinitCache
 

Public Member Functions

 ComputeUserObjectsThread (FEProblemBase &problem, const TheWarehouse::Query &query)
 
 ComputeUserObjectsThread (ComputeUserObjectsThread &x, Threads::split)
 
virtual ~ComputeUserObjectsThread ()
 
virtual void onElement (const Elem *elem) override
 Assembly of the element (not including surface assembly)
 
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 onInternalSide (const Elem *elem, unsigned int side) override
 Called when doing internal edge assembling.
 
virtual void onExternalSide (const Elem *elem, unsigned int side) override
 Called when iterating over external sides (no side neighbor)
 
virtual void onInterface (const Elem *elem, unsigned int side, BoundaryID bnd_id) override
 Called when doing interface assembling.
 
virtual void post () override
 Called after the element range loop.
 
virtual void subdomainChanged () override
 Called every time the current subdomain changes (i.e.
 
void join (const ComputeUserObjectsThread &)
 
virtual void caughtMooseException (MooseException &e) override
 Called if a MooseException is caught anywhere during the computation.
 
virtual bool keepGoing () override
 Whether or not the loop should continue.
 
virtual void preElement (const Elem *elem) override
 Called before the element assembly.
 
virtual void preInternalSide (const Elem *elem, unsigned int side) override
 Called before evaluations on an element internal side.
 
virtual void preBoundary (const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
 Called before the boundary assembly.
 
virtual void neighborSubdomainChanged () override
 Called every time the neighbor subdomain changes (i.e.
 
virtual void operator() (const RangeType &range, bool bypass_threading=false)
 
virtual void pre ()
 Called before the element range loop.
 
virtual void postElement (const Elem *elem)
 Called after the element assembly is done (including surface assembling)
 
virtual void postInternalSide (const Elem *elem, unsigned int side)
 Called after evaluations on an element internal side.
 

Protected Member Functions

void printGeneralExecutionInformation () const override
 Print general information about the loop, like the ordering of class of objects.
 
void printBlockExecutionInformation () const override
 Print information about the loop, mostly order of execution of particular objects.
 
template<typename T >
void printVectorOrdering (std::vector< T * > uos, const std::string &name) const
 Format output of vector of UOs.
 
void prepareElement (const Elem *elem)
 
void clearVarsAndMaterials ()
 
void getRequiredBoundaryMaterials (const std::vector< const MaterialPropertyInterface * > &material_consumers, BoundaryID bnd_id, SubdomainID subdomain_id, std::deque< MaterialBase * > &required_face_materials, std::deque< MaterialBase * > &required_boundary_materials) const
 Determine the face and boundary materials required by material property consumers.
 
void printExecutionOrdering (const std::vector< T * > &objs, const bool print_header=true, const std::string &line_prefix="[DBG]") const
 Routine to output the ordering of objects within a vector of pointers to these objects.
 
void printExecutionOrdering (const std::vector< std::shared_ptr< T > > &objs_ptrs, const bool print_header=true, const std::string &line_prefix="[DBG]") const
 
virtual void printBoundaryExecutionInformation (const unsigned int) const
 Print information about the particular ordering of objects on each boundary.
 
void resetExecPrintedSets () const
 Resets the set of blocks and boundaries visited.
 
virtual bool shouldComputeInternalSide (const Elem &elem, const Elem &neighbor) const
 Whether to compute the internal side for the provided element-neighbor pair.
 

Protected Attributes

FEProblemBase & _fe_problem
 
MooseMesh & _mesh
 
THREAD_ID _tid
 
SubdomainID _subdomain
 The subdomain for the current element.
 
SubdomainID _old_subdomain
 The subdomain for the last element.
 
SubdomainID _neighbor_subdomain
 The subdomain for the current neighbor.
 
SubdomainID _old_neighbor_subdomain
 The subdomain for the last neighbor.
 
std::set< SubdomainID > _blocks_exec_printed
 Keep track of which blocks were visited.
 
std::set< BoundaryID > _boundaries_exec_printed
 Keep track of which boundaries were visited.
 

Private Member Functions

template<typename T >
void querySubdomain (Interfaces iface, std::vector< T > &results)
 
template<typename T >
void queryBoundary (Interfaces iface, BoundaryID bnd, std::vector< T > &results)
 
const BoundaryMaterialReinitCache & getBoundaryMaterialReinitCache (BoundaryID bnd_id, SubdomainID subdomain_id)
 Return the exact face and boundary materials required while executing on this boundary.
 
const InternalSideMaterialReinitCache & getInternalSideMaterialReinitCache (SubdomainID subdomain_id, SubdomainID neighbor_subdomain_id)
 Return the face and neighbor materials required while executing on this internal side.
 
const InterfaceMaterialReinitCache & getInterfaceMaterialReinitCache (BoundaryID bnd_id, SubdomainID subdomain_id, SubdomainID neighbor_subdomain_id, const std::vector< UserObject * > &interface_objs)
 Return the face, boundary, and neighbor materials required while executing on this interface.
 

Private Attributes

const TheWarehouse::Query _query
 
TheWarehouse::QueryCache< AttribThread, AttribSubdomains, AttribInterfaces > _query_subdomain
 
TheWarehouse::QueryCache< AttribThread, AttribBoundaries, AttribInterfaces > _query_boundary
 
std::vector< InternalSideUserObject * > _internal_side_objs
 
std::vector< InterfaceUserObject * > _interface_user_objects
 
std::vector< ElementUserObject * > _element_objs
 
std::vector< ShapeElementUserObject * > _shape_element_objs
 
std::vector< DomainUserObject * > _domain_objs
 
std::vector< DomainUserObject * > _all_domain_objs
 
AuxiliarySystem & _aux_sys
 
std::map< std::pair< BoundaryID, SubdomainID >, BoundaryMaterialReinitCache > _boundary_material_reinit_cache
 
std::map< std::pair< SubdomainID, SubdomainID >, InternalSideMaterialReinitCache > _internal_side_material_reinit_cache
 
std::map< std::tuple< BoundaryID, SubdomainID, SubdomainID >, InterfaceMaterialReinitCache > _interface_material_reinit_cache
 

Detailed Description

Class for threaded computation of UserObjects.

Definition at line 37 of file ComputeUserObjectsThread.h.

Constructor & Destructor Documentation

◆ ComputeUserObjectsThread() [1/2]

ComputeUserObjectsThread::ComputeUserObjectsThread ( FEProblemBase &  problem,
const TheWarehouse::Query &  query 
)

Definition at line 29 of file ComputeUserObjectsThread.C.

32 _query(query),
36{
37}
const TheWarehouse::Query _query
TheWarehouse::QueryCache< AttribThread, AttribBoundaries, AttribInterfaces > _query_boundary
TheWarehouse::QueryCache< AttribThread, AttribSubdomains, AttribInterfaces > _query_subdomain
AuxiliarySystem & getAuxiliarySystem()
Base class for assembly-like calculations.

◆ ComputeUserObjectsThread() [2/2]

ComputeUserObjectsThread::ComputeUserObjectsThread ( ComputeUserObjectsThread &  x,
Threads::split   
)

◆ ~ComputeUserObjectsThread()

ComputeUserObjectsThread::~ComputeUserObjectsThread ( )
virtual

Definition at line 49 of file ComputeUserObjectsThread.C.

49{}

Member Function Documentation

◆ caughtMooseException()

void ThreadedElementLoop< ConstElemRange >::caughtMooseException ( MooseException &  e)
overridevirtualinherited

Called if a MooseException is caught anywhere during the computation.

The single input parameter taken is a MooseException object.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 44 of file ThreadedElementLoop.h.

113{
114 Threads::spin_mutex::scoped_lock lock(threaded_element_mutex);
115
116 std::string what(e.what());
118}
static Threads::spin_mutex threaded_element_mutex
This mutex is used by all derived classes of the ThreadedElementLoop.
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class,...
virtual const char * what() const
Get out the error message.

◆ clearVarsAndMaterials()

void ThreadedElementLoop< ConstElemRange >::clearVarsAndMaterials ( )
protectedinherited

Definition at line 61 of file ThreadedElementLoop.h.

203{
206}
void clearActiveMaterialProperties(const THREAD_ID tid)
Clear the active material properties.
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.

◆ getBoundaryMaterialReinitCache()

const ComputeUserObjectsThread::BoundaryMaterialReinitCache & ComputeUserObjectsThread::getBoundaryMaterialReinitCache ( BoundaryID  bnd_id,
SubdomainID  subdomain_id 
)
private

Return the exact face and boundary materials required while executing on this boundary.

Definition at line 162 of file ComputeUserObjectsThread.C.

164{
165 const auto cache_key = std::make_pair(bnd_id, subdomain_id);
166 auto [cache_it, inserted] = _boundary_material_reinit_cache.try_emplace(cache_key);
167 auto & cache = cache_it->second;
168
169 if (!inserted)
170 return cache;
171
172 // SideUserObjects are boundary-restricted, not block-restricted. The current subdomain is
173 // accounted for below when selecting the active face materials.
174 std::vector<UserObject *> userobjs;
175 queryBoundary(Interfaces::SideUserObject, bnd_id, userobjs);
176
177 std::vector<const MaterialPropertyInterface *> material_consumers;
178 material_consumers.reserve(userobjs.size() + _domain_objs.size());
179
180 const auto add_material_consumers = [&material_consumers](const auto & objects)
181 {
182 for (const auto * const object : objects)
183 if (const auto * const consumer = dynamic_cast<const MaterialPropertyInterface *>(object))
184 material_consumers.push_back(consumer);
185 };
186
187 add_material_consumers(userobjs);
188 add_material_consumers(_domain_objs);
190 material_consumers, bnd_id, subdomain_id, cache.face_materials, cache.boundary_materials);
191 return cache;
192}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
void queryBoundary(Interfaces iface, BoundaryID bnd, std::vector< T > &results)
std::map< std::pair< BoundaryID, SubdomainID >, BoundaryMaterialReinitCache > _boundary_material_reinit_cache
std::vector< DomainUserObject * > _domain_objs
An interface for accessing Materials.
void getRequiredBoundaryMaterials(const std::vector< const MaterialPropertyInterface * > &material_consumers, BoundaryID bnd_id, SubdomainID subdomain_id, std::deque< MaterialBase * > &required_face_materials, std::deque< MaterialBase * > &required_boundary_materials) const
Determine the face and boundary materials required by material property consumers.

Referenced by onBoundary().

◆ getInterfaceMaterialReinitCache()

const ComputeUserObjectsThread::InterfaceMaterialReinitCache & ComputeUserObjectsThread::getInterfaceMaterialReinitCache ( BoundaryID  bnd_id,
SubdomainID  subdomain_id,
SubdomainID  neighbor_subdomain_id,
const std::vector< UserObject * > &  interface_objs 
)
private

Return the face, boundary, and neighbor materials required while executing on this interface.

Definition at line 240 of file ComputeUserObjectsThread.C.

245{
246 const auto cache_key = std::make_tuple(bnd_id, subdomain_id, neighbor_subdomain_id);
247 auto [cache_it, inserted] = _interface_material_reinit_cache.try_emplace(cache_key);
248 auto & cache = cache_it->second;
249
250 if (!inserted)
251 return cache;
252
253 std::vector<const MaterialPropertyInterface *> material_consumers;
254 material_consumers.reserve(interface_objs.size() + _all_domain_objs.size());
255 const auto add_material_consumer = [&material_consumers](const auto * const object)
256 {
257 if (const auto * const consumer = dynamic_cast<const MaterialPropertyInterface *>(object))
258 material_consumers.push_back(consumer);
259 };
260
261 for (const auto * const uo : interface_objs)
262 add_material_consumer(uo);
263
264 for (const auto * const uo : _all_domain_objs)
265 if (uo->shouldExecuteOnInterface())
266 add_material_consumer(uo);
267
268 // Interface materials execute after face and neighbor reinitialization, so include their
269 // dependencies when selecting the materials that must execute first.
270 const auto & interface_materials = _fe_problem.getInterfaceMaterialsWarehouse();
271 if (interface_materials.hasActiveBoundaryObjects(bnd_id, _tid))
272 for (const auto & material : interface_materials.getActiveBoundaryObjects(bnd_id, _tid))
273 add_material_consumer(material.get());
274
276 material_consumers, bnd_id, subdomain_id, cache.face_materials, cache.boundary_materials);
277
278 const auto & neighbor_materials =
280 if (neighbor_materials.hasActiveBlockObjects(neighbor_subdomain_id, _tid))
281 cache.neighbor_materials = MaterialBase::buildRequiredMaterials(
282 material_consumers,
283 neighbor_materials.getActiveBlockObjects(neighbor_subdomain_id, _tid),
284 true);
285
286 return cache;
287}
std::vector< DomainUserObject * > _all_domain_objs
std::map< std::tuple< BoundaryID, SubdomainID, SubdomainID >, InterfaceMaterialReinitCache > _interface_material_reinit_cache
const MaterialWarehouse & getInterfaceMaterialsWarehouse() const
const MaterialWarehouse & getRegularMaterialsWarehouse() const
static std::deque< MaterialBase * > buildRequiredMaterials(const Consumers &mat_consumers, const std::vector< std::shared_ptr< MaterialBase > > &mats, const bool allow_stateful)
Build the materials required by a set of consumer objects.
@ NEIGHBOR_MATERIAL_DATA
Definition MooseTypes.h:754
const Elem & get(const ElemType type_in)

Referenced by onInterface().

◆ getInternalSideMaterialReinitCache()

const ComputeUserObjectsThread::InternalSideMaterialReinitCache & ComputeUserObjectsThread::getInternalSideMaterialReinitCache ( SubdomainID  subdomain_id,
SubdomainID  neighbor_subdomain_id 
)
private

Return the face and neighbor materials required while executing on this internal side.

Definition at line 195 of file ComputeUserObjectsThread.C.

197{
198 const auto cache_key = std::make_pair(subdomain_id, neighbor_subdomain_id);
199 auto [cache_it, inserted] = _internal_side_material_reinit_cache.try_emplace(cache_key);
200 auto & cache = cache_it->second;
201
202 if (!inserted)
203 return cache;
204
205 std::vector<const MaterialPropertyInterface *> material_consumers;
206 material_consumers.reserve(_internal_side_objs.size() + _domain_objs.size());
207 const auto add_material_consumer = [&material_consumers](const auto * const object)
208 {
209 if (const auto * const consumer = dynamic_cast<const MaterialPropertyInterface *>(object))
210 material_consumers.push_back(consumer);
211 };
212
213 for (const auto * const uo : _internal_side_objs)
214 if (!uo->blockRestricted() || uo->hasBlocks(neighbor_subdomain_id))
215 add_material_consumer(uo);
216
217 for (const auto * const uo : _domain_objs)
218 if (!uo->blockRestricted() || uo->hasBlocks(neighbor_subdomain_id))
219 add_material_consumer(uo);
220
221 // TwoMaterialPropertyInterface exposes one dependency set for face and neighbor properties, so
222 // use the same consumers to select both material data types.
223 const auto & materials = _fe_problem.getRegularMaterialsWarehouse();
224 const auto & face_materials = materials[Moose::FACE_MATERIAL_DATA];
225 if (face_materials.hasActiveBlockObjects(subdomain_id, _tid))
226 cache.face_materials = MaterialBase::buildRequiredMaterials(
227 material_consumers, face_materials.getActiveBlockObjects(subdomain_id, _tid), true);
228
229 const auto & neighbor_materials = materials[Moose::NEIGHBOR_MATERIAL_DATA];
230 if (neighbor_materials.hasActiveBlockObjects(neighbor_subdomain_id, _tid))
231 cache.neighbor_materials = MaterialBase::buildRequiredMaterials(
232 material_consumers,
233 neighbor_materials.getActiveBlockObjects(neighbor_subdomain_id, _tid),
234 true);
235
236 return cache;
237}
std::map< std::pair< SubdomainID, SubdomainID >, InternalSideMaterialReinitCache > _internal_side_material_reinit_cache
std::vector< InternalSideUserObject * > _internal_side_objs
@ FACE_MATERIAL_DATA
Definition MooseTypes.h:753

Referenced by onInternalSide().

◆ getRequiredBoundaryMaterials()

void ThreadedElementLoop< ConstElemRange >::getRequiredBoundaryMaterials ( const std::vector< const MaterialPropertyInterface * > &  material_consumers,
BoundaryID  bnd_id,
SubdomainID  subdomain_id,
std::deque< MaterialBase * > &  required_face_materials,
std::deque< MaterialBase * > &  required_boundary_materials 
) const
protectedinherited

Determine the face and boundary materials required by material property consumers.

Definition at line 63 of file ThreadedElementLoop.h.

216{
217 required_face_materials.clear();
218 required_boundary_materials.clear();
219
220 std::unordered_set<unsigned int> needed_face_props;
221 for (const auto * const consumer : material_consumers)
222 {
223 const auto & dependencies = consumer->getMatPropDependencies();
224 needed_face_props.insert(dependencies.begin(), dependencies.end());
225 }
226
227 const auto & materials = _fe_problem.getRegularMaterialsWarehouse();
228 // Resolve boundary materials first. A boundary material can depend on a property supplied by a
229 // face material, while a property supplied by the boundary-material chain does not also need a
230 // face producer.
231 if (!material_consumers.empty() && materials.hasActiveBoundaryObjects(bnd_id, this->_tid))
232 required_boundary_materials = MaterialBase::buildRequiredMaterials(
233 material_consumers, materials.getActiveBoundaryObjects(bnd_id, this->_tid), true);
234 for (const auto * const material : required_boundary_materials)
235 {
236 const auto & dependencies = material->getMatPropDependencies();
237 needed_face_props.insert(dependencies.begin(), dependencies.end());
238 }
239 // The boundary-material chain has already satisfied these properties. Removing them prevents a
240 // face material that happens to declare the same property from being selected unnecessarily.
241 for (const auto * const material : required_boundary_materials)
242 for (const auto supplied_prop : material->getSuppliedPropIDs())
243 needed_face_props.erase(supplied_prop);
244
245 struct MaterialDependencyConsumer
246 {
247 const std::unordered_set<unsigned int> & dependencies;
248 const std::unordered_set<unsigned int> & getMatPropDependencies() const { return dependencies; }
249 };
250 if (!needed_face_props.empty())
251 {
252 const auto & face_materials = materials[Moose::FACE_MATERIAL_DATA];
253 if (face_materials.hasActiveBlockObjects(subdomain_id, this->_tid))
254 {
255 const MaterialDependencyConsumer face_consumer{needed_face_props};
256 const std::vector<const MaterialDependencyConsumer *> face_consumers{&face_consumer};
257 required_face_materials = MaterialBase::buildRequiredMaterials(
258 face_consumers, face_materials.getActiveBlockObjects(subdomain_id, this->_tid), true);
259 }
260 }
261}
for(PetscInt i=0;i< nvars;++i)

◆ join()

void ComputeUserObjectsThread::join ( const ComputeUserObjectsThread &  )

Definition at line 473 of file ComputeUserObjectsThread.C.

474{
475}

◆ keepGoing()

virtual bool ThreadedElementLoop< ConstElemRange >::keepGoing ( )
inlineoverridevirtualinherited

Whether or not the loop should continue.

Returns
true to keep going, false to stop.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 46 of file ThreadedElementLoop.h.

46{ return !_fe_problem.hasException(); }
virtual bool hasException()
Whether or not an exception has occurred.

◆ neighborSubdomainChanged()

void ThreadedElementLoop< ConstElemRange >::neighborSubdomainChanged ( )
overridevirtualinherited

Called every time the neighbor subdomain changes (i.e.

the subdomain of this neighbor is not the same as the subdomain of the last neighbor). Beware of over-using this! You might think that you can do some expensive stuff in here and get away with it... but there are applications that have TONS of subdomains....

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 57 of file ThreadedElementLoop.h.

147{
150}
virtual void neighborSubdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
Base class for assembly-like calculations.

◆ onBoundary()

void ComputeUserObjectsThread::onBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
const Elem *  lower_d_elem = nullptr 
)
overridevirtual

Called when doing boundary assembling.

Parameters
elem- The element we are checking is on the boundary.
side- The side of the element in question.
bnd_id- ID of the boundary we are at
lower_d_elem- Lower dimensional element (e.g. Mortar)

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 290 of file ComputeUserObjectsThread.C.

294{
295 std::vector<UserObject *> userobjs;
296 queryBoundary(Interfaces::SideUserObject, bnd_id, userobjs);
297
298 bool has_domain_objs = false;
299 // we need to check all domain user objects because if the boundary is included as an interface
300 // boundary, it will be handled by onInterface
301 for (const auto * const domain_uo : _domain_objs)
302 if (domain_uo->shouldExecuteOnBoundary())
303 {
304 has_domain_objs = true;
305 break;
306 }
307
308 if (userobjs.size() == 0 && !has_domain_objs)
309 return;
310
311 _fe_problem.reinitElemFace(elem, side, _tid);
312
313 // Reinitialize lower-dimensional variables for use in boundary Materials
314 if (lower_d_elem)
315 _fe_problem.reinitLowerDElem(lower_d_elem, _tid);
316
317 const auto & required_mats = getBoundaryMaterialReinitCache(bnd_id, elem->subdomain_id());
318
319 // Set up Sentinel class so that, even if reinitMaterialsFace() throws, we
320 // still remember to swap back during stack unwinding.
322
323 // TODO: Explore whether stateful material property data needs to be swapped in user object
324 // loops by changing swap_stateful=false in the following calls.
326 bnd_id, elem->subdomain_id(), _tid, true, &required_mats.face_materials);
327 _fe_problem.reinitMaterialsBoundary(bnd_id, _tid, true, &required_mats.boundary_materials);
328
329 for (const auto & uo : userobjs)
330 uo->execute();
331
332 for (auto & uo : _domain_objs)
333 if (uo->shouldExecuteOnBoundary())
334 {
335 uo->preExecuteOnBoundary();
336 uo->executeOnBoundary();
337 }
338
339 // UserObject Jacobians
340 std::vector<ShapeSideUserObject *> shapers;
342 if (_fe_problem.currentlyComputingJacobian() && shapers.size() > 0)
343 {
344 // Prepare shape functions for ShapeSideUserObjects
345 const auto & jacobian_moose_vars = _fe_problem.getUserObjectJacobianVariables(_tid);
346 for (const auto & jvar : jacobian_moose_vars)
347 {
348 unsigned int jvar_id = jvar->number();
349 auto && dof_indices = jvar->dofIndices();
350
352
353 for (const auto & uo : shapers)
354 uo->executeJacobianWrapper(jvar_id, dof_indices);
355 }
356 }
357}
@ ShapeSideUserObject
const BoundaryMaterialReinitCache & getBoundaryMaterialReinitCache(BoundaryID bnd_id, SubdomainID subdomain_id)
Return the exact face and boundary materials required while executing on this boundary.
virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid) override
virtual void swapBackMaterialsFace(const THREAD_ID tid)
const std::vector< const MooseVariableFEBase * > & getUserObjectJacobianVariables(const THREAD_ID tid) const
void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
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) override
void reinitMaterialsFaceOnBoundary(const BoundaryID boundary_id, const SubdomainID blk_id, const THREAD_ID tid, const bool swap_stateful=true, const std::deque< MaterialBase * > *const reinit_mats=nullptr)
reinit materials on element faces on a boundary (internal or external) This specific routine helps us...
void reinitMaterialsBoundary(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on a boundary
const bool & currentlyComputingJacobian() const
Returns true if the problem is in the process of computing the Jacobian.
Definition SubProblem.h:695
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,...

◆ onElement()

void ComputeUserObjectsThread::onElement ( const Elem *  elem)
overridevirtual

Assembly of the element (not including surface assembly)

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 118 of file ComputeUserObjectsThread.C.

119{
120 _fe_problem.prepare(elem, _tid);
122
123 // Set up Sentinel class so that, even if reinitMaterials() throws, we
124 // still remember to swap back during stack unwinding.
127
128 for (const auto & uo : _element_objs)
129 {
130 uo->execute();
131
132 // update the aux solution vector if writable coupled variables are used
133 if (uo->hasWritableCoupledVariables())
134 for (auto * var : uo->getWritableCoupledVariables())
135 var->insert(_aux_sys.solution());
136 }
137
138 for (auto & uo : _domain_objs)
139 {
140 uo->preExecuteOnElement();
141 uo->executeOnElement();
142 }
143
144 // UserObject Jacobians
146 {
147 // Prepare shape functions for ShapeElementUserObjects
148 const auto & jacobian_moose_vars = _fe_problem.getUserObjectJacobianVariables(_tid);
149 for (const auto & jvar : jacobian_moose_vars)
150 {
151 unsigned int jvar_id = jvar->number();
152 auto && dof_indices = jvar->dofIndices();
153
155 for (const auto uo : _shape_element_objs)
156 uo->executeJacobianWrapper(jvar_id, dof_indices);
157 }
158 }
159}
std::vector< ElementUserObject * > _element_objs
std::vector< ShapeElementUserObject * > _shape_element_objs
virtual void prepareShapes(unsigned int var, const THREAD_ID tid) override
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
virtual void swapBackMaterials(const THREAD_ID tid)
SubdomainID _subdomain
The subdomain for the current element.

◆ onExternalSide()

void ComputeUserObjectsThread::onExternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtual

Called when iterating over external sides (no side neighbor)

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 396 of file ComputeUserObjectsThread.C.

397{
398 // We are not initializing any materials here because objects that perform calculations should
399 // run onBoundary. onExternalSide should be used for mesh updates (e.g. adding/removing
400 // boundaries). Note that _current_elem / _current_side are not getting updated either.
401 for (auto & uo : _domain_objs)
402 uo->executeOnExternalSide(elem, side);
403}

◆ onInterface()

void ComputeUserObjectsThread::onInterface ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
overridevirtual

Called when doing interface assembling.

Parameters
elem- Element we are on
side- local side number of the element 'elem'
bnd_id- ID of the interface we are at

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 406 of file ComputeUserObjectsThread.C.

407{
408 // Pointer to the neighbor we are currently working on.
409 const Elem * neighbor = elem->neighbor_ptr(side);
410 if (!(neighbor->active()))
411 return;
412
413 std::vector<UserObject *> interface_objs;
414 queryBoundary(Interfaces::InterfaceUserObject, bnd_id, interface_objs);
415
416 bool has_domain_objs = false;
417 // we need to check all domain user objects because a domain user object may not be active
418 // on the current subdomain but should be executed on the interface that it attaches to
419 for (const auto * const domain_uo : _all_domain_objs)
420 if (domain_uo->shouldExecuteOnInterface())
421 {
422 has_domain_objs = true;
423 break;
424 }
425
426 // if we do not have any interface user objects and domain user objects on the current
427 // interface
428 if (interface_objs.empty() && !has_domain_objs)
429 return;
430
432 _fe_problem.reinitNeighbor(elem, side, _tid);
433
434 const auto & required_mats = getInterfaceMaterialReinitCache(
435 bnd_id, elem->subdomain_id(), neighbor->subdomain_id(), interface_objs);
436
437 // Set up Sentinels so that, even if one of the reinitMaterialsXXX() calls throws, we
438 // still remember to swap back during stack unwinding.
439
442 bnd_id, elem->subdomain_id(), _tid, true, &required_mats.face_materials);
443 _fe_problem.reinitMaterialsBoundary(bnd_id, _tid, true, &required_mats.boundary_materials);
444
447 neighbor->subdomain_id(), _tid, true, &required_mats.neighbor_materials);
448 // Has to happen after face and neighbor properties have been computed. Note that we don't use
449 // a sentinel here because FEProblem::swapBackMaterialsFace is going to handle face materials,
450 // boundary materials, and interface materials (e.g. it queries the boundary material data
451 // with the current element and side
453
454 for (const auto & uo : interface_objs)
455 uo->execute();
456
457 for (auto & uo : _all_domain_objs)
458 if (uo->shouldExecuteOnInterface())
459 {
460 uo->preExecuteOnInterface();
461 uo->executeOnInterface();
462 }
463}
@ InterfaceUserObject
const InterfaceMaterialReinitCache & getInterfaceMaterialReinitCache(BoundaryID bnd_id, SubdomainID subdomain_id, SubdomainID neighbor_subdomain_id, const std::vector< UserObject * > &interface_objs)
Return the face, boundary, and neighbor materials required while executing on this interface.
void reinitMaterialsNeighbor(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on the neighboring element face
virtual void swapBackMaterialsNeighbor(const THREAD_ID tid)
virtual void prepareFace(const Elem *elem, const THREAD_ID tid) override
void reinitMaterialsInterface(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true)
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid) override

◆ onInternalSide()

void ComputeUserObjectsThread::onInternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtual

Called when doing internal edge assembling.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 360 of file ComputeUserObjectsThread.C.

361{
362 // Pointer to the neighbor we are currently working on.
363 const Elem * neighbor = elem->neighbor_ptr(side);
364
365 if (_internal_side_objs.size() == 0 && _domain_objs.size() == 0)
366 return;
367
369 _fe_problem.reinitNeighbor(elem, side, _tid);
370
371 const auto & required_mats =
372 getInternalSideMaterialReinitCache(elem->subdomain_id(), neighbor->subdomain_id());
373
374 // Set up Sentinels so that, even if one of the reinitMaterialsXXX() calls throws, we
375 // still remember to swap back during stack unwinding.
377 _fe_problem.reinitMaterialsFace(elem->subdomain_id(), _tid, true, &required_mats.face_materials);
378
381 neighbor->subdomain_id(), _tid, true, &required_mats.neighbor_materials);
382
383 for (const auto & uo : _internal_side_objs)
384 if (!uo->blockRestricted() || uo->hasBlocks(neighbor->subdomain_id()))
385 uo->execute();
386
387 for (auto & uo : _domain_objs)
388 if (!uo->blockRestricted() || uo->hasBlocks(neighbor->subdomain_id()))
389 {
390 uo->preExecuteOnInternalSide();
391 uo->executeOnInternalSide();
392 }
393}
const InternalSideMaterialReinitCache & getInternalSideMaterialReinitCache(SubdomainID subdomain_id, SubdomainID neighbor_subdomain_id)
Return the face and neighbor materials required while executing on this internal side.
void reinitMaterialsFace(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
reinit materials on element faces

◆ operator()()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::operator() ( const RangeType &  range,
bool  bypass_threading = false 
)
virtualinherited

Definition at line 226 of file ThreadedElementLoopBase.h.

227{
228 try
229 {
230 try
231 {
232 ParallelUniqueId puid;
233 _tid = bypass_threading ? 0 : puid.id;
234
235 pre();
237
240 typename RangeType::const_iterator el = range.begin();
241 for (el = range.begin(); el != range.end(); ++el)
242 {
243 if (!keepGoing())
244 break;
245
246 const Elem * elem = *el;
247
248 preElement(elem);
249
251 _subdomain = elem->subdomain_id();
253 {
256 }
257
258 onElement(elem);
259
260 if (_mesh.interiorLowerDBlocks().count(elem->subdomain_id()) > 0 ||
261 _mesh.boundaryLowerDBlocks().count(elem->subdomain_id()) > 0)
262 {
263 postElement(elem);
264 continue;
265 }
266
267 const auto elem_boundary_ids = _mesh.getBoundaryIDs(elem);
268 for (unsigned int side = 0; side < elem->n_sides(); side++)
269 {
270 const auto & boundary_ids = elem_boundary_ids[side];
271 const Elem * lower_d_elem = _mesh.getLowerDElem(elem, side);
272
273 for (const auto bnd_id : boundary_ids)
274 {
275 preBoundary(elem, side, bnd_id, lower_d_elem);
277 onBoundary(elem, side, bnd_id, lower_d_elem);
278 }
279
280 const Elem * neighbor = elem->neighbor_ptr(side);
281 if (neighbor)
282 {
283 preInternalSide(elem, side);
284
286 _neighbor_subdomain = neighbor->subdomain_id();
289
290 if (shouldComputeInternalSide(*elem, *neighbor))
291 onInternalSide(elem, side);
292
293 for (const auto bnd_id : boundary_ids)
294 {
295 preBoundary(elem, side, bnd_id);
296 onInterface(elem, side, bnd_id);
297 }
298
299 postInternalSide(elem, side);
300 }
301 else
302 onExternalSide(elem, side);
303 } // sides
304
305 postElement(elem);
306 } // range
307
308 post();
310 }
311 catch (MetaPhysicL::LogicError & e)
312 {
314 }
315 catch (std::exception & e)
316 {
317 // Continue if we find a libMesh degenerate map exception, but
318 // just re-throw for any real error
319 if (!strstr(e.what(), "Jacobian") && !strstr(e.what(), "singular") &&
320 !strstr(e.what(), "det != 0"))
321 throw; // not "throw e;" - that destroys type info!
322
323 mooseException("We caught a libMesh degeneracy exception in ThreadedElementLoopBase:\n",
324 e.what());
325 }
326 }
327 catch (MooseException & e)
328 {
330 }
331}
Provides a way for users to bail out of the current solve.
const Elem * getLowerDElem(const Elem *, unsigned short int) const
Returns a const pointer to a lower dimensional element that corresponds to a side of a higher dimensi...
Definition MooseMesh.C:1682
const std::set< SubdomainID > & interiorLowerDBlocks() const
Definition MooseMesh.h:1555
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side.
Definition MooseMesh.C:3024
const std::set< SubdomainID > & boundaryLowerDBlocks() const
Definition MooseMesh.h:1559
virtual void onExternalSide(const Elem *elem, unsigned int side)
Called when iterating over external sides (no side neighbor)
virtual void caughtMooseException(MooseException &)
Called if a MooseException is caught anywhere during the computation.
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr)
Called when doing boundary assembling.
virtual void printBoundaryExecutionInformation(const unsigned int) const
Print information about the particular ordering of objects on each boundary.
virtual void neighborSubdomainChanged()
Called every time the neighbor subdomain changes (i.e.
virtual void printGeneralExecutionInformation() const
Print information about the loop ordering.
virtual void onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id)
Called when doing interface assembling.
virtual bool keepGoing()
Whether or not the loop should continue.
void resetExecPrintedSets() const
Resets the set of blocks and boundaries visited.
SubdomainID _old_subdomain
The subdomain for the last element.
virtual void preInternalSide(const Elem *elem, unsigned int side)
Called before evaluations on an element internal side.
virtual void postInternalSide(const Elem *elem, unsigned int side)
Called after evaluations on an element internal side.
virtual void subdomainChanged()
Called every time the current subdomain changes (i.e.
virtual void onInternalSide(const Elem *elem, unsigned int side)
Called when doing internal edge assembling.
virtual void preBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr)
Called before the boundary assembly.
virtual void onElement(const Elem *elem)
Assembly of the element (not including surface assembly)
virtual void postElement(const Elem *elem)
Called after the element assembly is done (including surface assembling)
virtual void preElement(const Elem *elem)
Called before the element assembly.
SubdomainID _old_neighbor_subdomain
The subdomain for the last neighbor.
SubdomainID _neighbor_subdomain
The subdomain for the current neighbor.
virtual void printBlockExecutionInformation() const
Print information about the particular ordering of objects on each block.
virtual void post()
Called after the element range loop.
virtual void pre()
Called before the element range loop.
virtual bool shouldComputeInternalSide(const Elem &elem, const Elem &neighbor) const
Whether to compute the internal side for the provided element-neighbor pair.
const SubdomainID INVALID_BLOCK_ID
Definition MooseTypes.C:20
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
Definition MooseError.C:153

Referenced by NonlinearThread::operator()().

◆ post()

void ComputeUserObjectsThread::post ( )
overridevirtual

Called after the element range loop.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 466 of file ComputeUserObjectsThread.C.

◆ postElement()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::postElement ( const Elem *  elem)
virtualinherited

Called after the element assembly is done (including surface assembling)

Parameters
elem- active element

Reimplemented in ComputeDiracThread, ComputeIndicatorThread, ComputeJacobianThread, ComputeMarkerThread, NonlinearThread, and ComputeJacobianBlocksThread.

Definition at line 359 of file ThreadedElementLoopBase.h.

360{
361}

◆ postInternalSide()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::postInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtualinherited

Called after evaluations on an element internal side.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented in ComputeJacobianBlocksThread.

Definition at line 389 of file ThreadedElementLoopBase.h.

390{
391}

◆ pre()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::pre ( )
virtualinherited

Called before the element range loop.

Reimplemented in ComputeDiracThread.

Definition at line 335 of file ThreadedElementLoopBase.h.

336{
337}

Referenced by ComputeJacobianForScalingThread::operator()().

◆ preBoundary()

void ThreadedElementLoop< ConstElemRange >::preBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
const Elem *  lower_d_elem = nullptr 
)
overridevirtualinherited

Called before the boundary assembly.

Parameters
elem- The element we are checking is on the boundary.
side- The side of the element in question.
bnd_id- ID of the boundary we are at
lower_d_elem- Lower dimensional element (e.g. Mortar)

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 52 of file ThreadedElementLoop.h.

140{
142}
virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid) override
sets the current boundary ID in assembly

◆ preElement()

void ThreadedElementLoop< ConstElemRange >::preElement ( const Elem *  elem)
overridevirtualinherited

Called before the element assembly.

Parameters
elem- active element

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 48 of file ThreadedElementLoop.h.

123{
125}
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override

◆ preInternalSide()

void ThreadedElementLoop< ConstElemRange >::preInternalSide ( const Elem *  elem,
unsigned int  side 
)
overridevirtualinherited

Called before evaluations on an element internal side.

Parameters
elem- Element we are on
side- local side number of the element 'elem'

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 50 of file ThreadedElementLoop.h.

130{
132}
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override

◆ prepareElement()

void ThreadedElementLoop< ConstElemRange >::prepareElement ( const Elem *  elem)
protectedinherited

Definition at line 60 of file ThreadedElementLoop.h.

194{
195 _fe_problem.prepare(elem, this->_tid);
196 _fe_problem.reinitElem(elem, this->_tid);
198}

◆ printBlockExecutionInformation()

void ComputeUserObjectsThread::printBlockExecutionInformation ( ) const
overrideprotectedvirtual

Print information about the loop, mostly order of execution of particular objects.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 508 of file ComputeUserObjectsThread.C.

509{
511 return;
512
513 // Gather all user objects that may execute
514 // TODO: restrict this gathering of boundary objects to boundaries that are present
515 // in the current block
516 std::vector<ShapeSideUserObject *> shapers;
517 const_cast<ComputeUserObjectsThread *>(this)->queryBoundary(
519
520 std::vector<SideUserObject *> side_uos;
521 const_cast<ComputeUserObjectsThread *>(this)->queryBoundary(
523
524 std::vector<InterfaceUserObject *> interface_objs;
525 const_cast<ComputeUserObjectsThread *>(this)->queryBoundary(
527
528 std::vector<const DomainUserObject *> domain_interface_uos;
529 for (const auto * const domain_uo : _domain_objs)
530 if (domain_uo->shouldExecuteOnInterface())
531 domain_interface_uos.push_back(domain_uo);
532
533 // Approximation of the number of user objects currently executing
534 const auto num_objects = _element_objs.size() + _domain_objs.size() + _shape_element_objs.size() +
535 side_uos.size() + shapers.size() + _internal_side_objs.size() +
536 interface_objs.size() + domain_interface_uos.size();
537
538 const auto & console = _fe_problem.console();
539 const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
540
541 if (num_objects > 0)
542 {
544 return;
545
546 console << "[DBG] Ordering of User Objects on block " << _subdomain << std::endl;
547 // Output specific ordering of objects
548 printExecutionOrdering<ElementUserObject>(_element_objs, "element user objects");
549 printExecutionOrdering<DomainUserObject>(_domain_objs, "domain user objects");
551 printExecutionOrdering<ShapeElementUserObject>(
552 _shape_element_objs, "element user objects contributing to the Jacobian");
553 printExecutionOrdering<SideUserObject>(side_uos, "side user objects");
555 printExecutionOrdering<ShapeSideUserObject>(shapers,
556 "side user objects contributing to the Jacobian");
557 printExecutionOrdering<InternalSideUserObject>(_internal_side_objs,
558 "internal side user objects");
559 printExecutionOrdering<InterfaceUserObject>(interface_objs, "interface user objects");
560 console << "[DBG] Only user objects active on local element/sides are executed" << std::endl;
561 }
562 else if (num_objects == 0 && !_blocks_exec_printed.count(_subdomain))
563 console << "[DBG] No User Objects on block " << _subdomain << " on " << execute_on.name()
564 << std::endl;
565
566 // Mark subdomain as having printed to avoid printing again
568}
Class for threaded computation of UserObjects.
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
const ConsoleStream & console() const
Return console handle.
Definition Problem.h:48
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
const BoundaryID ANY_BOUNDARY_ID
Definition MooseTypes.C:21

◆ printBoundaryExecutionInformation()

template<typename RangeType >
virtual void ThreadedElementLoopBase< RangeType >::printBoundaryExecutionInformation ( const unsigned int  ) const
inlineprotectedvirtualinherited

Print information about the particular ordering of objects on each boundary.

Reimplemented in NonlinearThread.

Definition at line 187 of file ThreadedElementLoopBase.h.

187{}

◆ printExecutionOrdering() [1/2]

void ThreadedElementLoop< ConstElemRange >::printExecutionOrdering ( const std::vector< std::shared_ptr< T > > &  objs_ptrs,
const bool  print_header = true,
const std::string &  line_prefix = "[DBG]" 
) const
protectedinherited

Definition at line 87 of file ThreadedElementLoop.h.

184{
185 std::vector<T *> regular_ptrs;
186 for (auto shared_ptr : objs_ptrs)
187 regular_ptrs.push_back(shared_ptr.get());
188 printExecutionOrdering<T>(regular_ptrs, print_header, line_prefix);
189}

◆ printExecutionOrdering() [2/2]

void ThreadedElementLoop< ConstElemRange >::printExecutionOrdering ( const std::vector< T * > &  objs,
const bool  print_header = true,
const std::string &  line_prefix = "[DBG]" 
) const
protectedinherited

Routine to output the ordering of objects within a vector of pointers to these objects.

These objects must implement the name() routine, and it must return a string or compatible type.

Template Parameters
Tthe object type
Parameters
objsthe vector with all the objects (should be pointers)
objects_typethe name of the type of objects. Defaults to the CPP object name
print_headerwhether to print a header about the timing of execution and the type of objects

Definition at line 83 of file ThreadedElementLoop.h.

158{
159 if (!objs.size())
160 return;
161
162 auto & console = _fe_problem.console();
163 const auto objects_type = MooseUtils::prettyCppType(objs[0]);
164 std::vector<MooseObject *> moose_objs;
165 for (auto obj_ptr : objs)
166 moose_objs.push_back(dynamic_cast<MooseObject *>(obj_ptr));
167 const auto names = ConsoleUtils::mooseObjectVectorToString(moose_objs);
168
169 // Print string with a DBG prefix and with sufficient line breaks
170 std::string message = print_header ? "Executing " + objects_type + " on " +
172 : "";
173 message += (print_header ? "Order of execution:\n" : "") + names;
174 console << ConsoleUtils::formatString(message, line_prefix) << std::endl;
175}
const std::string & name() const
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
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...
std::string mooseObjectVectorToString(const std::vector< MooseObject * > &objs, const std::string &sep=" ")
Routine to output the name of MooseObjects in a string.
std::string prettyCppType(const std::string &cpp_type)

◆ printGeneralExecutionInformation()

void ComputeUserObjectsThread::printGeneralExecutionInformation ( ) const
overrideprotectedvirtual

Print general information about the loop, like the ordering of class of objects.

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 478 of file ComputeUserObjectsThread.C.

479{
481 {
482 const auto & console = _fe_problem.console();
483 const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
484 console << "[DBG] Computing elemental user objects on " << execute_on << std::endl;
485 mooseDoOnce(console << "[DBG] Execution order of objects types on each element then its sides:"
486 << std::endl;
487 // onElement
488 console << "[DBG] - element user objects" << std::endl;
489 console << "[DBG] - domain user objects" << std::endl;
490 console << "[DBG] - element user objects contributing to the Jacobian" << std::endl;
491
492 // onBoundary
493 console << "[DBG] - side user objects" << std::endl;
494 console << "[DBG] - domain user objects executing on sides" << std::endl;
495 console << "[DBG] - side user objects contributing to the Jacobian" << std::endl;
496
497 // onInternalSide
498 console << "[DBG] - internal side user objects" << std::endl;
499 console << "[DBG] - domain user objects executing on internal sides" << std::endl;
500
501 // onInterface
502 console << "[DBG] - interface user objects" << std::endl;
503 console << "[DBG] - domain user objects executing at interfaces" << std::endl;);
504 }
505}

◆ printVectorOrdering()

template<typename T >
void ComputeUserObjectsThread::printVectorOrdering ( std::vector< T * >  uos,
const std::string &  name 
) const
protected

Format output of vector of UOs.

◆ queryBoundary()

template<typename T >
void ComputeUserObjectsThread::queryBoundary ( Interfaces  iface,
BoundaryID  bnd,
std::vector< T > &  results 
)
inlineprivate

Definition at line 77 of file ComputeUserObjectsThread.h.

78 {
79 _query_boundary.queryInto(results, _tid, std::make_tuple(bnd, false), iface);
80 }
std::vector< T * > & queryInto(std::vector< T * > &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.

Referenced by getBoundaryMaterialReinitCache(), onBoundary(), onInterface(), and printBlockExecutionInformation().

◆ querySubdomain()

template<typename T >
void ComputeUserObjectsThread::querySubdomain ( Interfaces  iface,
std::vector< T > &  results 
)
inlineprivate

Definition at line 72 of file ComputeUserObjectsThread.h.

73 {
74 _query_subdomain.queryInto(results, _tid, _subdomain, iface);
75 }

Referenced by subdomainChanged().

◆ resetExecPrintedSets()

template<typename RangeType >
void ThreadedElementLoopBase< RangeType >::resetExecPrintedSets ( ) const
protectedinherited

Resets the set of blocks and boundaries visited.

Definition at line 457 of file ThreadedElementLoopBase.h.

458{
459 _blocks_exec_printed.clear();
461}
std::set< BoundaryID > _boundaries_exec_printed
Keep track of which boundaries were visited.

◆ shouldComputeInternalSide()

template<typename RangeType >
bool ThreadedElementLoopBase< RangeType >::shouldComputeInternalSide ( const Elem &  elem,
const Elem &  neighbor 
) const
protectedvirtualinherited

Whether to compute the internal side for the provided element-neighbor pair.

Typically this will return true if the element id is less than the neighbor id when the elements are equal level, or when the element is more refined than the neighbor, and then false otherwise. One type of loop where the logic will be different is when projecting stateful material properties

Reimplemented in FlagElementsThread, ProjectMaterialProperties, CacheChangedListsThread, and NonlinearThread.

Definition at line 427 of file ThreadedElementLoopBase.h.

429{
430 // If we're going to compute the internal side with this elem-neighbor pair, then they must both
431 // be active. Note that if elem is an active coarse element at an interface with finer elements,
432 // then its neighbor will be an equal-level inactive element, hence the following
433 // neighbor.active() check. In that case we'll catch current 'elem' when we come around and
434 // examine one of the finer elements as 'elem'
435 mooseAssert(elem.active(), "This method should never be called with an inactive element");
436 if (!neighbor.active())
437 return false;
438
439 //
440 // Define an ordering: first prefer finer by h (higher level()), then prefer finer by p (higher
441 // p_level()), then prefer smaller id()"
442 //
443
444 const auto elem_level = elem.level(), neighbor_level = neighbor.level();
445 if (elem_level != neighbor_level)
446 return elem_level > neighbor_level;
447
448 const auto elem_p_level = elem.p_level(), neighbor_p_level = neighbor.p_level();
449 if (elem_p_level != neighbor_p_level)
450 return elem_p_level > neighbor_p_level;
451
452 return elem.id() < neighbor.id();
453}

Referenced by NonlinearThread::shouldComputeInternalSide().

◆ subdomainChanged()

void ComputeUserObjectsThread::subdomainChanged ( )
overridevirtual

Called every time the current subdomain changes (i.e.

the subdomain of this element is not the same as the subdomain of the last element). Beware of over-using this! You might think that you can do some expensive stuff in here and get away with it... but there are applications that have TONS of subdomains....

Reimplemented from ThreadedElementLoopBase< RangeType >.

Definition at line 52 of file ComputeUserObjectsThread.C.

53{
54 // for the current thread get block objects for the current subdomain and *all* side objects
55 std::vector<UserObject *> objs;
58 objs);
59
62 .condition<AttribInterfaces>(Interfaces::DomainUserObject)
63 .queryInto(_all_domain_objs);
64
65 std::vector<UserObject *> side_objs;
68 .condition<AttribInterfaces>(Interfaces::SideUserObject)
69 .queryInto(side_objs);
70
71 objs.insert(objs.begin(), side_objs.begin(), side_objs.end());
72
73 // collect dependencies and run subdomain setup
75
76 std::set<MooseVariableFEBase *> needed_moose_vars;
77 std::unordered_set<unsigned int> needed_mat_props;
78 std::set<TagID> needed_fe_var_vector_tags;
79 for (const auto obj : objs)
80 {
81 auto v_obj = dynamic_cast<MooseVariableDependencyInterface *>(obj);
82 if (v_obj)
83 {
84 const auto & v_deps = v_obj->getMooseVariableDependencies();
85 needed_moose_vars.insert(v_deps.begin(), v_deps.end());
86 }
87
88 auto m_obj = dynamic_cast<MaterialPropertyInterface *>(obj);
89 if (m_obj)
90 {
91 auto & m_deps = m_obj->getMatPropDependencies();
92 needed_mat_props.insert(m_deps.begin(), m_deps.end());
93 }
94
95 auto c_obj = dynamic_cast<Coupleable *>(obj);
96 if (c_obj)
97 {
98 const auto & tag_deps = c_obj->getFEVariableCoupleableVectorTags();
99 needed_fe_var_vector_tags.insert(tag_deps.begin(), tag_deps.end());
100 }
101
102 obj->subdomainSetup();
103 }
105 _subdomain, needed_fe_var_vector_tags, _tid);
106
108 _fe_problem.setActiveFEVariableCoupleableVectorTags(needed_fe_var_vector_tags, _tid);
109 _fe_problem.prepareMaterials(needed_mat_props, _subdomain, _tid);
110
115}
@ InternalSideUserObject
@ ShapeElementUserObject
void querySubdomain(Interfaces iface, std::vector< T > &results)
Interface for objects that needs coupling capabilities.
Definition Coupleable.h:53
std::set< TagID > & getFEVariableCoupleableVectorTags()
Definition Coupleable.h:120
const MaterialWarehouse & getMaterialWarehouse() const
void prepareMaterials(const std::unordered_set< unsigned int > &consumer_needed_mat_props, const SubdomainID blk_id, const THREAD_ID tid)
Add the MooseVariables and the material properties that the current materials depend on to the depend...
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
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
virtual const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
const std::set< MooseVariableFieldBase * > & getMooseVariableDependencies() const
Retrieve the set of MooseVariableFieldBase that this object depends on.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
QueryCache clone() const
clone creates and returns an independent copy of the query in its current state.

Member Data Documentation

◆ _all_domain_objs

std::vector<DomainUserObject *> ComputeUserObjectsThread::_all_domain_objs
private

◆ _aux_sys

AuxiliarySystem& ComputeUserObjectsThread::_aux_sys
private

Definition at line 124 of file ComputeUserObjectsThread.h.

Referenced by onElement().

◆ _blocks_exec_printed

template<typename RangeType >
std::set<SubdomainID> ThreadedElementLoopBase< RangeType >::_blocks_exec_printed
mutableprotectedinherited

◆ _boundaries_exec_printed

template<typename RangeType >
std::set<BoundaryID> ThreadedElementLoopBase< RangeType >::_boundaries_exec_printed
mutableprotectedinherited

Keep track of which boundaries were visited.

Definition at line 193 of file ThreadedElementLoopBase.h.

Referenced by NonlinearThread::printBoundaryExecutionInformation().

◆ _boundary_material_reinit_cache

std::map<std::pair<BoundaryID, SubdomainID>, BoundaryMaterialReinitCache> ComputeUserObjectsThread::_boundary_material_reinit_cache
private

Definition at line 130 of file ComputeUserObjectsThread.h.

Referenced by getBoundaryMaterialReinitCache().

◆ _domain_objs

std::vector<DomainUserObject *> ComputeUserObjectsThread::_domain_objs
private

◆ _element_objs

std::vector<ElementUserObject *> ComputeUserObjectsThread::_element_objs
private

◆ _fe_problem

FEProblemBase& ThreadedElementLoop< ConstElemRange >::_fe_problem
protectedinherited

Definition at line 69 of file ThreadedElementLoop.h.

◆ _interface_material_reinit_cache

std::map<std::tuple<BoundaryID, SubdomainID, SubdomainID>, InterfaceMaterialReinitCache> ComputeUserObjectsThread::_interface_material_reinit_cache
private

Definition at line 134 of file ComputeUserObjectsThread.h.

Referenced by getInterfaceMaterialReinitCache().

◆ _interface_user_objects

std::vector<InterfaceUserObject *> ComputeUserObjectsThread::_interface_user_objects
private

Definition at line 118 of file ComputeUserObjectsThread.h.

◆ _internal_side_material_reinit_cache

std::map<std::pair<SubdomainID, SubdomainID>, InternalSideMaterialReinitCache> ComputeUserObjectsThread::_internal_side_material_reinit_cache
private

Definition at line 132 of file ComputeUserObjectsThread.h.

Referenced by getInternalSideMaterialReinitCache().

◆ _internal_side_objs

std::vector<InternalSideUserObject *> ComputeUserObjectsThread::_internal_side_objs
private

◆ _mesh

template<typename RangeType >
MooseMesh& ThreadedElementLoopBase< RangeType >::_mesh
protectedinherited

◆ _neighbor_subdomain

template<typename RangeType >
SubdomainID ThreadedElementLoopBase< RangeType >::_neighbor_subdomain
protectedinherited

◆ _old_neighbor_subdomain

template<typename RangeType >
SubdomainID ThreadedElementLoopBase< RangeType >::_old_neighbor_subdomain
protectedinherited

The subdomain for the last neighbor.

Definition at line 178 of file ThreadedElementLoopBase.h.

◆ _old_subdomain

template<typename RangeType >
SubdomainID ThreadedElementLoopBase< RangeType >::_old_subdomain
protectedinherited

The subdomain for the last element.

Definition at line 172 of file ThreadedElementLoopBase.h.

Referenced by ComputeJacobianForScalingThread::operator()().

◆ _query

const TheWarehouse::Query ComputeUserObjectsThread::_query
private

Definition at line 114 of file ComputeUserObjectsThread.h.

Referenced by subdomainChanged().

◆ _query_boundary

TheWarehouse::QueryCache<AttribThread, AttribBoundaries, AttribInterfaces> ComputeUserObjectsThread::_query_boundary
private

Definition at line 116 of file ComputeUserObjectsThread.h.

Referenced by queryBoundary().

◆ _query_subdomain

TheWarehouse::QueryCache<AttribThread, AttribSubdomains, AttribInterfaces> ComputeUserObjectsThread::_query_subdomain
private

Definition at line 115 of file ComputeUserObjectsThread.h.

Referenced by querySubdomain().

◆ _shape_element_objs

std::vector<ShapeElementUserObject *> ComputeUserObjectsThread::_shape_element_objs
private

◆ _subdomain

template<typename RangeType >
SubdomainID ThreadedElementLoopBase< RangeType >::_subdomain
protectedinherited

The subdomain for the current element.

Definition at line 169 of file ThreadedElementLoopBase.h.

Referenced by ComputeFullJacobianThread::computeOnBoundary(), NonlinearThread::computeOnElement(), ComputeFullJacobianThread::computeOnElement(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), ComputeResidualAndJacobianThread::computeOnInternalFace(), ComputeResidualThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), NonlinearThread::computeOnInternalFace(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), ComputeResidualThread::determineObjectWarehouses(), ComputeMaterialsObjectThread::onBoundary(), ComputeDiracThread::onElement(), ComputeIndicatorThread::onElement(), ComputeMarkerThread::onElement(), ComputeMaterialsObjectThread::onElement(), onElement(), ComputeMaterialsObjectThread::onInterface(), ComputeMaterialsObjectThread::onInternalSide(), ComputeJacobianForScalingThread::operator()(), ComputeJacobianBlocksThread::postInternalSide(), ComputeDiracThread::printBlockExecutionInformation(), ComputeIndicatorThread::printBlockExecutionInformation(), ComputeMarkerThread::printBlockExecutionInformation(), printBlockExecutionInformation(), NonlinearThread::printBlockExecutionInformation(), querySubdomain(), ComputeDiracThread::subdomainChanged(), ComputeIndicatorThread::subdomainChanged(), ComputeMarkerThread::subdomainChanged(), ComputeMaterialsObjectThread::subdomainChanged(), subdomainChanged(), NonlinearThread::subdomainChanged(), and ProjectMaterialProperties::subdomainChanged().

◆ _tid

template<typename RangeType >
THREAD_ID ThreadedElementLoopBase< RangeType >::_tid
protectedinherited

Definition at line 166 of file ThreadedElementLoopBase.h.

Referenced by ComputeResidualAndJacobianThread::accumulate(), ComputeResidualThread::accumulate(), ComputeJacobianThread::accumulateLower(), ComputeResidualAndJacobianThread::accumulateLower(), ComputeResidualThread::accumulateLower(), ComputeJacobianThread::accumulateNeighbor(), ComputeResidualAndJacobianThread::accumulateNeighbor(), ComputeResidualThread::accumulateNeighbor(), ComputeJacobianThread::accumulateNeighborLower(), ComputeResidualAndJacobianThread::accumulateNeighborLower(), ComputeResidualThread::accumulateNeighborLower(), NonlinearThread::computeOnBoundary(), ComputeFullJacobianThread::computeOnBoundary(), NonlinearThread::computeOnElement(), ComputeFullJacobianThread::computeOnElement(), NonlinearThread::computeOnInterface(), ComputeFullJacobianThread::computeOnInterface(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), ComputeResidualAndJacobianThread::computeOnInternalFace(), ComputeResidualThread::computeOnInternalFace(), ComputeJacobianThread::computeOnInternalFace(), NonlinearThread::computeOnInternalFace(), ComputeFullJacobianThread::computeOnInternalFace(), ComputeJacobianThread::determineObjectWarehouses(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), ComputeResidualThread::determineObjectWarehouses(), getInterfaceMaterialReinitCache(), getInternalSideMaterialReinitCache(), ComputeMaterialsObjectThread::onBoundary(), onBoundary(), NonlinearThread::onBoundary(), ProjectMaterialProperties::onBoundary(), ComputeDiracThread::onElement(), ComputeElemDampingThread::onElement(), ComputeIndicatorThread::onElement(), ComputeMarkerThread::onElement(), ComputeMaterialsObjectThread::onElement(), onElement(), NonlinearThread::onElement(), ProjectMaterialProperties::onElement(), UpdateErrorVectorsThread::onElement(), NonlinearThread::onExternalSide(), ComputeMaterialsObjectThread::onInterface(), onInterface(), NonlinearThread::onInterface(), NonlinearThread::onInterfaceWithHRefinementMismatch(), ComputeIndicatorThread::onInternalSide(), ComputeMaterialsObjectThread::onInternalSide(), onInternalSide(), NonlinearThread::onInternalSide(), ProjectMaterialProperties::onInternalSide(), ComputeJacobianForScalingThread::operator()(), ComputeDiracThread::post(), ComputeIndicatorThread::post(), ComputeMarkerThread::post(), ComputeMaterialsObjectThread::post(), post(), ComputeDiracThread::postElement(), ComputeJacobianThread::postElement(), ComputeJacobianBlocksThread::postElement(), ComputeJacobianBlocksThread::postInternalSide(), ComputeDiracThread::pre(), NonlinearThread::prepareFace(), ComputeDiracThread::printBlockExecutionInformation(), ComputeIndicatorThread::printBlockExecutionInformation(), ComputeMarkerThread::printBlockExecutionInformation(), printBlockExecutionInformation(), NonlinearThread::printBlockExecutionInformation(), NonlinearThread::printBoundaryExecutionInformation(), ComputeDiracThread::printGeneralExecutionInformation(), ComputeElemDampingThread::printGeneralExecutionInformation(), ComputeIndicatorThread::printGeneralExecutionInformation(), ComputeMarkerThread::printGeneralExecutionInformation(), printGeneralExecutionInformation(), NonlinearThread::printGeneralExecutionInformation(), queryBoundary(), querySubdomain(), ComputeDiracThread::subdomainChanged(), ComputeIndicatorThread::subdomainChanged(), ComputeMarkerThread::subdomainChanged(), ComputeMaterialsObjectThread::subdomainChanged(), subdomainChanged(), NonlinearThread::subdomainChanged(), and ProjectMaterialProperties::subdomainChanged().


The documentation for this class was generated from the following files: