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 "ComputeResidualThread.h" 11 : #include "NonlinearSystemBase.h" 12 : #include "KernelBase.h" 13 : #include "DGKernelBase.h" 14 : #include "IntegratedBCBase.h" 15 : #include "FVElementalKernel.h" 16 : #include "InterfaceKernelBase.h" 17 : #include "HDGKernel.h" 18 : #include "libmesh/threads.h" 19 : 20 3336000 : ComputeResidualThread::ComputeResidualThread(FEProblemBase & fe_problem, 21 3336000 : const std::set<TagID> & tags) 22 3336000 : : NonlinearThread(fe_problem), _tags(tags) 23 : { 24 3336000 : } 25 : 26 : // Splitting Constructor 27 292499 : ComputeResidualThread::ComputeResidualThread(ComputeResidualThread & x, Threads::split split) 28 292499 : : NonlinearThread(x, split), _tags(x._tags) 29 : { 30 292499 : } 31 : 32 3920960 : ComputeResidualThread::~ComputeResidualThread() {} 33 : 34 : void 35 751003639 : ComputeResidualThread::compute(ResidualObject & ro) 36 : { 37 751003639 : ro.computeResidual(); 38 751003585 : } 39 : 40 : void 41 20264 : ComputeResidualThread::accumulateLower() 42 : { 43 20264 : _fe_problem.addResidualLower(_tid); 44 20264 : } 45 : 46 : void 47 45333 : ComputeResidualThread::accumulateNeighbor() 48 : { 49 45333 : _fe_problem.addResidualNeighbor(_tid); 50 45333 : } 51 : 52 : void 53 2292137 : ComputeResidualThread::accumulateNeighborLower() 54 : { 55 2292137 : _fe_problem.addResidualNeighbor(_tid); 56 2292137 : _fe_problem.addResidualLower(_tid); 57 2292137 : } 58 : 59 : void 60 329256847 : ComputeResidualThread::accumulate() 61 : { 62 329256847 : _fe_problem.cacheResidual(_tid); 63 329256847 : _num_cached++; 64 : 65 329256847 : if (_num_cached % 20 == 0) 66 : { 67 15297546 : Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 68 15297546 : _fe_problem.addCachedResidual(_tid); 69 15297546 : } 70 329256847 : } 71 : 72 : void 73 292496 : ComputeResidualThread::join(const ComputeResidualThread & /*y*/) 74 : { 75 292496 : } 76 : 77 : void 78 4334515 : ComputeResidualThread::determineObjectWarehouses() 79 : { 80 : // If users pass a empty vector or a full size of vector, 81 : // we take all kernels 82 4334515 : if (!_tags.size() || _tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL)) 83 : { 84 4276059 : _tag_kernels = &_kernels; 85 4276059 : _dg_warehouse = &_dg_kernels; 86 4276059 : _ibc_warehouse = &_integrated_bcs; 87 4276059 : _ik_warehouse = &_interface_kernels; 88 4276059 : _hdg_warehouse = &_hdg_kernels; 89 : } 90 : // If we have one tag only, 91 : // We call tag based storage 92 58456 : else if (_tags.size() == 1) 93 : { 94 34190 : _tag_kernels = &(_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 95 34190 : _dg_warehouse = &(_dg_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 96 34190 : _ibc_warehouse = &(_integrated_bcs.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 97 34190 : _ik_warehouse = &(_interface_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 98 34190 : _hdg_warehouse = &(_hdg_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 99 : } 100 : // This one may be expensive 101 : else 102 : { 103 24266 : _tag_kernels = &(_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 104 24266 : _dg_warehouse = &(_dg_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 105 24266 : _ibc_warehouse = &(_integrated_bcs.getVectorTagsObjectWarehouse(_tags, _tid)); 106 24266 : _ik_warehouse = &(_interface_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 107 24266 : _hdg_warehouse = &(_hdg_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 108 : } 109 : 110 4334515 : if (_fe_problem.haveFV()) 111 : { 112 198814 : _fv_kernels.clear(); 113 198814 : _fe_problem.theWarehouse() 114 397628 : .query() 115 397628 : .template condition<AttribSysNum>(_nl.number()) 116 198814 : .template condition<AttribSystem>("FVElementalKernel") 117 198814 : .template condition<AttribSubdomains>(_subdomain) 118 198814 : .template condition<AttribThread>(_tid) 119 198814 : .template condition<AttribVectorTags>(_tags) 120 198814 : .queryInto(_fv_kernels); 121 : } 122 4334515 : } 123 : 124 : void 125 2646165 : ComputeResidualThread::computeOnInternalFace() 126 : { 127 : mooseAssert(_hdg_warehouse->hasActiveBlockObjects(_subdomain, _tid), 128 : "We should not be called if we have no active HDG kernels"); 129 6526029 : for (const auto & hdg_kernel : _hdg_warehouse->getActiveBlockObjects(_subdomain, _tid)) 130 : { 131 : mooseAssert( 132 : hdg_kernel->hasBlocks(_subdomain), 133 : "We queried the warehouse for active blocks on this subdomain, so this better be active"); 134 : mooseAssert( 135 : _neighbor_subdomain != Moose::INVALID_BLOCK_ID, 136 : "We should have set a valid neighbor subdomain ID if we made it in side this method"); 137 3879864 : if (hdg_kernel->hasBlocks(_neighbor_subdomain)) 138 3879846 : hdg_kernel->computeResidualOnSide(); 139 : } 140 2646165 : }