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 3036461 : ComputeResidualThread::ComputeResidualThread(FEProblemBase & fe_problem, 21 3036461 : const std::set<TagID> & tags) 22 3036461 : : NonlinearThread(fe_problem), _tags(tags) 23 : { 24 3036461 : } 25 : 26 : // Splitting Constructor 27 300381 : ComputeResidualThread::ComputeResidualThread(ComputeResidualThread & x, Threads::split split) 28 300381 : : NonlinearThread(x, split), _tags(x._tags) 29 : { 30 300381 : } 31 : 32 3637193 : ComputeResidualThread::~ComputeResidualThread() {} 33 : 34 : void 35 656999505 : ComputeResidualThread::compute(ResidualObject & ro) 36 : { 37 656999505 : ro.computeResidual(); 38 656999458 : } 39 : 40 : void 41 18220 : ComputeResidualThread::accumulateLower() 42 : { 43 18220 : _fe_problem.addResidualLower(_tid); 44 18220 : } 45 : 46 : void 47 36049 : ComputeResidualThread::accumulateNeighbor() 48 : { 49 36049 : _fe_problem.addResidualNeighbor(_tid); 50 36049 : } 51 : 52 : void 53 1948384 : ComputeResidualThread::accumulateNeighborLower() 54 : { 55 1948384 : _fe_problem.addResidualNeighbor(_tid); 56 1948384 : _fe_problem.addResidualLower(_tid); 57 1948384 : } 58 : 59 : void 60 287664189 : ComputeResidualThread::accumulate() 61 : { 62 287664189 : _fe_problem.cacheResidual(_tid); 63 287664189 : _num_cached++; 64 : 65 287664189 : if (_num_cached % 20 == 0) 66 13282549 : _fe_problem.addCachedResidual(_tid); 67 287664189 : } 68 : 69 : void 70 300378 : ComputeResidualThread::join(const ComputeResidualThread & /*y*/) 71 : { 72 300378 : } 73 : 74 : void 75 3922502 : ComputeResidualThread::determineObjectWarehouses() 76 : { 77 : // If users pass a empty vector or a full size of vector, 78 : // we take all kernels 79 3922502 : if (!_tags.size() || _tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL)) 80 : { 81 3871076 : _tag_kernels = &_kernels; 82 3871076 : _dg_warehouse = &_dg_kernels; 83 3871076 : _ibc_warehouse = &_integrated_bcs; 84 3871076 : _ik_warehouse = &_interface_kernels; 85 3871076 : _hdg_warehouse = &_hdg_kernels; 86 : } 87 : // If we have one tag only, 88 : // We call tag based storage 89 51426 : else if (_tags.size() == 1) 90 : { 91 30722 : _tag_kernels = &(_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 92 30722 : _dg_warehouse = &(_dg_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 93 30722 : _ibc_warehouse = &(_integrated_bcs.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 94 30722 : _ik_warehouse = &(_interface_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 95 30722 : _hdg_warehouse = &(_hdg_kernels.getVectorTagObjectWarehouse(*(_tags.begin()), _tid)); 96 : } 97 : // This one may be expensive 98 : else 99 : { 100 20704 : _tag_kernels = &(_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 101 20704 : _dg_warehouse = &(_dg_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 102 20704 : _ibc_warehouse = &(_integrated_bcs.getVectorTagsObjectWarehouse(_tags, _tid)); 103 20704 : _ik_warehouse = &(_interface_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 104 20704 : _hdg_warehouse = &(_hdg_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 105 : } 106 : 107 3922502 : if (_fe_problem.haveFV()) 108 : { 109 112690 : _fv_kernels.clear(); 110 112690 : _fe_problem.theWarehouse() 111 225380 : .query() 112 225380 : .template condition<AttribSysNum>(_nl.number()) 113 112690 : .template condition<AttribSystem>("FVElementalKernel") 114 112690 : .template condition<AttribSubdomains>(_subdomain) 115 112690 : .template condition<AttribThread>(_tid) 116 112690 : .template condition<AttribVectorTags>(_tags) 117 112690 : .queryInto(_fv_kernels); 118 : } 119 3922502 : } 120 : 121 : void 122 794269 : ComputeResidualThread::computeOnInternalFace() 123 : { 124 : mooseAssert(_hdg_warehouse->hasActiveBlockObjects(_subdomain, _tid), 125 : "We should not be called if we have no active HDG kernels"); 126 1718873 : 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 924604 : if (hdg_kernel->hasBlocks(_neighbor_subdomain)) 135 924588 : hdg_kernel->computeResidualOnSide(); 136 : } 137 794269 : }