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 3038590 : ComputeResidualThread::ComputeResidualThread(FEProblemBase & fe_problem, 21 3038590 : const std::set<TagID> & tags) 22 3038590 : : NonlinearThread(fe_problem), _tags(tags) 23 : { 24 3038590 : } 25 : 26 : // Splitting Constructor 27 300578 : ComputeResidualThread::ComputeResidualThread(ComputeResidualThread & x, Threads::split split) 28 300578 : : NonlinearThread(x, split), _tags(x._tags) 29 : { 30 300578 : } 31 : 32 3639716 : ComputeResidualThread::~ComputeResidualThread() {} 33 : 34 : void 35 657374833 : ComputeResidualThread::compute(ResidualObject & ro) 36 : { 37 657374833 : ro.computeResidual(); 38 657374784 : } 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 287839829 : ComputeResidualThread::accumulate() 61 : { 62 287839829 : _fe_problem.cacheResidual(_tid); 63 287839829 : _num_cached++; 64 : 65 287839829 : if (_num_cached % 20 == 0) 66 13291142 : _fe_problem.addCachedResidual(_tid); 67 287839829 : } 68 : 69 : void 70 300575 : ComputeResidualThread::join(const ComputeResidualThread & /*y*/) 71 : { 72 300575 : } 73 : 74 : void 75 3924937 : ComputeResidualThread::determineObjectWarehouses() 76 : { 77 : // If users pass a empty vector or a full size of vector, 78 : // we take all kernels 79 3924937 : if (!_tags.size() || _tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL)) 80 : { 81 3873516 : _tag_kernels = &_kernels; 82 3873516 : _dg_warehouse = &_dg_kernels; 83 3873516 : _ibc_warehouse = &_integrated_bcs; 84 3873516 : _ik_warehouse = &_interface_kernels; 85 3873516 : _hdg_warehouse = &_hdg_kernels; 86 : } 87 : // If we have one tag only, 88 : // We call tag based storage 89 51421 : 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 20699 : _tag_kernels = &(_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 101 20699 : _dg_warehouse = &(_dg_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 102 20699 : _ibc_warehouse = &(_integrated_bcs.getVectorTagsObjectWarehouse(_tags, _tid)); 103 20699 : _ik_warehouse = &(_interface_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 104 20699 : _hdg_warehouse = &(_hdg_kernels.getVectorTagsObjectWarehouse(_tags, _tid)); 105 : } 106 : 107 3924937 : if (_fe_problem.haveFV()) 108 : { 109 112670 : _fv_kernels.clear(); 110 112670 : _fe_problem.theWarehouse() 111 225340 : .query() 112 225340 : .template condition<AttribSysNum>(_nl.number()) 113 112670 : .template condition<AttribSystem>("FVElementalKernel") 114 112670 : .template condition<AttribSubdomains>(_subdomain) 115 112670 : .template condition<AttribThread>(_tid) 116 112670 : .template condition<AttribVectorTags>(_tags) 117 112670 : .queryInto(_fv_kernels); 118 : } 119 3924937 : } 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 : }