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 : #include "ComputeThreadedGeneralUserObjectsThread.h" 11 : 12 108 : ComputeThreadedGeneralUserObjectsThread::ComputeThreadedGeneralUserObjectsThread( 13 108 : FEProblemBase & fe_problem) 14 108 : : _fe_problem(fe_problem) 15 : { 16 108 : } 17 : 18 308 : ComputeThreadedGeneralUserObjectsThread::ComputeThreadedGeneralUserObjectsThread( 19 308 : ComputeThreadedGeneralUserObjectsThread & x, Threads::split /*split*/) 20 308 : : _fe_problem(x._fe_problem) 21 : { 22 308 : } 23 : 24 724 : ComputeThreadedGeneralUserObjectsThread::~ComputeThreadedGeneralUserObjectsThread() {} 25 : 26 : void 27 0 : ComputeThreadedGeneralUserObjectsThread::caughtMooseException(MooseException & e) 28 : { 29 0 : Threads::spin_mutex::scoped_lock lock(threaded_general_user_objects_mutex); 30 : 31 0 : std::string what(e.what()); 32 0 : _fe_problem.setException(what); 33 0 : } 34 : 35 : void 36 416 : ComputeThreadedGeneralUserObjectsThread::operator()(const GeneralUserObjectRange & range) 37 : { 38 : try 39 : { 40 416 : printGeneralExecutionInformation(range); 41 832 : for (auto it = range.begin(); it != range.end(); ++it) 42 : { 43 416 : auto & tguo = *it; 44 416 : tguo->execute(); 45 : } 46 : } 47 0 : catch (MooseException & e) 48 : { 49 0 : caughtMooseException(e); 50 0 : } 51 416 : } 52 : 53 : void 54 416 : ComputeThreadedGeneralUserObjectsThread::printGeneralExecutionInformation( 55 : const GeneralUserObjectRange & range) const 56 : { 57 : // TODO: Threaded UOs dont know their thread number so this will print too often 58 416 : if (!_fe_problem.shouldPrintExecution(0) || !range.size()) 59 396 : return; 60 : 61 20 : const auto & console = _fe_problem.console(); 62 20 : const auto & execute_on = _fe_problem.getCurrentExecuteOnFlag(); 63 20 : console << "[DBG] Executing Threaded General User Object " << (*range.begin())->name() << " on " 64 20 : << execute_on << std::endl; 65 : }