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 "HeatStructure2DCouplerBase.h" 11 : #include "HeatStructurePlate.h" 12 : #include "HeatStructureCylindricalBase.h" 13 : #include "THMMesh.h" 14 : 15 : InputParameters 16 304 : HeatStructure2DCouplerBase::validParams() 17 : { 18 304 : InputParameters params = BoundaryBase::validParams(); 19 : 20 608 : params.addRequiredParam<std::string>("primary_heat_structure", 21 : "The first heat structure to couple"); 22 608 : params.addRequiredParam<std::string>("secondary_heat_structure", 23 : "The second heat structure to couple"); 24 608 : params.addRequiredParam<BoundaryName>("primary_boundary", 25 : "The boundary of the first heat structure to couple"); 26 608 : params.addRequiredParam<BoundaryName>("secondary_boundary", 27 : "The boundary of the second heat structure to couple"); 28 : 29 304 : return params; 30 0 : } 31 : 32 152 : HeatStructure2DCouplerBase::HeatStructure2DCouplerBase(const InputParameters & parameters) 33 : : BoundaryBase(parameters), 34 : 35 608 : _hs_names({getParam<std::string>("primary_heat_structure"), 36 : getParam<std::string>("secondary_heat_structure")}), 37 608 : _hs_boundaries( 38 : {getParam<BoundaryName>("primary_boundary"), getParam<BoundaryName>("secondary_boundary")}), 39 : 40 152 : _mesh_alignment(constMesh()), 41 152 : _is_plate({false, false}), 42 304 : _is_cylindrical({false, false}) 43 : { 44 152 : addDependency(_hs_names[0]); 45 152 : addDependency(_hs_names[1]); 46 1064 : } 47 : 48 : void 49 152 : HeatStructure2DCouplerBase::setupMesh() 50 : { 51 152 : BoundaryBase::setupMesh(); 52 : 53 : if (hasComponentByName<HeatStructureBase>(_hs_names[0]) && 54 : hasComponentByName<HeatStructureBase>(_hs_names[1])) 55 : { 56 : const HeatStructureBase & primary_hs = getComponentByName<HeatStructureBase>(_hs_names[0]); 57 : const HeatStructureBase & secondary_hs = getComponentByName<HeatStructureBase>(_hs_names[1]); 58 : 59 150 : if (primary_hs.hasBoundary(_hs_boundaries[0]) && secondary_hs.hasBoundary(_hs_boundaries[1])) 60 : { 61 : // Initialize the alignment mapping 62 146 : _mesh_alignment.initialize(primary_hs.getBoundaryInfo(_hs_boundaries[0]), 63 : secondary_hs.getBoundaryInfo(_hs_boundaries[1])); 64 : 65 : // Add entries to sparsity pattern for coupling 66 146 : if (_mesh_alignment.meshesAreAligned()) 67 1362 : for (const auto & elem_id : _mesh_alignment.getPrimaryElemIDs()) 68 : { 69 1220 : if (_mesh_alignment.hasCoupledElemID(elem_id)) 70 1220 : getTHMProblem().augmentSparsity(elem_id, _mesh_alignment.getCoupledElemID(elem_id)); 71 : } 72 : } 73 : } 74 152 : } 75 : 76 : void 77 152 : HeatStructure2DCouplerBase::init() 78 : { 79 : BoundaryBase::init(); 80 : 81 : if (hasComponentByName<HeatStructureBase>(_hs_names[0]) && 82 : hasComponentByName<HeatStructureBase>(_hs_names[1])) 83 : { 84 : const HeatStructureBase & primary_hs = getComponentByName<HeatStructureBase>(_hs_names[0]); 85 : const HeatStructureBase & secondary_hs = getComponentByName<HeatStructureBase>(_hs_names[1]); 86 : 87 150 : if (primary_hs.hasBoundary(_hs_boundaries[0]) && secondary_hs.hasBoundary(_hs_boundaries[1])) 88 : { 89 : // Get the heat structure types 90 146 : _hs_side_types.resize(2); 91 146 : _hs_side_types[0] = primary_hs.getExternalBoundaryType(_hs_boundaries[0]); 92 146 : _hs_side_types[1] = secondary_hs.getExternalBoundaryType(_hs_boundaries[1]); 93 : 94 : // Areas 95 146 : _areas.resize(2); 96 146 : _areas[0] = primary_hs.getBoundaryArea(_hs_boundaries[0]); 97 146 : _areas[1] = secondary_hs.getBoundaryArea(_hs_boundaries[1]); 98 : 99 : // Compute the coupling area fractions in case areas are not equal 100 146 : _coupling_area_fractions.resize(2); 101 146 : if (_areas[0] > _areas[1]) 102 : { 103 20 : _coupling_area_fractions[0] = _areas[1] / _areas[0]; 104 20 : _coupling_area_fractions[1] = 1.0; 105 : } 106 : else 107 : { 108 126 : _coupling_area_fractions[0] = 1.0; 109 126 : _coupling_area_fractions[1] = _areas[0] / _areas[1]; 110 : } 111 : } 112 : } 113 : 114 456 : for (unsigned int i = 0; i < 2; i++) 115 : { 116 304 : if (hasComponentByName<HeatStructurePlate>(_hs_names[i])) 117 : _is_plate[i] = true; 118 : if (hasComponentByName<HeatStructureCylindricalBase>(_hs_names[i])) 119 : _is_cylindrical[i] = true; 120 : } 121 152 : } 122 : 123 : void 124 152 : HeatStructure2DCouplerBase::check() const 125 : { 126 152 : BoundaryBase::check(); 127 : 128 456 : for (unsigned int i = 0; i < 2; i++) 129 : { 130 304 : checkComponentOfTypeExistsByName<HeatStructureBase>(_hs_names[i]); 131 : 132 : if (hasComponentByName<HeatStructureBase>(_hs_names[i])) 133 : { 134 : const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_names[i]); 135 302 : if (!hs.hasBoundary(_hs_boundaries[i])) 136 4 : logError("The heat structure '", 137 : _hs_names[i], 138 : "' does not have the boundary '", 139 : _hs_boundaries[i], 140 : "'."); 141 : 142 302 : if ((!_is_plate[i]) && (!_is_cylindrical[i])) 143 0 : logError("The type of the heat structure '", 144 : _hs_names[i], 145 : "' is not 'HeatStructurePlate' or inherited from 'HeatStructureCylindricalBase'."); 146 : } 147 : } 148 : 149 152 : if ((_is_plate[0] && _is_cylindrical[1]) || (_is_cylindrical[0] && _is_plate[1])) 150 4 : logError("The coupled heat structures must have the same type."); 151 152 : }