Line data Source code
1 : /**********************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ 4 : /* */ 5 : /* Copyright 2017 Battelle Energy Alliance, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /**********************************************************************/ 8 : 9 : #include "ThreadedRecoilElementAveragedLoop.h" 10 : 11 142 : ThreadedRecoilElementAveragedLoop::ThreadedRecoilElementAveragedLoop( 12 142 : const MyTRIMRasterizer & rasterizer, const MooseMesh & mesh) 13 142 : : ThreadedRecoilLoopBase(rasterizer, mesh) 14 : { 15 142 : } 16 : 17 : // Splitting Constructor 18 34 : ThreadedRecoilElementAveragedLoop::ThreadedRecoilElementAveragedLoop( 19 34 : const ThreadedRecoilElementAveragedLoop & x, Threads::split /*split*/) 20 34 : : ThreadedRecoilLoopBase(x, Threads::split()) 21 : { 22 34 : } 23 : 24 : void 25 34 : ThreadedRecoilElementAveragedLoop::join(const ThreadedRecoilElementAveragedLoop & rl) 26 : { 27 26546 : for (auto && i : rl._result_map) 28 : { 29 : // find the result map entry corresponding to the other thread's position 30 : // lower_bound gives the first element that os _not_ less than the searched element. 31 : // This is either a match, or the right position for a hinted insertion (fast) 32 : auto j = _result_map.lower_bound(i.first); 33 26512 : if (j == _result_map.end() || j->first != i.first) 34 9742 : j = _result_map.emplace_hint(j, i.first, MyTRIMResult(_nvars)); 35 : 36 : const MyTRIMResult & src = i.second; 37 : MyTRIMResult & dst = j->second; 38 : 39 : mooseAssert(dst._defects.size() == src._defects.size(), "Defect vector sizes inconsistent."); 40 : mooseAssert(dst._defects.size() == _nvars, "Defect vector size must be _nvars."); 41 : 42 : // accumulate vacancies, interstitials, and replacements 43 59865 : for (auto k = beginIndex(dst._defects); k < _nvars; ++k) 44 166765 : for (std::size_t l = 0; l < N_DEFECTS; ++l) 45 133412 : dst._defects[k][l] += src._defects[k][l]; 46 : 47 26512 : dst._energy += src._energy; 48 : } 49 34 : } 50 : 51 : void 52 9629577 : ThreadedRecoilElementAveragedLoop::addDefectToResult( 53 : const Point & p, 54 : unsigned int var, 55 : Real weight, 56 : ThreadedRecoilElementAveragedLoop::DefectType type) 57 : { 58 9629577 : const Elem * elem = (*_pl)(p); 59 9629577 : if (elem == nullptr || var >= _nvars) 60 : return; 61 : 62 : // store into _result_map 63 : auto i = _result_map.lower_bound(elem->id()); 64 9629346 : if (i == _result_map.end() || i->first != elem->id()) 65 80544 : i = _result_map.emplace_hint(i, elem->id(), MyTRIMResult(_nvars)); 66 : 67 : // check for invalid types 68 : mooseAssert(type != NONE && type != N_DEFECTS, "Invalid defect type passed to addDefectToResult"); 69 : 70 : // increase the interstitial counter for the tagged element 71 9629346 : i->second._defects[var][type] += weight; 72 : } 73 : 74 : void 75 716499 : ThreadedRecoilElementAveragedLoop::addEnergyToResult(const Point & p, Real edep) 76 : { 77 716499 : const Elem * elem = (*_pl)(p); 78 716499 : if (elem == nullptr) 79 : return; 80 : 81 : // store into _result_map 82 : auto i = _result_map.lower_bound(elem->id()); 83 707499 : if (i == _result_map.end() || i->first != elem->id()) 84 72930 : i = _result_map.emplace_hint(i, elem->id(), MyTRIMResult(_nvars)); 85 : 86 707499 : i->second._energy += edep; 87 : } 88 : 89 : template <> 90 : void 91 52966 : dataStore(std::ostream & stream, 92 : ThreadedRecoilElementAveragedLoop::MyTRIMResult & eal, 93 : void * context) 94 : { 95 52966 : dataStore(stream, eal._defects, context); 96 52966 : dataStore(stream, eal._energy, context); 97 52966 : } 98 : 99 : template <> 100 : void 101 52966 : dataLoad(std::istream & stream, 102 : ThreadedRecoilElementAveragedLoop::MyTRIMResult & eal, 103 : void * context) 104 : { 105 52966 : dataLoad(stream, eal._defects, context); 106 52966 : dataLoad(stream, eal._energy, context); 107 52966 : }