Line data Source code
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 : 21 6474 : ComputeMarkerThread::ComputeMarkerThread(FEProblemBase & fe_problem) 22 : : ThreadedElementLoop<ConstElemRange>(fe_problem), 23 6474 : _fe_problem(fe_problem), 24 12948 : _aux_sys(fe_problem.getAuxiliarySystem()), 25 6474 : _marker_whs(_fe_problem.getMarkerWarehouse()) 26 : { 27 6474 : } 28 : 29 : // Splitting Constructor 30 620 : ComputeMarkerThread::ComputeMarkerThread(ComputeMarkerThread & x, Threads::split split) 31 : : ThreadedElementLoop<ConstElemRange>(x, split), 32 620 : _fe_problem(x._fe_problem), 33 620 : _aux_sys(x._aux_sys), 34 620 : _marker_whs(x._marker_whs) 35 : { 36 620 : } 37 : 38 7714 : ComputeMarkerThread::~ComputeMarkerThread() {} 39 : 40 : void 41 22667 : ComputeMarkerThread::subdomainChanged() 42 : { 43 22667 : _fe_problem.subdomainSetup(_subdomain, _tid); 44 22667 : _marker_whs.subdomainSetup(_tid); 45 : 46 22667 : std::set<MooseVariableFEBase *> needed_moose_vars; 47 22667 : _marker_whs.updateVariableDependency(needed_moose_vars, _tid); 48 : 49 70953 : for (auto * var : _aux_sys._elem_vars[_tid]) 50 48286 : var->prepareAux(); 51 : 52 22667 : std::unordered_set<unsigned int> needed_mat_props; 53 22667 : _marker_whs.updateMatPropDependency(needed_mat_props, _tid); 54 : 55 22667 : _fe_problem.setActiveElementalMooseVariables(needed_moose_vars, _tid); 56 22667 : _fe_problem.prepareMaterials(needed_mat_props, _subdomain, _tid); 57 22667 : } 58 : 59 : void 60 1661632 : ComputeMarkerThread::onElement(const Elem * elem) 61 : { 62 1661632 : _fe_problem.prepare(elem, _tid); 63 1661632 : _fe_problem.reinitElem(elem, _tid); 64 : 65 : // Set up Sentinel class so that, even if reinitMaterials() throws, we 66 : // still remember to swap back during stack unwinding. 67 : SwapBackSentinel sentinel(_fe_problem, 68 : &FEProblem::swapBackMaterials, 69 : _tid, 70 1661632 : _fe_problem.hasActiveMaterialProperties(_tid)); 71 : 72 1661632 : _fe_problem.reinitMaterials(_subdomain, _tid); 73 : 74 1661632 : if (_marker_whs.hasActiveBlockObjects(_subdomain, _tid)) 75 : { 76 : const std::vector<std::shared_ptr<Marker>> & markers = 77 1657888 : _marker_whs.getActiveBlockObjects(_subdomain, _tid); 78 3543280 : for (const auto & marker : markers) 79 1885392 : marker->computeMarker(); 80 : } 81 : 82 4650088 : for (auto * var : _aux_sys._elem_vars[_tid]) 83 2988456 : var->insert(_aux_sys.solution()); 84 1661632 : } 85 : 86 : void 87 302687 : ComputeMarkerThread::onBoundary(const Elem * /*elem*/, 88 : unsigned int /*side*/, 89 : BoundaryID /*bnd_id*/, 90 : const Elem * /*lower_d_elem = nullptr*/) 91 : { 92 302687 : } 93 : 94 : void 95 3332691 : ComputeMarkerThread::onInternalSide(const Elem * /*elem*/, unsigned int /*side*/) 96 : { 97 3332691 : } 98 : 99 : void 100 1661632 : ComputeMarkerThread::postElement(const Elem * /*elem*/) 101 : { 102 1661632 : } 103 : 104 : void 105 7094 : ComputeMarkerThread::post() 106 : { 107 7094 : _fe_problem.clearActiveElementalMooseVariables(_tid); 108 7094 : } 109 : 110 : void 111 620 : ComputeMarkerThread::join(const ComputeMarkerThread & /*y*/) 112 : { 113 620 : } 114 : 115 : void 116 7094 : ComputeMarkerThread::printGeneralExecutionInformation() const 117 : { 118 7094 : if (!_fe_problem.shouldPrintExecution(_tid)) 119 7031 : return; 120 63 : const auto & console = _fe_problem.console(); 121 63 : const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag(); 122 63 : console << "[DBG] Beginning elemental loop to compute Markers on " << execute_on << std::endl; 123 : } 124 : 125 : void 126 22667 : ComputeMarkerThread::printBlockExecutionInformation() const 127 : { 128 22730 : if (!_fe_problem.shouldPrintExecution(_tid) || _blocks_exec_printed.count(_subdomain) || 129 63 : !_marker_whs.hasActiveBlockObjects(_subdomain, _tid)) 130 22604 : return; 131 : 132 63 : const auto & console = _fe_problem.console(); 133 63 : const auto & markers = _marker_whs.getActiveBlockObjects(_subdomain, _tid); 134 63 : console << "[DBG] Execution order on block: " << _subdomain << std::endl; 135 126 : printExecutionOrdering<Marker>(markers, false); 136 63 : _blocks_exec_printed.insert(_subdomain); 137 : }