www.mooseframework.org
ComputeMarkerThread.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
16 #include "ComputeMarkerThread.h"
17 #include "AuxiliarySystem.h"
18 #include "Problem.h"
19 #include "FEProblem.h"
20 #include "Marker.h"
21 #include "MooseVariable.h"
22 #include "SwapBackSentinel.h"
23 
24 #include "libmesh/threads.h"
25 
27  : ThreadedElementLoop<ConstElemRange>(fe_problem),
28  _fe_problem(fe_problem),
29  _aux_sys(fe_problem.getAuxiliarySystem()),
30  _marker_whs(_fe_problem.getMarkerWarehouse())
31 {
32 }
33 
34 // Splitting Constructor
36  : ThreadedElementLoop<ConstElemRange>(x, split),
38  _aux_sys(x._aux_sys),
40 {
41 }
42 
44 
45 void
47 {
50 
51  std::set<MooseVariable *> needed_moose_vars;
52  _marker_whs.updateVariableDependency(needed_moose_vars, _tid);
53 
54  for (const auto & it : _aux_sys._elem_vars[_tid])
55  {
56  MooseVariable * var = it.second;
57  var->prepareAux();
58  }
59 
60  _fe_problem.setActiveElementalMooseVariables(needed_moose_vars, _tid);
62 }
63 
64 void
66 {
67  _fe_problem.prepare(elem, _tid);
69 
70  // Set up Sentinel class so that, even if reinitMaterials() throws, we
71  // still remember to swap back during stack unwinding.
73 
75 
77  {
78  const std::vector<std::shared_ptr<Marker>> & markers =
80  for (const auto & marker : markers)
81  marker->computeMarker();
82  }
83 
84  {
85  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
86  for (const auto & it : _aux_sys._elem_vars[_tid])
87  {
88  MooseVariable * var = it.second;
89  var->insert(_aux_sys.solution());
90  }
91  }
92 }
93 
94 void
95 ComputeMarkerThread::onBoundary(const Elem * /*elem*/, unsigned int /*side*/, BoundaryID /*bnd_id*/)
96 {
97 }
98 
99 void
100 ComputeMarkerThread::onInternalSide(const Elem * /*elem*/, unsigned int /*side*/)
101 {
102 }
103 
104 void
105 ComputeMarkerThread::postElement(const Elem * /*elem*/)
106 {
107 }
108 
109 void
111 {
113 }
114 
115 void
117 {
118 }
virtual void setActiveElementalMooseVariables(const std::set< MooseVariable * > &moose_vars, THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
virtual void prepare(const Elem *elem, THREAD_ID tid) override
FEProblemBase & _fe_problem
Base class for assembly-like calculations.
virtual void prepareMaterials(SubdomainID blk_id, THREAD_ID tid)
Add the MooseVariables that the current materials depend on to the dependency list.
Class for stuff related to variables.
Definition: MooseVariable.h:43
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.
virtual void subdomainSetup(THREAD_ID tid=0) const
static PetscErrorCode Vec x
virtual void reinitElem(const Elem *elem, THREAD_ID tid) override
virtual void reinitMaterials(SubdomainID blk_id, THREAD_ID tid, bool swap_stateful=true)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void subdomainSetup(SubdomainID subdomain, THREAD_ID tid)
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 subdomainChanged() override
Called every time the current subdomain changes (i.e.
virtual void post() override
Called after the element range loop.
std::vector< std::map< std::string, MooseVariable * > > _elem_vars
void updateVariableDependency(std::set< MooseVariable * > &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
AuxiliarySystem & _aux_sys
ComputeMarkerThread(FEProblemBase &fe_problem)
virtual void swapBackMaterials(THREAD_ID tid)
void join(const ComputeMarkerThread &)
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual NumericVector< Number > & solution() override
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing boundary assembling.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
SubdomainID _subdomain
The subdomain for the current element.
void insert(NumericVector< Number > &residual)
virtual void clearActiveElementalMooseVariables(THREAD_ID tid) override
Clear the active elemental MooseVariable.
boundary_id_type BoundaryID
Definition: MooseTypes.h:75
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}.