LCOV - code coverage report
Current view: top level - src/userobjects - LayeredFlowAreaChange.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 41 44 93.2 %
Date: 2026-05-29 20:41:18 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          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          19 : LayeredFlowAreaChange::validParams()
      16             : {
      17          19 :   InputParameters params = SpatialUserObjectFunctor<SideIntegralUserObject>::validParams();
      18          19 :   params += LayeredBase::validParams();
      19          38 :   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          19 :   params.suppressParameter<bool>("use_displaced_mesh");
      25          19 :   params.set<bool>("use_displaced_mesh") = false;
      26          19 :   params.suppressParameter<std::vector<SubdomainName>>("block");
      27             : 
      28          19 :   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          19 :   return params;
      34           0 : }
      35             : 
      36          10 : LayeredFlowAreaChange::LayeredFlowAreaChange(const InputParameters & parameters)
      37             :   : SpatialUserObjectFunctor<SideIntegralUserObject>(parameters),
      38             :     LayeredBase(parameters),
      39          10 :     _dim(_mesh.dimension())
      40             : {
      41          10 :   if (coupledComponents("displacements") != _dim)
      42           0 :     paramError("displacements",
      43             :                "The number of displacement components must be equal to the mesh displacement.");
      44             : 
      45          10 :   _disp.resize(_dim);
      46          30 :   for (unsigned int j = 0; j < _dim; ++j)
      47          20 :     _disp[j] = &coupledValue("displacements", j);
      48          10 : }
      49             : 
      50             : void
      51           9 : LayeredFlowAreaChange::initialize()
      52             : {
      53           9 :   SpatialUserObjectFunctor<SideIntegralUserObject>::initialize();
      54           9 :   LayeredBase::initialize();
      55           9 : }
      56             : 
      57             : void
      58         480 : LayeredFlowAreaChange::execute()
      59             : {
      60         480 :   unsigned int layer = getLayer(_current_elem->vertex_average());
      61         480 :   Real height = _interval_based ? (_direction_max - _direction_min) / _num_layers
      62           0 :                                 : _layer_bounds[layer + 1] - _layer_bounds[layer];
      63         480 :   Real integral_value = computeIntegral() / height;
      64             : 
      65         480 :   setLayerValue(layer, getLayerValue(layer) + integral_value);
      66         480 : }
      67             : 
      68             : Real
      69         480 : LayeredFlowAreaChange::computeIntegral()
      70             : {
      71             :   Real sum = 0;
      72        1440 :   for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      73         960 :     sum += _JxW[_qp] * _coord[_qp] * computeQpIntegral();
      74             : 
      75         480 :   return sum;
      76             : }
      77             : 
      78             : Real
      79         960 : LayeredFlowAreaChange::computeQpIntegral()
      80             : {
      81             :   RealVectorValue displacements;
      82        2880 :   for (unsigned int j = 0; j < _dim; ++j)
      83        1920 :     displacements(j) = (*_disp[j])[_qp];
      84         960 :   return -_normals[_qp] * displacements;
      85             : }
      86             : 
      87             : void
      88           8 : LayeredFlowAreaChange::finalize()
      89             : {
      90           8 :   LayeredBase::finalize();
      91           8 : }
      92             : 
      93             : void
      94           1 : LayeredFlowAreaChange::threadJoin(const UserObject & y)
      95             : {
      96           1 :   SpatialUserObjectFunctor<SideIntegralUserObject>::threadJoin(y);
      97           1 :   LayeredBase::threadJoin(y);
      98           1 : }

Generated by: LCOV version 1.14