LCOV - code coverage report
Current view: top level - src/userobjects - SideUserObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 42 43 97.7 %
Date: 2025-07-17 01:28:37 Functions: 3 3 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 "SideUserObject.h"
      11             : #include "SubProblem.h"
      12             : #include "MooseTypes.h"
      13             : #include "Assembly.h"
      14             : 
      15             : InputParameters
      16      852187 : SideUserObject::validParams()
      17             : {
      18      852187 :   InputParameters params = UserObject::validParams();
      19      852187 :   params += BoundaryRestrictableRequired::validParams();
      20      852187 :   params += MaterialPropertyInterface::validParams();
      21      852187 :   params.addRelationshipManager("GhostLowerDElems",
      22             :                                 Moose::RelationshipManagerType::GEOMETRIC |
      23             :                                     Moose::RelationshipManagerType::ALGEBRAIC);
      24      852187 :   return params;
      25           0 : }
      26             : 
      27        5286 : SideUserObject::SideUserObject(const InputParameters & parameters)
      28             :   : UserObject(parameters),
      29             :     BoundaryRestrictableRequired(this, false), // false for applying to sidesets
      30             :     MaterialPropertyInterface(this, Moose::EMPTY_BLOCK_IDS, boundaryIDs()),
      31             :     CoupleableMooseVariableDependencyIntermediateInterface(this, false),
      32             :     TransientInterface(this),
      33             :     ElementIDInterface(this),
      34       10572 :     _mesh(_subproblem.mesh()),
      35        5286 :     _q_point(_assembly.qPointsFace()),
      36        5286 :     _qrule(_assembly.qRuleFace()),
      37        5286 :     _JxW(_assembly.JxWFace()),
      38        5286 :     _coord(_assembly.coordTransformation()),
      39        5286 :     _normals(_assembly.normals()),
      40        5286 :     _current_elem(_assembly.elem()),
      41        5286 :     _current_side(_assembly.side()),
      42        5286 :     _current_side_elem(_assembly.sideElem()),
      43        5286 :     _current_side_volume(_assembly.sideElemVolume()),
      44       10572 :     _current_boundary_id(_assembly.currentBoundaryID())
      45             : {
      46        5286 : }
      47             : 
      48             : void
      49       22504 : SideUserObject::getFaceInfos()
      50             : {
      51       22504 :   _face_infos.clear();
      52             : 
      53             :   // Either the element or the (active) neighbor is a valid argument to get a face info
      54       22504 :   const Elem * side_neighbor = _current_elem->neighbor_ptr(_current_side);
      55             : 
      56             :   mooseAssert(_current_elem, "We should have an element");
      57             :   mooseAssert(_current_elem->active(), "The current element should be active");
      58             : 
      59             :   // No neighbor means we are at a boundary, a FaceInfo exists in the mesh
      60       22504 :   if (side_neighbor)
      61             :   {
      62       10848 :     std::vector<const Elem *> candidate_neighbors = {side_neighbor};
      63             : 
      64             :     // neighbor is not active, we have to seek its refined children to get a FaceInfo
      65       10848 :     if (!side_neighbor->active())
      66        1856 :       side_neighbor->active_family_tree_by_neighbor(candidate_neighbors, _current_elem);
      67             : 
      68       23552 :     for (const Elem * neighbor : candidate_neighbors)
      69             :     {
      70       12704 :       const Elem * element = _current_elem;
      71       12704 :       auto side = _current_side;
      72             : 
      73             :       // If a neighbor exists, the face info may only be defined on the other side
      74             :       // First check refinement level
      75       12704 :       if (_current_elem->level() < neighbor->level())
      76             :       {
      77        3712 :         element = neighbor;
      78        3712 :         side = neighbor->which_neighbor_am_i(_current_elem);
      79             :       }
      80             :       // Then check ids
      81       13344 :       else if ((_current_elem->level() == neighbor->level()) &&
      82        4352 :                (_current_elem->id() > neighbor->id()))
      83             :       {
      84        2219 :         element = neighbor;
      85        2219 :         side = neighbor->which_neighbor_am_i(_current_elem);
      86             :       }
      87       12704 :       const auto fi = _mesh.faceInfo(element, side);
      88             :       mooseAssert(fi, "Face info must not be null.");
      89       12704 :       _face_infos.push_back(fi);
      90             :     }
      91       10848 :   }
      92             :   else
      93             :   {
      94       11656 :     const auto fi = _mesh.faceInfo(_current_elem, _current_side);
      95             :     mooseAssert(fi, "Face info must not be null.");
      96       11656 :     _face_infos.push_back(fi);
      97             :   }
      98       22504 : }

Generated by: LCOV version 1.14