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 "UpdateErrorVectorsThread.h" 11 : 12 : // MOOSE includes 13 : #include "AuxiliarySystem.h" 14 : #include "FEProblem.h" 15 : #include "Marker.h" 16 : #include "MooseVariableFE.h" 17 : #include "Problem.h" 18 : 19 : #include "libmesh/threads.h" 20 : #include "libmesh/error_vector.h" 21 : 22 6428 : UpdateErrorVectorsThread::UpdateErrorVectorsThread( 23 : FEProblemBase & fe_problem, 24 6428 : const std::map<std::string, std::unique_ptr<ErrorVector>> & indicator_field_to_error_vector) 25 : : ThreadedElementLoop<ConstElemRange>(fe_problem), 26 6428 : _indicator_field_to_error_vector(indicator_field_to_error_vector), 27 12856 : _aux_sys(fe_problem.getAuxiliarySystem()), 28 6428 : _system_number(_aux_sys.number()), 29 6428 : _adaptivity(fe_problem.adaptivity()), 30 12856 : _solution(_aux_sys.solution()) 31 : { 32 : // Build up this map once so we don't have to do these lookups over and over again 33 8624 : for (const auto & it : _indicator_field_to_error_vector) 34 : { 35 2196 : unsigned int var_num = _aux_sys.getVariable(0, it.first).number(); 36 2196 : _indicator_field_number_to_error_vector.emplace(var_num, it.second.get()); 37 : } 38 6428 : } 39 : 40 : // Splitting Constructor 41 616 : UpdateErrorVectorsThread::UpdateErrorVectorsThread(UpdateErrorVectorsThread & x, 42 616 : Threads::split split) 43 : : ThreadedElementLoop<ConstElemRange>(x, split), 44 616 : _indicator_field_to_error_vector(x._indicator_field_to_error_vector), 45 616 : _aux_sys(x._aux_sys), 46 616 : _system_number(x._system_number), 47 616 : _adaptivity(x._adaptivity), 48 616 : _solution(x._solution), 49 616 : _indicator_field_number_to_error_vector(x._indicator_field_number_to_error_vector) 50 : { 51 616 : } 52 : 53 : void 54 1694642 : UpdateErrorVectorsThread::onElement(const Elem * elem) 55 : { 56 2478435 : for (const auto & it : _indicator_field_number_to_error_vector) 57 : { 58 783793 : unsigned int var_num = it.first; 59 783793 : ErrorVector & ev = *(it.second); 60 : 61 : // Must obey the block restriction of the indicator (error vector is global) 62 : // we have to check here because the loop is over all indicators, and other indicators 63 : // might have larger block restrictions. 64 783793 : if (_aux_sys.getVariable(_tid, var_num).hasBlocks(elem->subdomain_id())) 65 : { 66 783505 : dof_id_type dof_number = elem->dof_number(_system_number, var_num, 0); 67 783505 : Real value = _solution(dof_number); 68 783505 : ev[elem->id()] = value; 69 : } 70 : else 71 288 : ev[elem->id()] = 0; 72 : } 73 1694642 : } 74 : 75 : void 76 616 : UpdateErrorVectorsThread::join(const UpdateErrorVectorsThread & /*y*/) 77 : { 78 616 : }