www.mooseframework.org
ComputeMarkerThread.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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
31  : ThreadedElementLoop<ConstElemRange>(x, split),
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 
54 }
55 
56 void
58 {
59  _fe_problem.prepare(elem, _tid);
61 
62  // Set up Sentinel class so that, even if reinitMaterials() throws, we
63  // still remember to swap back during stack unwinding.
65 
67 
69  {
70  const std::vector<std::shared_ptr<Marker>> & markers =
72  for (const auto & marker : markers)
73  marker->computeMarker();
74  }
75 
76  {
77  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
78  for (auto * var : _aux_sys._elem_vars[_tid])
79  var->insert(_aux_sys.solution());
80  }
81 }
82 
83 void
84 ComputeMarkerThread::onBoundary(const Elem * /*elem*/, unsigned int /*side*/, BoundaryID /*bnd_id*/)
85 {
86 }
87 
88 void
89 ComputeMarkerThread::onInternalSide(const Elem * /*elem*/, unsigned int /*side*/)
90 {
91 }
92 
93 void
94 ComputeMarkerThread::postElement(const Elem * /*elem*/)
95 {
96 }
97 
98 void
100 {
102 }
103 
104 void
106 {
107 }
virtual void prepare(const Elem *elem, THREAD_ID tid) override
FEProblemBase & _fe_problem
Base class for assembly-like calculations.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual void prepareMaterials(SubdomainID blk_id, THREAD_ID tid)
Add the MooseVariables that the current materials depend on to the dependency list.
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFEBase *> &moose_vars, THREAD_ID tid) override
Set the MOOSE variables to be reinited on each element.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
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.
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.
std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Python like split function for strings.
Definition: MooseUtils.C:736
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
virtual void post() override
Called after the element range loop.
AuxiliarySystem & _aux_sys
boundary_id_type BoundaryID
ComputeMarkerThread(FEProblemBase &fe_problem)
NumericVector< Number > & solution() override
void updateVariableDependency(std::set< MooseVariableFEBase *> &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
virtual void swapBackMaterials(THREAD_ID tid)
void join(const ComputeMarkerThread &)
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id) override
Called when doing boundary assembling.
std::vector< std::vector< MooseVariableFEBase * > > _elem_vars
SubdomainID _subdomain
The subdomain for the current element.
virtual void subdomainSetup(THREAD_ID tid=0) const
virtual void clearActiveElementalMooseVariables(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}.