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 3042826 : ComputeResidualThread::ComputeResidualThread(FEProblemBase & fe_problem, 21 3042826 : const std::set<TagID> & tags) 22 3042826 : : NonlinearThread(fe_problem), _tags(tags) 23 : { 24 3042826 : } 25 : 26 : // Splitting Constructor 27 983 : ComputeResidualThread::ComputeResidualThread(ComputeResidualThread & x, Threads::split split) 28 983 : : NonlinearThread(x, split), _tags(x._tags) 29 : { 30 983 : } 31 : 32 3044768 : ComputeResidualThread::~ComputeResidualThread() {} 33 : 34 : void 35 657870954 : ComputeResidualThread::compute(ResidualObject & ro) 36 : { 37 657870954 : ro.computeResidual(); 38 657870910 : } 39 : 40 : void 41 18232 : ComputeResidualThread::accumulateLower() 42 : { 43 18232 : _fe_problem.addResidualLower(_tid); 44 18232 : } 45 : 46 : void 47 36079 : ComputeResidualThread::accumulateNeighbor() 48 : { 49 36079 : _fe_problem.addResidualNeighbor(_tid); 50 36079 : } 51 : 52 : void 53 1948940 : ComputeResidualThread::accumulateNeighborLower() 54 : { 55 1948940 : _fe_problem.addResidualNeighbor(_tid); 56 1948940 : _fe_problem.addResidualLower(_tid); 57 1948940 : } 58 : 59 : void 60 288080526 : ComputeResidualThread::accumulate() 61 : { 62 288080526 : _fe_problem.cacheResidual(_tid); 63 288080526 : _num_cached++; 64 : 65 288080526 : if (_num_cached % 20 == 0) 66 13504831 : _fe_problem.addCachedResidual(_tid); 67 288080526 : } 68 : 69 : void 70 983 : ComputeResidualThread::join(const ComputeResidualThread & /*y*/) 71 : { 72 983 : } 73 : 74 : void 75 3643549 : ComputeResidualThread::determineObjectWarehouses() 76 : { 77 : // If users pass a empty vector or a full size of vector, 78 : // we take all kernels 79 3643549 : if (!_tags.size() || _tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL)) 80 : { 81 3594979 : _tag_kernels = &_kernels; 82 3594979 : _dg_warehouse = &_dg_kernels; 83 3594979 : _ibc_warehouse = &_integrated_bcs; 84 3594979 : _ik_warehouse = &_interface_kernels; 85 3594979 : _hdg_warehouse = &_hdg_kernels; 86 : } 87 : // If we have one tag only, 88 : // We call tag based storage 89 48570 : else if (_tags.size() == 1) 90 : { 91 29357 : _tag_kernels = &(_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 92 29357 : _dg_warehouse = &(_dg_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 93 29357 : _ibc_warehouse = &(_integrated_bcs.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 94 29357 : _ik_warehouse = &(_interface_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 95 29357 : _hdg_warehouse = &(_hdg_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 96 : } 97 : // This one may be expensive 98 : else 99 : { 100 19213 : _tag_kernels = &(_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 101 19213 : _dg_warehouse = &(_dg_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 102 19213 : _ibc_warehouse = &(_integrated_bcs.getVectorTagsObjectWarehouse(_tags, _tid)); 103 19213 : _ik_warehouse = &(_interface_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 104 19213 : _hdg_warehouse = &(_hdg_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 105 : } 106 : 107 3643549 : if (_fe_problem.haveFV()) 108 : { 109 107938 : _fv_kernels.clear(); 110 107938 : _fe_problem.theWarehouse() 111 215876 : .query() 112 215876 : .template condition<AttribSysNum>(_nl.number()) 113 107938 : .template condition<AttribSystem>("FVElementalKernel") 114 107938 : .template condition<AttribSubdomains>(_subdomain) 115 107938 : .template condition<AttribThread>(_tid) 116 107938 : .template condition<AttribVectorTags>(_tags) 117 107938 : .queryInto(_fv_kernels); 118 : } 119 3643549 : } 120 : 121 : void 122 797373 : ComputeResidualThread::computeOnInternalFace() 123 : { 124 : mooseAssert(_hdg_warehouse->hasActiveBlockObjects(_subdomain, _tid), 125 : "We should not be called if we have no active HDG kernels"); 126 1725081 : for (const auto & hdg_kernel : _hdg_warehouse->getActiveBlockObjects(_subdomain, _tid)) 127 : { 128 : mooseAssert( 129 : hdg_kernel->hasBlocks(_subdomain), 130 : "We queried the warehouse for active blocks on this subdomain, so this better be active"); 131 : mooseAssert( 132 : _neighbor_subdomain != Moose::INVALID_BLOCK_ID, 133 : "We should have set a valid neighbor subdomain ID if we made it in side this method"); 134 927708 : if (hdg_kernel->hasBlocks(_neighbor_subdomain)) 135 927692 : hdg_kernel->computeResidualOnSide(); 136 : } 137 797373 : }