https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
40void
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
57 // Only prepare (and therefore reinit) materials if a marker actually consumes a material
58 // property. Otherwise skip the material system entirely to avoid recomputing the whole stack.
59 if (!needed_mat_props.empty())
60 _fe_problem.prepareMaterials(needed_mat_props, _subdomain, _tid);
61 else
63}
64
65void
67{
70
71 // Set up Sentinel class so that, even if reinitMaterials() throws, we
72 // still remember to swap back during stack unwinding.
75 _tid,
77
79
81 {
82 const std::vector<std::shared_ptr<Marker>> & markers =
84 for (const auto & marker : markers)
85 marker->computeMarker();
86 }
87
88 for (auto * var : _aux_sys._elem_vars[_tid])
89 var->insert(_aux_sys.solution());
90}
91
92void
93ComputeMarkerThread::onBoundary(const Elem * /*elem*/,
94 unsigned int /*side*/,
95 BoundaryID /*bnd_id*/,
96 const Elem * /*lower_d_elem = nullptr*/)
97{
98}
99
100void
101ComputeMarkerThread::onInternalSide(const Elem * /*elem*/, unsigned int /*side*/)
102{
103}
104
105void
107{
108}
109
110void
115
116void
120
121void
123{
125 return;
126 const auto & console = _fe_problem.console();
127 const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag();
128 console << "[DBG] Beginning elemental loop to compute Markers on " << execute_on << std::endl;
129}
130
131void
133{
136 return;
137
138 const auto & console = _fe_problem.console();
139 const auto & markers = _marker_whs.getActiveBlockObjects(_subdomain, _tid);
140 console << "[DBG] Execution order on block: " << _subdomain << std::endl;
141 printExecutionOrdering<Marker>(markers, false);
143}
boundary_id_type BoundaryID
std::vector< std::vector< MooseVariableFieldBase * > > _elem_vars
Elemental variables.
void printBlockExecutionInformation() const override
Print information about ordering of objects on each block.
ComputeMarkerThread(FEProblemBase &fe_problem)
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
AuxiliarySystem & _aux_sys
virtual void onInternalSide(const Elem *elem, unsigned int side) override
Called when doing internal edge assembling.
virtual void post() override
Called after the element range loop.
FEProblemBase & _fe_problem
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 postElement(const Elem *) override
Called after the element assembly is done (including surface assembling)
void join(const ComputeMarkerThread &)
const MooseObjectWarehouse< Marker > & _marker_whs
Reference to the Marker warhouse in FEProblemBase.
virtual void subdomainChanged() override
Called every time the current subdomain changes (i.e.
void printGeneralExecutionInformation() const override
Print information about the loop.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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
void clearActiveMaterialProperties(const THREAD_ID tid)
Clear the active material properties.
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid) override
Clear the active elemental MooseVariableFEBase.
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...
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
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 swapBackMaterials(const THREAD_ID tid)
bool shouldPrintExecution(const THREAD_ID tid) const
Check whether the problem should output execution orders at this time.
virtual void subdomainSetup(SubdomainID subdomain, const THREAD_ID tid)
bool hasActiveMaterialProperties(const THREAD_ID tid) const
Method to check whether or not a list of active material roperties has been set.
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 updateMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0, const bool producer_only=false) const
Update material property dependency vector.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual void subdomainSetup(THREAD_ID tid=0) const
const ConsoleStream & console() const
Return console handle.
Definition Problem.h:48
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,...
NumericVector< Number > & solution()
Definition SystemBase.h:203
SubdomainID _subdomain
The subdomain for the current element.
std::set< SubdomainID > _blocks_exec_printed
Keep track of which blocks were visited.
Base class for assembly-like calculations.