https://mooseframework.inl.gov
ComputeMarkerThread.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 "ComputeMarkerThread.h"
12 #include "AuxiliarySystem.h"
13 #include "Problem.h"
14 #include "FEProblem.h"
15 #include "Marker.h"
16 #include "MooseVariableFE.h"
17 #include "SwapBackSentinel.h"
18 
19 #include "libmesh/threads.h"
20 
22  : ThreadedElementLoop<ConstElemRange>(fe_problem),
23  _fe_problem(fe_problem),
24  _aux_sys(fe_problem.getAuxiliarySystem()),
25  _marker_whs(_fe_problem.getMarkerWarehouse())
26 {
27 }
28 
29 // Splitting Constructor
32  _fe_problem(x._fe_problem),
33  _aux_sys(x._aux_sys),
34  _marker_whs(x._marker_whs)
35 {
36 }
37 
39 
40 void
42 {
45 
46  std::set<MooseVariableFEBase *> needed_moose_vars;
47  _marker_whs.updateVariableDependency(needed_moose_vars, _tid);
48 
49  for (auto * var : _aux_sys._elem_vars[_tid])
50  var->prepareAux();
51 
52  std::unordered_set<unsigned int> needed_mat_props;
53  _marker_whs.updateMatPropDependency(needed_mat_props, _tid);
54 
56  _fe_problem.prepareMaterials(needed_mat_props, _subdomain, _tid);
57 }
58 
59 void
61 {
62  _fe_problem.prepare(elem, _tid);
64 
65  // Set up Sentinel class so that, even if reinitMaterials() throws, we
66  // still remember to swap back during stack unwinding.
69  _tid,
71 
73 
75  {
76  const std::vector<std::shared_ptr<Marker>> & markers =
78  for (const auto & marker : markers)
79  marker->computeMarker();
80  }
81 
82  {
83  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
84  for (auto * var : _aux_sys._elem_vars[_tid])
85  var->insert(_aux_sys.solution());
86  }
87 }
88 
89 void
90 ComputeMarkerThread::onBoundary(const Elem * /*elem*/,
91  unsigned int /*side*/,
92  BoundaryID /*bnd_id*/,
93  const Elem * /*lower_d_elem = nullptr*/)
94 {
95 }
96 
97 void
98 ComputeMarkerThread::onInternalSide(const Elem * /*elem*/, unsigned int /*side*/)
99 {
100 }
101 
102 void
103 ComputeMarkerThread::postElement(const Elem * /*elem*/)
104 {
105 }
106 
107 void
109 {
111 }
112 
113 void
115 {
116 }
117 
118 void
120 {
122  return;
123  const auto & console = _fe_problem.console();
124  const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
125  console << "[DBG] Beginning elemental loop to compute Markers on " << execute_on << std::endl;
126 }
127 
128 void
130 {
133  return;
134 
135  const auto & console = _fe_problem.console();
136  const auto & markers = _marker_whs.getActiveBlockObjects(_subdomain, _tid);
137  console << "[DBG] Execution order on block: " << _subdomain << std::endl;
138  printExecutionOrdering<Marker>(markers, false);
140 }
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id, const Elem *lower_d_elem=nullptr) override
Called when doing boundary assembling.
void updateVariableDependency(std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
FEProblemBase & _fe_problem
Base class for assembly-like calculations.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
NumericVector< Number > & solution()
Definition: SystemBase.h:195
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
const MooseObjectWarehouse< Marker > & _marker_whs
Reference to the Marker warhouse in FEProblemBase.
void printGeneralExecutionInformation() const override
Print information about the loop.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void postElement(const Elem *) override
Called after the element assembly is done (including surface assembling)
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
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 subdomainChanged() override
Called every time the current subdomain changes (i.e.
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
virtual void post() override
Called after the element range loop.
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
AuxiliarySystem & _aux_sys
boundary_id_type BoundaryID
void printBlockExecutionInformation() const override
Print information about ordering of objects on each block.
ComputeMarkerThread(FEProblemBase &fe_problem)
void join(const ComputeMarkerThread &)
void updateMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
Update material property dependency vector.
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
std::vector< std::vector< MooseVariableFieldBase * > > _elem_vars
Elemental variables.
tbb::split split
const ConsoleStream & console() const
Return console handle.
Definition: Problem.h:48
virtual void swapBackMaterials(const THREAD_ID tid)
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
SubdomainID _subdomain
The subdomain for the current element.
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...
bool hasActiveMaterialProperties(const THREAD_ID tid) const
Method to check whether or not a list of active material roperties has been set.
virtual void subdomainSetup(THREAD_ID tid=0) const
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.
The "SwapBackSentinel" class&#39;s destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.