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 : #pragma once 11 : 12 : #include "MooseTypes.h" 13 : #include "INSFVAttributes.h" 14 : #include "SubProblem.h" 15 : #include "MooseMesh.h" 16 : #include "TheWarehouse.h" 17 : #include "MooseApp.h" 18 : #include "INSFVNoSlipWallBC.h" 19 : #include "INSFVSlipWallBC.h" 20 : #include "INSFVFreeSurfaceBC.h" 21 : #include "INSFVSymmetryBC.h" 22 : #include "INSFVFullyDevelopedFlowBC.h" 23 : #include <set> 24 : 25 : /** 26 : * This interface gives the inheriting class information about all the different boundary conditions 27 : * that surround a flow physics region. A use case for this interface is forcing execution of 28 : * advection kernels on flow boundaries 29 : */ 30 : class INSFVBCInterface 31 : { 32 : protected: 33 : /** 34 : * setup all the boundary condition member information 35 : */ 36 : template <typename T> 37 : void initialSetup(T & insfv_fk); 38 : 39 : /// Boundary IDs with no slip walls 40 : std::set<BoundaryID> _no_slip_wall_boundaries; 41 : 42 : /// Boundary IDs with slip walls 43 : std::set<BoundaryID> _slip_wall_boundaries; 44 : 45 : /// Boundary IDs for free surfaces 46 : std::set<BoundaryID> _free_surface_boundaries; 47 : 48 : /// Flow Boundary IDs 49 : std::set<BoundaryID> _flow_boundaries; 50 : 51 : /// Fully Developed Flow Boundary IDs. This is a subset of \p _flow_boundaries 52 : std::set<BoundaryID> _fully_developed_flow_boundaries; 53 : 54 : /// Symmetry Boundary IDs 55 : std::set<BoundaryID> _symmetry_boundaries; 56 : 57 : /// All the BoundaryIDs covered by our different types of INSFVBCs 58 : std::set<BoundaryID> _all_boundaries; 59 : 60 : private: 61 : /** 62 : * Query for \p INSFVBCs::INSFVFlowBC on \p bc_id and add if query successful 63 : */ 64 : template <typename T> 65 : void setupFlowBoundaries(T & insfv_fk, BoundaryID bnd_id); 66 : 67 : /** 68 : * Query for \p INSFVBCs on \p bc_id and add if query successful 69 : */ 70 : template <typename T, typename T2> 71 : void setupBoundaries(T2 & insfv_fk, 72 : const BoundaryID bnd_id, 73 : INSFVBCs bc_type, 74 : std::set<BoundaryID> & bnd_ids); 75 : }; 76 : 77 : template <typename T> 78 : void 79 38942 : INSFVBCInterface::initialSetup(T & insfv_fk) 80 : { 81 38942 : const auto & mesh = insfv_fk.subProblem().mesh(); 82 : 83 : std::set<BoundaryID> all_connected_boundaries; 84 38942 : const auto & blk_ids = insfv_fk.blockRestricted() ? insfv_fk.blockIDs() : mesh.meshSubdomains(); 85 86150 : for (const auto blk_id : blk_ids) 86 : { 87 47208 : const auto & connected_boundaries = mesh.getSubdomainInterfaceBoundaryIds(blk_id); 88 232792 : for (const auto bnd_id : connected_boundaries) 89 185584 : all_connected_boundaries.insert(bnd_id); 90 : } 91 : 92 204180 : for (const auto bnd_id : all_connected_boundaries) 93 : { 94 165238 : setupFlowBoundaries(insfv_fk, bnd_id); 95 165238 : setupBoundaries<INSFVNoSlipWallBC>( 96 165238 : insfv_fk, bnd_id, INSFVBCs::INSFVNoSlipWallBC, _no_slip_wall_boundaries); 97 165238 : setupBoundaries<INSFVSlipWallBC>( 98 165238 : insfv_fk, bnd_id, INSFVBCs::INSFVSlipWallBC, _slip_wall_boundaries); 99 165238 : setupBoundaries<INSFVFreeSurfaceBC>( 100 165238 : insfv_fk, bnd_id, INSFVBCs::INSFVFreeSurfaceBC, _free_surface_boundaries); 101 165238 : setupBoundaries<INSFVSymmetryBC>( 102 165238 : insfv_fk, bnd_id, INSFVBCs::INSFVSymmetryBC, _symmetry_boundaries); 103 : } 104 38942 : } 105 : 106 : template <typename T> 107 : void 108 165238 : INSFVBCInterface::setupFlowBoundaries(T & insfv_fk, const BoundaryID bnd_id) 109 : { 110 : std::vector<INSFVFlowBC *> flow_bcs; 111 : 112 : insfv_fk.subProblem() 113 : .getMooseApp() 114 : .theWarehouse() 115 : .query() 116 330476 : .template condition<AttribBoundaries>(bnd_id) 117 330476 : .template condition<AttribINSFVBCs>(INSFVBCs::INSFVFlowBC) 118 : .queryInto(flow_bcs); 119 : 120 165238 : if (!flow_bcs.empty()) 121 : { 122 52314 : if (dynamic_cast<INSFVFullyDevelopedFlowBC *>(flow_bcs.front())) 123 : { 124 24826 : _fully_developed_flow_boundaries.insert(bnd_id); 125 : 126 : #ifndef NDEBUG 127 : for (auto * flow_bc : flow_bcs) 128 : mooseAssert(dynamic_cast<INSFVFullyDevelopedFlowBC *>(flow_bc), 129 : "If one BC is a fully developed flow BC, then all other flow BCs on that " 130 : "boundary must also be fully developed flow BCs. This flow BC is not: " + 131 : dynamic_cast<MooseObject *>(flow_bc)->name()); 132 : } 133 : else 134 : for (auto * flow_bc : flow_bcs) 135 : mooseAssert(!dynamic_cast<INSFVFullyDevelopedFlowBC *>(flow_bc), 136 : "If one BC is not a fully developed flow BC, then all other flow BCs on that " 137 : "boundary must also not be fully developed flow BCs. This flow BC is not: " + 138 : dynamic_cast<MooseObject *>(flow_bc)->name()); 139 : #else 140 : } 141 : #endif 142 : 143 52314 : _flow_boundaries.insert(bnd_id); 144 52314 : _all_boundaries.insert(bnd_id); 145 : } 146 165238 : } 147 : 148 : template <typename T, typename T2> 149 : void 150 660952 : INSFVBCInterface::setupBoundaries(T2 & insfv_fk, 151 : const BoundaryID bnd_id, 152 : const INSFVBCs bc_type, 153 : std::set<BoundaryID> & bnd_ids) 154 : { 155 : std::vector<T *> bcs; 156 : 157 : insfv_fk.subProblem() 158 : .getMooseApp() 159 : .theWarehouse() 160 : .query() 161 1321904 : .template condition<AttribBoundaries>(bnd_id) 162 660952 : .template condition<AttribINSFVBCs>(bc_type) 163 : .queryInto(bcs); 164 : 165 660952 : if (!bcs.empty()) 166 : { 167 102129 : bnd_ids.insert(bnd_id); 168 102129 : _all_boundaries.insert(bnd_id); 169 : } 170 660952 : }