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 "LayeredFlowAreaChange.h" 11 : 12 : registerMooseObject("ThermalHydraulicsApp", LayeredFlowAreaChange); 13 : 14 : InputParameters 15 41 : LayeredFlowAreaChange::validParams() 16 : { 17 41 : InputParameters params = SpatialUserObjectFunctor<SideIntegralUserObject>::validParams(); 18 41 : params += LayeredBase::validParams(); 19 82 : params.addRequiredCoupledVar("displacements", 20 : "Displacements, size must match problem dimension."); 21 : 22 : // this layered object should not be used on the displaced mesh 23 : // because it measures deviation from the undisplaced mesh 24 41 : params.suppressParameter<bool>("use_displaced_mesh"); 25 41 : params.set<bool>("use_displaced_mesh") = false; 26 41 : params.suppressParameter<std::vector<SubdomainName>>("block"); 27 : 28 41 : params.addClassDescription( 29 : "This layered user object computes the change in cross sectional area " 30 : "of a flow channel from the displacement variables. Note: the convention is" 31 : "that reduction in flow area is negative. For this to be satisfied, normals must" 32 : "point INTO the flow channel."); 33 41 : return params; 34 0 : } 35 : 36 22 : LayeredFlowAreaChange::LayeredFlowAreaChange(const InputParameters & parameters) 37 : : SpatialUserObjectFunctor<SideIntegralUserObject>(parameters), 38 : LayeredBase(parameters), 39 22 : _dim(_mesh.dimension()) 40 : { 41 22 : if (coupledComponents("displacements") != _dim) 42 0 : paramError("displacements", 43 : "The number of displacement components must be equal to the mesh displacement."); 44 : 45 22 : _disp.resize(_dim); 46 66 : for (unsigned int j = 0; j < _dim; ++j) 47 44 : _disp[j] = &coupledValue("displacements", j); 48 22 : } 49 : 50 : void 51 17 : LayeredFlowAreaChange::initialize() 52 : { 53 17 : SpatialUserObjectFunctor<SideIntegralUserObject>::initialize(); 54 17 : LayeredBase::initialize(); 55 17 : } 56 : 57 : void 58 720 : LayeredFlowAreaChange::execute() 59 : { 60 720 : unsigned int layer = getLayer(_current_elem->vertex_average()); 61 720 : Real height = _interval_based ? (_direction_max - _direction_min) / _num_layers 62 0 : : _layer_bounds[layer + 1] - _layer_bounds[layer]; 63 720 : Real integral_value = computeIntegral() / height; 64 : 65 720 : setLayerValue(layer, getLayerValue(layer) + integral_value); 66 720 : } 67 : 68 : Real 69 720 : LayeredFlowAreaChange::computeIntegral() 70 : { 71 : Real sum = 0; 72 2160 : for (_qp = 0; _qp < _qrule->n_points(); _qp++) 73 1440 : sum += _JxW[_qp] * _coord[_qp] * computeQpIntegral(); 74 : 75 720 : return sum; 76 : } 77 : 78 : Real 79 1440 : LayeredFlowAreaChange::computeQpIntegral() 80 : { 81 : RealVectorValue displacements; 82 4320 : for (unsigned int j = 0; j < _dim; ++j) 83 2880 : displacements(j) = (*_disp[j])[_qp]; 84 1440 : return -_normals[_qp] * displacements; 85 : } 86 : 87 : void 88 14 : LayeredFlowAreaChange::finalize() 89 : { 90 14 : LayeredBase::finalize(); 91 14 : } 92 : 93 : void 94 3 : LayeredFlowAreaChange::threadJoin(const UserObject & y) 95 : { 96 3 : SpatialUserObjectFunctor<SideIntegralUserObject>::threadJoin(y); 97 3 : LayeredBase::threadJoin(y); 98 3 : }